fix(linter_codegen): compute rule IDs relative to previous rule#19350
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
This pull request changes how rule IDs are calculated in the linter code generation to reduce merge conflicts when new rules are added. Previously, rule IDs were generated as sequential numeric literals (0, 1, 2, etc.), meaning that adding a new rule would increment all subsequent IDs. Now, rule IDs are defined as constants where each constant is calculated relative to the previous one (PREV_RULE_ID + 1usize), so adding a new rule only affects the new constant and its immediate successor.
Changes:
- Modified the code generator to emit ID constants defined relative to the previous rule instead of using sequential numeric literals
- Added
generate_id_constants()function to generate the relative constant definitions - Added
make_const_ident()helper to create constant identifiers - Updated
generate_rule_enum_impl()to reference constants instead of using index-based literals
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tasks/linter_codegen/src/rules_enum.rs | Adds code generation logic for relative ID constants and updates the ID assignment to use constants instead of literal indices |
| crates/oxc_linter/src/generated/rules_enum.rs | Generated output showing constants defined relative to previous constants and id() method returning constants instead of literals |
|
I don't think there's anything too controversial here, going to go ahead and merge |
Merge activity
|
The main cause of merge conflicts in new rule PRs lately has been due to the calculation of the rule ID. Currently, adding a new rule causes the ID of every subsequent rule to increment by one, causing a large amount of lines to change. With these changes, the rule ID is calculated relative to the ID of the previous rule. The actual ID values are calculated elsewhere. This means that adding a new rule doesn't result in a diff, because most IDs are unchanged since the rule order is not changed. Here is an example `git diff` from running `just new-eslint-rule` with a new rule after these changes: ```diff diff --git a/crates/oxc_linter/src/generated/rule_runner_impls.rs b/crates/oxc_linter/src/generated/rule_runner_impls.rs index 3d3da94..3143f56b72 100644 --- a/crates/oxc_linter/src/generated/rule_runner_impls.rs +++ b/crates/oxc_linter/src/generated/rule_runner_impls.rs @@ -205,6 +205,11 @@ impl RuleRunner for crate::rules::import::unambiguous::Unambiguous { const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::RunOnce; } +impl RuleRunner for crate::rules::eslint::consistent_this::ConsistentThis { + const NODE_TYPES: Option<&AstTypesBitset> = None; + const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run; +} + impl RuleRunner for crate::rules::eslint::accessor_pairs::AccessorPairs { const NODE_TYPES: Option<&AstTypesBitset> = Some(&AstTypesBitset::from_types(&[ AstType::CallExpression, diff --git a/crates/oxc_linter/src/generated/rules_enum.rs b/crates/oxc_linter/src/generated/rules_enum.rs index 61c5e19..b94238878e 100644 --- a/crates/oxc_linter/src/generated/rules_enum.rs +++ b/crates/oxc_linter/src/generated/rules_enum.rs @@ -15,6 +15,7 @@ pub use crate::rules::eslint::block_scoped_var::BlockScopedVar as EslintBlockSco pub use crate::rules::eslint::capitalized_comments::CapitalizedComments as EslintCapitalizedComments; pub use crate::rules::eslint::class_methods_use_this::ClassMethodsUseThis as EslintClassMethodsUseThis; pub use crate::rules::eslint::complexity::Complexity as EslintComplexity; +pub use crate::rules::eslint::consistent_this::ConsistentThis as EslintConsistentThis; pub use crate::rules::eslint::constructor_super::ConstructorSuper as EslintConstructorSuper; pub use crate::rules::eslint::curly::Curly as EslintCurly; pub use crate::rules::eslint::default_case::DefaultCase as EslintDefaultCase; @@ -720,6 +721,7 @@ pub enum RuleEnum { ImportNoWebpackLoaderSyntax(ImportNoWebpackLoaderSyntax), ImportPreferDefaultExport(ImportPreferDefaultExport), ImportUnambiguous(ImportUnambiguous), + EslintConsistentThis(EslintConsistentThis), EslintAccessorPairs(EslintAccessorPairs), EslintArrayCallbackReturn(EslintArrayCallbackReturn), EslintArrowBodyStyle(EslintArrowBodyStyle), @@ -1396,7 +1398,8 @@ const IMPORT_NO_UNASSIGNED_IMPORT_ID: usize = IMPORT_NO_SELF_IMPORT_ID + 1usize; const IMPORT_NO_WEBPACK_LOADER_SYNTAX_ID: usize = IMPORT_NO_UNASSIGNED_IMPORT_ID + 1usize; const IMPORT_PREFER_DEFAULT_EXPORT_ID: usize = IMPORT_NO_WEBPACK_LOADER_SYNTAX_ID + 1usize; const IMPORT_UNAMBIGUOUS_ID: usize = IMPORT_PREFER_DEFAULT_EXPORT_ID + 1usize; -const ESLINT_ACCESSOR_PAIRS_ID: usize = IMPORT_UNAMBIGUOUS_ID + 1usize; +const ESLINT_CONSISTENT_THIS_ID: usize = IMPORT_UNAMBIGUOUS_ID + 1usize; +const ESLINT_ACCESSOR_PAIRS_ID: usize = ESLINT_CONSISTENT_THIS_ID + 1usize; const ESLINT_ARRAY_CALLBACK_RETURN_ID: usize = ESLINT_ACCESSOR_PAIRS_ID + 1usize; const ESLINT_ARROW_BODY_STYLE_ID: usize = ESLINT_ARRAY_CALLBACK_RETURN_ID + 1usize; const ESLINT_BLOCK_SCOPED_VAR_ID: usize = ESLINT_ARROW_BODY_STYLE_ID + 1usize; @@ -2151,6 +2154,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(_) => IMPORT_NO_WEBPACK_LOADER_SYNTAX_ID, Self::ImportPreferDefaultExport(_) => IMPORT_PREFER_DEFAULT_EXPORT_ID, Self::ImportUnambiguous(_) => IMPORT_UNAMBIGUOUS_ID, + Self::EslintConsistentThis(_) => ESLINT_CONSISTENT_THIS_ID, Self::EslintAccessorPairs(_) => ESLINT_ACCESSOR_PAIRS_ID, Self::EslintArrayCallbackReturn(_) => ESLINT_ARRAY_CALLBACK_RETURN_ID, Self::EslintArrowBodyStyle(_) => ESLINT_ARROW_BODY_STYLE_ID, @@ -2920,6 +2924,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(_) => ImportNoWebpackLoaderSyntax::NAME, Self::ImportPreferDefaultExport(_) => ImportPreferDefaultExport::NAME, Self::ImportUnambiguous(_) => ImportUnambiguous::NAME, + Self::EslintConsistentThis(_) => EslintConsistentThis::NAME, Self::EslintAccessorPairs(_) => EslintAccessorPairs::NAME, Self::EslintArrayCallbackReturn(_) => EslintArrayCallbackReturn::NAME, Self::EslintArrowBodyStyle(_) => EslintArrowBodyStyle::NAME, @@ -3683,6 +3688,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(_) => ImportNoWebpackLoaderSyntax::CATEGORY, Self::ImportPreferDefaultExport(_) => ImportPreferDefaultExport::CATEGORY, Self::ImportUnambiguous(_) => ImportUnambiguous::CATEGORY, + Self::EslintConsistentThis(_) => EslintConsistentThis::CATEGORY, Self::EslintAccessorPairs(_) => EslintAccessorPairs::CATEGORY, Self::EslintArrayCallbackReturn(_) => EslintArrayCallbackReturn::CATEGORY, Self::EslintArrowBodyStyle(_) => EslintArrowBodyStyle::CATEGORY, @@ -4487,6 +4493,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(_) => ImportNoWebpackLoaderSyntax::FIX, Self::ImportPreferDefaultExport(_) => ImportPreferDefaultExport::FIX, Self::ImportUnambiguous(_) => ImportUnambiguous::FIX, + Self::EslintConsistentThis(_) => EslintConsistentThis::FIX, Self::EslintAccessorPairs(_) => EslintAccessorPairs::FIX, Self::EslintArrayCallbackReturn(_) => EslintArrayCallbackReturn::FIX, Self::EslintArrowBodyStyle(_) => EslintArrowBodyStyle::FIX, @@ -5255,6 +5262,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(_) => ImportNoWebpackLoaderSyntax::documentation(), Self::ImportPreferDefaultExport(_) => ImportPreferDefaultExport::documentation(), Self::ImportUnambiguous(_) => ImportUnambiguous::documentation(), + Self::EslintConsistentThis(_) => EslintConsistentThis::documentation(), Self::EslintAccessorPairs(_) => EslintAccessorPairs::documentation(), Self::EslintArrayCallbackReturn(_) => EslintArrayCallbackReturn::documentation(), Self::EslintArrowBodyStyle(_) => EslintArrowBodyStyle::documentation(), @@ -6248,6 +6256,8 @@ impl RuleEnum { } Self::ImportUnambiguous(_) => ImportUnambiguous::config_schema(generator) .or_else(|| ImportUnambiguous::schema(generator)), + Self::EslintConsistentThis(_) => EslintConsistentThis::config_schema(generator) + .or_else(|| EslintConsistentThis::schema(generator)), Self::EslintAccessorPairs(_) => EslintAccessorPairs::config_schema(generator) .or_else(|| EslintAccessorPairs::schema(generator)), Self::EslintArrayCallbackReturn(_) => { @@ -8093,6 +8103,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(_) => "import", Self::ImportPreferDefaultExport(_) => "import", Self::ImportUnambiguous(_) => "import", + Self::EslintConsistentThis(_) => "eslint", Self::EslintAccessorPairs(_) => "eslint", Self::EslintArrayCallbackReturn(_) => "eslint", Self::EslintArrowBodyStyle(_) => "eslint", @@ -8831,6 +8842,9 @@ impl RuleEnum { Self::ImportUnambiguous(_) => { Ok(Self::ImportUnambiguous(ImportUnambiguous::from_configuration(value)?)) } + Self::EslintConsistentThis(_) => { + Ok(Self::EslintConsistentThis(EslintConsistentThis::from_configuration(value)?)) + } Self::EslintAccessorPairs(_) => { Ok(Self::EslintAccessorPairs(EslintAccessorPairs::from_configuration(value)?)) } @@ -10918,6 +10932,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(rule) => rule.to_configuration(), Self::ImportPreferDefaultExport(rule) => rule.to_configuration(), Self::ImportUnambiguous(rule) => rule.to_configuration(), + Self::EslintConsistentThis(rule) => rule.to_configuration(), Self::EslintAccessorPairs(rule) => rule.to_configuration(), Self::EslintArrayCallbackReturn(rule) => rule.to_configuration(), Self::EslintArrowBodyStyle(rule) => rule.to_configuration(), @@ -11597,6 +11612,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(rule) => rule.run(node, ctx), Self::ImportPreferDefaultExport(rule) => rule.run(node, ctx), Self::ImportUnambiguous(rule) => rule.run(node, ctx), + Self::EslintConsistentThis(rule) => rule.run(node, ctx), Self::EslintAccessorPairs(rule) => rule.run(node, ctx), Self::EslintArrayCallbackReturn(rule) => rule.run(node, ctx), Self::EslintArrowBodyStyle(rule) => rule.run(node, ctx), @@ -12272,6 +12288,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(rule) => rule.run_once(ctx), Self::ImportPreferDefaultExport(rule) => rule.run_once(ctx), Self::ImportUnambiguous(rule) => rule.run_once(ctx), + Self::EslintConsistentThis(rule) => rule.run_once(ctx), Self::EslintAccessorPairs(rule) => rule.run_once(ctx), Self::EslintArrayCallbackReturn(rule) => rule.run_once(ctx), Self::EslintArrowBodyStyle(rule) => rule.run_once(ctx), @@ -12951,6 +12968,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(rule) => rule.run_on_jest_node(jest_node, ctx), Self::ImportPreferDefaultExport(rule) => rule.run_on_jest_node(jest_node, ctx), Self::ImportUnambiguous(rule) => rule.run_on_jest_node(jest_node, ctx), + Self::EslintConsistentThis(rule) => rule.run_on_jest_node(jest_node, ctx), Self::EslintAccessorPairs(rule) => rule.run_on_jest_node(jest_node, ctx), Self::EslintArrayCallbackReturn(rule) => rule.run_on_jest_node(jest_node, ctx), Self::EslintArrowBodyStyle(rule) => rule.run_on_jest_node(jest_node, ctx), @@ -13712,6 +13730,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(rule) => rule.should_run(ctx), Self::ImportPreferDefaultExport(rule) => rule.should_run(ctx), Self::ImportUnambiguous(rule) => rule.should_run(ctx), + Self::EslintConsistentThis(rule) => rule.should_run(ctx), Self::EslintAccessorPairs(rule) => rule.should_run(ctx), Self::EslintArrayCallbackReturn(rule) => rule.should_run(ctx), Self::EslintArrowBodyStyle(rule) => rule.should_run(ctx), @@ -14393,6 +14412,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(_) => ImportNoWebpackLoaderSyntax::IS_TSGOLINT_RULE, Self::ImportPreferDefaultExport(_) => ImportPreferDefaultExport::IS_TSGOLINT_RULE, Self::ImportUnambiguous(_) => ImportUnambiguous::IS_TSGOLINT_RULE, + Self::EslintConsistentThis(_) => EslintConsistentThis::IS_TSGOLINT_RULE, Self::EslintAccessorPairs(_) => EslintAccessorPairs::IS_TSGOLINT_RULE, Self::EslintArrayCallbackReturn(_) => EslintArrayCallbackReturn::IS_TSGOLINT_RULE, Self::EslintArrowBodyStyle(_) => EslintArrowBodyStyle::IS_TSGOLINT_RULE, @@ -15335,6 +15355,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(_) => ImportNoWebpackLoaderSyntax::HAS_CONFIG, Self::ImportPreferDefaultExport(_) => ImportPreferDefaultExport::HAS_CONFIG, Self::ImportUnambiguous(_) => ImportUnambiguous::HAS_CONFIG, + Self::EslintConsistentThis(_) => EslintConsistentThis::HAS_CONFIG, Self::EslintAccessorPairs(_) => EslintAccessorPairs::HAS_CONFIG, Self::EslintArrayCallbackReturn(_) => EslintArrayCallbackReturn::HAS_CONFIG, Self::EslintArrowBodyStyle(_) => EslintArrowBodyStyle::HAS_CONFIG, @@ -16162,6 +16183,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(rule) => rule.types_info(), Self::ImportPreferDefaultExport(rule) => rule.types_info(), Self::ImportUnambiguous(rule) => rule.types_info(), + Self::EslintConsistentThis(rule) => rule.types_info(), Self::EslintAccessorPairs(rule) => rule.types_info(), Self::EslintArrayCallbackReturn(rule) => rule.types_info(), Self::EslintArrowBodyStyle(rule) => rule.types_info(), @@ -16837,6 +16859,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(rule) => rule.run_info(), Self::ImportPreferDefaultExport(rule) => rule.run_info(), Self::ImportUnambiguous(rule) => rule.run_info(), + Self::EslintConsistentThis(rule) => rule.run_info(), Self::EslintAccessorPairs(rule) => rule.run_info(), Self::EslintArrayCallbackReturn(rule) => rule.run_info(), Self::EslintArrowBodyStyle(rule) => rule.run_info(), @@ -17534,6 +17557,7 @@ pub static RULES: std::sync::LazyLock<Vec<RuleEnum>> = std::sync::LazyLock::new( RuleEnum::ImportNoWebpackLoaderSyntax(ImportNoWebpackLoaderSyntax::default()), RuleEnum::ImportPreferDefaultExport(ImportPreferDefaultExport::default()), RuleEnum::ImportUnambiguous(ImportUnambiguous::default()), + RuleEnum::EslintConsistentThis(EslintConsistentThis::default()), RuleEnum::EslintAccessorPairs(EslintAccessorPairs::default()), RuleEnum::EslintArrayCallbackReturn(EslintArrayCallbackReturn::default()), RuleEnum::EslintArrowBodyStyle(EslintArrowBodyStyle::default()), ```
7a12378 to
81f0039
Compare
# Oxlint ### 💥 BREAKING CHANGES - 7711821 oxlint: [**BREAKING**] `no-shadow-restricted-names` report `globalThis` by default (#19407) (Sysix) ### 🚀 Features - ce1baa0 linter: Implement eslint/no-shadow (#18979) (Víctor Fernández) - 7a333c1 linter: Support dynamic configs via CLI arguments (#19384) (camc314) - 1bf569b linter: Implement typescript/unified-signatures (#19375) (camc314) - 6562a9b linter: Implement typescript/parameter-properties (#19374) (camc314) - 94d8d74 linter: Implement typescript/no-use-before-define (#19373) (camc314) - 80b002a linter: Implement fixer for unicorn/no-instanceof-builtins (#19371) (camc314) - 5c3784b linter: Implement eslint/no-unmodified-loop-condition (#19341) (Vincent R) - cc00a59 linter/const-comparisons: Improve diagnostics when mixing logical/comparison operators (#19370) (camc314) - ea2c401 linter: Add support for no constructed context values (#18067) (Jovi De Croock) - f2440eb linter: Mark eslint/no-return-assign as having no fixer (#19327) (camc314) - 8588670 linter/unicorn: Implement suggestion for `unicorn/no-await-in-promise-methods` rule (#19359) (Mikhail Baev) - f0af965 linter: Move `jsx-a11y/no-static-element-interactions` rule out of the nursery. (#19355) (connorshea) - be0ce50 linter/tsgolint: Add support for labeled ranges in tsgolint diagnostics (#19201) (camchenry) - b5bc900 linter: Implement fixer for unicorn/no-new-buffer (#19326) (camc314) - 1612932 linter: Add typescript/no-unnecessary-condition (#19130) (camc314) - 37dc6c5 linter: Implement fixer for unicorn/prefer-includes (#19323) (camc314) ### 🐛 Bug Fixes - c2b1870 linter: Enforce config options for `react/forbid-dom-props` rule. (#19387) (connorshea) - 3d24e44 linter: Honor no-empty-function allow getters/setters for object literals (#19393) (camc314) - bbced8d linter: Enforce config options for `eslint/no-empty-function` rule, improve docs. (#19390) (connorshea) - 6bc8aec linter: Fix the behavior of `import/extensions` rule for a file that has multiple extensions. (#18919) (connorshea) - c62a295 linter/img-redundant-alt: Enforce whole-word matching for redundant alt text (#19367) (camc314) - 98956fe linter/describe-function-title: Skip autofix for type-only imports (#19329) (camc314) - d96d26d linter/plugins: Provide `parser.version` (#19364) (overlookmotel) - 81f0039 linter_codegen: Compute rule IDs relative to previous rule (#19350) (camchenry) - b7ef0a8 linter/consistent-indexed-object-style: Avoid unsafe Record conversions for mapped types (#19320) (camc314) ### 📚 Documentation - 3a6059f linter: Improve docs for `eslint/require-await` rule. (#19361) (connorshea) - b069269 linter/plugins: Add comment about deprecated `ScopeManager` methods (#19363) (overlookmotel) - 2d8aaf9 linter: Disable formatting for `eslint/no-unsafe-negation` examples. (#19347) (connorshea) - fb87806 linter: Ensure that we do not auto-format the docs for `unicorn/number-literal-case` rule. (#19346) (connorshea) - 8d3ae27 linter/typescript: Skip docs for deprecated type aware rule options (#19324) (camc314) # Oxfmt ### 💥 BREAKING CHANGES - 00135b5 formatter/sort_imports: [**BREAKING**] Change default `groups` order (#19427) (leaysgur) - 9c34f72 formatter/sort_imports: [**BREAKING**] Report invalid group name with renaming `side-effect` > `side_effect` (#19416) (leaysgur) ### 🚀 Features - 4baebef formatter/sort_imports: Support `{ newlinesBetween: bool }` inside `groups` (#19358) (leaysgur) - d1c2fb6 formatter/sort_imports: Support `customGroups` attributes(`selector` and `modifiers`) (#19356) (leaysgur) ### 🐛 Bug Fixes - f084ea6 oxfmt: Explicitly pass `process.env` for the forked process (#19380) (Long Ho) - 2bc7a14 formatter: Arrow function body incorrectly broken when return type has comment (#19368) (Dunqing) - 90ec3d2 oxfmt: Update tailwind plugin which fixes crash on non-js file (#19353) (leaysgur) - e9c5b1e formatter: Treat `PrivateFieldExpression` as simple call argument (#19348) (Dunqing) - 80643d5 formatter: Match Prettier union indentation with leading comments (#19271) (Dunqing) ### ⚡ Performance - c169c77 syntax: Optimize `is_identifier_name_patched` (#19386) (sapphi-red)
…project#19350) The main cause of merge conflicts in new rule PRs lately has been due to the calculation of the rule ID. Currently, adding a new rule causes the ID of every subsequent rule to increment by one, causing a large amount of lines to change. With these changes, the rule ID is calculated relative to the ID of the previous rule. The actual ID values are calculated elsewhere. This means that adding a new rule doesn't result in a diff, because most IDs are unchanged since the rule order is not changed. Here is an example `git diff` from running `just new-eslint-rule` with a new rule after these changes: ```diff diff --git a/crates/oxc_linter/src/generated/rule_runner_impls.rs b/crates/oxc_linter/src/generated/rule_runner_impls.rs index 3d3da94..3143f56b72 100644 --- a/crates/oxc_linter/src/generated/rule_runner_impls.rs +++ b/crates/oxc_linter/src/generated/rule_runner_impls.rs @@ -205,6 +205,11 @@ impl RuleRunner for crate::rules::import::unambiguous::Unambiguous { const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::RunOnce; } +impl RuleRunner for crate::rules::eslint::consistent_this::ConsistentThis { + const NODE_TYPES: Option<&AstTypesBitset> = None; + const RUN_FUNCTIONS: RuleRunFunctionsImplemented = RuleRunFunctionsImplemented::Run; +} + impl RuleRunner for crate::rules::eslint::accessor_pairs::AccessorPairs { const NODE_TYPES: Option<&AstTypesBitset> = Some(&AstTypesBitset::from_types(&[ AstType::CallExpression, diff --git a/crates/oxc_linter/src/generated/rules_enum.rs b/crates/oxc_linter/src/generated/rules_enum.rs index 61c5e19..b94238878e 100644 --- a/crates/oxc_linter/src/generated/rules_enum.rs +++ b/crates/oxc_linter/src/generated/rules_enum.rs @@ -15,6 +15,7 @@ pub use crate::rules::eslint::block_scoped_var::BlockScopedVar as EslintBlockSco pub use crate::rules::eslint::capitalized_comments::CapitalizedComments as EslintCapitalizedComments; pub use crate::rules::eslint::class_methods_use_this::ClassMethodsUseThis as EslintClassMethodsUseThis; pub use crate::rules::eslint::complexity::Complexity as EslintComplexity; +pub use crate::rules::eslint::consistent_this::ConsistentThis as EslintConsistentThis; pub use crate::rules::eslint::constructor_super::ConstructorSuper as EslintConstructorSuper; pub use crate::rules::eslint::curly::Curly as EslintCurly; pub use crate::rules::eslint::default_case::DefaultCase as EslintDefaultCase; @@ -720,6 +721,7 @@ pub enum RuleEnum { ImportNoWebpackLoaderSyntax(ImportNoWebpackLoaderSyntax), ImportPreferDefaultExport(ImportPreferDefaultExport), ImportUnambiguous(ImportUnambiguous), + EslintConsistentThis(EslintConsistentThis), EslintAccessorPairs(EslintAccessorPairs), EslintArrayCallbackReturn(EslintArrayCallbackReturn), EslintArrowBodyStyle(EslintArrowBodyStyle), @@ -1396,7 +1398,8 @@ const IMPORT_NO_UNASSIGNED_IMPORT_ID: usize = IMPORT_NO_SELF_IMPORT_ID + 1usize; const IMPORT_NO_WEBPACK_LOADER_SYNTAX_ID: usize = IMPORT_NO_UNASSIGNED_IMPORT_ID + 1usize; const IMPORT_PREFER_DEFAULT_EXPORT_ID: usize = IMPORT_NO_WEBPACK_LOADER_SYNTAX_ID + 1usize; const IMPORT_UNAMBIGUOUS_ID: usize = IMPORT_PREFER_DEFAULT_EXPORT_ID + 1usize; -const ESLINT_ACCESSOR_PAIRS_ID: usize = IMPORT_UNAMBIGUOUS_ID + 1usize; +const ESLINT_CONSISTENT_THIS_ID: usize = IMPORT_UNAMBIGUOUS_ID + 1usize; +const ESLINT_ACCESSOR_PAIRS_ID: usize = ESLINT_CONSISTENT_THIS_ID + 1usize; const ESLINT_ARRAY_CALLBACK_RETURN_ID: usize = ESLINT_ACCESSOR_PAIRS_ID + 1usize; const ESLINT_ARROW_BODY_STYLE_ID: usize = ESLINT_ARRAY_CALLBACK_RETURN_ID + 1usize; const ESLINT_BLOCK_SCOPED_VAR_ID: usize = ESLINT_ARROW_BODY_STYLE_ID + 1usize; @@ -2151,6 +2154,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(_) => IMPORT_NO_WEBPACK_LOADER_SYNTAX_ID, Self::ImportPreferDefaultExport(_) => IMPORT_PREFER_DEFAULT_EXPORT_ID, Self::ImportUnambiguous(_) => IMPORT_UNAMBIGUOUS_ID, + Self::EslintConsistentThis(_) => ESLINT_CONSISTENT_THIS_ID, Self::EslintAccessorPairs(_) => ESLINT_ACCESSOR_PAIRS_ID, Self::EslintArrayCallbackReturn(_) => ESLINT_ARRAY_CALLBACK_RETURN_ID, Self::EslintArrowBodyStyle(_) => ESLINT_ARROW_BODY_STYLE_ID, @@ -2920,6 +2924,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(_) => ImportNoWebpackLoaderSyntax::NAME, Self::ImportPreferDefaultExport(_) => ImportPreferDefaultExport::NAME, Self::ImportUnambiguous(_) => ImportUnambiguous::NAME, + Self::EslintConsistentThis(_) => EslintConsistentThis::NAME, Self::EslintAccessorPairs(_) => EslintAccessorPairs::NAME, Self::EslintArrayCallbackReturn(_) => EslintArrayCallbackReturn::NAME, Self::EslintArrowBodyStyle(_) => EslintArrowBodyStyle::NAME, @@ -3683,6 +3688,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(_) => ImportNoWebpackLoaderSyntax::CATEGORY, Self::ImportPreferDefaultExport(_) => ImportPreferDefaultExport::CATEGORY, Self::ImportUnambiguous(_) => ImportUnambiguous::CATEGORY, + Self::EslintConsistentThis(_) => EslintConsistentThis::CATEGORY, Self::EslintAccessorPairs(_) => EslintAccessorPairs::CATEGORY, Self::EslintArrayCallbackReturn(_) => EslintArrayCallbackReturn::CATEGORY, Self::EslintArrowBodyStyle(_) => EslintArrowBodyStyle::CATEGORY, @@ -4487,6 +4493,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(_) => ImportNoWebpackLoaderSyntax::FIX, Self::ImportPreferDefaultExport(_) => ImportPreferDefaultExport::FIX, Self::ImportUnambiguous(_) => ImportUnambiguous::FIX, + Self::EslintConsistentThis(_) => EslintConsistentThis::FIX, Self::EslintAccessorPairs(_) => EslintAccessorPairs::FIX, Self::EslintArrayCallbackReturn(_) => EslintArrayCallbackReturn::FIX, Self::EslintArrowBodyStyle(_) => EslintArrowBodyStyle::FIX, @@ -5255,6 +5262,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(_) => ImportNoWebpackLoaderSyntax::documentation(), Self::ImportPreferDefaultExport(_) => ImportPreferDefaultExport::documentation(), Self::ImportUnambiguous(_) => ImportUnambiguous::documentation(), + Self::EslintConsistentThis(_) => EslintConsistentThis::documentation(), Self::EslintAccessorPairs(_) => EslintAccessorPairs::documentation(), Self::EslintArrayCallbackReturn(_) => EslintArrayCallbackReturn::documentation(), Self::EslintArrowBodyStyle(_) => EslintArrowBodyStyle::documentation(), @@ -6248,6 +6256,8 @@ impl RuleEnum { } Self::ImportUnambiguous(_) => ImportUnambiguous::config_schema(generator) .or_else(|| ImportUnambiguous::schema(generator)), + Self::EslintConsistentThis(_) => EslintConsistentThis::config_schema(generator) + .or_else(|| EslintConsistentThis::schema(generator)), Self::EslintAccessorPairs(_) => EslintAccessorPairs::config_schema(generator) .or_else(|| EslintAccessorPairs::schema(generator)), Self::EslintArrayCallbackReturn(_) => { @@ -8093,6 +8103,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(_) => "import", Self::ImportPreferDefaultExport(_) => "import", Self::ImportUnambiguous(_) => "import", + Self::EslintConsistentThis(_) => "eslint", Self::EslintAccessorPairs(_) => "eslint", Self::EslintArrayCallbackReturn(_) => "eslint", Self::EslintArrowBodyStyle(_) => "eslint", @@ -8831,6 +8842,9 @@ impl RuleEnum { Self::ImportUnambiguous(_) => { Ok(Self::ImportUnambiguous(ImportUnambiguous::from_configuration(value)?)) } + Self::EslintConsistentThis(_) => { + Ok(Self::EslintConsistentThis(EslintConsistentThis::from_configuration(value)?)) + } Self::EslintAccessorPairs(_) => { Ok(Self::EslintAccessorPairs(EslintAccessorPairs::from_configuration(value)?)) } @@ -10918,6 +10932,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(rule) => rule.to_configuration(), Self::ImportPreferDefaultExport(rule) => rule.to_configuration(), Self::ImportUnambiguous(rule) => rule.to_configuration(), + Self::EslintConsistentThis(rule) => rule.to_configuration(), Self::EslintAccessorPairs(rule) => rule.to_configuration(), Self::EslintArrayCallbackReturn(rule) => rule.to_configuration(), Self::EslintArrowBodyStyle(rule) => rule.to_configuration(), @@ -11597,6 +11612,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(rule) => rule.run(node, ctx), Self::ImportPreferDefaultExport(rule) => rule.run(node, ctx), Self::ImportUnambiguous(rule) => rule.run(node, ctx), + Self::EslintConsistentThis(rule) => rule.run(node, ctx), Self::EslintAccessorPairs(rule) => rule.run(node, ctx), Self::EslintArrayCallbackReturn(rule) => rule.run(node, ctx), Self::EslintArrowBodyStyle(rule) => rule.run(node, ctx), @@ -12272,6 +12288,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(rule) => rule.run_once(ctx), Self::ImportPreferDefaultExport(rule) => rule.run_once(ctx), Self::ImportUnambiguous(rule) => rule.run_once(ctx), + Self::EslintConsistentThis(rule) => rule.run_once(ctx), Self::EslintAccessorPairs(rule) => rule.run_once(ctx), Self::EslintArrayCallbackReturn(rule) => rule.run_once(ctx), Self::EslintArrowBodyStyle(rule) => rule.run_once(ctx), @@ -12951,6 +12968,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(rule) => rule.run_on_jest_node(jest_node, ctx), Self::ImportPreferDefaultExport(rule) => rule.run_on_jest_node(jest_node, ctx), Self::ImportUnambiguous(rule) => rule.run_on_jest_node(jest_node, ctx), + Self::EslintConsistentThis(rule) => rule.run_on_jest_node(jest_node, ctx), Self::EslintAccessorPairs(rule) => rule.run_on_jest_node(jest_node, ctx), Self::EslintArrayCallbackReturn(rule) => rule.run_on_jest_node(jest_node, ctx), Self::EslintArrowBodyStyle(rule) => rule.run_on_jest_node(jest_node, ctx), @@ -13712,6 +13730,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(rule) => rule.should_run(ctx), Self::ImportPreferDefaultExport(rule) => rule.should_run(ctx), Self::ImportUnambiguous(rule) => rule.should_run(ctx), + Self::EslintConsistentThis(rule) => rule.should_run(ctx), Self::EslintAccessorPairs(rule) => rule.should_run(ctx), Self::EslintArrayCallbackReturn(rule) => rule.should_run(ctx), Self::EslintArrowBodyStyle(rule) => rule.should_run(ctx), @@ -14393,6 +14412,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(_) => ImportNoWebpackLoaderSyntax::IS_TSGOLINT_RULE, Self::ImportPreferDefaultExport(_) => ImportPreferDefaultExport::IS_TSGOLINT_RULE, Self::ImportUnambiguous(_) => ImportUnambiguous::IS_TSGOLINT_RULE, + Self::EslintConsistentThis(_) => EslintConsistentThis::IS_TSGOLINT_RULE, Self::EslintAccessorPairs(_) => EslintAccessorPairs::IS_TSGOLINT_RULE, Self::EslintArrayCallbackReturn(_) => EslintArrayCallbackReturn::IS_TSGOLINT_RULE, Self::EslintArrowBodyStyle(_) => EslintArrowBodyStyle::IS_TSGOLINT_RULE, @@ -15335,6 +15355,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(_) => ImportNoWebpackLoaderSyntax::HAS_CONFIG, Self::ImportPreferDefaultExport(_) => ImportPreferDefaultExport::HAS_CONFIG, Self::ImportUnambiguous(_) => ImportUnambiguous::HAS_CONFIG, + Self::EslintConsistentThis(_) => EslintConsistentThis::HAS_CONFIG, Self::EslintAccessorPairs(_) => EslintAccessorPairs::HAS_CONFIG, Self::EslintArrayCallbackReturn(_) => EslintArrayCallbackReturn::HAS_CONFIG, Self::EslintArrowBodyStyle(_) => EslintArrowBodyStyle::HAS_CONFIG, @@ -16162,6 +16183,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(rule) => rule.types_info(), Self::ImportPreferDefaultExport(rule) => rule.types_info(), Self::ImportUnambiguous(rule) => rule.types_info(), + Self::EslintConsistentThis(rule) => rule.types_info(), Self::EslintAccessorPairs(rule) => rule.types_info(), Self::EslintArrayCallbackReturn(rule) => rule.types_info(), Self::EslintArrowBodyStyle(rule) => rule.types_info(), @@ -16837,6 +16859,7 @@ impl RuleEnum { Self::ImportNoWebpackLoaderSyntax(rule) => rule.run_info(), Self::ImportPreferDefaultExport(rule) => rule.run_info(), Self::ImportUnambiguous(rule) => rule.run_info(), + Self::EslintConsistentThis(rule) => rule.run_info(), Self::EslintAccessorPairs(rule) => rule.run_info(), Self::EslintArrayCallbackReturn(rule) => rule.run_info(), Self::EslintArrowBodyStyle(rule) => rule.run_info(), @@ -17534,6 +17557,7 @@ pub static RULES: std::sync::LazyLock<Vec<RuleEnum>> = std::sync::LazyLock::new( RuleEnum::ImportNoWebpackLoaderSyntax(ImportNoWebpackLoaderSyntax::default()), RuleEnum::ImportPreferDefaultExport(ImportPreferDefaultExport::default()), RuleEnum::ImportUnambiguous(ImportUnambiguous::default()), + RuleEnum::EslintConsistentThis(EslintConsistentThis::default()), RuleEnum::EslintAccessorPairs(EslintAccessorPairs::default()), RuleEnum::EslintArrayCallbackReturn(EslintArrayCallbackReturn::default()), RuleEnum::EslintArrowBodyStyle(EslintArrowBodyStyle::default()), ```
# Oxlint ### 💥 BREAKING CHANGES - 7711821 oxlint: [**BREAKING**] `no-shadow-restricted-names` report `globalThis` by default (oxc-project#19407) (Sysix) ### 🚀 Features - ce1baa0 linter: Implement eslint/no-shadow (oxc-project#18979) (Víctor Fernández) - 7a333c1 linter: Support dynamic configs via CLI arguments (oxc-project#19384) (camc314) - 1bf569b linter: Implement typescript/unified-signatures (oxc-project#19375) (camc314) - 6562a9b linter: Implement typescript/parameter-properties (oxc-project#19374) (camc314) - 94d8d74 linter: Implement typescript/no-use-before-define (oxc-project#19373) (camc314) - 80b002a linter: Implement fixer for unicorn/no-instanceof-builtins (oxc-project#19371) (camc314) - 5c3784b linter: Implement eslint/no-unmodified-loop-condition (oxc-project#19341) (Vincent R) - cc00a59 linter/const-comparisons: Improve diagnostics when mixing logical/comparison operators (oxc-project#19370) (camc314) - ea2c401 linter: Add support for no constructed context values (oxc-project#18067) (Jovi De Croock) - f2440eb linter: Mark eslint/no-return-assign as having no fixer (oxc-project#19327) (camc314) - 8588670 linter/unicorn: Implement suggestion for `unicorn/no-await-in-promise-methods` rule (oxc-project#19359) (Mikhail Baev) - f0af965 linter: Move `jsx-a11y/no-static-element-interactions` rule out of the nursery. (oxc-project#19355) (connorshea) - be0ce50 linter/tsgolint: Add support for labeled ranges in tsgolint diagnostics (oxc-project#19201) (camchenry) - b5bc900 linter: Implement fixer for unicorn/no-new-buffer (oxc-project#19326) (camc314) - 1612932 linter: Add typescript/no-unnecessary-condition (oxc-project#19130) (camc314) - 37dc6c5 linter: Implement fixer for unicorn/prefer-includes (oxc-project#19323) (camc314) ### 🐛 Bug Fixes - c2b1870 linter: Enforce config options for `react/forbid-dom-props` rule. (oxc-project#19387) (connorshea) - 3d24e44 linter: Honor no-empty-function allow getters/setters for object literals (oxc-project#19393) (camc314) - bbced8d linter: Enforce config options for `eslint/no-empty-function` rule, improve docs. (oxc-project#19390) (connorshea) - 6bc8aec linter: Fix the behavior of `import/extensions` rule for a file that has multiple extensions. (oxc-project#18919) (connorshea) - c62a295 linter/img-redundant-alt: Enforce whole-word matching for redundant alt text (oxc-project#19367) (camc314) - 98956fe linter/describe-function-title: Skip autofix for type-only imports (oxc-project#19329) (camc314) - d96d26d linter/plugins: Provide `parser.version` (oxc-project#19364) (overlookmotel) - 81f0039 linter_codegen: Compute rule IDs relative to previous rule (oxc-project#19350) (camchenry) - b7ef0a8 linter/consistent-indexed-object-style: Avoid unsafe Record conversions for mapped types (oxc-project#19320) (camc314) ### 📚 Documentation - 3a6059f linter: Improve docs for `eslint/require-await` rule. (oxc-project#19361) (connorshea) - b069269 linter/plugins: Add comment about deprecated `ScopeManager` methods (oxc-project#19363) (overlookmotel) - 2d8aaf9 linter: Disable formatting for `eslint/no-unsafe-negation` examples. (oxc-project#19347) (connorshea) - fb87806 linter: Ensure that we do not auto-format the docs for `unicorn/number-literal-case` rule. (oxc-project#19346) (connorshea) - 8d3ae27 linter/typescript: Skip docs for deprecated type aware rule options (oxc-project#19324) (camc314) # Oxfmt ### 💥 BREAKING CHANGES - 00135b5 formatter/sort_imports: [**BREAKING**] Change default `groups` order (oxc-project#19427) (leaysgur) - 9c34f72 formatter/sort_imports: [**BREAKING**] Report invalid group name with renaming `side-effect` > `side_effect` (oxc-project#19416) (leaysgur) ### 🚀 Features - 4baebef formatter/sort_imports: Support `{ newlinesBetween: bool }` inside `groups` (oxc-project#19358) (leaysgur) - d1c2fb6 formatter/sort_imports: Support `customGroups` attributes(`selector` and `modifiers`) (oxc-project#19356) (leaysgur) ### 🐛 Bug Fixes - f084ea6 oxfmt: Explicitly pass `process.env` for the forked process (oxc-project#19380) (Long Ho) - 2bc7a14 formatter: Arrow function body incorrectly broken when return type has comment (oxc-project#19368) (Dunqing) - 90ec3d2 oxfmt: Update tailwind plugin which fixes crash on non-js file (oxc-project#19353) (leaysgur) - e9c5b1e formatter: Treat `PrivateFieldExpression` as simple call argument (oxc-project#19348) (Dunqing) - 80643d5 formatter: Match Prettier union indentation with leading comments (oxc-project#19271) (Dunqing) ### ⚡ Performance - c169c77 syntax: Optimize `is_identifier_name_patched` (oxc-project#19386) (sapphi-red)

The main cause of merge conflicts in new rule PRs lately has been due to the calculation of the rule ID. Currently, adding a new rule causes the ID of every subsequent rule to increment by one, causing a large amount of lines to change.
With these changes, the rule ID is calculated relative to the ID of the previous rule. The actual ID values are calculated elsewhere. This means that adding a new rule doesn't result in a diff, because most IDs are unchanged since the rule order is not changed.
Here is an example
git difffrom runningjust new-eslint-rulewith a new rule after these changes: