Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const { default: js } = await importEslintTool('@eslint/js');
const { default: babelEslintParser } = await importEslintTool('@babel/eslint-parser');
const babelPluginSyntaxImportSource = resolveEslintTool('@babel/plugin-syntax-import-source');
const { default: jsdoc } = await importEslintTool('eslint-plugin-jsdoc');
const { default: regexpPlugin } = await importEslintTool('eslint-plugin-regexp');
const { default: markdown } = await importEslintTool('@eslint/markdown');
const { default: stylisticJs } = await importEslintTool('@stylistic/eslint-plugin');

Expand Down Expand Up @@ -84,6 +85,7 @@ export default [
// #region general config
js.configs.recommended,
jsdoc.configs['flat/recommended'],
regexpPlugin.configs.recommended,
{
files: ['**/*.js'],
languageOptions: {
Expand Down Expand Up @@ -275,6 +277,42 @@ export default [
'jsdoc/reject-any-type': 'off',
'jsdoc/reject-function-type': 'off',

// RegExp recommended rules that we disable.
// Todo: Investigate which rules should be enabled.
'prefer-regex-literals': 'off',
'regexp/control-character-escape': 'off',
'regexp/match-any': 'off',
'regexp/negation': 'off',
'regexp/no-contradiction-with-assertion': 'off',
'regexp/no-dupe-characters-character-class': 'off',
'regexp/no-dupe-disjunctions': 'off',
'regexp/no-empty-alternative': 'off',
'regexp/no-legacy-features': 'off',
'regexp/no-misleading-capturing-group': 'off',
'regexp/no-obscure-range': 'off',
'regexp/no-potentially-useless-backreference': 'off',
'regexp/no-super-linear-backtracking': 'off',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule can prevent issues like #61904.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be error then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be error then?

Per PR description

To seek consensus on whether we should use this plugin, we have disabled all rules which the current codebase does not meet, so there is no change in the current codebase.

There are around 20 errors from this rule, to limit the scope of this PR, I suggest we discuss whether we should add this eslint plugin. If there is a consensus to add it, then we can always open a new PR to enable rules and fix linting errors.

'regexp/no-trivially-nested-quantifier': 'off',
'regexp/no-unused-capturing-group': 'off',
'regexp/no-useless-assertions': 'off',
'regexp/no-useless-character-class': 'off',
'regexp/no-useless-escape': 'off',
'regexp/no-useless-flag': 'off',
'regexp/no-useless-lazy': 'off',
'regexp/no-useless-non-capturing-group': 'off',
'regexp/no-useless-quantifier': 'off',
'regexp/no-useless-range': 'off',
'regexp/optimal-lookaround-quantifier': 'off',
'regexp/optimal-quantifier-concatenation': 'off',
'regexp/prefer-character-class': 'off',
'regexp/prefer-d': 'off',
'regexp/prefer-question-quantifier': 'off',
'regexp/prefer-star-quantifier': 'off',
'regexp/prefer-w': 'off',
'regexp/sort-flags': 'off',
'regexp/strict': 'off',
'regexp/use-ignore-case': 'off',

// Stylistic rules.
'@stylistic/js/arrow-parens': 'error',
'@stylistic/js/arrow-spacing': 'error',
Expand Down
69 changes: 65 additions & 4 deletions tools/eslint/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tools/eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"eslint": "^10.0.1",
"eslint-formatter-tap": "^9.0.1",
"eslint-plugin-jsdoc": "^62.7.0",
"eslint-plugin-regexp": "^3.0.0",
"globals": "^17.3.0"
}
}
Loading