You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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):
importsimpleImportSortfrom"eslint-plugin-simple-import-sort";exportdefault[{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],]}],},},];
The text was updated successfully, but these errors were encountered:
regex literals would be cool. To solve your first problem I've been using String.raw
'simple-import-sort/imports': ['error',{groups: [// react, react-native, and side effect imports.['^react$','^react-native$',String.raw`^\u0000`],// Things that start with a letter (or digit or underscore), or `@` followed by a letter.[String.raw`^@?\w`],// Anything starting with a tilde. Anything starting with a dot.['^~/',String.raw`^\.`],// type imports[String.raw`^@?\w.*\u0000$`,String.raw`^[^.].*\u0000$`,String.raw`^\..*\u0000$`],],},
It's maybe slightly more readable and done via another eslint rule so I don't really have to think about it. 😛
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:
/\w/
instead of"\\w"
.i
for case in-sensitive.What needs to be done:
Example (the default groups):
The text was updated successfully, but these errors were encountered: