Skip to content

fix: add eslint-plugin-regexp and resolve linting errors#3673

Merged
BobbieGoede merged 2 commits intonextfrom
fix/lint-regexp
Jun 3, 2025
Merged

fix: add eslint-plugin-regexp and resolve linting errors#3673
BobbieGoede merged 2 commits intonextfrom
fix/lint-regexp

Conversation

@BobbieGoede
Copy link
Copy Markdown
Member

@BobbieGoede BobbieGoede commented Jun 3, 2025

🔗 Linked issue

📚 Description

Summary by CodeRabbit

  • Chores

    • Updated linting setup to include recommended regular expression rules.
    • Added a new development dependency for enhanced regex linting.
  • Bug Fixes

    • Corrected regular expressions for file extension matching, improving detection of JavaScript and TypeScript files.
    • Simplified and improved regular expressions used for domain normalization and translation function detection.
  • Style

    • Refined regular expressions for extracting script content in Vue components for stricter matching.

@BobbieGoede BobbieGoede self-assigned this Jun 3, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2025

Walkthrough

This update revises several regular expressions across the codebase for improved accuracy and simplicity, particularly in domain normalization, translation function detection, Vue SFC script extraction, and file extension matching. Additionally, it introduces the eslint-plugin-regexp dependency and configuration to enhance regex linting in the ESLint setup.

Changes

File(s) Summary
eslint.config.js, package.json Added eslint-plugin-regexp as a dev dependency and included its recommended config in ESLint.
src/runtime/domain.ts Simplified the regex for removing protocol prefixes in domain normalization.
src/transform/i18n-function-injection.ts Refined regexes for translation function detection and SFC script content extraction.
src/transform/resource.ts Corrected regex patterns for matching JS/TS file extensions in resource transformation logic.

Sequence Diagram(s)

sequenceDiagram
    participant ESLint
    participant RegexpPlugin
    participant Developer

    Developer->>ESLint: Run lint
    ESLint->>RegexpPlugin: Apply regexp recommended rules
    RegexpPlugin-->>ESLint: Return lint results
    ESLint-->>Developer: Report lint findings
Loading

Possibly related PRs

  • nuxt-modules/i18n#3640: Refactors and simplifies domain utility functions in src/runtime/domain.ts, closely related to the regex simplification for domain normalization in this PR.
  • nuxt-modules/i18n#3632: Refactors locale extraction logic in src/runtime/domain.ts by replacing regex with utility functions, related by file but addressing different regex usage.

Poem

Regexes pruned and patterns made neat,
Linting grows stronger with each tidy feat.
Domains and translations, scripts in their place,
Extensions now match with elegant grace.
With regexp plugin, the code’s in full bloom—
A rabbit’s delight, in the linting room! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ad44e9d and aab6b35.

📒 Files selected for processing (1)
  • src/transform/resource.ts (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/transform/resource.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test (lts/*, windows-latest)
  • GitHub Check: test (lts/*, ubuntu-latest)
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

Copy link
Copy Markdown
Contributor

@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: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1ddd922 and ad44e9d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • eslint.config.js (2 hunks)
  • package.json (1 hunks)
  • src/runtime/domain.ts (1 hunks)
  • src/transform/i18n-function-injection.ts (2 hunks)
  • src/transform/resource.ts (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test (lts/*, windows-latest)
  • GitHub Check: test (lts/*, ubuntu-latest)
🔇 Additional comments (6)
package.json (1)

127-127: LGTM! Correctly adds the eslint-plugin-regexp dependency.

The addition of eslint-plugin-regexp as a dev dependency aligns perfectly with the PR objectives and supports the ESLint configuration changes.

eslint.config.js (2)

5-5: LGTM! Proper import of the regexp plugin.

The import statement correctly brings in the entire eslint-plugin-regexp plugin for use in the flat config.


45-45: LGTM! Correctly integrates the regexp plugin configuration.

The flat/recommended config is properly added to enable the recommended regexp linting rules. The placement in the config array is appropriate.

src/runtime/domain.ts (1)

21-21: LGTM! Correctly removes unnecessary capturing group.

The regex simplification from /(https?):\/\// to /https?:\/\// removes an unused capturing group while maintaining identical functionality. This is a good optimization that likely addresses an eslint-plugin-regexp rule.

src/transform/i18n-function-injection.ts (2)

18-18: LGTM! Regex optimization maintains functionality.

The reordering of the alternation from /(t|rt|d|n|tm|te)/ to /([tdn]|rt|tm|te)/ groups single-character functions together, which is a performance optimization likely suggested by eslint-plugin-regexp. The functionality remains identical.


141-141: LGTM! Appropriate regex simplification.

Removing the optional whitespace matching (\s*) after <script and before </script makes the regex more efficient. While this is technically stricter, it's appropriate since <script > or < /script> patterns are extremely uncommon in practice.

Comment thread src/transform/resource.ts Outdated
Comment thread src/transform/resource.ts Outdated
Comment thread src/transform/resource.ts Outdated
@BobbieGoede BobbieGoede merged commit 7bea178 into next Jun 3, 2025
11 checks passed
@BobbieGoede BobbieGoede deleted the fix/lint-regexp branch June 3, 2025 23:09
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.

1 participant