-
-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(linter): use diagnostic codes in lint rules #4349
refactor(linter): use diagnostic codes in lint rules #4349
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Your org has enabled the Graphite merge queue for merging into mainAdd the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
CodSpeed Performance ReportMerging #4349 will not alter performanceComparing Summary
|
84545df
to
21d0eee
Compare
910cee3
to
830c293
Compare
449098a
to
a4b00fa
Compare
c11f20f
to
101892b
Compare
Let's merge this, It's good to me, and Donlaac needs to resolve conflict every time a linter rule added. The error code shown in diagnostics above needs Boshen's advice then. |
Merge activity
|
> This PR is (unfortunately) quite large, but all changes are needed in tandem for this to work properly. ## What This PR Does Updates the linter to populate diagnostics reported by rules with error codes statically derived from `RuleMeta` + `RuleEnum`. Doing so required changing how we handle vitest rules. I know @mysterven was hoping to refactor that part of the code, and I think this approach is an improvement (but could probably be cleaned up further). ## Changes ### 1. Auto-Populate Error Codes `LintContext` now sets an error code scope + error code number for diagnostics reported by lint rules. `LintContext` will not clobber existing codes set by rules, allowing for rule-specific override behavior (e.g. to use `eslint-plugin-react-hooks` as an error scope). In order to accomplish this, I had to update every diagnostic factory for every rule. While doing this I found some incorrect error messages, or messages that could be easily improved. This is where a large majority of the snapshot diffs come from. Additionally, I was able to reduce string allocations from `format!` usages in diagnostic factories, especially within jest rules. ### 2. Framework and Library Detection This PR adds `FrameworkFlags`, which specify what (if any) set of libraries and frameworks are being used by a project and/or file. They are passed in two ways: 1. `LintOptions` can specify a set of `framework_hints` that apply to the entire target codebase. Right now these are always empty, but I'm thinking in the future we could sniff `package.json`. It may be helpful for enabling/disabling default rules. 2. When `Linter` gets run on a file, framework information is sniffed from the `LintContext`. Right now, we are only checking for `vitest` imports in `ModuleRecord` and test path prefixes from `source_path`. It may be useful to do something similar for React/NextJS rules in the future. I know that [next/no-html-link-for-pages](https://nextjs.org/docs/messages/no-html-link-for-pages) could benefit greatly from this.
101892b
to
7a75e0f
Compare
╭─[consistent_test_it.tsx:1:1] | ||
1 │ test.skip("foo") | ||
· ──── | ||
╰──── | ||
help: Prefer using "it" instead of "test" | ||
|
||
⚠ eslint-plugin-jest(consistent-test-it): Enforce `test` and `it` usage conventions | ||
⚠ eslint-plugin-vitest(consistent-test-it): Enforce `test` and `it` usage conventions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure that this is correct?
it looks like all rules listed in is_jest_rule_adapted_to_vitest
are now marked in tests as vitest
rules
oxc/crates/oxc_linter/src/utils/mod.rs
Line 16 in 7a75e0f
pub fn is_jest_rule_adapted_to_vitest(rule_name: &str) -> bool { |
## [0.22.0] - 2024-07-22 - 85a7cea semantic: [**BREAKING**] Remove name from `reference` (#4329) (Dunqing) - f68b659 ast: [**BREAKING**] Reorder fields of `ArrowFunctionExpression` (#4364) (Dunqing) ### Features - d345b84 ast: Add `#[ast]` attribute to non-visited AST types. (#4309) (rzvxa) - 3c0c709 linter: Add typescript-eslint/no-extraneous-class (#4357) (Jaden Rodriguez) - 0deb027 minfier: Dce `if (xxx) else if (false) { REMOVE }` (#4407) (Boshen) - e33ec18 minifier: Compress `typeof foo == "undefined"` into `typeof foo > "u"` (#4412) (Boshen)- 6068e6b Add error codes to OxcDiagnostic (#4334) (DonIsaac) ### Bug Fixes - aece1df ast: Visit `Program`s `hashbang` field first (#4368) (overlookmotel) - 44a10c4 codegen: Object shorthand with parens `({x: (x)})` -> `({ x })` (#4391) (Boshen) - 3d88f20 codegen: Print shorthand for all `{ x }` variants (#4374) (Boshen) - e624dff codegen,mangler: Do not print shorthand for `ObjectProperty` (#4350) (Boshen) - 267f7c4 minifier: Skip `Object.defineProperty(exports, ...)` for `cjs-module-lexer` (#4409) (Boshen) - bc8d4e5 semantic: Correct comment (#4410) (overlookmotel) - 6ffce86 semantic: Align `visit_arrow_function_expression` field visit order with ast (#4366) (Dunqing) - 4cd5df0 sourcemap: Avoid negative line if token_chunks has same prev_dst_line (#4348) (underfin) - f8565ae transformer/typescript: Unexpectedly removed class binding from ExportNamedDeclaration (#4351) (Dunqing)- ea33f94 Impl PartialEq<str> for CompactStr (#4352) (DonIsaac) ### Performance - 1b51511 semantic: Use `Atom` instead of `CompactStr` for `UnresolvedReferencesStack` (#4401) (Dunqing) - 40f9356 semantic: Calculate number of nodes, scopes, symbols, references before visiting AST (#4367) (Dunqing) - da13d93 semantic: Remove bounds checks on unresolved references stack (#4390) (overlookmotel) - e70c67b semantic: Remove a branch from `add_scope` (#4384) (overlookmotel) - 402006f semantic: Simplify logic in `enter_scope` + `leave_scope` (#4383) (overlookmotel) - 7469e01 semantic: Remove branch from `Nodes::add_node` (#4361) (overlookmotel) - 7eb2864 traverse: Speed up finding UID binding name (#4356) (overlookmotel)- a207923 Replace some CompactStr usages with Cows (#4377) (DonIsaac) ### Refactor - d213773 ast: Replace serde rename "lowercase" with "camelCase" (#4376) (overlookmotel) - abfccbd ast: Reduce `#[cfg_attr]` boilerplate in AST type defs (#4375) (overlookmotel) - 5f1c7ec ast: Rename the `visited_node` marker to `ast`. (#4289) (rzvxa) - 58f6ec2 ast: Enter node before scope (#4347) (Dunqing) - 59aea73 ast: Scope is created only if CatchClause has param (#4346) (Dunqing) - 7a3e925 ast_codegen: Better visit marker parsing. (#4371) (rzvxa) - 7a75e0f linter: Use diagnostic codes in lint rules (#4349) (DonIsaac) - a2eabe1 parser: Use error codes for ts diagnostics (#4335) (DonIsaac) - 5d77b36 semantic: `visit_program` visit `hashbang` field (#4370) (overlookmotel) - f7b9ada semantic: `Program` visitor leave scope before node (#4369) (overlookmotel) - 729b288 semantic: Shorten code (#4358) (overlookmotel) - 21d0eee semantic: Use error codes for ts diagnostics (#4336) (DonIsaac) Co-authored-by: Boshen <Boshen@users.noreply.github.com>
## [0.22.0] - 2024-07-23 - 85a7cea semantic: [**BREAKING**] Remove name from `reference` (#4329) (Dunqing) - f68b659 ast: [**BREAKING**] Reorder fields of `ArrowFunctionExpression` (#4364) (Dunqing) ### Features - d345b84 ast: Add `#[ast]` attribute to non-visited AST types. (#4309) (rzvxa) - 3c0c709 linter: Add typescript-eslint/no-extraneous-class (#4357) (Jaden Rodriguez) - 68efcd4 linter/react-perf: Handle new objects and arrays in prop assignment patterns (#4396) (DonIsaac) - 0deb027 minfier: Dce `if (xxx) else if (false) { REMOVE }` (#4407) (Boshen) - e33ec18 minifier: Compress `typeof foo == "undefined"` into `typeof foo > "u"` (#4412) (Boshen)- 6068e6b Add error codes to OxcDiagnostic (#4334) (DonIsaac) ### Bug Fixes - aece1df ast: Visit `Program`s `hashbang` field first (#4368) (overlookmotel) - 44a10c4 codegen: Object shorthand with parens `({x: (x)})` -> `({ x })` (#4391) (Boshen) - 3d88f20 codegen: Print shorthand for all `{ x }` variants (#4374) (Boshen) - e624dff codegen,mangler: Do not print shorthand for `ObjectProperty` (#4350) (Boshen) - ac08de8 linter/react_perf: Allow new objects, array, fns, etc in top scope (#4395) (DonIsaac) - 267f7c4 minifier: Skip `Object.defineProperty(exports, ...)` for `cjs-module-lexer` (#4409) (Boshen) - bc8d4e5 semantic: Correct comment (#4410) (overlookmotel) - 6ffce86 semantic: Align `visit_arrow_function_expression` field visit order with ast (#4366) (Dunqing) - 4cd5df0 sourcemap: Avoid negative line if token_chunks has same prev_dst_line (#4348) (underfin) - f8565ae transformer/typescript: Unexpectedly removed class binding from ExportNamedDeclaration (#4351) (Dunqing)- ea33f94 Impl PartialEq<str> for CompactStr (#4352) (DonIsaac) ### Performance - 1b51511 semantic: Use `Atom` instead of `CompactStr` for `UnresolvedReferencesStack` (#4401) (Dunqing) - 40f9356 semantic: Calculate number of nodes, scopes, symbols, references before visiting AST (#4367) (Dunqing) - da13d93 semantic: Remove bounds checks on unresolved references stack (#4390) (overlookmotel) - e70c67b semantic: Remove a branch from `add_scope` (#4384) (overlookmotel) - 402006f semantic: Simplify logic in `enter_scope` + `leave_scope` (#4383) (overlookmotel) - 7469e01 semantic: Remove branch from `Nodes::add_node` (#4361) (overlookmotel) - 7eb2864 traverse: Speed up finding UID binding name (#4356) (overlookmotel)- a207923 Replace some CompactStr usages with Cows (#4377) (DonIsaac) ### Refactor - d213773 ast: Replace serde rename "lowercase" with "camelCase" (#4376) (overlookmotel) - abfccbd ast: Reduce `#[cfg_attr]` boilerplate in AST type defs (#4375) (overlookmotel) - 5f1c7ec ast: Rename the `visited_node` marker to `ast`. (#4289) (rzvxa) - 58f6ec2 ast: Enter node before scope (#4347) (Dunqing) - 59aea73 ast: Scope is created only if CatchClause has param (#4346) (Dunqing) - 7a3e925 ast_codegen: Better visit marker parsing. (#4371) (rzvxa) - 7a75e0f linter: Use diagnostic codes in lint rules (#4349) (DonIsaac) - a2eabe1 parser: Use error codes for ts diagnostics (#4335) (DonIsaac) - 5d77b36 semantic: `visit_program` visit `hashbang` field (#4370) (overlookmotel) - f7b9ada semantic: `Program` visitor leave scope before node (#4369) (overlookmotel) - 729b288 semantic: Shorten code (#4358) (overlookmotel) - 21d0eee semantic: Use error codes for ts diagnostics (#4336) (DonIsaac) Co-authored-by: Boshen <Boshen@users.noreply.github.com>
## [0.22.0] - 2024-07-22 - 85a7cea semantic: [**BREAKING**] Remove name from `reference` (#4329) (Dunqing) - f68b659 ast: [**BREAKING**] Reorder fields of `ArrowFunctionExpression` (#4364) (Dunqing) ### Features - d345b84 ast: Add `#[ast]` attribute to non-visited AST types. (#4309) (rzvxa) - 3c0c709 linter: Add typescript-eslint/no-extraneous-class (#4357) (Jaden Rodriguez) - 0deb027 minfier: Dce `if (xxx) else if (false) { REMOVE }` (#4407) (Boshen) - e33ec18 minifier: Compress `typeof foo == "undefined"` into `typeof foo > "u"` (#4412) (Boshen)- 6068e6b Add error codes to OxcDiagnostic (#4334) (DonIsaac) ### Bug Fixes - aece1df ast: Visit `Program`s `hashbang` field first (#4368) (overlookmotel) - 44a10c4 codegen: Object shorthand with parens `({x: (x)})` -> `({ x })` (#4391) (Boshen) - 3d88f20 codegen: Print shorthand for all `{ x }` variants (#4374) (Boshen) - e624dff codegen,mangler: Do not print shorthand for `ObjectProperty` (#4350) (Boshen) - 267f7c4 minifier: Skip `Object.defineProperty(exports, ...)` for `cjs-module-lexer` (#4409) (Boshen) - bc8d4e5 semantic: Correct comment (#4410) (overlookmotel) - 6ffce86 semantic: Align `visit_arrow_function_expression` field visit order with ast (#4366) (Dunqing) - 4cd5df0 sourcemap: Avoid negative line if token_chunks has same prev_dst_line (#4348) (underfin) - f8565ae transformer/typescript: Unexpectedly removed class binding from ExportNamedDeclaration (#4351) (Dunqing)- ea33f94 Impl PartialEq<str> for CompactStr (#4352) (DonIsaac) ### Performance - 1b51511 semantic: Use `Atom` instead of `CompactStr` for `UnresolvedReferencesStack` (#4401) (Dunqing) - 40f9356 semantic: Calculate number of nodes, scopes, symbols, references before visiting AST (#4367) (Dunqing) - da13d93 semantic: Remove bounds checks on unresolved references stack (#4390) (overlookmotel) - e70c67b semantic: Remove a branch from `add_scope` (#4384) (overlookmotel) - 402006f semantic: Simplify logic in `enter_scope` + `leave_scope` (#4383) (overlookmotel) - 7469e01 semantic: Remove branch from `Nodes::add_node` (#4361) (overlookmotel) - 7eb2864 traverse: Speed up finding UID binding name (#4356) (overlookmotel)- a207923 Replace some CompactStr usages with Cows (#4377) (DonIsaac) ### Refactor - d213773 ast: Replace serde rename "lowercase" with "camelCase" (#4376) (overlookmotel) - abfccbd ast: Reduce `#[cfg_attr]` boilerplate in AST type defs (#4375) (overlookmotel) - 5f1c7ec ast: Rename the `visited_node` marker to `ast`. (#4289) (rzvxa) - 58f6ec2 ast: Enter node before scope (#4347) (Dunqing) - 59aea73 ast: Scope is created only if CatchClause has param (#4346) (Dunqing) - 7a3e925 ast_codegen: Better visit marker parsing. (#4371) (rzvxa) - 7a75e0f linter: Use diagnostic codes in lint rules (#4349) (DonIsaac) - a2eabe1 parser: Use error codes for ts diagnostics (#4335) (DonIsaac) - 5d77b36 semantic: `visit_program` visit `hashbang` field (#4370) (overlookmotel) - f7b9ada semantic: `Program` visitor leave scope before node (#4369) (overlookmotel) - 729b288 semantic: Shorten code (#4358) (overlookmotel) - 21d0eee semantic: Use error codes for ts diagnostics (#4336) (DonIsaac) Co-authored-by: Boshen <Boshen@users.noreply.github.com>
## [0.22.0] - 2024-07-23 - 85a7cea semantic: [**BREAKING**] Remove name from `reference` (#4329) (Dunqing) - f68b659 ast: [**BREAKING**] Reorder fields of `ArrowFunctionExpression` (#4364) (Dunqing) ### Features - d345b84 ast: Add `#[ast]` attribute to non-visited AST types. (#4309) (rzvxa) - 3c0c709 linter: Add typescript-eslint/no-extraneous-class (#4357) (Jaden Rodriguez) - 68efcd4 linter/react-perf: Handle new objects and arrays in prop assignment patterns (#4396) (DonIsaac) - 0deb027 minfier: Dce `if (xxx) else if (false) { REMOVE }` (#4407) (Boshen) - e33ec18 minifier: Compress `typeof foo == "undefined"` into `typeof foo > "u"` (#4412) (Boshen)- 6068e6b Add error codes to OxcDiagnostic (#4334) (DonIsaac) ### Bug Fixes - aece1df ast: Visit `Program`s `hashbang` field first (#4368) (overlookmotel) - 44a10c4 codegen: Object shorthand with parens `({x: (x)})` -> `({ x })` (#4391) (Boshen) - 3d88f20 codegen: Print shorthand for all `{ x }` variants (#4374) (Boshen) - e624dff codegen,mangler: Do not print shorthand for `ObjectProperty` (#4350) (Boshen) - ac08de8 linter/react_perf: Allow new objects, array, fns, etc in top scope (#4395) (DonIsaac) - 267f7c4 minifier: Skip `Object.defineProperty(exports, ...)` for `cjs-module-lexer` (#4409) (Boshen) - bc8d4e5 semantic: Correct comment (#4410) (overlookmotel) - 6ffce86 semantic: Align `visit_arrow_function_expression` field visit order with ast (#4366) (Dunqing) - 4cd5df0 sourcemap: Avoid negative line if token_chunks has same prev_dst_line (#4348) (underfin) - f8565ae transformer/typescript: Unexpectedly removed class binding from ExportNamedDeclaration (#4351) (Dunqing)- ea33f94 Impl PartialEq<str> for CompactStr (#4352) (DonIsaac) ### Performance - 1b51511 semantic: Use `Atom` instead of `CompactStr` for `UnresolvedReferencesStack` (#4401) (Dunqing) - 40f9356 semantic: Calculate number of nodes, scopes, symbols, references before visiting AST (#4367) (Dunqing) - da13d93 semantic: Remove bounds checks on unresolved references stack (#4390) (overlookmotel) - e70c67b semantic: Remove a branch from `add_scope` (#4384) (overlookmotel) - 402006f semantic: Simplify logic in `enter_scope` + `leave_scope` (#4383) (overlookmotel) - 7469e01 semantic: Remove branch from `Nodes::add_node` (#4361) (overlookmotel) - 7eb2864 traverse: Speed up finding UID binding name (#4356) (overlookmotel)- a207923 Replace some CompactStr usages with Cows (#4377) (DonIsaac) ### Refactor - d213773 ast: Replace serde rename "lowercase" with "camelCase" (#4376) (overlookmotel) - abfccbd ast: Reduce `#[cfg_attr]` boilerplate in AST type defs (#4375) (overlookmotel) - 5f1c7ec ast: Rename the `visited_node` marker to `ast`. (#4289) (rzvxa) - 58f6ec2 ast: Enter node before scope (#4347) (Dunqing) - 59aea73 ast: Scope is created only if CatchClause has param (#4346) (Dunqing) - 7a3e925 ast_codegen: Better visit marker parsing. (#4371) (rzvxa) - 7a75e0f linter: Use diagnostic codes in lint rules (#4349) (DonIsaac) - a2eabe1 parser: Use error codes for ts diagnostics (#4335) (DonIsaac) - 5d77b36 semantic: `visit_program` visit `hashbang` field (#4370) (overlookmotel) - f7b9ada semantic: `Program` visitor leave scope before node (#4369) (overlookmotel) - 729b288 semantic: Shorten code (#4358) (overlookmotel) - 21d0eee semantic: Use error codes for ts diagnostics (#4336) (DonIsaac) Co-authored-by: Boshen <Boshen@users.noreply.github.com>
## [0.22.0] - 2024-07-23 - 85a7cea semantic: [**BREAKING**] Remove name from `reference` (#4329) (Dunqing) - f68b659 ast: [**BREAKING**] Reorder fields of `ArrowFunctionExpression` (#4364) (Dunqing) ### Features - d345b84 ast: Add `#[ast]` attribute to non-visited AST types. (#4309) (rzvxa) - 3c0c709 linter: Add typescript-eslint/no-extraneous-class (#4357) (Jaden Rodriguez) - 68efcd4 linter/react-perf: Handle new objects and arrays in prop assignment patterns (#4396) (DonIsaac) - 0deb027 minfier: Dce `if (xxx) else if (false) { REMOVE }` (#4407) (Boshen) - e33ec18 minifier: Compress `typeof foo == "undefined"` into `typeof foo > "u"` (#4412) (Boshen)- 6068e6b Add error codes to OxcDiagnostic (#4334) (DonIsaac) ### Bug Fixes - aece1df ast: Visit `Program`s `hashbang` field first (#4368) (overlookmotel) - 44a10c4 codegen: Object shorthand with parens `({x: (x)})` -> `({ x })` (#4391) (Boshen) - 3d88f20 codegen: Print shorthand for all `{ x }` variants (#4374) (Boshen) - e624dff codegen,mangler: Do not print shorthand for `ObjectProperty` (#4350) (Boshen) - ac08de8 linter/react_perf: Allow new objects, array, fns, etc in top scope (#4395) (DonIsaac) - 267f7c4 minifier: Skip `Object.defineProperty(exports, ...)` for `cjs-module-lexer` (#4409) (Boshen) - bc8d4e5 semantic: Correct comment (#4410) (overlookmotel) - 6ffce86 semantic: Align `visit_arrow_function_expression` field visit order with ast (#4366) (Dunqing) - 4cd5df0 sourcemap: Avoid negative line if token_chunks has same prev_dst_line (#4348) (underfin) - f8565ae transformer/typescript: Unexpectedly removed class binding from ExportNamedDeclaration (#4351) (Dunqing)- ea33f94 Impl PartialEq<str> for CompactStr (#4352) (DonIsaac) ### Performance - 1b51511 semantic: Use `Atom` instead of `CompactStr` for `UnresolvedReferencesStack` (#4401) (Dunqing) - 40f9356 semantic: Calculate number of nodes, scopes, symbols, references before visiting AST (#4367) (Dunqing) - da13d93 semantic: Remove bounds checks on unresolved references stack (#4390) (overlookmotel) - e70c67b semantic: Remove a branch from `add_scope` (#4384) (overlookmotel) - 402006f semantic: Simplify logic in `enter_scope` + `leave_scope` (#4383) (overlookmotel) - 7469e01 semantic: Remove branch from `Nodes::add_node` (#4361) (overlookmotel) - 7eb2864 traverse: Speed up finding UID binding name (#4356) (overlookmotel)- a207923 Replace some CompactStr usages with Cows (#4377) (DonIsaac) ### Refactor - 504daed allocator: Rename fn params for `Box::new_in` (#4431) (overlookmotel) - d213773 ast: Replace serde rename "lowercase" with "camelCase" (#4376) (overlookmotel) - abfccbd ast: Reduce `#[cfg_attr]` boilerplate in AST type defs (#4375) (overlookmotel) - 5f1c7ec ast: Rename the `visited_node` marker to `ast`. (#4289) (rzvxa) - 58f6ec2 ast: Enter node before scope (#4347) (Dunqing) - 59aea73 ast: Scope is created only if CatchClause has param (#4346) (Dunqing) - 7a3e925 ast_codegen: Better visit marker parsing. (#4371) (rzvxa) - 0e1ea90 isolated-declarations: Remove useless code from scope (#4420) (Dunqing) - 7a75e0f linter: Use diagnostic codes in lint rules (#4349) (DonIsaac) - a2eabe1 parser: Use error codes for ts diagnostics (#4335) (DonIsaac) - 5d77b36 semantic: `visit_program` visit `hashbang` field (#4370) (overlookmotel) - f7b9ada semantic: `Program` visitor leave scope before node (#4369) (overlookmotel) - 729b288 semantic: Shorten code (#4358) (overlookmotel) - 21d0eee semantic: Use error codes for ts diagnostics (#4336) (DonIsaac) Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
- 85a7cea semantic: [**BREAKING**] Remove name from `reference` (#4329) (Dunqing) - f68b659 ast: [**BREAKING**] Reorder fields of `ArrowFunctionExpression` (#4364) (Dunqing) - d345b84 ast: Add `#[ast]` attribute to non-visited AST types. (#4309) (rzvxa) - 3c0c709 linter: Add typescript-eslint/no-extraneous-class (#4357) (Jaden Rodriguez) - 68efcd4 linter/react-perf: Handle new objects and arrays in prop assignment patterns (#4396) (DonIsaac) - 0deb027 minfier: Dce `if (xxx) else if (false) { REMOVE }` (#4407) (Boshen) - e33ec18 minifier: Compress `typeof foo == "undefined"` into `typeof foo > "u"` (#4412) (Boshen)- 6068e6b Add error codes to OxcDiagnostic (#4334) (DonIsaac) - aece1df ast: Visit `Program`s `hashbang` field first (#4368) (overlookmotel) - 44a10c4 codegen: Object shorthand with parens `({x: (x)})` -> `({ x })` (#4391) (Boshen) - 3d88f20 codegen: Print shorthand for all `{ x }` variants (#4374) (Boshen) - e624dff codegen,mangler: Do not print shorthand for `ObjectProperty` (#4350) (Boshen) - ac08de8 linter/react_perf: Allow new objects, array, fns, etc in top scope (#4395) (DonIsaac) - 267f7c4 minifier: Skip `Object.defineProperty(exports, ...)` for `cjs-module-lexer` (#4409) (Boshen) - bc8d4e5 semantic: Correct comment (#4410) (overlookmotel) - 6ffce86 semantic: Align `visit_arrow_function_expression` field visit order with ast (#4366) (Dunqing) - 4cd5df0 sourcemap: Avoid negative line if token_chunks has same prev_dst_line (#4348) (underfin) - f8565ae transformer/typescript: Unexpectedly removed class binding from ExportNamedDeclaration (#4351) (Dunqing)- ea33f94 Impl PartialEq<str> for CompactStr (#4352) (DonIsaac) - 1b51511 semantic: Use `Atom` instead of `CompactStr` for `UnresolvedReferencesStack` (#4401) (Dunqing) - 40f9356 semantic: Calculate number of nodes, scopes, symbols, references before visiting AST (#4367) (Dunqing) - da13d93 semantic: Remove bounds checks on unresolved references stack (#4390) (overlookmotel) - e70c67b semantic: Remove a branch from `add_scope` (#4384) (overlookmotel) - 402006f semantic: Simplify logic in `enter_scope` + `leave_scope` (#4383) (overlookmotel) - 7469e01 semantic: Remove branch from `Nodes::add_node` (#4361) (overlookmotel) - 7eb2864 traverse: Speed up finding UID binding name (#4356) (overlookmotel)- a207923 Replace some CompactStr usages with Cows (#4377) (DonIsaac) - d213773 ast: Replace serde rename "lowercase" with "camelCase" (#4376) (overlookmotel) - abfccbd ast: Reduce `#[cfg_attr]` boilerplate in AST type defs (#4375) (overlookmotel) - 5f1c7ec ast: Rename the `visited_node` marker to `ast`. (#4289) (rzvxa) - 58f6ec2 ast: Enter node before scope (#4347) (Dunqing) - 59aea73 ast: Scope is created only if CatchClause has param (#4346) (Dunqing) - 7a3e925 ast_codegen: Better visit marker parsing. (#4371) (rzvxa) - 7a75e0f linter: Use diagnostic codes in lint rules (#4349) (DonIsaac) - a2eabe1 parser: Use error codes for ts diagnostics (#4335) (DonIsaac) - 5d77b36 semantic: `visit_program` visit `hashbang` field (#4370) (overlookmotel) - f7b9ada semantic: `Program` visitor leave scope before node (#4369) (overlookmotel) - 729b288 semantic: Shorten code (#4358) (overlookmotel) - 21d0eee semantic: Use error codes for ts diagnostics (#4336) (DonIsaac) Co-authored-by: Boshen <Boshen@users.noreply.github.com>
## [0.7.0] - 2024-08-05 - 85a7cea semantic: [**BREAKING**] Remove name from `reference` (#4329) (Dunqing) ### Features - aaee07e ast: Add `AstKind::AssignmentTargetPattern`, `AstKind::ArrayAssignmentTarget` and `AstKind::ObjectAssignmentTarget` (#4456) (Dunqing) - 9df7b56 jsx-a11y/no-autofocus: Implement fixer support (#4171) (Jelle van der Waa) - b87bf70 linter: Add fix capabilties to existing lint rules (#4560) (DonIsaac) - ddd8b27 linter: Support conditional fix capabilities (#4559) (DonIsaac) - b952942 linter: Add eslint/no-unused-vars (⭐ attempt 3.2) (#4445) (DonIsaac) - 6543958 linter: Add auto-fix metadata to RuleMeta (#4557) (Don Isaac) - 85e8418 linter: Add react/jsx-curly-brace-presence (#3949) (Don Isaac) - 4c4da56 linter: Add typescript-eslint/prefer-keyword-namespce (#4438) (Aza Walker) - d8c2a83 linter: Eslint-plugin-vitest/no-import-node-test (#4440) (cinchen) - e3b0c40 linter: Eslint-plugin-vitest/no-identical-title (#4422) (cinchen) - c936782 linter: Eslint-plugin-vitest/no-conditional-expect (#4425) (cinchen) - 27fdd69 linter: Eslint-plugin-vitest/no-commented-out-tests (#4424) (cinchen) - 51f5025 linter: Add fixer for unicorn/prefer-string-starts-ends-with (#4378) (DonIsaac) - 3c0c709 linter: Add typescript-eslint/no-extraneous-class (#4357) (Jaden Rodriguez) - 7afa1f0 linter: Support suggestions and dangerous fixes (#4223) (DonIsaac) - acc5729 linter: Eslint-plugin-vitest/expect-expect (#4299) (cinchen) - 2213f93 linter: Eslint-plugin-vitest/no-alias-methods (#4301) (cinchen) - c296bc3 linter/eslint: Implement func-names (#4618) (Alexander S.) - e116ae0 linter/eslint: Implement fixer for prefer-numeric-literals (#4591) (Jelle van der Waa) - eaf834f linter/eslint: Implement prefer-numeric-literals (#4109) (Jelle van der Waa) - db2fd70 linter/eslint-plugin-promise: Implement no-webpack-loader-syntax (#4331) (Jelle van der Waa) - 5f1e070 linter/eslint-plugin-unicorn: Add fixer for prefer-code-point (#4353) (Jelle van der Waa) - ed49e16 linter/eslint-plugin-unicorn: Implement fixer for prefer-dom-node-append (#4306) (Jelle van der Waa) - e2b15ac linter/react: Implement react-jsx-boolean-value (#4613) (Jelle van der Waa) - 68efcd4 linter/react-perf: Handle new objects and arrays in prop assignment patterns (#4396) (DonIsaac) ### Bug Fixes - 368112c ast: Remove `#[visit(ignore)]` from `ExportDefaultDeclarationKind`'s `TSInterfaceDeclaration` (#4497) (Dunqing) - d384f60 ci: Remove unused(?) .html file (#4545) (Yuji Sugiura) - 06aec77 linter: Invalid binary expression with overflow (#4647) (DonIsaac) - b2da22b linter: Invalid tags in rule docs (#4646) (DonIsaac) - 94440ad linter: Panic on invalid lang in `a11y/lang`. (#4630) (rzvxa) - e0b03f8 linter: Improve the boundary for eslint/for-direction (#4590) (heygsc) - 70b8cfa linter: Missing return in no-obj-calls recursion (#4594) (DonIsaac) - fe1356d linter: Change no-unused-vars to nursery (#4588) (DonIsaac) - 72337b1 linter: Change typescript-eslint/no-namespace to restriction (#4539) (Don Isaac) - 732f4e2 linter: Fix `oxlint` allocator cfg (#4527) (overlookmotel) - 289dc39 linter: Overflow in no-obj-calls (#4397) (DonIsaac) - a664715 linter/eslint: Fix invalid regexp in no_regex_spaces test (#4605) (Yuji Sugiura) - 74fa75a linter/eslint: Drop quotes around max-params lint warning (#4608) (Jelle van der Waa) - 9fcd9ae linter/eslint: Fix invalid regexp in no_control_regex test (#4544) (leaysgur) - ac08de8 linter/react_perf: Allow new objects, array, fns, etc in top scope (#4395) (DonIsaac) - 0fba738 npm: SyntaxError caused by optional chaining in low version node (#4650) (heygsc) - 73d2558 oxlint: Fix oxlint failed to build due to missing feature (Boshen) ### Performance - 6ff200d linter: Change react rules and utils to use `Cow` and `CompactStr` instead of `String` (#4603) (DonIsaac) - f259df0 linter: Make img-redundant-alt only build a regex once (#4604) (DonIsaac) - 7585e16 linter: Remove allocations for string comparisons (#4570) (DonIsaac) - b60bdf1 linter: `no_shadow_restricted_names` only look up name in hashmap once (#4472) (overlookmotel) - 81384f5 linter: Avoid unnecessary work in `nextjs:no_duplicate_head` rule (#4465) (overlookmotel) - f7da22d linter: Disable lint rules by file type (#4380) (DonIsaac) - 348c1ad semantic: Remove `span` field from `Reference` (#4464) (overlookmotel) - 6a9f4db semantic: Reduce storage size for symbol redeclarations (#4463) (overlookmotel)- a207923 Replace some CompactStr usages with Cows (#4377) (DonIsaac) ### Refactor - 7a75e0f linter: Use diagnostic codes in lint rules (#4349) (DonIsaac) - ccb1835 semantic: Methods take `Span` as param, not `&Span` (#4470) (overlookmotel) - 7cd53f3 semantic: Var hoisting (#4379) (Dunqing) - c99b3eb syntax: Give `ScopeId` a niche (#4468) (overlookmotel) Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
What This PR Does
Updates the linter to populate diagnostics reported by rules with error codes statically derived from
RuleMeta
+RuleEnum
.Doing so required changing how we handle vitest rules. I know @mysterven was hoping to refactor that part of the code, and I think this approach is an improvement (but could probably be cleaned up further).
Changes
1. Auto-Populate Error Codes
LintContext
now sets an error code scope + error code number for diagnostics reported by lint rules.LintContext
will not clobber existing codes set by rules, allowing for rule-specific override behavior (e.g. to useeslint-plugin-react-hooks
as an error scope).In order to accomplish this, I had to update every diagnostic factory for every rule. While doing this I found some incorrect error messages, or messages that could be easily improved. This is where a large majority of the snapshot diffs come from. Additionally, I was able to reduce string allocations from
format!
usages in diagnostic factories, especially within jest rules.2. Framework and Library Detection
This PR adds
FrameworkFlags
, which specify what (if any) set of libraries and frameworks are being used by a project and/or file. They are passed in two ways:LintOptions
can specify a set offramework_hints
that apply to the entire target codebase. Right now these are always empty, but I'm thinking in the future we could sniffpackage.json
. It may be helpful for enabling/disabling default rules.Linter
gets run on a file, framework information is sniffed from theLintContext
. Right now, we are only checking forvitest
imports inModuleRecord
and test path prefixes fromsource_path
. It may be useful to do something similar for React/NextJS rules in the future. I know that next/no-html-link-for-pages could benefit greatly from this.