diff --git a/eslint-configs/eslint-config-seekingalpha-base/CHANGELOG.md b/eslint-configs/eslint-config-seekingalpha-base/CHANGELOG.md index 9924ae33..a22fea9a 100644 --- a/eslint-configs/eslint-config-seekingalpha-base/CHANGELOG.md +++ b/eslint-configs/eslint-config-seekingalpha-base/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 10.0.0 - 2025-03-09 + +- [breaking] migrate to ESM and make flat config default + ## 9.1.0 - 2025-03-06 - [deps] update `eslint-plugin-array-func` to version `5.0.2` diff --git a/eslint-configs/eslint-config-seekingalpha-base/README.md b/eslint-configs/eslint-config-seekingalpha-base/README.md index 4396d208..371d459e 100644 --- a/eslint-configs/eslint-config-seekingalpha-base/README.md +++ b/eslint-configs/eslint-config-seekingalpha-base/README.md @@ -10,32 +10,35 @@ Install ESLint and all [Peer Dependencies](https://nodejs.org/en/blog/npm/peer-d Install SeekingAlpha shareable ESLint: - npm install eslint-config-seekingalpha-base --save-dev + npm install eslint-config-seekingalpha-base@latest --save-dev ## Usage -This shareable config includes all ESLint rules including ECMAScript 6 features and set of [legacy rules](https://eslint.org/docs/rules/#deprecated). We also extend our configuration with following plugins: +This shareable config includes all ESLint rules. We also extend our configuration with following plugins: - [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) - [eslint-plugin-array-func](https://github.com/freaktechnik/eslint-plugin-array-func) - [eslint-plugin-promise](https://github.com/xjamundx/eslint-plugin-promise) - [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) -We expose three configurations: - -- `seekingalpha-base` - exports all avaliable ESLint [rules](https://eslint.org/docs/rules/) and all rules of plugins above. -- `seekingalpha-base/browser` - exports only browser related rules for ESLint and mentioned plugins. It also sets `browser` as [default environment](https://eslint.org/docs/user-guide/configuring#specifying-environments). -- `seekingalpha-base/node` - exports only Node.js related rules for ESLint and mentioned plugins. It also sets `node` as [default environment](https://eslint.org/docs/user-guide/configuring#specifying-environments). - -Simply [extend](https://eslint.org/docs/user-guide/configuring#extending-configuration-files) the .eslintrc.js in your project with relevant configuration: +Simply [use](https://eslint.org/docs/latest/extend/shareable-configs) the eslint.config.js in your project with the configuration: ```javascript -// for seekingalpha-base -{ - extends: [ - 'seekingalpha-base' - ] -} +import baseConfig from 'eslint-config-seekingalpha-base'; + +export default [ + { + plugins: { + ...baseConfig.plugins, + }, + rules: { + ...baseConfig.rules, + }, + settings: { + ...baseConfig.settings, + }, + }, +]; ``` ## License diff --git a/eslint-configs/eslint-config-seekingalpha-base/flat.js b/eslint-configs/eslint-config-seekingalpha-base/flat.js deleted file mode 100644 index b72c79fa..00000000 --- a/eslint-configs/eslint-config-seekingalpha-base/flat.js +++ /dev/null @@ -1,24 +0,0 @@ -import esLintConfig from './rules/eslint/flat.js'; -import esLintPluginArrayFuncConfig from './rules/eslint-plugin-array-func/flat.js'; -import esLintPluginImport from './rules/eslint-plugin-import/flat.js'; -import esLintPluginPromise from './rules/eslint-plugin-promise/flat.js'; -import esLintPluginUnicorn from './rules/eslint-plugin-unicorn/flat.js'; - -export default { - plugins: { - ...esLintPluginArrayFuncConfig.plugins, - ...esLintPluginImport.plugins, - ...esLintPluginPromise.plugins, - ...esLintPluginUnicorn.plugins, - }, - rules: { - ...esLintConfig.rules, - ...esLintPluginArrayFuncConfig.rules, - ...esLintPluginImport.rules, - ...esLintPluginPromise.rules, - ...esLintPluginUnicorn.rules, - }, - settings: { - ...esLintPluginImport.settings, - }, -}; diff --git a/eslint-configs/eslint-config-seekingalpha-base/index.js b/eslint-configs/eslint-config-seekingalpha-base/index.js index 00aa27ee..542997bc 100644 --- a/eslint-configs/eslint-config-seekingalpha-base/index.js +++ b/eslint-configs/eslint-config-seekingalpha-base/index.js @@ -1,27 +1,24 @@ -module.exports = { - extends: [ - // ESLint rules (https://eslint.org/docs/rules/) - './rules/eslint/index.js', +import esLintConfig from './rules/eslint/index.js'; +import esLintPluginArrayFuncConfig from './rules/eslint-plugin-array-func/index.js'; +import esLintPluginImport from './rules/eslint-plugin-import/index.js'; +import esLintPluginPromise from './rules/eslint-plugin-promise/index.js'; +import esLintPluginUnicorn from './rules/eslint-plugin-unicorn/index.js'; - // eslint-plugin-import rules (https://github.com/benmosher/eslint-plugin-import) - './rules/eslint-plugin-import/index.js', - - // eslint-plugin-array-func rules (https://github.com/freaktechnik/eslint-plugin-array-func) - './rules/eslint-plugin-array-func/index.js', - - // eslint-plugin-promise rules (https://github.com/xjamundx/eslint-plugin-promise) - './rules/eslint-plugin-promise/index.js', - - // eslint-plugin-unicorn rules (https://github.com/sindresorhus/eslint-plugin-unicorn) - './rules/eslint-plugin-unicorn/index.js', - ], - - parserOptions: { - ecmaVersion: 12, - sourceType: 'module', - ecmaFeatures: { - impliedStrict: true, - globalReturn: false, - }, +export default { + plugins: { + ...esLintPluginArrayFuncConfig.plugins, + ...esLintPluginImport.plugins, + ...esLintPluginPromise.plugins, + ...esLintPluginUnicorn.plugins, + }, + rules: { + ...esLintConfig.rules, + ...esLintPluginArrayFuncConfig.rules, + ...esLintPluginImport.rules, + ...esLintPluginPromise.rules, + ...esLintPluginUnicorn.rules, + }, + settings: { + ...esLintPluginImport.settings, }, }; diff --git a/eslint-configs/eslint-config-seekingalpha-base/package.json b/eslint-configs/eslint-config-seekingalpha-base/package.json index 4bebaf09..2b03a6f3 100644 --- a/eslint-configs/eslint-config-seekingalpha-base/package.json +++ b/eslint-configs/eslint-config-seekingalpha-base/package.json @@ -1,11 +1,11 @@ { "name": "eslint-config-seekingalpha-base", - "version": "9.1.0", + "version": "10.0.0", "description": "SeekingAlpha's sharable base ESLint config", "main": "index.js", + "type": "module", "scripts": { "eslint-find-rules": "eslint-find-rules -u ./index.js", - "lint": "eslint --ext .js .", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { diff --git a/eslint-configs/eslint-config-seekingalpha-base/rules/config.js b/eslint-configs/eslint-config-seekingalpha-base/rules/config.js index 43d723c9..2da6adf8 100644 --- a/eslint-configs/eslint-config-seekingalpha-base/rules/config.js +++ b/eslint-configs/eslint-config-seekingalpha-base/rules/config.js @@ -1,4 +1,4 @@ -module.exports = { +export default { complexity: 10, maxClassesPerFile: 1, arrayElementNewlineMinItems: 5, diff --git a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-array-func/flat.js b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-array-func/flat.js deleted file mode 100644 index 84589b91..00000000 --- a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-array-func/flat.js +++ /dev/null @@ -1,10 +0,0 @@ -import pluginArrayFunc from 'eslint-plugin-array-func'; - -import config from './index.js'; - -export default { - plugins: { - 'array-func': pluginArrayFunc, - }, - rules: config.rules, -}; diff --git a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-array-func/index.js b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-array-func/index.js index d3cb2eec..0b22cf4a 100644 --- a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-array-func/index.js +++ b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-array-func/index.js @@ -1,8 +1,9 @@ -// https://github.com/freaktechnik/eslint-plugin-array-func - -module.exports = { - plugins: ['array-func'], +import pluginArrayFunc from 'eslint-plugin-array-func'; +export default { + plugins: { + 'array-func': pluginArrayFunc, + }, rules: { 'array-func/from-map': 'error', diff --git a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/flat.js b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/flat.js deleted file mode 100644 index 9ad0c359..00000000 --- a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/flat.js +++ /dev/null @@ -1,21 +0,0 @@ -import importPlugin from 'eslint-plugin-import'; - -import helpfulWarnings from './helpful-warnings.js'; -import moduleSystem from './module-systems.js'; -import staticAnalysis from './static-analysis.js'; -import styleGuide from './style-guide.js'; - -import config from './index.js'; - -export default { - plugins: { - import: importPlugin, - }, - rules: { - ...helpfulWarnings.rules, - ...moduleSystem.rules, - ...staticAnalysis.rules, - ...styleGuide.rules, - }, - settings: config.settings, -}; diff --git a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/helpful-warnings.js b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/helpful-warnings.js index da5ce2b3..3e86277d 100644 --- a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/helpful-warnings.js +++ b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/helpful-warnings.js @@ -1,36 +1,34 @@ // https://github.com/benmosher/eslint-plugin-import#helpful-warnings -module.exports = { - rules: { - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md - 'import/export': 'error', +export default { + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md + 'import/export': 'error', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md - 'import/no-named-as-default': 'error', + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md + 'import/no-named-as-default': 'error', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md - 'import/no-named-as-default-member': 'error', + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md + 'import/no-named-as-default-member': 'error', - /* - * Stage 0 rule, may be changed. Cool one ;) - * https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md - */ - 'import/no-deprecated': 'error', + /* + * Stage 0 rule, may be changed. Cool one ;) + * https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md + */ + 'import/no-deprecated': 'error', - // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-empty-named-blocks.md - 'import/no-empty-named-blocks': 'error', + // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-empty-named-blocks.md + 'import/no-empty-named-blocks': 'error', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md - 'import/no-extraneous-dependencies': [ - 'error', - { - devDependencies: true, - optionalDependencies: true, - peerDependencies: true, - }, - ], + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md + 'import/no-extraneous-dependencies': [ + 'error', + { + devDependencies: true, + optionalDependencies: true, + peerDependencies: true, + }, + ], - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md - 'import/no-mutable-exports': 'error', - }, + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md + 'import/no-mutable-exports': 'error', }; diff --git a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/index.js b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/index.js index 86e24e2a..06fc4a33 100644 --- a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/index.js +++ b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/index.js @@ -1,15 +1,20 @@ -// eslint-plugin-import rules (https://github.com/benmosher/eslint-plugin-import) +import importPlugin from 'eslint-plugin-import'; -module.exports = { - extends: [ - './helpful-warnings.js', - './module-systems.js', - './static-analysis.js', - './style-guide.js', - ], - - plugins: ['import'], +import helpfulWarnings from './helpful-warnings.js'; +import moduleSystem from './module-systems.js'; +import staticAnalysis from './static-analysis.js'; +import styleGuide from './style-guide.js'; +export default { + plugins: { + import: importPlugin, + }, + rules: { + ...helpfulWarnings, + ...moduleSystem, + ...staticAnalysis, + ...styleGuide, + }, settings: { 'import/resolver': { node: { diff --git a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/module-systems.js b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/module-systems.js index 07dc9552..cc97f7b1 100644 --- a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/module-systems.js +++ b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/module-systems.js @@ -1,20 +1,18 @@ // https://github.com/benmosher/eslint-plugin-import#module-systems -module.exports = { - rules: { - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/unambiguous.md - 'import/unambiguous': 'off', +export default { + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/unambiguous.md + 'import/unambiguous': 'off', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md - 'import/no-commonjs': 'off', + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md + 'import/no-commonjs': 'off', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-amd.md - 'import/no-amd': 'error', + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-amd.md + 'import/no-amd': 'error', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md - 'import/no-nodejs-modules': 'off', + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md + 'import/no-nodejs-modules': 'off', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-import-module-exports.md - 'import/no-import-module-exports': 'error', - }, + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-import-module-exports.md + 'import/no-import-module-exports': 'error', }; diff --git a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/static-analysis.js b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/static-analysis.js index 4f71c19b..b9e074c3 100644 --- a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/static-analysis.js +++ b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/static-analysis.js @@ -1,71 +1,69 @@ // https://github.com/benmosher/eslint-plugin-import#static-analysis -module.exports = { - rules: { - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md - 'import/no-unresolved': [ - 'error', - { - commonjs: true, - caseSensitive: true, - }, - ], +export default { + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md + 'import/no-unresolved': [ + 'error', + { + commonjs: true, + caseSensitive: true, + }, + ], - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it - 'import/named': 'error', + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it + 'import/named': 'error', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it - 'import/default': 'error', + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it + 'import/default': 'error', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/namespace.md - 'import/namespace': [ - 'error', - { - allowComputed: true, - }, - ], + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/namespace.md + 'import/namespace': [ + 'error', + { + allowComputed: true, + }, + ], - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md - 'import/no-restricted-paths': 'off', + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md + 'import/no-restricted-paths': 'off', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md - 'import/no-absolute-path': [ - 'error', - { - esmodule: true, - commonjs: true, - amd: false, - }, - ], + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md + 'import/no-absolute-path': [ + 'error', + { + esmodule: true, + commonjs: true, + amd: false, + }, + ], - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md - 'import/no-dynamic-require': 'error', + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md + 'import/no-dynamic-require': 'error', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-internal-modules.md - 'import/no-internal-modules': 'off', + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-internal-modules.md + 'import/no-internal-modules': 'off', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md - 'import/no-webpack-loader-syntax': 'error', + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md + 'import/no-webpack-loader-syntax': 'error', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-self-import.md - 'import/no-self-import': 'error', + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-self-import.md + 'import/no-self-import': 'error', - /* - * very slow - * https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-cycle.md - */ - 'import/no-cycle': 'off', + /* + * very slow + * https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-cycle.md + */ + 'import/no-cycle': 'off', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-useless-path-segments.md - 'import/no-useless-path-segments': 'error', + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-useless-path-segments.md + 'import/no-useless-path-segments': 'error', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-relative-parent-imports.md - 'import/no-relative-parent-imports': 'off', + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-relative-parent-imports.md + 'import/no-relative-parent-imports': 'off', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-relative-packages.md - 'import/no-relative-packages': 'error', + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-relative-packages.md + 'import/no-relative-packages': 'error', - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unused-modules.md - 'import/no-unused-modules': 'error', - }, + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unused-modules.md + 'import/no-unused-modules': 'error', }; diff --git a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/style-guide.js b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/style-guide.js index dec745d9..fd917433 100644 --- a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/style-guide.js +++ b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-import/style-guide.js @@ -1,86 +1,84 @@ // https://github.com/benmosher/eslint-plugin-import#style-guide -module.exports = { - rules: { - // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/consistent-type-specifier-style.md - 'import/consistent-type-specifier-style': ['error', 'prefer-top-level'], - - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md - 'import/first': 'error', - - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/exports-last.md - 'import/exports-last': 'off', - - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md - 'import/no-duplicates': 'error', - - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md - 'import/no-namespace': 'error', - - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md - 'import/extensions': [ - 'error', - 'ignorePackages', - { - js: 'never', - jsx: 'never', - ts: 'never', - tsx: 'never', - }, - ], - - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md - 'import/order': [ - 'error', - { - groups: [ - 'builtin', - 'external', - 'internal', - 'parent', - 'sibling', - 'unknown', - 'index', - 'type', - ], - - 'newlines-between': 'always', - }, - ], - - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md - 'import/newline-after-import': 'error', - - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md - 'import/prefer-default-export': 'off', - - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/max-dependencies.md - 'import/max-dependencies': 'off', - - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md - 'import/no-unassigned-import': 'error', - - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-default.md - 'import/no-named-default': 'error', - - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-default-export.md - 'import/no-default-export': 'error', - - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-anonymous-default-export.md - 'import/no-anonymous-default-export': 'error', - - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/group-exports.md - 'import/group-exports': 'off', - - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/dynamic-import-chunkname.md - 'import/dynamic-import-chunkname': [ - 'error', - { - importFunctions: [], - webpackChunknameFormat: String.raw`[a-zA-Z\d]+-[S|R|W|M](_(Pro|Pre|In|Out)+)?`, - }, - ], - - // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-export.md - 'import/no-named-export': 'off', - }, +export default { + // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/consistent-type-specifier-style.md + 'import/consistent-type-specifier-style': ['error', 'prefer-top-level'], + + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md + 'import/first': 'error', + + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/exports-last.md + 'import/exports-last': 'off', + + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md + 'import/no-duplicates': 'error', + + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md + 'import/no-namespace': 'error', + + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md + 'import/extensions': [ + 'error', + 'ignorePackages', + { + js: 'never', + jsx: 'never', + ts: 'never', + tsx: 'never', + }, + ], + + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md + 'import/order': [ + 'error', + { + groups: [ + 'builtin', + 'external', + 'internal', + 'parent', + 'sibling', + 'unknown', + 'index', + 'type', + ], + + 'newlines-between': 'always', + }, + ], + + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md + 'import/newline-after-import': 'error', + + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md + 'import/prefer-default-export': 'off', + + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/max-dependencies.md + 'import/max-dependencies': 'off', + + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md + 'import/no-unassigned-import': 'error', + + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-default.md + 'import/no-named-default': 'error', + + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-default-export.md + 'import/no-default-export': 'error', + + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-anonymous-default-export.md + 'import/no-anonymous-default-export': 'error', + + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/group-exports.md + 'import/group-exports': 'off', + + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/dynamic-import-chunkname.md + 'import/dynamic-import-chunkname': [ + 'error', + { + importFunctions: [], + webpackChunknameFormat: String.raw`[a-zA-Z\d]+-[S|R|W|M](_(Pro|Pre|In|Out)+)?`, + }, + ], + + // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-export.md + 'import/no-named-export': 'off', }; diff --git a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-promise/flat.js b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-promise/flat.js deleted file mode 100644 index 365a5386..00000000 --- a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-promise/flat.js +++ /dev/null @@ -1,10 +0,0 @@ -import promisePlugin from 'eslint-plugin-promise'; - -import config from './index.js'; - -export default { - plugins: { - promise: promisePlugin, - }, - rules: config.rules, -}; diff --git a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-promise/index.js b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-promise/index.js index 146d384e..f091591d 100644 --- a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-promise/index.js +++ b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-promise/index.js @@ -1,8 +1,9 @@ -// https://github.com/xjamundx/eslint-plugin-promise - -module.exports = { - plugins: ['promise'], +import promisePlugin from 'eslint-plugin-promise'; +export default { + plugins: { + promise: promisePlugin, + }, rules: { // https://github.com/xjamundx/eslint-plugin-promise/blob/master/docs/rules/always-return.md 'promise/always-return': 'error', diff --git a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-unicorn/flat.js b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-unicorn/flat.js deleted file mode 100644 index 93b5408b..00000000 --- a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-unicorn/flat.js +++ /dev/null @@ -1,10 +0,0 @@ -import eslintPluginUnicorn from 'eslint-plugin-unicorn'; - -import config from './index.js'; - -export default { - plugins: { - unicorn: eslintPluginUnicorn, - }, - rules: config.rules, -}; diff --git a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-unicorn/index.js b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-unicorn/index.js index 528e0fcb..1ced167f 100644 --- a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-unicorn/index.js +++ b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint-plugin-unicorn/index.js @@ -1,8 +1,9 @@ -// https://github.com/sindresorhus/eslint-plugin-unicorn - -module.exports = { - plugins: ['unicorn'], +import eslintPluginUnicorn from 'eslint-plugin-unicorn'; +export default { + plugins: { + unicorn: eslintPluginUnicorn, + }, rules: { // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/better-regex.md 'unicorn/better-regex': 'error', diff --git a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint/flat.js b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint/flat.js deleted file mode 100644 index b8ef03f5..00000000 --- a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint/flat.js +++ /dev/null @@ -1,11 +0,0 @@ -import layout from './layout-and-formatting.js'; -import problems from './possible-problems.js'; -import suggestions from './suggestions.js'; - -export default { - rules: { - ...layout.rules, - ...problems.rules, - ...suggestions.rules, - }, -}; diff --git a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint/index.js b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint/index.js index 5c4635b0..fafbf87f 100644 --- a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint/index.js +++ b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint/index.js @@ -1,7 +1,11 @@ -module.exports = { - extends: [ - './possible-problems.js', - './suggestions.js', - './layout-and-formatting.js', - ], +import layout from './layout-and-formatting.js'; +import problems from './possible-problems.js'; +import suggestions from './suggestions.js'; + +export default { + rules: { + ...layout, + ...problems, + ...suggestions, + }, }; diff --git a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint/layout-and-formatting.js b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint/layout-and-formatting.js index 95b0d0ad..70f28792 100644 --- a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint/layout-and-formatting.js +++ b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint/layout-and-formatting.js @@ -1,21 +1,18 @@ -module.exports = { - // https://eslint.org/docs/rules/#layout-formatting +// https://eslint.org/docs/rules/#layout-formatting +export default { + // https://eslint.org/docs/rules/line-comment-position + 'line-comment-position': [ + 'error', + { + position: 'above', + ignorePattern: '', + applyDefaultPatterns: true, + }, + ], - rules: { - // https://eslint.org/docs/rules/line-comment-position - 'line-comment-position': [ - 'error', - { - position: 'above', - ignorePattern: '', - applyDefaultPatterns: true, - }, - ], - - /* - * https://eslint.org/docs/rules/unicode-bom - * disabled to work with prettier - */ - 'unicode-bom': 'off', - }, + /* + * https://eslint.org/docs/rules/unicode-bom + * disabled to work with prettier + */ + 'unicode-bom': 'off', }; diff --git a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint/possible-problems.js b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint/possible-problems.js index 67b19819..94e23c2b 100644 --- a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint/possible-problems.js +++ b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint/possible-problems.js @@ -1,223 +1,220 @@ -module.exports = { - // https://eslint.org/docs/rules/#possible-problems +// https://eslint.org/docs/rules/#possible-problems +export default { + // https://eslint.org/docs/rules/array-callback-return + 'array-callback-return': 'error', - rules: { - // https://eslint.org/docs/rules/array-callback-return - 'array-callback-return': 'error', + // https://eslint.org/docs/rules/constructor-super + 'constructor-super': 'error', - // https://eslint.org/docs/rules/constructor-super - 'constructor-super': 'error', + // https://eslint.org/docs/rules/for-direction + 'for-direction': 'error', - // https://eslint.org/docs/rules/for-direction - 'for-direction': 'error', + // https://eslint.org/docs/rules/getter-return + 'getter-return': [ + 'error', + { + allowImplicit: false, + }, + ], - // https://eslint.org/docs/rules/getter-return - 'getter-return': [ - 'error', - { - allowImplicit: false, - }, - ], + // https://eslint.org/docs/rules/no-async-promise-executor + 'no-async-promise-executor': 'error', - // https://eslint.org/docs/rules/no-async-promise-executor - 'no-async-promise-executor': 'error', + // https://eslint.org/docs/rules/no-await-in-loop + 'no-await-in-loop': 'error', - // https://eslint.org/docs/rules/no-await-in-loop - 'no-await-in-loop': 'error', + // https://eslint.org/docs/rules/no-class-assign + 'no-class-assign': 'error', - // https://eslint.org/docs/rules/no-class-assign - 'no-class-assign': 'error', + // https://eslint.org/docs/rules/no-compare-neg-zero + 'no-compare-neg-zero': 'error', - // https://eslint.org/docs/rules/no-compare-neg-zero - 'no-compare-neg-zero': 'error', + // https://eslint.org/docs/rules/no-cond-assign + 'no-cond-assign': 'error', - // https://eslint.org/docs/rules/no-cond-assign - 'no-cond-assign': 'error', + // https://eslint.org/docs/rules/no-const-assign + 'no-const-assign': 'error', - // https://eslint.org/docs/rules/no-const-assign - 'no-const-assign': 'error', + // https://eslint.org/docs/rules/no-constant-binary-expression + 'no-constant-binary-expression': 'error', - // https://eslint.org/docs/rules/no-constant-binary-expression - 'no-constant-binary-expression': 'error', + // https://eslint.org/docs/rules/no-constant-condition + 'no-constant-condition': 'error', - // https://eslint.org/docs/rules/no-constant-condition - 'no-constant-condition': 'error', + // https://eslint.org/docs/rules/no-constructor-return + 'no-constructor-return': 'error', - // https://eslint.org/docs/rules/no-constructor-return - 'no-constructor-return': 'error', + // https://eslint.org/docs/rules/no-control-regex + 'no-control-regex': 'error', - // https://eslint.org/docs/rules/no-control-regex - 'no-control-regex': 'error', + // https://eslint.org/docs/rules/no-debugger + 'no-debugger': 'error', - // https://eslint.org/docs/rules/no-debugger - 'no-debugger': 'error', + // https://eslint.org/docs/rules/no-dupe-args + 'no-dupe-args': 'error', - // https://eslint.org/docs/rules/no-dupe-args - 'no-dupe-args': 'error', + // https://eslint.org/docs/rules/no-dupe-class-members + 'no-dupe-class-members': 'error', - // https://eslint.org/docs/rules/no-dupe-class-members - 'no-dupe-class-members': 'error', + // https://eslint.org/docs/rules/no-dupe-else-if + 'no-dupe-else-if': 'error', - // https://eslint.org/docs/rules/no-dupe-else-if - 'no-dupe-else-if': 'error', + // https://eslint.org/docs/rules/no-dupe-keys + 'no-dupe-keys': 'error', - // https://eslint.org/docs/rules/no-dupe-keys - 'no-dupe-keys': 'error', + // https://eslint.org/docs/rules/no-duplicate-case + 'no-duplicate-case': 'error', - // https://eslint.org/docs/rules/no-duplicate-case - 'no-duplicate-case': 'error', + // https://eslint.org/docs/rules/no-duplicate-imports + 'no-duplicate-imports': 'off', - // https://eslint.org/docs/rules/no-duplicate-imports - 'no-duplicate-imports': 'off', + // https://eslint.org/docs/rules/no-empty-character-class + 'no-empty-character-class': 'error', - // https://eslint.org/docs/rules/no-empty-character-class - 'no-empty-character-class': 'error', + // https://eslint.org/docs/rules/no-empty-pattern + 'no-empty-pattern': 'error', - // https://eslint.org/docs/rules/no-empty-pattern - 'no-empty-pattern': 'error', + /* + * https://eslint.org/docs/rules/no-ex-assign + * https://bocoup.com/blog/the-catch-with-try-catch + */ + 'no-ex-assign': 'error', - /* - * https://eslint.org/docs/rules/no-ex-assign - * https://bocoup.com/blog/the-catch-with-try-catch - */ - 'no-ex-assign': 'error', + // https://eslint.org/docs/rules/no-fallthrough + 'no-fallthrough': 'error', - // https://eslint.org/docs/rules/no-fallthrough - 'no-fallthrough': 'error', + // https://eslint.org/docs/rules/no-func-assign + 'no-func-assign': 'error', - // https://eslint.org/docs/rules/no-func-assign - 'no-func-assign': 'error', + // https://eslint.org/docs/rules/no-import-assign + 'no-import-assign': 'error', - // https://eslint.org/docs/rules/no-import-assign - 'no-import-assign': 'error', + // https://eslint.org/docs/rules/no-inner-declarations + 'no-inner-declarations': 'error', - // https://eslint.org/docs/rules/no-inner-declarations - 'no-inner-declarations': 'error', + // https://eslint.org/docs/rules/no-invalid-regexp + 'no-invalid-regexp': 'error', - // https://eslint.org/docs/rules/no-invalid-regexp - 'no-invalid-regexp': 'error', + // https://eslint.org/docs/rules/no-irregular-whitespace + 'no-irregular-whitespace': 'error', - // https://eslint.org/docs/rules/no-irregular-whitespace - 'no-irregular-whitespace': 'error', + // https://eslint.org/docs/rules/no-loss-of-precision + 'no-loss-of-precision': 'error', - // https://eslint.org/docs/rules/no-loss-of-precision - 'no-loss-of-precision': 'error', + // https://eslint.org/docs/rules/no-misleading-character-class + 'no-misleading-character-class': 'error', - // https://eslint.org/docs/rules/no-misleading-character-class - 'no-misleading-character-class': 'error', + // https://eslint.org/docs/latest/rules/no-new-native-nonconstructor + 'no-new-native-nonconstructor': 'error', - // https://eslint.org/docs/latest/rules/no-new-native-nonconstructor - 'no-new-native-nonconstructor': 'error', + // https://eslint.org/docs/rules/no-new-symbol + 'no-new-symbol': 'error', - // https://eslint.org/docs/rules/no-new-symbol - 'no-new-symbol': 'error', + // https://eslint.org/docs/rules/no-obj-calls + 'no-obj-calls': 'error', - // https://eslint.org/docs/rules/no-obj-calls - 'no-obj-calls': 'error', + // https://eslint.org/docs/rules/no-promise-executor-return + 'no-promise-executor-return': 'error', - // https://eslint.org/docs/rules/no-promise-executor-return - 'no-promise-executor-return': 'error', + // https://eslint.org/docs/rules/no-prototype-builtins + 'no-prototype-builtins': 'error', - // https://eslint.org/docs/rules/no-prototype-builtins - 'no-prototype-builtins': 'error', + // https://eslint.org/docs/rules/no-self-assign + 'no-self-assign': [ + 'error', + { + props: false, + }, + ], - // https://eslint.org/docs/rules/no-self-assign - 'no-self-assign': [ - 'error', - { - props: false, - }, - ], + // https://eslint.org/docs/rules/no-self-compare + 'no-self-compare': 'error', - // https://eslint.org/docs/rules/no-self-compare - 'no-self-compare': 'error', + // https://eslint.org/docs/rules/no-setter-return + 'no-setter-return': 'error', - // https://eslint.org/docs/rules/no-setter-return - 'no-setter-return': 'error', + /* + * https://eslint.org/docs/rules/no-sparse-arrays + * https://humanwhocodes.com/blog/2007/09/09/inconsistent-array-literals/ + */ + 'no-sparse-arrays': 'error', - /* - * https://eslint.org/docs/rules/no-sparse-arrays - * https://humanwhocodes.com/blog/2007/09/09/inconsistent-array-literals/ - */ - 'no-sparse-arrays': 'error', + // https://eslint.org/docs/rules/no-template-curly-in-string + 'no-template-curly-in-string': 'error', - // https://eslint.org/docs/rules/no-template-curly-in-string - 'no-template-curly-in-string': 'error', + // https://eslint.org/docs/rules/no-this-before-super + 'no-this-before-super': 'error', - // https://eslint.org/docs/rules/no-this-before-super - 'no-this-before-super': 'error', + // https://eslint.org/docs/rules/no-undef + 'no-undef': 'error', - // https://eslint.org/docs/rules/no-undef - 'no-undef': 'error', + // https://eslint.org/docs/rules/no-unexpected-multiline + 'no-unexpected-multiline': 'error', - // https://eslint.org/docs/rules/no-unexpected-multiline - 'no-unexpected-multiline': 'error', + // https://eslint.org/docs/rules/no-unmodified-loop-condition + 'no-unmodified-loop-condition': 'error', - // https://eslint.org/docs/rules/no-unmodified-loop-condition - 'no-unmodified-loop-condition': 'error', + // https://eslint.org/docs/rules/no-unreachable + 'no-unreachable': 'error', - // https://eslint.org/docs/rules/no-unreachable - 'no-unreachable': 'error', + // https://eslint.org/docs/rules/no-unreachable-loop + 'no-unreachable-loop': 'error', - // https://eslint.org/docs/rules/no-unreachable-loop - 'no-unreachable-loop': 'error', + // https://eslint.org/docs/rules/no-unsafe-finally + 'no-unsafe-finally': 'error', - // https://eslint.org/docs/rules/no-unsafe-finally - 'no-unsafe-finally': 'error', - - // https://eslint.org/docs/rules/no-unsafe-negation - 'no-unsafe-negation': 'error', - - // https://eslint.org/docs/rules/no-unsafe-optional-chaining - 'no-unsafe-optional-chaining': [ - 'error', - { - disallowArithmeticOperators: true, - }, - ], - - // https://eslint.org/docs/rules/no-unused-private-class-members - 'no-unused-private-class-members': 'error', - - // https://eslint.org/docs/rules/no-unused-vars - 'no-unused-vars': [ - 'error', - { - args: 'after-used', - argsIgnorePattern: '[iI]gnored', - caughtErrors: 'all', - caughtErrorsIgnorePattern: '[iI]gnored', - ignoreRestSiblings: false, - vars: 'all', - varsIgnorePattern: '[iI]gnored', - }, - ], - - // https://eslint.org/docs/rules/no-use-before-define - 'no-use-before-define': [ - 'error', - { - functions: true, - classes: true, - variables: true, - }, - ], - - // https://eslint.org/docs/rules/no-useless-backreference - 'no-useless-backreference': 'error', - - // https://eslint.org/docs/rules/require-atomic-updates - 'require-atomic-updates': 'error', - - // https://eslint.org/docs/rules/use-isnan - 'use-isnan': 'error', - - // https://eslint.org/docs/rules/valid-typeof - 'valid-typeof': [ - 'error', - { - requireStringLiterals: true, - }, - ], - }, + // https://eslint.org/docs/rules/no-unsafe-negation + 'no-unsafe-negation': 'error', + + // https://eslint.org/docs/rules/no-unsafe-optional-chaining + 'no-unsafe-optional-chaining': [ + 'error', + { + disallowArithmeticOperators: true, + }, + ], + + // https://eslint.org/docs/rules/no-unused-private-class-members + 'no-unused-private-class-members': 'error', + + // https://eslint.org/docs/rules/no-unused-vars + 'no-unused-vars': [ + 'error', + { + args: 'after-used', + argsIgnorePattern: '[iI]gnored', + caughtErrors: 'all', + caughtErrorsIgnorePattern: '[iI]gnored', + ignoreRestSiblings: false, + vars: 'all', + varsIgnorePattern: '[iI]gnored', + }, + ], + + // https://eslint.org/docs/rules/no-use-before-define + 'no-use-before-define': [ + 'error', + { + functions: true, + classes: true, + variables: true, + }, + ], + + // https://eslint.org/docs/rules/no-useless-backreference + 'no-useless-backreference': 'error', + + // https://eslint.org/docs/rules/require-atomic-updates + 'require-atomic-updates': 'error', + + // https://eslint.org/docs/rules/use-isnan + 'use-isnan': 'error', + + // https://eslint.org/docs/rules/valid-typeof + 'valid-typeof': [ + 'error', + { + requireStringLiterals: true, + }, + ], }; diff --git a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint/suggestions.js b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint/suggestions.js index 7ec348ff..ee71aa32 100644 --- a/eslint-configs/eslint-config-seekingalpha-base/rules/eslint/suggestions.js +++ b/eslint-configs/eslint-config-seekingalpha-base/rules/eslint/suggestions.js @@ -1,709 +1,705 @@ -const config = require('../config'); - -module.exports = { - // https://eslint.org/docs/rules/#suggestions - - rules: { - // https://eslint.org/docs/rules/accessor-pairs - 'accessor-pairs': [ - 'error', - { - setWithoutGet: true, - getWithoutSet: false, - enforceForClassMembers: true, - }, - ], - - // https://eslint.org/docs/rules/arrow-body-style - 'arrow-body-style': ['error', 'always'], - - // https://eslint.org/docs/rules/block-scoped-var - 'block-scoped-var': 'error', - - // https://eslint.org/docs/rules/camelcase - camelcase: [ - 'error', - { - properties: 'never', - ignoreDestructuring: false, - }, - ], - - // https://eslint.org/docs/rules/capitalized-comments - 'capitalized-comments': [ - 'off', - 'never', - { - line: { - ignorePattern: '.*', - ignoreInlineComments: true, - ignoreConsecutiveComments: true, - }, - block: { - ignorePattern: '.*', - ignoreInlineComments: true, - ignoreConsecutiveComments: true, - }, - }, - ], - - // https://eslint.org/docs/rules/class-methods-use-this - 'class-methods-use-this': 'error', - - // https://eslint.org/docs/rules/complexity - complexity: [ - 'error', - { - max: config.complexity, - }, - ], - - // https://eslint.org/docs/rules/consistent-return - 'consistent-return': 'error', - - // https://eslint.org/docs/rules/consistent-this - 'consistent-this': ['error', 'that'], - - // https://eslint.org/docs/rules/curly - curly: 'error', - - // https://eslint.org/docs/rules/default-case - 'default-case': [ - 'error', - { - commentPattern: String.raw`^skip\sdefault`, - }, - ], - - // https://eslint.org/docs/rules/default-case-last - 'default-case-last': 'error', - - // https://eslint.org/docs/rules/default-param-last - 'default-param-last': 'error', - - // https://eslint.org/docs/rules/dot-notation - 'dot-notation': [ - 'error', - { - allowKeywords: true, - }, - ], - - // https://eslint.org/docs/rules/eqeqeq - eqeqeq: ['error', 'always'], - - // https://eslint.org/docs/rules/func-name-matching - 'func-name-matching': [ - 'error', - 'always', - { - considerPropertyDescriptor: true, - includeCommonJSModuleExports: true, - }, - ], - - /* - * https://eslint.org/docs/rules/func-names - * TODO enable when needed? - */ - 'func-names': ['off', 'always'], - - // https://eslint.org/docs/rules/func-style - 'func-style': [ - 'error', - 'expression', - { - allowArrowFunctions: true, - }, - ], - - // https://eslint.org/docs/rules/grouped-accessor-pairs - 'grouped-accessor-pairs': ['error', 'getBeforeSet'], - - /* - * https://eslint.org/docs/rules/guard-for-in - * http://2ality.com/2012/01/objects-as-maps.html - */ - 'guard-for-in': 'error', - - // https://eslint.org/docs/rules/id-blacklist - 'id-denylist': 'off', - - // https://eslint.org/docs/rules/id-length - 'id-length': [ - 'error', - { - max: config.idLengthMax, - properties: 'always', - exceptions: [], - }, - ], - - // https://eslint.org/docs/rules/id-match - 'id-match': 'off', - - // https://eslint.org/docs/rules/init-declarations - 'init-declarations': ['off', 'always'], - - // https://eslint.org/docs/latest/rules/logical-assignment-operators - 'logical-assignment-operators': ['error', 'always'], - - // https://eslint.org/docs/rules/max-classes-per-file - 'max-classes-per-file': ['error', config.maxClassesPerFile], - - // https://eslint.org/docs/rules/max-depth - 'max-depth': ['error', config.maxDepth], - - // https://eslint.org/docs/rules/max-lines - 'max-lines': [ - 'off', - { - max: config.maxLinesMax, - skipBlankLines: true, - skipComments: true, - }, - ], - - // https://eslint.org/docs/rules/max-lines-per-function - 'max-lines-per-function': [ - 'error', - { - max: config.maxLinesPerFunctionMax, - skipBlankLines: true, - skipComments: true, - IIFEs: true, - }, - ], - - // https://eslint.org/docs/rules/max-nested-callbacks - 'max-nested-callbacks': ['error', config.maxNestedCallbacks], - - // https://eslint.org/docs/rules/max-params - 'max-params': ['error', config.maxParams], - - // https://eslint.org/docs/rules/max-statements - 'max-statements': ['error', config.maxStatements], - - // https://eslint.org/docs/rules/multiline-comment-style - 'multiline-comment-style': ['error', 'starred-block'], - - // https://eslint.org/docs/rules/new-cap - 'new-cap': [ - 'error', - { - newIsCap: true, // eslint-disable-line unicorn/no-keyword-prefix - newIsCapExceptions: [], // eslint-disable-line unicorn/no-keyword-prefix - capIsNew: false, - capIsNewExceptions: [], - properties: true, - }, - ], - - // https://eslint.org/docs/rules/no-alert - 'no-alert': 'error', - - // https://eslint.org/docs/rules/no-array-constructor - 'no-array-constructor': 'error', - - // https://eslint.org/docs/rules/no-bitwise - 'no-bitwise': 'error', - - // https://eslint.org/docs/rules/no-caller - 'no-caller': 'error', - - // https://eslint.org/docs/rules/no-case-declarations - 'no-case-declarations': 'error', - - // https://eslint.org/docs/rules/no-console - 'no-console': 'error', - - // https://eslint.org/docs/rules/no-continue - 'no-continue': 'error', - - // https://eslint.org/docs/rules/no-delete-var - 'no-delete-var': 'error', - - // https://eslint.org/docs/rules/no-div-regex - 'no-div-regex': 'error', - - // https://eslint.org/docs/rules/no-else-return - 'no-else-return': [ - 'error', - { - allowElseIf: false, - }, - ], - - // https://eslint.org/docs/rules/no-empty - 'no-empty': [ - 'error', - { - allowEmptyCatch: true, - }, - ], - - // https://eslint.org/docs/rules/no-empty-function - 'no-empty-function': 'error', - - // https://eslint.org/docs/rules/no-eq-null - 'no-eq-null': 'error', - - // https://eslint.org/docs/latest/rules/no-empty-static-block - 'no-empty-static-block': 'error', - - // https://eslint.org/docs/rules/no-eval - 'no-eval': 'error', - - // https://eslint.org/docs/rules/no-extend-native - 'no-extend-native': 'error', - - // https://eslint.org/docs/rules/no-extra-bind - 'no-extra-bind': 'error', - - // https://eslint.org/docs/rules/no-extra-boolean-cast - 'no-extra-boolean-cast': 'error', - - // https://eslint.org/docs/rules/no-extra-label - 'no-extra-label': 'error', - - // https://eslint.org/docs/rules/no-global-assign - 'no-global-assign': [ - 'error', - { - exceptions: [], - }, - ], - - // https://eslint.org/docs/rules/no-implicit-coercion - 'no-implicit-coercion': 'error', - - // https://eslint.org/docs/rules/no-implicit-globals - 'no-implicit-globals': 'error', - - // https://eslint.org/docs/rules/no-implied-eval - 'no-implied-eval': 'error', - - // https://eslint.org/docs/rules/no-inline-comments - 'no-inline-comments': 'off', - - // https://eslint.org/docs/rules/no-invalid-this - 'no-invalid-this': 'off', - - // https://eslint.org/docs/rules/no-iterator - 'no-iterator': 'error', - - // https://eslint.org/docs/rules/no-label-va - 'no-label-var': 'error', - - // https://eslint.org/docs/rules/no-labels - 'no-labels': 'error', - - // https://eslint.org/docs/rules/no-lone-blocks - 'no-lone-blocks': 'error', - - // https://eslint.org/docs/rules/no-lonely-if - 'no-lonely-if': 'error', - - // https://eslint.org/docs/rules/no-loop-func - 'no-loop-func': 'error', - - // https://eslint.org/docs/rules/no-magic-numbers - 'no-magic-numbers': [ - 'error', - { - // These numbers are used in simple cases, we can exclude them - ignore: [-1, 0, 1], - ignoreArrayIndexes: true, - enforceConst: true, - detectObjects: false, - }, - ], +import config from '../config.js'; + +// https://eslint.org/docs/rules/#suggestions +export default { + // https://eslint.org/docs/rules/accessor-pairs + 'accessor-pairs': [ + 'error', + { + setWithoutGet: true, + getWithoutSet: false, + enforceForClassMembers: true, + }, + ], + + // https://eslint.org/docs/rules/arrow-body-style + 'arrow-body-style': ['error', 'always'], + + // https://eslint.org/docs/rules/block-scoped-var + 'block-scoped-var': 'error', + + // https://eslint.org/docs/rules/camelcase + camelcase: [ + 'error', + { + properties: 'never', + ignoreDestructuring: false, + }, + ], + + // https://eslint.org/docs/rules/capitalized-comments + 'capitalized-comments': [ + 'off', + 'never', + { + line: { + ignorePattern: '.*', + ignoreInlineComments: true, + ignoreConsecutiveComments: true, + }, + block: { + ignorePattern: '.*', + ignoreInlineComments: true, + ignoreConsecutiveComments: true, + }, + }, + ], + + // https://eslint.org/docs/rules/class-methods-use-this + 'class-methods-use-this': 'error', + + // https://eslint.org/docs/rules/complexity + complexity: [ + 'error', + { + max: config.complexity, + }, + ], + + // https://eslint.org/docs/rules/consistent-return + 'consistent-return': 'error', + + // https://eslint.org/docs/rules/consistent-this + 'consistent-this': ['error', 'that'], + + // https://eslint.org/docs/rules/curly + curly: 'error', + + // https://eslint.org/docs/rules/default-case + 'default-case': [ + 'error', + { + commentPattern: String.raw`^skip\sdefault`, + }, + ], + + // https://eslint.org/docs/rules/default-case-last + 'default-case-last': 'error', + + // https://eslint.org/docs/rules/default-param-last + 'default-param-last': 'error', + + // https://eslint.org/docs/rules/dot-notation + 'dot-notation': [ + 'error', + { + allowKeywords: true, + }, + ], + + // https://eslint.org/docs/rules/eqeqeq + eqeqeq: ['error', 'always'], + + // https://eslint.org/docs/rules/func-name-matching + 'func-name-matching': [ + 'error', + 'always', + { + considerPropertyDescriptor: true, + includeCommonJSModuleExports: true, + }, + ], + + /* + * https://eslint.org/docs/rules/func-names + * TODO enable when needed? + */ + 'func-names': ['off', 'always'], + + // https://eslint.org/docs/rules/func-style + 'func-style': [ + 'error', + 'expression', + { + allowArrowFunctions: true, + }, + ], + + // https://eslint.org/docs/rules/grouped-accessor-pairs + 'grouped-accessor-pairs': ['error', 'getBeforeSet'], + + /* + * https://eslint.org/docs/rules/guard-for-in + * http://2ality.com/2012/01/objects-as-maps.html + */ + 'guard-for-in': 'error', + + // https://eslint.org/docs/rules/id-blacklist + 'id-denylist': 'off', + + // https://eslint.org/docs/rules/id-length + 'id-length': [ + 'error', + { + max: config.idLengthMax, + properties: 'always', + exceptions: [], + }, + ], + + // https://eslint.org/docs/rules/id-match + 'id-match': 'off', + + // https://eslint.org/docs/rules/init-declarations + 'init-declarations': ['off', 'always'], + + // https://eslint.org/docs/latest/rules/logical-assignment-operators + 'logical-assignment-operators': ['error', 'always'], + + // https://eslint.org/docs/rules/max-classes-per-file + 'max-classes-per-file': ['error', config.maxClassesPerFile], + + // https://eslint.org/docs/rules/max-depth + 'max-depth': ['error', config.maxDepth], + + // https://eslint.org/docs/rules/max-lines + 'max-lines': [ + 'off', + { + max: config.maxLinesMax, + skipBlankLines: true, + skipComments: true, + }, + ], + + // https://eslint.org/docs/rules/max-lines-per-function + 'max-lines-per-function': [ + 'error', + { + max: config.maxLinesPerFunctionMax, + skipBlankLines: true, + skipComments: true, + IIFEs: true, + }, + ], + + // https://eslint.org/docs/rules/max-nested-callbacks + 'max-nested-callbacks': ['error', config.maxNestedCallbacks], + + // https://eslint.org/docs/rules/max-params + 'max-params': ['error', config.maxParams], + + // https://eslint.org/docs/rules/max-statements + 'max-statements': ['error', config.maxStatements], + + // https://eslint.org/docs/rules/multiline-comment-style + 'multiline-comment-style': ['error', 'starred-block'], + + // https://eslint.org/docs/rules/new-cap + 'new-cap': [ + 'error', + { + newIsCap: true, // eslint-disable-line unicorn/no-keyword-prefix + newIsCapExceptions: [], // eslint-disable-line unicorn/no-keyword-prefix + capIsNew: false, + capIsNewExceptions: [], + properties: true, + }, + ], + + // https://eslint.org/docs/rules/no-alert + 'no-alert': 'error', + + // https://eslint.org/docs/rules/no-array-constructor + 'no-array-constructor': 'error', + + // https://eslint.org/docs/rules/no-bitwise + 'no-bitwise': 'error', + + // https://eslint.org/docs/rules/no-caller + 'no-caller': 'error', + + // https://eslint.org/docs/rules/no-case-declarations + 'no-case-declarations': 'error', + + // https://eslint.org/docs/rules/no-console + 'no-console': 'error', + + // https://eslint.org/docs/rules/no-continue + 'no-continue': 'error', + + // https://eslint.org/docs/rules/no-delete-var + 'no-delete-var': 'error', + + // https://eslint.org/docs/rules/no-div-regex + 'no-div-regex': 'error', + + // https://eslint.org/docs/rules/no-else-return + 'no-else-return': [ + 'error', + { + allowElseIf: false, + }, + ], - // https://eslint.org/docs/rules/no-multi-assign - 'no-multi-assign': 'error', + // https://eslint.org/docs/rules/no-empty + 'no-empty': [ + 'error', + { + allowEmptyCatch: true, + }, + ], - // https://eslint.org/docs/rules/no-multi-str - 'no-multi-str': 'error', + // https://eslint.org/docs/rules/no-empty-function + 'no-empty-function': 'error', - // https://eslint.org/docs/rules/no-negated-condition - 'no-negated-condition': 'error', + // https://eslint.org/docs/rules/no-eq-null + 'no-eq-null': 'error', - // https://eslint.org/docs/rules/no-nested-ternary - 'no-nested-ternary': 'error', + // https://eslint.org/docs/latest/rules/no-empty-static-block + 'no-empty-static-block': 'error', - // https://eslint.org/docs/rules/no-new - 'no-new': 'error', + // https://eslint.org/docs/rules/no-eval + 'no-eval': 'error', - // https://eslint.org/docs/rules/no-new-func - 'no-new-func': 'error', + // https://eslint.org/docs/rules/no-extend-native + 'no-extend-native': 'error', - // https://eslint.org/docs/rules/no-new-wrappers - 'no-new-wrappers': 'error', + // https://eslint.org/docs/rules/no-extra-bind + 'no-extra-bind': 'error', - // https://eslint.org/docs/rules/no-nonoctal-decimal-escape - 'no-nonoctal-decimal-escape': 'error', + // https://eslint.org/docs/rules/no-extra-boolean-cast + 'no-extra-boolean-cast': 'error', - // https://eslint.org/docs/latest/rules/no-object-constructor - 'no-object-constructor': 'error', + // https://eslint.org/docs/rules/no-extra-label + 'no-extra-label': 'error', - // https://eslint.org/docs/rules/no-octal - 'no-octal': 'error', + // https://eslint.org/docs/rules/no-global-assign + 'no-global-assign': [ + 'error', + { + exceptions: [], + }, + ], - // https://eslint.org/docs/rules/no-octal-escape - 'no-octal-escape': 'error', + // https://eslint.org/docs/rules/no-implicit-coercion + 'no-implicit-coercion': 'error', - // https://eslint.org/docs/rules/no-param-reassign - 'no-param-reassign': 'error', + // https://eslint.org/docs/rules/no-implicit-globals + 'no-implicit-globals': 'error', - // https://eslint.org/docs/rules/no-plusplus - 'no-plusplus': 'error', + // https://eslint.org/docs/rules/no-implied-eval + 'no-implied-eval': 'error', - // https://eslint.org/docs/rules/no-proto - 'no-proto': 'error', + // https://eslint.org/docs/rules/no-inline-comments + 'no-inline-comments': 'off', - // https://eslint.org/docs/rules/no-redeclare - 'no-redeclare': 'error', + // https://eslint.org/docs/rules/no-invalid-this + 'no-invalid-this': 'off', - // https://eslint.org/docs/rules/no-regex-spaces - 'no-regex-spaces': 'error', + // https://eslint.org/docs/rules/no-iterator + 'no-iterator': 'error', - // https://eslint.org/docs/rules/no-restricted-exports - 'no-restricted-exports': 'off', - - // https://eslint.org/docs/rules/no-restricted-globals - 'no-restricted-globals': [ - 'error', - { - name: 'event', - message: 'Use local parameter instead.', - }, - { - name: 'fdescribe', - message: 'Do not commit fdescribe. Use describe instead.', - }, - { - name: 'isFinite', - message: 'Use Number.isFinite instead.', - }, - { - name: 'isNaN', - message: 'Use Number.isNaN instead', - }, - ], - - // https://eslint.org/docs/rules/no-restricted-imports - 'no-restricted-imports': 'error', - - // https://eslint.org/docs/rules/no-restricted-properties - 'no-restricted-properties': [ - 'error', - { - object: 'arguments', - property: 'callee', - message: 'arguments.callee is deprecated', - }, - { - object: 'global', - property: 'isFinite', - message: 'Use Number.isFinite instead', - }, - { - object: 'window', - property: 'isFinite', - message: 'Use Number.isFinite instead', - }, - { - object: 'global', - property: 'isNaN', - message: 'Use Number.isNaN instead', - }, - { - object: 'window', - property: 'isNaN', - message: 'Use Number.isNaN instead', - }, - { - property: '__defineGetter__', - message: 'Use Object.defineProperty instead', - }, - { - property: '__defineSetter__', - message: 'Use Object.defineProperty instead', - }, - { - object: 'require', - message: 'Please call require() directly.', - }, - ], - - // https://eslint.org/docs/rules/no-restricted-syntax - 'no-restricted-syntax': [ - 'error', - { - selector: - 'CallExpression[callee.name="setTimeout"][arguments.length!=2]', - message: 'setTimeout must always be invoked with two arguments.', - }, - { - selector: 'ForInStatement', - message: 'Use Object.(keys || values) instead', - }, - { - selector: 'LabeledStatement', - message: - 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.', - }, - { - selector: 'WithStatement', - message: 'Do not use with DOT', - }, - ], - - // https://eslint.org/docs/rules/no-return-assign - 'no-return-assign': 'error', - - // https://eslint.org/docs/rules/no-script-url - 'no-script-url': 'error', - - // https://eslint.org/docs/rules/no-sequences - 'no-sequences': 'error', - - /* - * https://eslint.org/docs/rules/no-shadow - * https://en.wikipedia.org/wiki/Variable_shadowing - */ - 'no-shadow': [ - 'error', - { - builtinGlobals: true, - hoist: 'all', - allow: [], - }, - ], - - // https://eslint.org/docs/rules/no-shadow-restricted-names - 'no-shadow-restricted-names': 'error', - - // https://eslint.org/docs/rules/no-ternary - 'no-ternary': 'off', - - // https://eslint.org/docs/rules/no-throw-literal - 'no-throw-literal': 'error', - - // https://eslint.org/docs/rules/no-undef-init - 'no-undef-init': 'error', - - // https://eslint.org/docs/rules/no-undefined - 'no-undefined': 'error', - - // https://eslint.org/docs/rules/no-underscore-dangle - 'no-underscore-dangle': [ - 'error', - { - allow: [], - allowAfterThis: false, - allowAfterSuper: false, - enforceInMethodNames: false, - }, - ], - - // https://eslint.org/docs/rules/no-unneeded-ternary - 'no-unneeded-ternary': [ - 'error', - { - defaultAssignment: false, - }, - ], - - // https://eslint.org/docs/rules/no-unused-expressions - 'no-unused-expressions': [ - 'error', - { - allowShortCircuit: false, - allowTernary: false, - allowTaggedTemplates: false, - }, - ], - - // https://eslint.org/docs/rules/no-unused-labels - 'no-unused-labels': 'error', - - // https://eslint.org/docs/rules/no-useless-call - 'no-useless-call': 'error', - - // https://eslint.org/docs/rules/no-useless-catch - 'no-useless-catch': 'error', - - // https://eslint.org/docs/rules/no-useless-computed-key - 'no-useless-computed-key': 'error', - - // https://eslint.org/docs/rules/no-useless-concat - 'no-useless-concat': 'error', - - // https://eslint.org/docs/rules/no-useless-constructor - 'no-useless-constructor': 'error', - - // https://eslint.org/docs/rules/no-useless-escape - 'no-useless-escape': 'error', - - // https://eslint.org/docs/rules/no-useless-rename - 'no-useless-rename': [ - 'error', - { - ignoreDestructuring: false, - ignoreImport: false, - ignoreExport: false, - }, - ], - - // https://eslint.org/docs/rules/no-useless-return - 'no-useless-return': 'error', - - // https://eslint.org/docs/rules/no-var - 'no-var': 'error', - - // https://eslint.org/docs/rules/no-void - 'no-void': 'error', - - // https://eslint.org/docs/rules/no-warning-comments - 'no-warning-comments': 'off', - - // https://eslint.org/docs/rules/no-with - 'no-with': 'error', - - // https://eslint.org/docs/rules/object-shorthand - 'object-shorthand': [ - 'error', - 'always', - { - ignoreConstructors: false, - avoidQuotes: true, - }, - ], - - // https://eslint.org/docs/rules/one-var - 'one-var': ['error', 'never'], - - // https://eslint.org/docs/rules/operator-assignment - 'operator-assignment': ['error', 'never'], - - // https://eslint.org/docs/rules/prefer-arrow-callback - 'prefer-arrow-callback': [ - 'error', - { - allowNamedFunctions: false, - allowUnboundThis: true, - }, - ], - - // https://eslint.org/docs/rules/prefer-const - 'prefer-const': [ - 'error', - { - destructuring: 'any', - ignoreReadBeforeAssign: false, - }, - ], - - // https://eslint.org/docs/rules/prefer-destructuring - 'prefer-destructuring': [ - 'error', - { - VariableDeclarator: { - array: false, - object: true, - }, - AssignmentExpression: { - array: true, - object: true, - }, - }, - { - enforceForRenamedProperties: false, - }, - ], - - // https://eslint.org/docs/rules/prefer-exponentiation-operator - 'prefer-exponentiation-operator': 'error', - - /* - * https://eslint.org/docs/rules/prefer-named-capture-group - * supported only by ECMAScript 2018 - */ - 'prefer-named-capture-group': 'off', - - // https://eslint.org/docs/rules/prefer-numeric-literals - 'prefer-numeric-literals': 'error', - - // https://eslint.org/docs/rules/prefer-object-has-own - 'prefer-object-has-own': 'off', - - // https://eslint.org/docs/rules/prefer-object-spread - 'prefer-object-spread': 'error', - - // https://eslint.org/docs/rules/prefer-promise-reject-errors - 'prefer-promise-reject-errors': [ - 'error', - { - allowEmptyReject: true, - }, - ], - - // https://eslint.org/docs/rules/prefer-regex-literals - 'prefer-regex-literals': 'error', - - // https://eslint.org/docs/rules/prefer-rest-params - 'prefer-rest-params': 'error', - - // https://eslint.org/docs/rules/prefer-spread - 'prefer-spread': 'error', - - // https://eslint.org/docs/rules/prefer-template - 'prefer-template': 'error', - - // https://eslint.org/docs/rules/radix - radix: 'error', - - // https://eslint.org/docs/rules/require-await - 'require-await': 'error', - - // https://eslint.org/docs/rules/require-unicode-regexp - 'require-unicode-regexp': 'error', - - // https://eslint.org/docs/rules/require-yield - 'require-yield': 'error', - - // https://eslint.org/docs/rules/sort-imports - 'sort-imports': 'off', - - // https://eslint.org/docs/rules/sort-keys - 'sort-keys': [ - 'off', - 'asc', - { - caseSensitive: false, - natural: true, - }, - ], - - // https://eslint.org/docs/rules/sort-vars - 'sort-vars': [ - 'off', - { - ignoreCase: true, - }, - ], + // https://eslint.org/docs/rules/no-label-va + 'no-label-var': 'error', - // https://eslint.org/docs/rules/strict - strict: ['error', 'never'], + // https://eslint.org/docs/rules/no-labels + 'no-labels': 'error', - // https://eslint.org/docs/rules/symbol-description - 'symbol-description': 'error', + // https://eslint.org/docs/rules/no-lone-blocks + 'no-lone-blocks': 'error', - // https://eslint.org/docs/rules/vars-on-top - 'vars-on-top': 'error', + // https://eslint.org/docs/rules/no-lonely-if + 'no-lonely-if': 'error', - // https://eslint.org/docs/rules/yoda - yoda: 'error', - }, + // https://eslint.org/docs/rules/no-loop-func + 'no-loop-func': 'error', + + // https://eslint.org/docs/rules/no-magic-numbers + 'no-magic-numbers': [ + 'error', + { + // These numbers are used in simple cases, we can exclude them + ignore: [-1, 0, 1], + ignoreArrayIndexes: true, + enforceConst: true, + detectObjects: false, + }, + ], + + // https://eslint.org/docs/rules/no-multi-assign + 'no-multi-assign': 'error', + + // https://eslint.org/docs/rules/no-multi-str + 'no-multi-str': 'error', + + // https://eslint.org/docs/rules/no-negated-condition + 'no-negated-condition': 'error', + + // https://eslint.org/docs/rules/no-nested-ternary + 'no-nested-ternary': 'error', + + // https://eslint.org/docs/rules/no-new + 'no-new': 'error', + + // https://eslint.org/docs/rules/no-new-func + 'no-new-func': 'error', + + // https://eslint.org/docs/rules/no-new-wrappers + 'no-new-wrappers': 'error', + + // https://eslint.org/docs/rules/no-nonoctal-decimal-escape + 'no-nonoctal-decimal-escape': 'error', + + // https://eslint.org/docs/latest/rules/no-object-constructor + 'no-object-constructor': 'error', + + // https://eslint.org/docs/rules/no-octal + 'no-octal': 'error', + + // https://eslint.org/docs/rules/no-octal-escape + 'no-octal-escape': 'error', + + // https://eslint.org/docs/rules/no-param-reassign + 'no-param-reassign': 'error', + + // https://eslint.org/docs/rules/no-plusplus + 'no-plusplus': 'error', + + // https://eslint.org/docs/rules/no-proto + 'no-proto': 'error', + + // https://eslint.org/docs/rules/no-redeclare + 'no-redeclare': 'error', + + // https://eslint.org/docs/rules/no-regex-spaces + 'no-regex-spaces': 'error', + + // https://eslint.org/docs/rules/no-restricted-exports + 'no-restricted-exports': 'off', + + // https://eslint.org/docs/rules/no-restricted-globals + 'no-restricted-globals': [ + 'error', + { + name: 'event', + message: 'Use local parameter instead.', + }, + { + name: 'fdescribe', + message: 'Do not commit fdescribe. Use describe instead.', + }, + { + name: 'isFinite', + message: 'Use Number.isFinite instead.', + }, + { + name: 'isNaN', + message: 'Use Number.isNaN instead', + }, + ], + + // https://eslint.org/docs/rules/no-restricted-imports + 'no-restricted-imports': 'error', + + // https://eslint.org/docs/rules/no-restricted-properties + 'no-restricted-properties': [ + 'error', + { + object: 'arguments', + property: 'callee', + message: 'arguments.callee is deprecated', + }, + { + object: 'global', + property: 'isFinite', + message: 'Use Number.isFinite instead', + }, + { + object: 'window', + property: 'isFinite', + message: 'Use Number.isFinite instead', + }, + { + object: 'global', + property: 'isNaN', + message: 'Use Number.isNaN instead', + }, + { + object: 'window', + property: 'isNaN', + message: 'Use Number.isNaN instead', + }, + { + property: '__defineGetter__', + message: 'Use Object.defineProperty instead', + }, + { + property: '__defineSetter__', + message: 'Use Object.defineProperty instead', + }, + { + object: 'require', + message: 'Please call require() directly.', + }, + ], + + // https://eslint.org/docs/rules/no-restricted-syntax + 'no-restricted-syntax': [ + 'error', + { + selector: 'CallExpression[callee.name="setTimeout"][arguments.length!=2]', + message: 'setTimeout must always be invoked with two arguments.', + }, + { + selector: 'ForInStatement', + message: 'Use Object.(keys || values) instead', + }, + { + selector: 'LabeledStatement', + message: + 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.', + }, + { + selector: 'WithStatement', + message: 'Do not use with DOT', + }, + ], + + // https://eslint.org/docs/rules/no-return-assign + 'no-return-assign': 'error', + + // https://eslint.org/docs/rules/no-script-url + 'no-script-url': 'error', + + // https://eslint.org/docs/rules/no-sequences + 'no-sequences': 'error', + + /* + * https://eslint.org/docs/rules/no-shadow + * https://en.wikipedia.org/wiki/Variable_shadowing + */ + 'no-shadow': [ + 'error', + { + builtinGlobals: true, + hoist: 'all', + allow: [], + }, + ], + + // https://eslint.org/docs/rules/no-shadow-restricted-names + 'no-shadow-restricted-names': 'error', + + // https://eslint.org/docs/rules/no-ternary + 'no-ternary': 'off', + + // https://eslint.org/docs/rules/no-throw-literal + 'no-throw-literal': 'error', + + // https://eslint.org/docs/rules/no-undef-init + 'no-undef-init': 'error', + + // https://eslint.org/docs/rules/no-undefined + 'no-undefined': 'error', + + // https://eslint.org/docs/rules/no-underscore-dangle + 'no-underscore-dangle': [ + 'error', + { + allow: [], + allowAfterThis: false, + allowAfterSuper: false, + enforceInMethodNames: false, + }, + ], + + // https://eslint.org/docs/rules/no-unneeded-ternary + 'no-unneeded-ternary': [ + 'error', + { + defaultAssignment: false, + }, + ], + + // https://eslint.org/docs/rules/no-unused-expressions + 'no-unused-expressions': [ + 'error', + { + allowShortCircuit: false, + allowTernary: false, + allowTaggedTemplates: false, + }, + ], + + // https://eslint.org/docs/rules/no-unused-labels + 'no-unused-labels': 'error', + + // https://eslint.org/docs/rules/no-useless-call + 'no-useless-call': 'error', + + // https://eslint.org/docs/rules/no-useless-catch + 'no-useless-catch': 'error', + + // https://eslint.org/docs/rules/no-useless-computed-key + 'no-useless-computed-key': 'error', + + // https://eslint.org/docs/rules/no-useless-concat + 'no-useless-concat': 'error', + + // https://eslint.org/docs/rules/no-useless-constructor + 'no-useless-constructor': 'error', + + // https://eslint.org/docs/rules/no-useless-escape + 'no-useless-escape': 'error', + + // https://eslint.org/docs/rules/no-useless-rename + 'no-useless-rename': [ + 'error', + { + ignoreDestructuring: false, + ignoreImport: false, + ignoreExport: false, + }, + ], + + // https://eslint.org/docs/rules/no-useless-return + 'no-useless-return': 'error', + + // https://eslint.org/docs/rules/no-var + 'no-var': 'error', + + // https://eslint.org/docs/rules/no-void + 'no-void': 'error', + + // https://eslint.org/docs/rules/no-warning-comments + 'no-warning-comments': 'off', + + // https://eslint.org/docs/rules/no-with + 'no-with': 'error', + + // https://eslint.org/docs/rules/object-shorthand + 'object-shorthand': [ + 'error', + 'always', + { + ignoreConstructors: false, + avoidQuotes: true, + }, + ], + + // https://eslint.org/docs/rules/one-var + 'one-var': ['error', 'never'], + + // https://eslint.org/docs/rules/operator-assignment + 'operator-assignment': ['error', 'never'], + + // https://eslint.org/docs/rules/prefer-arrow-callback + 'prefer-arrow-callback': [ + 'error', + { + allowNamedFunctions: false, + allowUnboundThis: true, + }, + ], + + // https://eslint.org/docs/rules/prefer-const + 'prefer-const': [ + 'error', + { + destructuring: 'any', + ignoreReadBeforeAssign: false, + }, + ], + + // https://eslint.org/docs/rules/prefer-destructuring + 'prefer-destructuring': [ + 'error', + { + VariableDeclarator: { + array: false, + object: true, + }, + AssignmentExpression: { + array: true, + object: true, + }, + }, + { + enforceForRenamedProperties: false, + }, + ], + + // https://eslint.org/docs/rules/prefer-exponentiation-operator + 'prefer-exponentiation-operator': 'error', + + /* + * https://eslint.org/docs/rules/prefer-named-capture-group + * supported only by ECMAScript 2018 + */ + 'prefer-named-capture-group': 'off', + + // https://eslint.org/docs/rules/prefer-numeric-literals + 'prefer-numeric-literals': 'error', + + // https://eslint.org/docs/rules/prefer-object-has-own + 'prefer-object-has-own': 'off', + + // https://eslint.org/docs/rules/prefer-object-spread + 'prefer-object-spread': 'error', + + // https://eslint.org/docs/rules/prefer-promise-reject-errors + 'prefer-promise-reject-errors': [ + 'error', + { + allowEmptyReject: true, + }, + ], + + // https://eslint.org/docs/rules/prefer-regex-literals + 'prefer-regex-literals': 'error', + + // https://eslint.org/docs/rules/prefer-rest-params + 'prefer-rest-params': 'error', + + // https://eslint.org/docs/rules/prefer-spread + 'prefer-spread': 'error', + + // https://eslint.org/docs/rules/prefer-template + 'prefer-template': 'error', + + // https://eslint.org/docs/rules/radix + radix: 'error', + + // https://eslint.org/docs/rules/require-await + 'require-await': 'error', + + // https://eslint.org/docs/rules/require-unicode-regexp + 'require-unicode-regexp': 'error', + + // https://eslint.org/docs/rules/require-yield + 'require-yield': 'error', + + // https://eslint.org/docs/rules/sort-imports + 'sort-imports': 'off', + + // https://eslint.org/docs/rules/sort-keys + 'sort-keys': [ + 'off', + 'asc', + { + caseSensitive: false, + natural: true, + }, + ], + + // https://eslint.org/docs/rules/sort-vars + 'sort-vars': [ + 'off', + { + ignoreCase: true, + }, + ], + + // https://eslint.org/docs/rules/strict + strict: ['error', 'never'], + + // https://eslint.org/docs/rules/symbol-description + 'symbol-description': 'error', + + // https://eslint.org/docs/rules/vars-on-top + 'vars-on-top': 'error', + + // https://eslint.org/docs/rules/yoda + yoda: 'error', }; diff --git a/eslint-configs/eslint-config-seekingalpha-node/CHANGELOG.md b/eslint-configs/eslint-config-seekingalpha-node/CHANGELOG.md index 26d2abbc..87481a00 100644 --- a/eslint-configs/eslint-config-seekingalpha-node/CHANGELOG.md +++ b/eslint-configs/eslint-config-seekingalpha-node/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 8.0.0 - 2025-03-09 + +- [breaking] migrate to ESM and make flat config default + ## 7.0.0 - 2025-03-06 - [deps] update `eslint-plugin-n` to version `17.16.2` diff --git a/eslint-configs/eslint-config-seekingalpha-node/README.md b/eslint-configs/eslint-config-seekingalpha-node/README.md index a3bb290d..0cdf9057 100644 --- a/eslint-configs/eslint-config-seekingalpha-node/README.md +++ b/eslint-configs/eslint-config-seekingalpha-node/README.md @@ -10,7 +10,7 @@ Install ESLint and all [Peer Dependencies](https://nodejs.org/en/blog/npm/peer-d Install SeekingAlpha shareable ESLint: - npm install eslint-config-seekingalpha-node --save-dev + npm install eslint-config-seekingalpha-node@latest --save-dev ## Usage @@ -18,14 +18,21 @@ This shareable config includes all rules from following plugins: - [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n) -Simply [extend](https://eslint.org/docs/user-guide/configuring#extending-configuration-files) the relevant .eslintrc.js configuration in your project with `seekingalpha-node` rules: +Simply [use](https://eslint.org/docs/latest/extend/shareable-configs) the eslint.config.js in your project with the configuration: ```javascript -{ - extends: [ - 'seekingalpha-node' - ] -} +import nodeConfig from 'eslint-config-seekingalpha-node'; + +export default [ + { + plugins: { + ...nodeConfig.plugins, + }, + rules: { + ...nodeConfig.rules, + }, + }, +]; ``` ## License diff --git a/eslint-configs/eslint-config-seekingalpha-node/flat.js b/eslint-configs/eslint-config-seekingalpha-node/flat.js deleted file mode 100644 index c9e992ae..00000000 --- a/eslint-configs/eslint-config-seekingalpha-node/flat.js +++ /dev/null @@ -1,6 +0,0 @@ -import config from './rules/eslint-plugin-n/flat.js'; - -export default { - plugins: config.plugins, - rules: config.rules, -}; diff --git a/eslint-configs/eslint-config-seekingalpha-node/index.js b/eslint-configs/eslint-config-seekingalpha-node/index.js index b9e15fae..f2a51a55 100644 --- a/eslint-configs/eslint-config-seekingalpha-node/index.js +++ b/eslint-configs/eslint-config-seekingalpha-node/index.js @@ -1,15 +1,6 @@ -module.exports = { - extends: [ - // https://github.com/eslint-community/eslint-plugin-n - './rules/eslint-plugin-n/index.js', - ], +import config from './rules/eslint-plugin-n/index.js'; - parserOptions: { - ecmaVersion: 12, - sourceType: 'module', - ecmaFeatures: { - impliedStrict: true, - globalReturn: false, - }, - }, +export default { + plugins: config.plugins, + rules: config.rules, }; diff --git a/eslint-configs/eslint-config-seekingalpha-node/package.json b/eslint-configs/eslint-config-seekingalpha-node/package.json index a2a8ab55..55c3434f 100644 --- a/eslint-configs/eslint-config-seekingalpha-node/package.json +++ b/eslint-configs/eslint-config-seekingalpha-node/package.json @@ -1,8 +1,9 @@ { "name": "eslint-config-seekingalpha-node", - "version": "7.0.0", + "version": "8.0.0", "description": "SeekingAlpha's sharable node.js ESLint config", "main": "index.js", + "type": "module", "scripts": { "eslint-find-rules": "eslint-find-rules -u ./index.js", "test": "echo \"Error: no test specified\" && exit 1" diff --git a/eslint-configs/eslint-config-seekingalpha-node/rules/eslint-plugin-n/flat.js b/eslint-configs/eslint-config-seekingalpha-node/rules/eslint-plugin-n/flat.js deleted file mode 100644 index 8a646c31..00000000 --- a/eslint-configs/eslint-config-seekingalpha-node/rules/eslint-plugin-n/flat.js +++ /dev/null @@ -1,11 +0,0 @@ -import nodePlugin from 'eslint-plugin-n'; - -import config from './index.js'; - -export default { - plugins: { - // eslint-disable-next-line id-length - n: nodePlugin, - }, - rules: config.rules, -}; diff --git a/eslint-configs/eslint-config-seekingalpha-node/rules/eslint-plugin-n/index.js b/eslint-configs/eslint-config-seekingalpha-node/rules/eslint-plugin-n/index.js index ce1e6856..60658a3c 100644 --- a/eslint-configs/eslint-config-seekingalpha-node/rules/eslint-plugin-n/index.js +++ b/eslint-configs/eslint-config-seekingalpha-node/rules/eslint-plugin-n/index.js @@ -1,6 +1,10 @@ -module.exports = { - plugins: ['n'], +import nodePlugin from 'eslint-plugin-n'; +export default { + plugins: { + // eslint-disable-next-line id-length + n: nodePlugin, + }, rules: { // https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-extraneous-require.md 'n/no-extraneous-require': 'error', diff --git a/package.json b/package.json index 4de6b4bf..57cd5c4a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "seekingalpha-javascript-style", - "version": "6.2.0", + "version": "7.0.0", "description": "Set of linting rules, guides and best practices for best Javascript code", "main": "index.js", "type": "module",