diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 0000000..cb67a35 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,32 @@ +name: Format + +on: + push: + branches: [main] + pull_request: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + +jobs: + prettier: + name: Prettier + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Setup Node.js + uses: ./.github/actions/setup-node-cached + with: + node-version: '24' + + - name: Install dependencies + run: npm install + + # No paths filter: most of what drifted out of style lives at the + # repo root, which the js-ci and php-ci filters never match. + - name: Check formatting + run: npx prettier --check . --ignore-path .gitignore --ignore-path .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..b7e2c14 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,13 @@ +# Generated by release-please — reformatting them only creates churn, since +# the next release rewrites them in its own style. +CHANGELOG.md +packages/*/CHANGELOG.md +.release-please-manifest.json + +# Test fixtures are inputs, not source. Their exact bytes are what is under +# test — indentation included. +packages/php/tests/Fixtures/ + +# Infection reads json5; Prettier rewrites the quoting style, which would +# fork this file away from its twin in safeaccess-identum. +packages/php/infection.json5 diff --git a/codecov.yml b/codecov.yml index c4f3dd1..1bef090 100644 --- a/codecov.yml +++ b/codecov.yml @@ -16,6 +16,6 @@ flags: carryforward: false comment: - layout: "condensed_header, flags, tree" + layout: 'condensed_header, flags, tree' behavior: default require_changes: false diff --git a/commitlint.config.js b/commitlint.config.js index df4852c..7a9257d 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1,11 +1,7 @@ export default { - extends: ['@commitlint/config-conventional'], - rules: { - 'scope-enum': [ - 2, - 'always', - ['js', 'php', 'docs', 'ci', 'deps'], - ], - 'scope-empty': [1, 'never'], - }, + extends: ['@commitlint/config-conventional'], + rules: { + 'scope-enum': [2, 'always', ['js', 'php', 'docs', 'ci', 'deps']], + 'scope-empty': [1, 'never'], + }, }; diff --git a/eslint.config.js b/eslint.config.js index 4513671..d7604c9 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,5 +1,5 @@ -import eslint from "@eslint/js"; -import tseslint from "typescript-eslint"; +import eslint from '@eslint/js'; +import tseslint from 'typescript-eslint'; /** * Shared ESLint configuration for all TypeScript packages in the monorepo. @@ -10,14 +10,11 @@ export default tseslint.config( ...tseslint.configs.recommended, { rules: { - "@typescript-eslint/no-explicit-any": "error", - "@typescript-eslint/no-unused-vars": [ - "error", - { argsIgnorePattern: "^_" }, - ], + '@typescript-eslint/no-explicit-any': 'error', + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], }, }, { - ignores: ["dist/", "node_modules/"], + ignores: ['dist/', 'node_modules/'], }, ); diff --git a/packages/js/src/core/inline-builder-accessor.ts b/packages/js/src/core/inline-builder-accessor.ts index 4f2633f..feb4218 100644 --- a/packages/js/src/core/inline-builder-accessor.ts +++ b/packages/js/src/core/inline-builder-accessor.ts @@ -84,13 +84,15 @@ export class InlineBuilderAccessor { * @returns New builder instance with the integration configured. */ withParserIntegration(integration: ParseIntegrationInterface): this { - return new (this.constructor as new ( - guard: SecurityGuardInterface, - secParser: SecurityParserInterface, - pathCache: PathCacheInterface | null, - integration: ParseIntegrationInterface | null, - strictMode: boolean | null, - ) => this)(this._guard, this._secParser, this._pathCache, integration, this._strictMode); + return new ( + this.constructor as new ( + guard: SecurityGuardInterface, + secParser: SecurityParserInterface, + pathCache: PathCacheInterface | null, + integration: ParseIntegrationInterface | null, + strictMode: boolean | null, + ) => this + )(this._guard, this._secParser, this._pathCache, integration, this._strictMode); } /** @@ -100,13 +102,15 @@ export class InlineBuilderAccessor { * @returns New builder instance with the guard configured. */ withSecurityGuard(guard: SecurityGuardInterface): this { - return new (this.constructor as new ( - guard: SecurityGuardInterface, - secParser: SecurityParserInterface, - pathCache: PathCacheInterface | null, - integration: ParseIntegrationInterface | null, - strictMode: boolean | null, - ) => this)(guard, this._secParser, this._pathCache, this._integration, this._strictMode); + return new ( + this.constructor as new ( + guard: SecurityGuardInterface, + secParser: SecurityParserInterface, + pathCache: PathCacheInterface | null, + integration: ParseIntegrationInterface | null, + strictMode: boolean | null, + ) => this + )(guard, this._secParser, this._pathCache, this._integration, this._strictMode); } /** @@ -116,13 +120,15 @@ export class InlineBuilderAccessor { * @returns New builder instance with the parser configured. */ withSecurityParser(parser: SecurityParserInterface): this { - return new (this.constructor as new ( - guard: SecurityGuardInterface, - secParser: SecurityParserInterface, - pathCache: PathCacheInterface | null, - integration: ParseIntegrationInterface | null, - strictMode: boolean | null, - ) => this)(this._guard, parser, this._pathCache, this._integration, this._strictMode); + return new ( + this.constructor as new ( + guard: SecurityGuardInterface, + secParser: SecurityParserInterface, + pathCache: PathCacheInterface | null, + integration: ParseIntegrationInterface | null, + strictMode: boolean | null, + ) => this + )(this._guard, parser, this._pathCache, this._integration, this._strictMode); } /** @@ -132,13 +138,15 @@ export class InlineBuilderAccessor { * @returns New builder instance with the cache configured. */ withPathCache(cache: PathCacheInterface): this { - return new (this.constructor as new ( - guard: SecurityGuardInterface, - secParser: SecurityParserInterface, - pathCache: PathCacheInterface | null, - integration: ParseIntegrationInterface | null, - strictMode: boolean | null, - ) => this)(this._guard, this._secParser, cache, this._integration, this._strictMode); + return new ( + this.constructor as new ( + guard: SecurityGuardInterface, + secParser: SecurityParserInterface, + pathCache: PathCacheInterface | null, + integration: ParseIntegrationInterface | null, + strictMode: boolean | null, + ) => this + )(this._guard, this._secParser, cache, this._integration, this._strictMode); } /** @@ -152,12 +160,14 @@ export class InlineBuilderAccessor { * Only use with fully trusted, application-controlled input. */ withStrictMode(strict: boolean): this { - return new (this.constructor as new ( - guard: SecurityGuardInterface, - secParser: SecurityParserInterface, - pathCache: PathCacheInterface | null, - integration: ParseIntegrationInterface | null, - strictMode: boolean | null, - ) => this)(this._guard, this._secParser, this._pathCache, this._integration, strict); + return new ( + this.constructor as new ( + guard: SecurityGuardInterface, + secParser: SecurityParserInterface, + pathCache: PathCacheInterface | null, + integration: ParseIntegrationInterface | null, + strictMode: boolean | null, + ) => this + )(this._guard, this._secParser, this._pathCache, this._integration, strict); } } diff --git a/packages/js/tsconfig.json b/packages/js/tsconfig.json index 6c931f5..8af2ab8 100644 --- a/packages/js/tsconfig.json +++ b/packages/js/tsconfig.json @@ -1,16 +1,16 @@ { - "compilerOptions": { - "target": "ES2022", - "module": "ESNext", - "moduleResolution": "bundler", - "strict": true, - "declaration": true, - "outDir": "./dist", - "rootDir": "./src", - "noImplicitAny": true, - "noImplicitReturns": true, - "exactOptionalPropertyTypes": true - }, - "include": ["src/**/*"], - "exclude": ["node_modules", "dist", "tests", "vitest.config.ts"] + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "bundler", + "strict": true, + "declaration": true, + "outDir": "./dist", + "rootDir": "./src", + "noImplicitAny": true, + "noImplicitReturns": true, + "exactOptionalPropertyTypes": true + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist", "tests", "vitest.config.ts"] }