Skip to content
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

Explore configuration with real regex instead of strings #165

Open
lydell opened this issue Apr 13, 2024 · 0 comments
Open

Explore configuration with real regex instead of strings #165

lydell opened this issue Apr 13, 2024 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@lydell
Copy link
Owner

lydell commented Apr 13, 2024

Now that ESLint 9 is here with Flat config written in JavaScript, it would be cool if it was possible to use regex literals instead of string literals when configuring this plugin.

Pros:

  • No double escaping. Can write /\w/ instead of "\\w".
  • Can choose flags. Like adding i for case in-sensitive.
  • Can get more help from an IDE since it knows you are writing a regex.

What needs to be done:

  • See if this is possible at all in Flat config.
  • Figure out the eslintrc compatibility story.
  • Update docs.
  • Update tests.
  • Support strings forever since it’s easy and then doesn’t force people to do boring update chores?

Example (the default groups):

import simpleImportSort from "eslint-plugin-simple-import-sort";

export default [
  {
    plugins: {
      "simple-import-sort": simpleImportSort,
    },
    rules: {
      "simple-import-sort/imports": ["error", {
        groups: [
          // Side effect imports.
          [/^\u0000/u],
          // Node.js builtins prefixed with `node:`.
          [/^node:/u],
          // Packages.
          // Things that start with a letter (or digit or underscore), or `@` followed by a letter.
          [/^@?\w/u],
          // Absolute imports and other imports such as Vue-style `@/foo`.
          // Anything not matched in another group.
          [/^/u],
          // Relative imports.
          // Anything that starts with a dot.
          [/^\./u],
        ]
      }],
    },
  },
];
@lydell lydell added the help wanted Extra attention is needed label Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant