Skip to content

Commit cf83dee

Browse files
committed
feat: close guideline coverage gaps for JavaScript and TypeScript
Every numbered clause of the pinned guide had a catalog row, but several rows claimed enforcement that the resolved settings did not provide, the guideline policy reversed only one prose/sample conflict, and TypeScript files ran pinned JavaScript rules that misreport TypeScript syntax. Catalog: record a disposition per policy (compatibility and guideline), add a `partial` enforcement level, scope mappings to the base preset, the guideline policy, or an opt-in profile, and record the TypeScript implementation of each replaced rule. Dispositions for 5.2, 10.4, 10.10, 10.11, 16.1, 17.1, 18.1, 18.6, and 7.2 now match actual behavior. Guideline policy: enforce the prose for clauses 5.2, 6.2/18.13, 10.1, 10.2, 10.6, 10.10 (selectable `importGroups: example | prose`), 10.11, 16.1, 17.1, 17.2, 18.1 (JSX), 18.6, 18.7, 22.1, and 22.7. Add rules no-multiline-string-concat, multiline-condition-layout, constant-name, and a lineCommentRuns option for require-docblock. TypeScript: replace pinned rules that report valid TypeScript or ignore TypeScript syntax with TypeScript-aware implementations of the same rules and options (native no-dupe-class-members, no-array-constructor, default-param-last, no-use-before-define; Stylistic comma-dangle, comma-spacing, key-spacing, lines-between-class-members, lines-around-comment, object-curly-spacing, semi, space-before-blocks, space-infix-ops; merge-aware ag-ts/no-redeclare). no-accessors covers abstract, signature, and auto-accessors; unknown-catch covers every catch binding pattern. `--check-tsconfig` verifies clauses 26.1/26.2. Profile: move AdGuard project conventions that the guide does not require (stricter JSDoc, MV2/MV3 imports, import-newlines, boundaries, logger context, @typescript-eslint rules) from the base preset into the opt-in `adguard-projects` profile with accurate provenance. Tests: run every enforced clause's good and bad examples through the complete preset for both policies, require partial and overridden dispositions to be demonstrated, and require an idiomatic TypeScript corpus to pass the full TypeScript preset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MCeDV2VhbUtLyAP9XRG1zL
1 parent 3a4ae06 commit cf83dee

44 files changed

Lines changed: 6528 additions & 1371 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.oxlintrc.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"extends": [
3-
"./packages/oxlint-config/dist/typescript.json",
3+
"./packages/oxlint-config/dist/typescript-adguard-projects.json",
44
"./packages/oxlint-config/dist/node.json"
55
],
66
"ignorePatterns": [

‎README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# AdGuard guidelines for Oxlint
22

3-
An Oxlint-only implementation of the pinned [AdGuard JavaScript guidelines](docs/reference/Javascript.md), including the complete inherited Airbnb and JSDoc sample configuration. The sample configuration takes precedence when it conflicts with prose. Every one of the 134 numbered clauses has a disposition in the generated [coverage catalog](docs/coverage.md).
3+
An Oxlint-only implementation of the pinned [AdGuard JavaScript guidelines](docs/reference/Javascript.md), including the complete inherited Airbnb and JSDoc sample configuration and the guide's TypeScript section. The default `compatibility` policy gives the sample configuration precedence when it conflicts with prose; the opt-in `guideline` policy enforces the prose instead. Every one of the 134 numbered clauses has a disposition for both policies in the generated [coverage catalog](docs/coverage.md), and `tests/clauses.test.ts` runs each enforced clause's good and bad examples through the complete preset.
44

55
The pnpm workspace contains three reusable packages:
66

@@ -33,7 +33,7 @@ pnpm exec ag-oxlint-config --language typescript --environment node
3333
pnpm exec oxlint --config .oxlintrc.json .
3434
```
3535

36-
The CLI preserves existing files unless passed `--force`. `--output -` prints JSON. JavaScript/browser/module are the defaults. Use `--source-type script` for browser scripts; `.cjs` and `.cts` retain CommonJS semantics.
36+
The CLI preserves existing files unless passed `--force`. `--output -` prints JSON. JavaScript/browser/module are the defaults. Use `--source-type script` for browser scripts; `.cjs` and `.cts` retain CommonJS semantics. `--policy guideline` enforces guide prose over conflicting sample settings (`--import-groups example|prose` selects the clause 10.10 interpretation), and `--profile adguard-projects` adds conventions shared by AdGuard projects that the guide does not require. `--check-tsconfig` verifies the compiler options of clauses 26.1 and 26.2.
3737

3838
The programmatic API works in TypeScript scripts executed with `tsx`:
3939

@@ -57,7 +57,7 @@ For compiler checking:
5757
}
5858
```
5959

60-
TypeScript presets preserve documentation requirements while avoiding duplicate JSDoc type annotations. Type checking uses the TypeScript compiler; the default presets require no separate typed lint service. Optional `createConfig({ language: 'typescript', typeAware: true })` enables type-dependent lint rules with `oxlint-tsgolint@7.0.2002`; see [type-aware linting](packages/oxlint-config/README.md#type-aware-linting). Compiler checking remains a separate gate.
60+
TypeScript presets apply the JavaScript rules through TypeScript-aware implementations where the pinned JavaScript ones misreport TypeScript syntax, and preserve documentation requirements while avoiding duplicate JSDoc type annotations. Type checking uses the TypeScript compiler; the default presets require no separate typed lint service. Optional `createConfig({ language: 'typescript', typeAware: true, profile: 'adguard-projects' })` enables type-dependent lint rules with `oxlint-tsgolint@7.0.2002`; see [type-aware linting](packages/oxlint-config/README.md#type-aware-linting). Compiler checking remains a separate gate.
6161

6262
## Scope and maintenance
6363

‎docs/conformance.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ The handwritten adapters address standalone scope metadata and comment globals,
1212

1313
Vitest coverage includes every handwritten TypeScript runtime file under `packages/*/src`, including files not otherwise imported. Thresholds are 95% for statements, lines, and functions and 90% for branches. Vendored source is assessed through conformance rather than included in that percentage. Repeated CLI executions used to check stability are not counted as distinct corpus scenarios.
1414

15-
For TypeScript files, the preset uses Oxlint's native `no-unused-vars`, `no-shadow`, `no-useless-constructor`, and `no-empty-function` implementations to understand type signatures and constructor parameter properties. It retains inherited settings, explicitly preserves the baseline's `caughtErrors: none` default, and uses Stylistic's TypeScript-capable indentation rule with the inherited four-space setting. These syntax-specific overrides have dedicated cases for all four TypeScript extensions; exact upstream JavaScript conformance continues to use the pinned implementations. Type-only declarations and modern TypeScript binding behavior are governed by these documented overrides rather than an ESLint TypeScript parser or a typed lint service.
15+
The guide applies the JavaScript rules to TypeScript. For TypeScript files, the preset replaces pinned JavaScript implementations that report valid TypeScript or ignore TypeScript syntax with TypeScript-aware implementations of the same rules and options: Oxlint's native `no-unused-vars`, `no-shadow`, `no-useless-constructor`, `no-empty-function`, `no-dupe-class-members`, `no-array-constructor`, `default-param-last`, and `no-use-before-define`; Stylistic's `indent`, `comma-dangle` (extended to enums, type parameters, and tuples as airbnb-typescript does), `comma-spacing`, `key-spacing`, `lines-between-class-members`, `lines-around-comment`, `object-curly-spacing`, `semi`, `space-before-blocks`, and `space-infix-ops`; and `ag-ts/no-redeclare`, which runs the pinned rule but accepts overloads and the declaration merges that TypeScript permits. Import and React settings gain TypeScript extensions and development globs. The generator records each replacement and its reason in the catalog; `tests/typescript-preset.test.ts` requires idiomatic TypeScript to pass the complete preset under both policies and requires each replacement to report TypeScript-only violations. Replacements are limited to rules with an observed difference: TypeScript syntax the pinned rules neither misreport nor check, such as generic call spacing, remains outside the preset. The pinned `import/export` rule reports exported interface merges, as upstream does. Exact upstream JavaScript conformance continues to use the pinned implementations.
1616

17-
The default presets remain syntax-only. `createConfig({ language: 'typescript', typeAware: true })` opts into mappings marked `requiresTypeInfo` using the optional `oxlint-tsgolint@7.0.2002` peer. Currently this adds `typescript/consistent-type-exports` only in the TypeScript file override. A real multi-file project and a packed-package consumer test check both an invalid re-export and its type-only correction. This establishes execution of that rule, not complete Airbnb TypeScript parity, compatibility with a project's nested policies, or full guideline-prose compliance. Compiler checking, declaration emission, and manual review remain separate requirements.
17+
The default presets remain syntax-only. `createConfig({ language: 'typescript', typeAware: true })` opts into mappings marked `requiresTypeInfo` using the optional `oxlint-tsgolint@7.0.2002` peer. Currently this adds `typescript/consistent-type-exports`, part of the `adguard-projects` profile, only in the TypeScript file override. A real multi-file project and a packed-package consumer test check both an invalid re-export and its type-only correction. This establishes execution of that rule, not complete Airbnb TypeScript parity, compatibility with a project's nested policies, or full guideline-prose compliance. Compiler checking, declaration emission, and manual review remain separate requirements.

0 commit comments

Comments
 (0)