Open lydell opened 5 months ago
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. 😛
See if this is possible at all in Flat config. Figure out the eslintrc compatibility story.
In my experience, regex literal works for both flat config and eslintrc.
unicorn/prevent-abbreviation
accepts Array<string | RegExp>
for many years. https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prevent-abbreviations.md#ignore
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):