Skip to content

Commit

Permalink
feat(eslint-config): enable regexp strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
foray1010 committed Nov 17, 2023
1 parent 5739708 commit 07d035b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
14 changes: 8 additions & 6 deletions packages/eslint-config/bases/base.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ async function generateTypeScriptConfig() {
// reduce the difficult to use this rule
ignoreInferredTypes: true,
// escape hatch without using eslint-disable
ignoreNamePattern: /Mutable$/.source,
ignoreNamePattern: /Mutable$/u.source,
ignoreTypePattern: [
/^React\./.source, // Some React types does not work with `Readonly`
/^React\./u.source, // Some React types does not work with `Readonly`
],
},
],
Expand All @@ -205,12 +205,12 @@ async function generateTypeScriptConfig() {
// modified from https://github.com/eslint-functional/eslint-plugin-functional/blob/main/docs/rules/type-declaration-immutability.md#preset-overrides
fixer: [
{
pattern: /^(Array|Map|Set)<(.+)>$/.source,
replace: /Readonly\$1<\$2>/.source,
pattern: /^(Array|Map|Set)<(.+)>$/u.source,
replace: /Readonly\$1<\$2>/u.source,
},
{
pattern: /^(.+)$/.source,
replace: /Readonly<\$1>/.source,
pattern: /^(.+)$/u.source,
replace: /Readonly<\$1>/u.source,
},
],
},
Expand Down Expand Up @@ -411,6 +411,8 @@ const baseConfig = [
destructuring: 'all',
},
],
// enable regexp strict mode
'regexp/require-unicode-regexp': 'error',
// use with `unicorn/throw-new-error`
// disallow builtins to be created without `new` operator, to be consistent with es6 class syntax
'unicorn/new-for-builtins': 'error',
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/utils/applyConfig.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function generateCombinations(prefixes, originalGlobs) {

return prefixes.flatMap((prefix) => {
return verifiedOriginalGlobs.flatMap((originalGlob) => {
const signRegexp = /^!/
const signRegexp = /^!/u
const sign = originalGlob.match(signRegexp)?.[0] ?? ''
return sign + path.join(prefix, originalGlob.replace(signRegexp, ''))
})
Expand Down
12 changes: 6 additions & 6 deletions packages/jest-preset/jest-preset.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const preset = {
collectCoverage: true,
collectCoverageFrom: ['<rootDir>/src/**/*.{cjs,cts,js,mjs,mts,ts,tsx}'],
coveragePathIgnorePatterns: [
/\/\./.source, // ignore all hidden files
/\/__fixtures__\//.source,
/\/__mocks__\//.source,
/\/__tests__\//.source,
/\/node_modules\//.source,
/\.d\.(?:cts|mts|ts|tsx)$/.source, // ignore type definition files
/\/\./u.source, // ignore all hidden files
/\/__fixtures__\//u.source,
/\/__mocks__\//u.source,
/\/__tests__\//u.source,
/\/node_modules\//u.source,
/\.d\.(?:cts|mts|ts|tsx)$/u.source, // ignore type definition files
],
coverageReporters: ['lcov', 'text-summary'],
errorOnDeprecated: true,
Expand Down

0 comments on commit 07d035b

Please sign in to comment.