Skip to content

feat(eslint): turn off prefer-const in editor#223

Merged
kodiakhq[bot] merged 2 commits intomainfrom
222-prefer-const
Jan 21, 2025
Merged

feat(eslint): turn off prefer-const in editor#223
kodiakhq[bot] merged 2 commits intomainfrom
222-prefer-const

Conversation

@mheob
Copy link
Copy Markdown
Owner

@mheob mheob commented Jan 21, 2025

Resolves #222

Summary by CodeRabbit

  • Chores

    • Updated various dependencies across the project, including ESLint, TypeScript, and other development tools.
    • Minor version upgrades for lint-staged, eslint, and other packages.
  • Configuration

    • Modified ESLint configuration to turn off prefer-const rule in editor settings.
    • Updated documentation to clarify disabled ESLint rules in IDE integrations.
  • Development

    • Enhanced linting configurations for React, Astro, and JavaScript files.
    • Added new linting rules and plugins to improve code quality and consistency.

@mheob mheob added enhancement 📈 New feature or request eslint 🚨 Belongs to ESLint config labels Jan 21, 2025
@height
Copy link
Copy Markdown

height bot commented Jan 21, 2025

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jan 21, 2025

🦋 Changeset detected

Latest commit: becb099

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@mheob/eslint-config Minor

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

@vercel
Copy link
Copy Markdown

vercel bot commented Jan 21, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
eslint-config ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 21, 2025 3:20pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 21, 2025

Walkthrough

This 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 prefer-const rule in editor settings, updating various package dependencies to their latest versions, and adding new linting rules for React, Astro, and other configurations.

Changes

File Change Summary
.changeset/orange-books-trade.md Turned off prefer-const ESLint rule
package.json Updated lint-staged from ^15.4.0 to ^15.4.1
packages/eslint-config/README.md Expanded list of disabled ESLint rules in IDE integrations
packages/eslint-config/package.json Multiple dependency version updates for various packages
packages/eslint-config/src/configs/... Multiple configuration files updated with new rules and plugins
pnpm-workspace.yaml Updated eslint to ^9.18.0 and typescript to ^5.7.3

Possibly related PRs

Suggested labels

configuration changes, review effort [1-5]: 2, documentation

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sonarqubecloud
Copy link
Copy Markdown

@mheob mheob changed the title Turn off prefer-const rule in editor turn off prefer-const in editor Jan 21, 2025
@mheob mheob changed the title turn off prefer-const in editor feat(eslint): turn off prefer-const in editor Jan 21, 2025
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between eebbfa8 and becb099.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is 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) of eslint-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$//' | \
  sort

Length 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.json

Length of output: 853

packages/eslint-config/src/factory.ts (3)

30-31: LGTM! New import supports the PR objective.

The addition of the disables import 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 before prettier configuration, 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-const only 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.0
  • eslint-config-flat-gitignore: ^0.3.0 → ^1.0.0
  • eslint-merge-processors: ^0.1.0 → ^1.0.0
  • eslint-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 intent

The 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-const rule 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 help eslint/no-unused-vars recognize 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 rules

The following rules may conflict:

  • 'import/no-mutable-exports' at line 771
  • 'import/no-named-default' at line 786

Verify that these rules are configured as intended and will not cause unnecessary linting conflicts.

Also applies to: 786-786


2856-2864: 🛠️ Refactor suggestion

Consolidate 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 2899

Please review these rules to ensure they are not duplicates or conflicting with each other.

Also applies to: 2881-2885, 2895-2899

@kodiakhq kodiakhq bot merged commit 8f04432 into main Jan 21, 2025
@kodiakhq kodiakhq bot deleted the 222-prefer-const branch January 21, 2025 15:28
kodiakhq bot pushed a commit that referenced this pull request Jan 21, 2025
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement 📈 New feature or request eslint 🚨 Belongs to ESLint config

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Turn off prefer-const rule in editor

1 participant