feat(eslint): turn off prefer-const in editor#223
Conversation
|
🦋 Changeset detectedLatest commit: becb099 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis pull request introduces a comprehensive update to the ESLint configuration and dependency management across multiple files in the project. The changes primarily focus on updating dependency versions, modifying ESLint rules, and enhancing configuration flexibility. Key modifications include turning off the Changes
Possibly related PRs
Suggested labels
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
prefer-const rule in editorThere was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
packages/eslint-config/src/configs/disables.ts (1)
4-58: LGTM! Well-structured rule configurations for different file types.The implementation provides a clear organization of rule disabling based on file types and their specific requirements.
Consider adding JSDoc comments to document the purpose of each configuration group and why specific rules are disabled. For example:
export async function disables(): Promise<TypedFlatConfigItem[]> { return [ + // Disable specific rules for script files that require top-level await and console usage { files: [`**/scripts/${GLOB_SRC}`], name: 'antfu/disables/scripts',packages/eslint-config/src/configs/react.ts (1)
52-52: LGTM! Added important memory leak prevention rules.The addition of web API-related rules will help catch common memory leaks in React applications.
Consider adding comments explaining the potential memory leak scenarios these rules prevent. For example:
// recommended rules from @eslint-react/web-api + // Prevent memory leaks from unmounted components that don't clean up event listeners 'react-web-api/no-leaked-event-listener': 'warn', + // Prevent memory leaks from setInterval calls that aren't cleared 'react-web-api/no-leaked-interval': 'warn',Also applies to: 107-111
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (12)
.changeset/orange-books-trade.md(1 hunks)package.json(1 hunks)packages/eslint-config/README.md(1 hunks)packages/eslint-config/package.json(2 hunks)packages/eslint-config/src/configs/astro.ts(1 hunks)packages/eslint-config/src/configs/disables.ts(1 hunks)packages/eslint-config/src/configs/ignores.ts(1 hunks)packages/eslint-config/src/configs/javascript.ts(2 hunks)packages/eslint-config/src/configs/react.ts(2 hunks)packages/eslint-config/src/factory.ts(4 hunks)packages/eslint-config/src/typegen.d.ts(42 hunks)pnpm-workspace.yaml(1 hunks)
✅ Files skipped from review due to trivial changes (3)
- .changeset/orange-books-trade.md
- pnpm-workspace.yaml
- packages/eslint-config/README.md
🔇 Additional comments (13)
packages/eslint-config/src/configs/ignores.ts (1)
4-4: LGTM! Well-implemented enhancement to support custom ignore patterns.The changes allow for flexible configuration by accepting user-defined ignore patterns while maintaining backward compatibility.
Also applies to: 7-7
packages/eslint-config/src/configs/astro.ts (1)
28-28: LGTM! Comprehensive enhancement of Astro configuration.The changes properly configure the Astro environment and add essential rules for preventing common issues.
Let's verify that all new rules exist in the latest version of
eslint-plugin-astro:Also applies to: 34-34, 37-37, 39-49
✅ Verification successful
✓ Astro ESLint rules are valid and properly configured
All configured rules follow the official
astro/prefix and are focused on important aspects like security, deprecations, and best practices. The rules are sourced from a stable version (1.3.x) ofeslint-plugin-astro.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that all new Astro rules exist in the plugin # Get the rules from package npm info eslint-plugin-astro@latest dist.tarball | \ xargs curl -s | \ tar -xzO package/lib/rules | \ grep -l "meta:" | \ sed 's/\.js$//' | \ sortLength of output: 237
Script:
#!/bin/bash # First, let's see what rules are being configured rg "rules.*:" -A 10 packages/eslint-config/src/configs/astro.ts # Then, let's check if we have the plugin source locally fd "eslint-plugin-astro" --type d # As a fallback, let's check package.json for the plugin version rg '"eslint-plugin-astro"' -A 1 packages/eslint-config/package.jsonLength of output: 853
packages/eslint-config/src/factory.ts (3)
30-31: LGTM! New import supports the PR objective.The addition of the
disablesimport aligns with the goal of turning off specific rules in the editor context.
69-72: Type safety improvement.The explicit return type
Partial<Linter.RulesRecord & RuleOptions>enhances type safety and clarity.
223-223: LGTM! Proper integration of rule disabling.The
disables()call is correctly placed beforeprettierconfiguration, ensuring proper rule precedence.packages/eslint-config/src/configs/javascript.ts (2)
198-206: LGTM! Proper implementation of editor-specific rule.The conditional configuration correctly implements the PR objective by turning off
prefer-constonly in editor context while maintaining strict rules elsewhere.
Line range hint
231-231: Consistent handling of editor-specific rules.The same conditional logic is appropriately applied to
unused-imports/no-unused-imports, maintaining consistency in the editor experience.package.json (1)
42-42: LGTM! Minor dependency update.Update of lint-staged to ^15.4.1 is a patch version increment, likely containing bug fixes.
packages/eslint-config/package.json (1)
Line range hint
39-77: Verify compatibility with major dependency updates.Several dependencies have major version updates that warrant verification:
@antfu/install-pkg: ^0.5.0 → ^1.0.0eslint-config-flat-gitignore: ^0.3.0 → ^1.0.0eslint-merge-processors: ^0.1.0 → ^1.0.0eslint-plugin-command: ^0.2.7 → ^2.1.0✅ Verification successful
Major version updates appear safe to proceed with
After analyzing the implementation details:
- All packages are used with basic, straightforward patterns
- No complex configurations that could be affected by breaking changes
- Each package serves an isolated function with minimal integration points
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check for any breaking changes in the updated packages echo "Checking for potential breaking changes in updated packages..." # Check git history for any related configuration changes git log -p --all --full-history -- "**/eslint*config*" | grep -A 5 -B 5 "flat-gitignore\|merge-processors\|plugin-command" # Verify if any of these packages are actively used in the configuration rg "@antfu/install-pkg|eslint-config-flat-gitignore|eslint-merge-processors|eslint-plugin-command" .Length of output: 2519
Script:
#!/bin/bash # Check the specific usage patterns of these packages echo "Checking implementation details..." # Check gitignore configuration usage ast-grep --pattern 'import $_ from "eslint-config-flat-gitignore"' ast-grep --pattern 'interopDefault(import("eslint-config-flat-gitignore"))' # Check markdown processor usage ast-grep --pattern 'import { $_ } from "eslint-merge-processors"' # Check command plugin configuration ast-grep --pattern 'import $_ from "eslint-plugin-command/config"'Length of output: 362
Script:
#!/bin/bash # Broader search for implementation details echo "Checking broader implementation patterns..." # Check actual files where these packages are used rg -A 5 -B 5 "eslint-config-flat-gitignore" ./packages/eslint-config/src/ rg -A 5 -B 5 "eslint-merge-processors" ./packages/eslint-config/src/ rg -A 5 -B 5 "eslint-plugin-command" ./packages/eslint-config/src/ rg -A 5 -B 5 "@antfu/install-pkg" ./packages/eslint-config/src/Length of output: 5407
packages/eslint-config/src/typegen.d.ts (4)
Line range hint
1-9304: Verify the extensive additions align with the PR's intentThe changes in this file introduce a large number of new ESLint rule type definitions across multiple plugins. Given that the PR's objective is to turn off the
prefer-construle in the editor, these extensive additions seem beyond the scope of this PR. Please verify that these changes are intentional and necessary.
3217-3220: Correct the rule key for 'react/use-jsx-vars'The rule
'react/use-jsx-vars'is intended to helpeslint/no-unused-varsrecognize JSX variables as used. Ensure that this rule key is correct and matches the ESLint plugin's documentation, as there may be a discrepancy with'react/jsx-uses-vars'.
771-771: Review conflicting export rulesThe following rules may conflict:
'import/no-mutable-exports'at line 771'import/no-named-default'at line 786Verify that these rules are configured as intended and will not cause unnecessary linting conflicts.
Also applies to: 786-786
2856-2864: 🛠️ Refactor suggestionConsolidate similar 'react-hooks-extra' rules
Multiple rules seem to address the enforcement of custom hooks using other hooks:
'react-hooks-extra/ensure-custom-hooks-using-other-hooks'at lines 2857'react-hooks-extra/no-redundant-custom-hook'at lines 2885'react-hooks-extra/no-useless-custom-hooks'at lines 2899Please review these rules to ensure they are not duplicates or conflicting with each other.
Also applies to: 2881-2885, 2895-2899
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @mheob/eslint-config@7.1.0 ### Minor Changes - [#223](#223) ([@mheob](https://github.com/mheob)): turn off `prefer-const` rule in editor ### Patch Changes - [#219](#219) ([@renovate](https://github.com/apps/renovate)): fix(deps): update all non-major dependencies ## Summary by CodeRabbit - **New Features** - Turned off `prefer-const` ESLint rule in the editor - **Chores** - Updated package version from 7.0.0 to 7.1.0 - Updated non-major dependencies



Resolves #222
Summary by CodeRabbit
Chores
lint-staged,eslint, and other packages.Configuration
prefer-construle in editor settings.Development