-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(eslint): add regexp
and vue
rules
#238
Conversation
Also update all dependencies.
|
🦋 Changeset detectedLatest commit: d6371b4 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 updates the ESLint configuration for the Changes
Sequence Diagram(s)sequenceDiagram
participant C as Caller
participant F as mheob()
participant P as isPackageExists()
participant V as Vue Config (vue)
participant R as Regexp Config (regexp)
C->>F: Call mheob(options)
F->>P: Check for Vue package presence
P-->>F: Return enableVue status
alt enableVue is true
F->>V: Invoke vue() with sub-options
V-->>F: Return Vue configuration object
end
alt enableRegexp is true
F->>R: Invoke regexp() with options
R-->>F: Return regexp configuration object
end
F->>C: Return consolidated ESLint configurations
Possibly related PRs
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
Scope: all 2 workspace projects This error happened while installing a direct dependency of /tmp/eslint/packages/eslint-config Packages found in the workspace: Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
✨ Finishing Touches
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. 🪧 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 (
|
|
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.
Actionable comments posted: 1
🧹 Nitpick comments (5)
packages/eslint-config/src/configs/regexp.ts (2)
16-20
: Extend logic for array-based rule severity
Right now, only string'error'
rules get converted to'warn'
. If a rule is configured like['error', {...}]
, it won't be updated. Consider expanding the condition to handle array-based severity levels.if (options.level === 'warn') { for (const key in rules) { - if (rules[key] === 'error') rules[key] = 'warn'; + const current = rules[key]; + if (Array.isArray(current)) { + if (current[0] === 'error') { + current[0] = 'warn'; + } + } else if (current === 'error') { + rules[key] = 'warn'; + } } }
22-31
: Add usage example or mention test coverage
Consider adding usage examples or tests for this new configuration to ensure that the returned config remains correct as your code evolves.packages/eslint-config/src/types.ts (1)
59-64
: Fix documentation grammar
The JSDoc comment says "Override rulelevels". For clarity, replace it with "Override rule levels"./** - * Override rulelevels + * Override rule levels */ level?: 'error' | 'warn';packages/eslint-config/package.json (1)
69-69
: Consider adding Vue and Svelte peer dependenciesWhile you've added the Vue and Svelte dependencies and updated their parsers, you might want to consider adding them to the
peerDependenciesMeta
section withoptional: true
, similar to how you've handled other framework-specific dependencies. This would clarify that they're optional dependencies for users.Also applies to: 71-71
packages/eslint-config/src/typegen.d.ts (1)
3152-3159
: Duplicate comment descriptions for nested components.The same comment description is used for both
no-nested-component-definitions
andno-nested-components
. Consider documenting the specific differences between these rules if they exist.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (14)
.changeset/violet-lemons-flash.md
(1 hunks).cspell.json
(1 hunks)package.json
(1 hunks)packages/eslint-config/package.json
(2 hunks)packages/eslint-config/scripts/typegen.ts
(2 hunks)packages/eslint-config/src/configs/index.ts
(2 hunks)packages/eslint-config/src/configs/regexp.ts
(1 hunks)packages/eslint-config/src/configs/sort.ts
(1 hunks)packages/eslint-config/src/configs/unicorn.ts
(1 hunks)packages/eslint-config/src/configs/vue.ts
(1 hunks)packages/eslint-config/src/factory.ts
(7 hunks)packages/eslint-config/src/globs.ts
(2 hunks)packages/eslint-config/src/typegen.d.ts
(56 hunks)packages/eslint-config/src/types.ts
(3 hunks)
🧰 Additional context used
🧬 Code Definitions (5)
packages/eslint-config/scripts/typegen.ts (1)
packages/eslint-config/src/configs/regexp.ts (1) (1)
regexp
(7:32)
packages/eslint-config/src/configs/regexp.ts (1)
packages/eslint-config/src/types.ts (3) (3)
OptionsOverrides
(55:57)OptionsRegExp
(59:64)TypedFlatConfigItem
(14:23)
packages/eslint-config/src/configs/vue.ts (2)
packages/eslint-config/src/types.ts (4) (4)
OptionsFiles
(25:28)OptionsHasTypeScript
(39:41)OptionsOverrides
(55:57)TypedFlatConfigItem
(14:23)packages/eslint-config/src/globs.ts (1) (1)
GLOB_VUE
(23:23)
packages/eslint-config/src/factory.ts (3)
packages/eslint-config/src/utils/package.ts (1) (1)
existsPackage
(60:62)packages/eslint-config/src/configs/regexp.ts (1) (1)
regexp
(7:32)packages/eslint-config/src/configs/vue.ts (1) (1)
vue
(10:137)
packages/eslint-config/src/typegen.d.ts (1)
packages/eslint-config/src/types.ts (1) (1)
ConfigNames
(8:8)
🪛 Biome (1.9.4)
packages/eslint-config/src/configs/vue.ts
[error] 69-69: Avoid the use of spread (...
) syntax on accumulators.
Spread syntax should be avoided on accumulators (like those in .reduce
) because it causes a time complexity of O(n^2)
.
Consider methods such as .splice or .push instead.
(lint/performance/noAccumulatingSpread)
[error] 72-72: Avoid the use of spread (...
) syntax on accumulators.
Spread syntax should be avoided on accumulators (like those in .reduce
) because it causes a time complexity of O(n^2)
.
Consider methods such as .splice or .push instead.
(lint/performance/noAccumulatingSpread)
[error] 75-75: Avoid the use of spread (...
) syntax on accumulators.
Spread syntax should be avoided on accumulators (like those in .reduce
) because it causes a time complexity of O(n^2)
.
Consider methods such as .splice or .push instead.
(lint/performance/noAccumulatingSpread)
🔇 Additional comments (30)
.cspell.json (1)
36-36
: Appropriate dictionary additions for ESLint rule developmentThese new entries enhance the spell checker dictionary to recognize terms related to regexp rules and ESLint configuration levels, which aligns with the PR's objective of adding new rule configurations.
Also applies to: 41-41
.changeset/violet-lemons-flash.md (1)
1-5
: Well-structured changeset for package version updateThe changeset correctly identifies this as a minor version update, which is appropriate for adding new features (regexp and Vue rules) without breaking existing functionality. The description is concise and accurately captures the changes.
packages/eslint-config/src/configs/unicorn.ts (1)
31-31
: Good additions to allowed abbreviationsAdding
db
,idx
, andutils
to the allowed abbreviations is sensible as these are widely understood terms in development contexts. This will prevent unnecessary warnings while maintaining the overall benefit of theprevent-abbreviations
rule.Also applies to: 35-35, 40-40
packages/eslint-config/scripts/typegen.ts (1)
18-18
: Correctly integrates regexp configurationThe changes properly integrate the new regexp configuration into the type generation system. The import is added in the correct location, and the regexp() function is appropriately included in the combine function call, ensuring the regexp rules will be included in the generated types.
Also applies to: 48-48
package.json (2)
42-42
: LGTM! Dependency version update.The update to lint-staged from ^15.4.3 to ^15.5.0 is a minor version bump which should maintain backward compatibility.
48-48
: LGTM! Package manager version update.Updating pnpm from 10.6.1 to 10.6.4 is a patch version update that typically includes bug fixes.
packages/eslint-config/src/configs/index.ts (1)
4-4
: LGTM! New module exports added.The added exports for
disables
,regexp
, andvue
align with the PR objective of adding support for regexp and Vue rules.Also applies to: 15-15, 22-22
packages/eslint-config/src/configs/sort.ts (1)
165-168
: LGTM! Enhanced YAML sorting capability.Adding a catch-all pattern
'.*'
ensures that all keys in YAML files are sorted in ascending order, improving consistency across the codebase.packages/eslint-config/src/globs.ts (2)
23-23
: LGTM! Added Vue file pattern.The addition of a dedicated glob pattern for Vue files is essential for the Vue rules implementation.
47-47
: LGTM! Included Vue files in sources.Adding the Vue glob pattern to GLOB_ALL_SRC ensures that Vue files will be properly processed by the ESLint configuration.
packages/eslint-config/src/configs/regexp.ts (1)
1-2
: Confirm necessity of @ts-nocheck
The file is ignoring TS checks; confirm if it's required or if we can enable type-checking for better reliability and catch potential issues earlier.packages/eslint-config/src/types.ts (2)
178-185
: Verify default behavior for RegExp rules
The doc states@default true
, so confirm that your configuration code applies atrue
default ifregexp
is omitted. Otherwise, the eventual config might not load the plugin as intended.
239-245
: Confirm design for Vue integration
The newvue
property follows the precedent of other booleans for optional features. Verify that any auto-detection or fallback logic aligns with user needs—for example, turning on Vue rules only if Vue is actually installed.packages/eslint-config/src/factory.ts (6)
6-6
: Good addition ofisPackageExists
fromlocal-pkg
Using
isPackageExists
function fromlocal-pkg
is a better approach than the existingexistsPackage
from your utils. It provides more reliable package detection which is important for the Vue auto-detection feature.
12-12
: LGTM - Necessary imports for new functionalityCorrectly importing the new configuration functions (
disables
,regexp
, andvue
) to support the expanded ESLint ruleset. Thedisables
function was already used on line 246 but wasn't explicitly imported before.Also applies to: 23-23, 32-32
51-51
: Good approach for Vue package detectionDefining a constant with all common Vue-related packages makes the auto-detection feature more robust and maintainable.
152-152
: Well-designed default configuration flagsThe default values are well thought out:
regexp: enableRegexp = true
: Enabling regexp rules by default is sensible as they're broadly applicablevue: enableVue = VuePackages.some(i => isPackageExists(i))
: Auto-detecting Vue makes the config more user-friendlyThis approach provides good defaults while still allowing users to override them.
Also applies to: 156-156
193-195
: Good implementation of regexp configurationThe configuration properly handles both boolean and object options for the regexp plugin, allowing users to either simply enable/disable or provide detailed configuration.
206-215
: Well-structured Vue integrationThe Vue integration is comprehensive:
- Adds
.vue
file extension to component extensions- Correctly passes TypeScript configuration
- Handles sub-options and overrides appropriately
This implementation ensures Vue files will be properly linted with the appropriate parser and rule set.
packages/eslint-config/package.json (3)
38-40
: Good dependency maintenance - minor version updatesKeeping dependencies up-to-date with minor version updates is a good practice for bug fixes and security improvements. These updates seem well-coordinated and don't include any major version jumps that might introduce breaking changes.
Also applies to: 42-42, 49-50, 55-55
57-57
: Appropriate new dependencies for feature additionsThe newly added dependencies align perfectly with the functionality additions in the codebase:
eslint-plugin-regexp
(2.7.0) - For the new regexp ruleseslint-plugin-vue
(10.0.0) - For Vue.js linting supportlocal-pkg
(1.1.1) - For package detection used in Vue auto-detectionThese are all at stable versions and are necessary for the new features.
Also applies to: 61-61, 65-65
76-76
: Development dependencies properly updatedThe updated development dependencies ensure compatibility with the main dependencies and provide the latest features for the development workflow.
Also applies to: 85-86, 90-90
packages/eslint-config/src/typegen.d.ts (8)
640-867
: Documentation links updated to the latest version.All import plugin documentation URLs have been updated from their previous version to v4.8.0, ensuring links point to the current documentation.
2815-2819
: Added React DOM modernization rules.Added new React DOM rules that help migrate from legacy APIs to modern ones:
react-dom/no-hydrate
: ReplacesReactDom.hydrate()
withhydrateRoot()
react-dom/no-render
: ReplacesReactDom.render()
withcreateRoot(node).render()
react-dom/no-use-form-state
: Adds checks for form state usageAlso applies to: 2835-2839, 2865-2869
3231-3235
: Added forward ref validation rule.Added rule to enforce that a
ref
parameter is set when usingforwardRef
which aligns with React best practices.
3271-3680
: Added comprehensive support for RegExp rules.Added extensive rule definitions from eslint-plugin-regexp, covering:
- Pattern validation and optimization
- Best practices for regular expressions
- Performance considerations (backtracking, linear vs. super-linear behavior)
- Style and readability improvements
This is a significant enhancement that will help catch common regex issues and improve regex quality across the codebase.
4024-4028
: Added Svelte-specific rules.Added two new Svelte rules:
svelte/no-unnecessary-state-wrap
: Prevents unnecessary $state wrappingsvelte/no-unused-props
: Helps identify unused props in componentsThese additions will help maintain cleaner Svelte components.
Also applies to: 4034-4038
10652-10769
: Added comprehensive type definitions for RegExp rules.Added detailed TypeScript interfaces for all the RegExp rule options, providing proper type checking and documentation for each configuration option. This enables proper IDE autocomplete and validation when configuring these rules.
10998-11012
: Added Svelte rule type definitions.Added TypeScript interfaces for the new Svelte rules with appropriate configuration options:
SvelteNoUnnecessaryStateWrap
: Controls reactive class detection and reassignmentSvelteNoUnusedProps
: Configures prop usage checking with pattern exclusionsThese provide proper type safety when configuring these rules.
12935-12935
: Updated ConfigNames type to include the new RegExp rules.The new RegExp rules configuration has been properly added to the ConfigNames type, ensuring type completeness for the configuration system.
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/[email protected] ### Minor Changes - [#238](#238) ([@mheob](https://github.com/mheob)): add `regexp` and `vue` rules ## Summary by CodeRabbit - **New Features** - Enhanced linting capabilities with added rules for regular expression and Vue file support. - **Chores** - Updated the package version to 8.3.0.
Summary by CodeRabbit
New Features
Chores