Skip to content

Conversation

@azat-io
Copy link
Owner

@azat-io azat-io commented Dec 22, 2025

Description

Remove meta.defaultOptions from all rules to prevent ESLint from auto-merging defaults into options. This allows users to explicitly set values that match defaults and override global settings.

Additional context

#653


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves.
  • Ideally, include relevant tests that fail without this PR but pass with it.
  • Read contribution guidelines.

@coderabbitai
Copy link

coderabbitai bot commented Dec 22, 2025

📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • Standardized ESLint rule structure across multiple rules by reorganizing default option declarations
    • Updated base ESLint configuration to adjust specific rule handling
    • Refactored configuration merging logic to use streamlined object composition

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

This PR removes meta.defaultOptions from 22 ESLint rule definitions, rewrites the complete utility function to use flat object merging instead of recursive default-value stripping, and updates the ESLint configuration to disable the require-meta-default-options rule.

Changes

Cohort / File(s) Change Summary
ESLint Configuration
eslint.config.ts
Modified extends from single value to array, adding inline config to disable eslint-plugin/require-meta-default-options rule while keeping the recommended config
Rule Meta Cleanup
rules/sort-array-includes.ts, rules/sort-classes.ts, rules/sort-decorators.ts, rules/sort-enums.ts, rules/sort-export-attributes.ts, rules/sort-exports.ts, rules/sort-heritage-clauses.ts, rules/sort-import-attributes.ts, rules/sort-imports.ts, rules/sort-interfaces.ts, rules/sort-intersection-types.ts, rules/sort-jsx-props.ts, rules/sort-maps.ts, rules/sort-modules.ts, rules/sort-named-exports.ts, rules/sort-named-imports.ts, rules/sort-objects.ts, rules/sort-sets.ts, rules/sort-switch-case.ts, rules/sort-union-types.ts, rules/sort-variable-declarations.ts
Removed defaultOptions property from meta object in each rule; top-level defaultOptions declaration preserved
Rule Restructuring
rules/sort-object-types.ts
Relocated create handler from separate top-level block to inline field within exported rule object; removed defaultOptions from meta
Utility Simplification
utils/complete.ts
Replaced recursive stripDefaultValues logic with flat object spread merge (...defaults, ...settings, ...options); removed helper functions stripDefaultValues, isDeepEqual, and isPlainObject

Possibly related issues

Possibly related PRs

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

The review involves 22 homogeneous rule file changes (simple property removals) that form a repetitive pattern, offset by a more complex utility rewrite (utils/complete.ts) that replaces recursive logic with flat merging and requires verification of the new behavior. The config change is straightforward.

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: allowing users to override settings with default values, which is the core objective of this PR.
Description check ✅ Passed The PR description includes all key required sections: a clear description of what is being fixed, a reference to the related issue (#653), selection of bug fix category, and confirmation of checklist items.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1430b19 and 4bfd74e.

📒 Files selected for processing (24)
  • eslint.config.ts
  • rules/sort-array-includes.ts
  • rules/sort-classes.ts
  • rules/sort-decorators.ts
  • rules/sort-enums.ts
  • rules/sort-export-attributes.ts
  • rules/sort-exports.ts
  • rules/sort-heritage-clauses.ts
  • rules/sort-import-attributes.ts
  • rules/sort-imports.ts
  • rules/sort-interfaces.ts
  • rules/sort-intersection-types.ts
  • rules/sort-jsx-props.ts
  • rules/sort-maps.ts
  • rules/sort-modules.ts
  • rules/sort-named-exports.ts
  • rules/sort-named-imports.ts
  • rules/sort-object-types.ts
  • rules/sort-objects.ts
  • rules/sort-sets.ts
  • rules/sort-switch-case.ts
  • rules/sort-union-types.ts
  • rules/sort-variable-declarations.ts
  • utils/complete.ts
💤 Files with no reviewable changes (21)
  • rules/sort-heritage-clauses.ts
  • rules/sort-decorators.ts
  • rules/sort-jsx-props.ts
  • rules/sort-union-types.ts
  • rules/sort-exports.ts
  • rules/sort-objects.ts
  • rules/sort-modules.ts
  • rules/sort-enums.ts
  • rules/sort-array-includes.ts
  • rules/sort-classes.ts
  • rules/sort-intersection-types.ts
  • rules/sort-variable-declarations.ts
  • rules/sort-export-attributes.ts
  • rules/sort-named-imports.ts
  • rules/sort-import-attributes.ts
  • rules/sort-imports.ts
  • rules/sort-switch-case.ts
  • rules/sort-interfaces.ts
  • rules/sort-maps.ts
  • rules/sort-named-exports.ts
  • rules/sort-sets.ts
🧰 Additional context used
🧬 Code graph analysis (1)
rules/sort-object-types.ts (2)
rules/sort-imports.ts (1)
  • MessageId (76-82)
rules/sort-objects/types.ts (5)
  • MessageId (21-26)
  • MISSED_SPACING_ERROR_ID (31-31)
  • EXTRA_SPACING_ERROR_ID (30-30)
  • GROUP_ORDER_ERROR_ID (29-29)
  • ORDER_ERROR_ID (28-28)
🔇 Additional comments (4)
eslint.config.ts (1)

7-14: LGTM - Disabling the rule aligns with the structural change.

Disabling eslint-plugin/require-meta-default-options is appropriate since the PR moves defaultOptions out of the meta object across all rules to prevent ESLint's auto-merge behavior.

rules/sort-object-types.ts (2)

131-144: LGTM - Structural reorganization.

The create handler logic remains unchanged; it's simply moved inline. This is consistent with relocating defaultOptions outside of meta.


161-161: Verify the actual API implementation of createEslintRule in the project.

The @typescript-eslint/utils RuleCreator officially supports defaultOptions as a top-level property. However, confirm that the project's createEslintRule function follows the same pattern and correctly applies default options through wrapper logic. Check the implementation of createEslintRule to ensure it wraps the create function and applies defaults as intended.

utils/complete.ts (1)

35-35: The shallow merge implementation is intentional for this utility's purpose.

The complete() function is designed specifically to merge three configuration levels (defaults → settings → options) at the top level only. While the shallow spread operator does completely replace nested objects rather than merging them, this is appropriate because:

  1. Nested object merging happens separately: The codebase uses dedicated utilities like computeOverriddenOptionsByGroupIndex for handling nested property merging within objects like fallbackSort.

  2. Function scope is limited: The docstring example shows this function handles only top-level keys. Nested object overrides occur through rule-specific logic (e.g., custom groups), not through this utility.

  3. No breaking change: All existing tests pass, and there's no evidence of users relying on partial nested object overrides at the rule-options level. The PR's goal—allowing settings to override defaults—is achieved correctly at the top level.

The implementation aligns with the PR objective and the existing architecture.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Dec 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (1430b19) to head (4bfd74e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #654   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          143       143           
  Lines         3554      3521   -33     
  Branches      1106      1088   -18     
=========================================
- Hits          3554      3521   -33     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@hugop95 hugop95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@azat-io Thanks !

@azat-io azat-io merged commit 08d69ca into main Dec 22, 2025
12 checks passed
@azat-io azat-io deleted the fix/settings-override branch December 22, 2025 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants