diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 08518b0b..00000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -!.eslint.config.js diff --git a/eslint-configs/eslint-config-seekingalpha-react/CHANGELOG.md b/eslint-configs/eslint-config-seekingalpha-react/CHANGELOG.md index b50390df..95d0cf5a 100644 --- a/eslint-configs/eslint-config-seekingalpha-react/CHANGELOG.md +++ b/eslint-configs/eslint-config-seekingalpha-react/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 9.0.0 - 2025-03-09 + +- [breaking] migrate to ESM and make flat config default + ## 8.0.0 - 2025-03-07 - [new] expose flat config diff --git a/eslint-configs/eslint-config-seekingalpha-react/README.md b/eslint-configs/eslint-config-seekingalpha-react/README.md index 88b21a4b..578516d3 100644 --- a/eslint-configs/eslint-config-seekingalpha-react/README.md +++ b/eslint-configs/eslint-config-seekingalpha-react/README.md @@ -10,26 +10,31 @@ Install ESLint and all [Peer Dependencies](https://nodejs.org/en/blog/npm/peer-d Install SeekingAlpha shareable ESLint: - npm install eslint-config-seekingalpha-react --save-dev + npm install eslint-config-seekingalpha-react@latest --save-dev ## Usage -This shareable config includes all ESLint rules including ECMAScript 6 features, set of [legacy rules](https://eslint.org/docs/rules/#deprecated) and additional rules for `React` We also extend our configuration with following plugins: +This shareable config includes all rules from following plugins: - [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react) - [eslint-plugin-jsx-a11y](https://github.com/evcohen/eslint-plugin-jsx-a11y) - [eslint-plugin-react-hooks](https://www.npmjs.com/package/eslint-plugin-react-hooks) -If you don't need configuration extended with `React` rules, check out our [base config](https://www.npmjs.com/package/eslint-config-seekingalpha-base). - -Simply [extend](https://eslint.org/docs/user-guide/configuring#extending-configuration-files) the relevant .eslintrc.js configuration in your project with `seekingalpha-react` rules: +Simply [use](https://eslint.org/docs/latest/extend/shareable-configs) the eslint.config.js in your project with the configuration: ```javascript -{ - extends: [ - 'seekingalpha-react' - ] -} +import reactConfig from 'eslint-config-seekingalpha-react'; + +export default [ + { + plugins: { + ...reactConfig.plugins, + }, + rules: { + ...reactConfig.rules, + }, + }, +]; ``` ## License diff --git a/eslint-configs/eslint-config-seekingalpha-react/flat.js b/eslint-configs/eslint-config-seekingalpha-react/flat.js deleted file mode 100644 index 0d8c277e..00000000 --- a/eslint-configs/eslint-config-seekingalpha-react/flat.js +++ /dev/null @@ -1,16 +0,0 @@ -import jsxA11yConfig from './rules/eslint-plugin-jsx-a11y/flat.js'; -import reactConfig from './rules/eslint-plugin-react/flat.js'; -import reactHooksConfig from './rules/eslint-plugin-react-hooks/flat.js'; - -export default { - plugins: { - ...jsxA11yConfig.plugins, - ...reactConfig.plugins, - ...reactHooksConfig.plugins, - }, - rules: { - ...jsxA11yConfig.rules, - ...reactConfig.rules, - ...reactHooksConfig.rules, - }, -}; diff --git a/eslint-configs/eslint-config-seekingalpha-react/index.js b/eslint-configs/eslint-config-seekingalpha-react/index.js index 9e99da5a..8f1ea659 100644 --- a/eslint-configs/eslint-config-seekingalpha-react/index.js +++ b/eslint-configs/eslint-config-seekingalpha-react/index.js @@ -1,22 +1,16 @@ -module.exports = { - extends: [ - // https://github.com/yannickcr/eslint-plugin-react - './rules/eslint-plugin-react/index.js', +import jsxA11yConfig from './rules/eslint-plugin-jsx-a11y/index.js'; +import reactConfig from './rules/eslint-plugin-react/index.js'; +import reactHooksConfig from './rules/eslint-plugin-react-hooks/index.js'; - // https://github.com/evcohen/eslint-plugin-jsx-a11y - './rules/eslint-plugin-jsx-a11y/index.js', - - // https://reactjs.org/docs/hooks-rules.html - './rules/eslint-plugin-react-hooks/index.js', - ], - - parserOptions: { - ecmaVersion: 12, - sourceType: 'module', - ecmaFeatures: { - impliedStrict: true, - globalReturn: false, - jsx: true, - }, +export default { + plugins: { + ...jsxA11yConfig.plugins, + ...reactConfig.plugins, + ...reactHooksConfig.plugins, + }, + rules: { + ...jsxA11yConfig.rules, + ...reactConfig.rules, + ...reactHooksConfig.rules, }, }; diff --git a/eslint-configs/eslint-config-seekingalpha-react/package.json b/eslint-configs/eslint-config-seekingalpha-react/package.json index 942b3323..8bd8bf48 100644 --- a/eslint-configs/eslint-config-seekingalpha-react/package.json +++ b/eslint-configs/eslint-config-seekingalpha-react/package.json @@ -1,8 +1,9 @@ { "name": "eslint-config-seekingalpha-react", - "version": "8.0.0", + "version": "9.0.0", "description": "SeekingAlpha's sharable React.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-react/rules/config.js b/eslint-configs/eslint-config-seekingalpha-react/rules/config.js index a2e71f62..c50028ec 100644 --- a/eslint-configs/eslint-config-seekingalpha-react/rules/config.js +++ b/eslint-configs/eslint-config-seekingalpha-react/rules/config.js @@ -1,4 +1,4 @@ -module.exports = { +export default { jsxIndent: 2, jsxIndentProps: 2, jsxMaxDepth: 10, diff --git a/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-jsx-a11y/flat.js b/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-jsx-a11y/flat.js deleted file mode 100644 index 8d02c8b2..00000000 --- a/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-jsx-a11y/flat.js +++ /dev/null @@ -1,10 +0,0 @@ -import jsxA11y from 'eslint-plugin-jsx-a11y'; - -import config from './index.js'; - -export default { - plugins: { - 'jsx-a11y': jsxA11y, - }, - rules: config.rules, -}; diff --git a/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-jsx-a11y/index.js b/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-jsx-a11y/index.js index 5f150a05..87d62df7 100644 --- a/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-jsx-a11y/index.js +++ b/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-jsx-a11y/index.js @@ -1,8 +1,9 @@ -// - -module.exports = { - plugins: ['jsx-a11y'], +import jsxA11y from 'eslint-plugin-jsx-a11y'; +export default { + plugins: { + 'jsx-a11y': jsxA11y, + }, rules: { // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md 'jsx-a11y/alt-text': [ diff --git a/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react-hooks/flat.js b/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react-hooks/flat.js deleted file mode 100644 index 01886f06..00000000 --- a/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react-hooks/flat.js +++ /dev/null @@ -1,10 +0,0 @@ -import reactHooksPlugin from 'eslint-plugin-react-hooks'; - -import config from './index.js'; - -export default { - plugins: { - 'react-hooks': reactHooksPlugin, - }, - rules: config.rules, -}; diff --git a/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react-hooks/index.js b/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react-hooks/index.js index fbd80a49..b7582b09 100644 --- a/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react-hooks/index.js +++ b/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react-hooks/index.js @@ -1,6 +1,9 @@ -module.exports = { - plugins: ['react-hooks'], +import reactHooksPlugin from 'eslint-plugin-react-hooks'; +export default { + plugins: { + 'react-hooks': reactHooksPlugin, + }, rules: { // React Hooks Plugin https://www.npmjs.com/package/eslint-plugin-react-hooks diff --git a/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react/flat.js b/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react/flat.js deleted file mode 100644 index f73653de..00000000 --- a/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react/flat.js +++ /dev/null @@ -1,14 +0,0 @@ -import reactPlugin from 'eslint-plugin-react'; - -import jsxConfig from './jsx.js'; -import reactConfig from './react.js'; - -export default { - plugins: { - react: reactPlugin, - }, - rules: { - ...jsxConfig.rules, - ...reactConfig.rules, - }, -}; diff --git a/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react/index.js b/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react/index.js index 93d583e2..f73653de 100644 --- a/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react/index.js +++ b/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react/index.js @@ -1,5 +1,14 @@ -module.exports = { - plugins: ['react'], +import reactPlugin from 'eslint-plugin-react'; - extends: ['./react.js', './jsx.js'], +import jsxConfig from './jsx.js'; +import reactConfig from './react.js'; + +export default { + plugins: { + react: reactPlugin, + }, + rules: { + ...jsxConfig.rules, + ...reactConfig.rules, + }, }; diff --git a/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react/jsx.js b/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react/jsx.js index 26843683..cbc30e56 100644 --- a/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react/jsx.js +++ b/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react/jsx.js @@ -1,245 +1,242 @@ -const config = require('../config'); +import config from '../config'; // https://github.com/yannickcr/eslint-plugin-react#jsx-specific-rules - -module.exports = { - rules: { - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md - 'react/jsx-boolean-value': [ - 'error', - 'never', - { - always: [], - }, - ], - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-child-element-spacing.md - * Disabled to work with prettier - */ - 'react/jsx-child-element-spacing': 'off', - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md - * disable to work with prettier - */ - 'react/jsx-closing-bracket-location': 'off', - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md - * disable to work with prettier - */ - 'react/jsx-closing-tag-location': 'off', - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md - * disable to work with prettier - */ - 'react/jsx-curly-spacing': 'off', - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md - * disable to work with prettier - */ - 'react/jsx-equals-spacing': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md - 'react/jsx-filename-extension': [ - 'error', - { - extensions: ['.tsx'], - }, - ], - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md - * disable to work with prettier - */ - 'react/jsx-first-prop-new-line': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md - 'react/jsx-fragments': ['error', 'syntax'], - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md - 'react/jsx-handler-names': 'off', - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md - * disable to work with prettier - */ - 'react/jsx-indent': 'off', - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md - * disable ti work with prettier - */ - 'react/jsx-indent-props': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md - 'react/jsx-key': [ - 'error', - { - checkFragmentShorthand: true, - checkKeyMustBeforeSpread: true, - warnOnDuplicates: true, - }, - ], - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-depth.md - 'react/jsx-max-depth': [ - 'error', - { - max: config.jsxMaxDepth, - }, - ], - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md - * disable to work with prettier - */ - 'react/jsx-max-props-per-line': 'off', - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-newline.md - * disable to work with prettier - */ - 'react/jsx-newline': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md - 'react/jsx-no-bind': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md - 'react/jsx-no-comment-textnodes': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-constructed-context-values.md - 'react/jsx-no-constructed-context-values': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md - 'react/jsx-no-duplicate-props': [ - 'error', - { - ignoreCase: true, - }, - ], - - // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-leaked-render.md - 'react/jsx-no-leaked-render': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md - 'react/jsx-no-literals': [ - 'off', - { - noStrings: true, - }, - ], - - // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spread-multi.md - 'react/jsx-props-no-spread-multi': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md - 'react/jsx-no-target-blank': [ - 'error', - { - enforceDynamicLinks: 'always', - }, - ], - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md - 'react/jsx-no-undef': 'error', - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-one-expression-per-line.md - * disable to worl with prettier - */ - 'react/jsx-one-expression-per-line': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md - 'react/jsx-curly-brace-presence': [ - 'error', - { - props: 'never', - children: 'never', - }, - ], - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md - 'react/jsx-pascal-case': [ - 'error', - { - allowAllCaps: false, - ignore: [], - }, - ], - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-multi-spaces.md - * disable to work with prettier - */ - 'react/jsx-props-no-multi-spaces': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-default-props.md - 'react/sort-default-props': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md - 'react/jsx-sort-props': [ - 'error', - { - ignoreCase: true, - callbacksLast: true, - shorthandFirst: true, - shorthandLast: false, - noSortAlphabetically: false, - reservedFirst: false, - }, - ], - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md - * disable to work with prettier - */ - 'react/jsx-tag-spacing': 'off', - - /* - * off after update to 16.4 - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md - */ - 'react/jsx-uses-react': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md - 'react/jsx-uses-vars': 'error', - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md - * disable to work with prettier - */ - 'react/jsx-wrap-multilines': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger.md - 'react/no-danger': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md - 'react/jsx-props-no-spreading': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-read-only-props.md - 'react/prefer-read-only-props': 'error', - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md - * disable to work with prettier - */ - 'react/jsx-curly-newline': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md - 'react/jsx-no-useless-fragment': [ - 'error', - { - allowExpressions: true, - }, - ], - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-script-url.md - 'react/jsx-no-script-url': 'error', - - 'react/no-object-type-as-default-prop': 'error', - }, +export default { + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md + 'react/jsx-boolean-value': [ + 'error', + 'never', + { + always: [], + }, + ], + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-child-element-spacing.md + * Disabled to work with prettier + */ + 'react/jsx-child-element-spacing': 'off', + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md + * disable to work with prettier + */ + 'react/jsx-closing-bracket-location': 'off', + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md + * disable to work with prettier + */ + 'react/jsx-closing-tag-location': 'off', + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md + * disable to work with prettier + */ + 'react/jsx-curly-spacing': 'off', + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md + * disable to work with prettier + */ + 'react/jsx-equals-spacing': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md + 'react/jsx-filename-extension': [ + 'error', + { + extensions: ['.tsx'], + }, + ], + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md + * disable to work with prettier + */ + 'react/jsx-first-prop-new-line': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md + 'react/jsx-fragments': ['error', 'syntax'], + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md + 'react/jsx-handler-names': 'off', + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md + * disable to work with prettier + */ + 'react/jsx-indent': 'off', + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md + * disable ti work with prettier + */ + 'react/jsx-indent-props': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md + 'react/jsx-key': [ + 'error', + { + checkFragmentShorthand: true, + checkKeyMustBeforeSpread: true, + warnOnDuplicates: true, + }, + ], + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-depth.md + 'react/jsx-max-depth': [ + 'error', + { + max: config.jsxMaxDepth, + }, + ], + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md + * disable to work with prettier + */ + 'react/jsx-max-props-per-line': 'off', + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-newline.md + * disable to work with prettier + */ + 'react/jsx-newline': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md + 'react/jsx-no-bind': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md + 'react/jsx-no-comment-textnodes': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-constructed-context-values.md + 'react/jsx-no-constructed-context-values': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md + 'react/jsx-no-duplicate-props': [ + 'error', + { + ignoreCase: true, + }, + ], + + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-leaked-render.md + 'react/jsx-no-leaked-render': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md + 'react/jsx-no-literals': [ + 'off', + { + noStrings: true, + }, + ], + + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spread-multi.md + 'react/jsx-props-no-spread-multi': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md + 'react/jsx-no-target-blank': [ + 'error', + { + enforceDynamicLinks: 'always', + }, + ], + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md + 'react/jsx-no-undef': 'error', + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-one-expression-per-line.md + * disable to worl with prettier + */ + 'react/jsx-one-expression-per-line': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md + 'react/jsx-curly-brace-presence': [ + 'error', + { + props: 'never', + children: 'never', + }, + ], + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md + 'react/jsx-pascal-case': [ + 'error', + { + allowAllCaps: false, + ignore: [], + }, + ], + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-multi-spaces.md + * disable to work with prettier + */ + 'react/jsx-props-no-multi-spaces': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-default-props.md + 'react/sort-default-props': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md + 'react/jsx-sort-props': [ + 'error', + { + ignoreCase: true, + callbacksLast: true, + shorthandFirst: true, + shorthandLast: false, + noSortAlphabetically: false, + reservedFirst: false, + }, + ], + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md + * disable to work with prettier + */ + 'react/jsx-tag-spacing': 'off', + + /* + * off after update to 16.4 + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md + */ + 'react/jsx-uses-react': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md + 'react/jsx-uses-vars': 'error', + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md + * disable to work with prettier + */ + 'react/jsx-wrap-multilines': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger.md + 'react/no-danger': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md + 'react/jsx-props-no-spreading': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-read-only-props.md + 'react/prefer-read-only-props': 'error', + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md + * disable to work with prettier + */ + 'react/jsx-curly-newline': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md + 'react/jsx-no-useless-fragment': [ + 'error', + { + allowExpressions: true, + }, + ], + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-script-url.md + 'react/jsx-no-script-url': 'error', + + 'react/no-object-type-as-default-prop': 'error', }; diff --git a/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react/react.js b/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react/react.js index ffe4bf72..91f44c9c 100644 --- a/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react/react.js +++ b/eslint-configs/eslint-config-seekingalpha-react/rules/eslint-plugin-react/react.js @@ -1,368 +1,366 @@ // https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules -module.exports = { - rules: { - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/boolean-prop-naming.md - 'react/boolean-prop-naming': [ - 'error', - { - propTypeNames: ['bool', 'mutuallyExclusiveTrueProps'], - rule: '^(is|has|should)[A-Z]([A-Za-z0-9]?)+', - message: - 'It is better if your prop ({{ propName }}) matches this pattern: ({{ pattern }})', - }, - ], - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/button-has-type.md - 'react/button-has-type': [ - 'error', - { - button: true, - submit: true, - reset: true, - }, - ], - - // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/checked-requires-onchange-or-readonly.md - 'react/checked-requires-onchange-or-readonly': 'error', - - /* - * no prop types usage - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/default-props-match-prop-types.md - */ - 'react/default-props-match-prop-types': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md - 'react/destructuring-assignment': ['error', 'always'], - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md - 'react/display-name': [ - 'off', - { - ignoreTranspilerName: false, - }, - ], - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-component-props.md - * https://brigade.engineering/don-t-pass-css-classes-between-components-e9f7ab192785 - */ - 'react/forbid-component-props': [ - 'error', - { - forbid: [ - 'style', - { - propName: 'className', - allowedFor: ['Button', 'Icon', 'Link'], - }, - ], - }, - ], - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-dom-props.md - * https://www.w3.org/TR/html5-diff/#obsolete-attributes - */ - 'react/forbid-dom-props': [ - 'error', - { - forbid: [ - 'abbr', - 'align', - 'axis', - 'bgcolor', - 'border', - 'cellpadding', - 'cellspacing', - 'char', - 'charoff', - 'charset', - 'clear', - 'coords', - 'frame', - 'frameborder', - 'hspace', - 'longdesc', - 'marginheight', - 'marginwidth', - 'rev', - 'scope', - 'scrolling', - 'shape', - 'size', - 'valign', - 'vspace', - ], - }, - ], - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-elements.md - * https://www.w3.org/TR/html5-diff/#obsolete-elements - */ - 'react/forbid-elements': [ - 'error', - { - forbid: [ - 'acronym', - 'applet', - 'basefont', - 'big', - 'center', - 'dir', - 'font', - 'frame', - 'frameset', - 'noframes', - 'isindex', - 'noframes', - 's', - 'strike', - 'tt', - 'u', - ], - }, - ], - - /* - * no prop types usage - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md - */ - 'react/forbid-foreign-prop-types': 'off', - - /* - * no prop types usage - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md - */ - 'react/forbid-prop-types': 'off', - - 'react/forward-ref-uses-ref': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md - 'react/function-component-definition': [ - 'error', - { - namedComponents: 'arrow-function', - unnamedComponents: 'arrow-function', - }, - ], - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/hook-use-state.md - 'react/hook-use-state': [ - 'error', - { - allowDestructuredState: true, - }, - ], - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/iframe-missing-sandbox.md - 'react/iframe-missing-sandbox': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-access-state-in-setstate.md - 'react/no-access-state-in-setstate': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-adjacent-inline-elements.md - 'react/no-adjacent-inline-elements': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md - 'react/no-array-index-key': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-arrow-function-lifecycle.md - 'react/no-arrow-function-lifecycle': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md - 'react/no-children-prop': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md - 'react/no-danger-with-children': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md - 'react/no-deprecated': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md - 'react/no-did-mount-set-state': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md - 'react/no-did-update-set-state': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md - 'react/no-direct-mutation-state': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md - 'react/no-find-dom-node': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-invalid-html-attribute.md - 'react/no-invalid-html-attribute': 'error', - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md - * https://reactjs.org/blog/2015/12/16/ismounted-antipattern.html - */ - 'react/no-is-mounted': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md - 'react/no-multi-comp': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-namespace.md - 'react/no-namespace': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-redundant-should-component-update.md - 'react/no-redundant-should-component-update': 'error', - - /* - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md - * using this return value is legacy and should be avoided because future versions of React may render - * components asynchronously in some cases. - */ - 'react/no-render-return-value': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-set-state.md - 'react/no-set-state': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-typos.md - 'react/no-typos': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md - 'react/no-string-refs': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-this-in-sfc.md - 'react/no-this-in-sfc': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md - 'react/no-unescaped-entities': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md - 'react/no-unknown-property': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unsafe.md - 'react/no-unsafe': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unstable-nested-components.md - 'react/no-unstable-nested-components': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-class-component-methods.md - 'react/no-unused-class-component-methods': 'error', - - /* - * no prop types usage - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md - */ - 'react/no-unused-prop-types': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-state.md - 'react/no-unused-state': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-will-update-set-state.md - 'react/no-will-update-set-state': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md - 'react/prefer-es6-class': ['error', 'always'], - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-exact-props.md - 'react/prefer-exact-props': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md - 'react/prefer-stateless-function': [ - 'error', - { - ignorePureComponents: true, - }, - ], - - /* - * no prop types usage - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md - */ - 'react/prop-types': 'off', - - /* - * off after update to 16.4 - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md - */ - 'react/react-in-jsx-scope': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-default-props.md - 'react/require-default-props': 'off', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-optimization.md - 'react/require-optimization': [ - 'error', - { - allowDecorators: ['pureComponentDecorator'], - }, - ], - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-render-return.md - 'react/require-render-return': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md - 'react/self-closing-comp': 'error', - - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md - 'react/sort-comp': [ - 'error', - { - order: [ - 'static-methods', - 'lifecycle', - '/^on.+$/', - 'getters', - 'setters', - 'instance-methods', - 'everything-else', - 'rendering', - ], - groups: { - lifecycle: [ - 'displayName', - 'propTypes', - 'contextTypes', - 'childContextTypes', - 'mixins', - 'statics', - 'defaultProps', - 'instance-variables', - 'constructor', - 'getDefaultProps', - 'state', - 'getInitialState', - 'getChildContext', - 'getDerivedStateFromProps', - 'componentWillMount', - 'UNSAFE_componentWillMount', - 'componentDidMount', - 'componentWillReceiveProps', - 'UNSAFE_componentWillReceiveProps', - 'shouldComponentUpdate', - 'componentWillUpdate', - 'UNSAFE_componentWillUpdate', - 'getSnapshotBeforeUpdate', - 'componentDidUpdate', - 'componentDidCatch', - 'componentWillUnmount', - ], - rendering: ['/^render.+$/', 'render'], +export default { + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/boolean-prop-naming.md + 'react/boolean-prop-naming': [ + 'error', + { + propTypeNames: ['bool', 'mutuallyExclusiveTrueProps'], + rule: '^(is|has|should)[A-Z]([A-Za-z0-9]?)+', + message: + 'It is better if your prop ({{ propName }}) matches this pattern: ({{ pattern }})', + }, + ], + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/button-has-type.md + 'react/button-has-type': [ + 'error', + { + button: true, + submit: true, + reset: true, + }, + ], + + // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/checked-requires-onchange-or-readonly.md + 'react/checked-requires-onchange-or-readonly': 'error', + + /* + * no prop types usage + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/default-props-match-prop-types.md + */ + 'react/default-props-match-prop-types': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md + 'react/destructuring-assignment': ['error', 'always'], + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md + 'react/display-name': [ + 'off', + { + ignoreTranspilerName: false, + }, + ], + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-component-props.md + * https://brigade.engineering/don-t-pass-css-classes-between-components-e9f7ab192785 + */ + 'react/forbid-component-props': [ + 'error', + { + forbid: [ + 'style', + { + propName: 'className', + allowedFor: ['Button', 'Icon', 'Link'], }, + ], + }, + ], + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-dom-props.md + * https://www.w3.org/TR/html5-diff/#obsolete-attributes + */ + 'react/forbid-dom-props': [ + 'error', + { + forbid: [ + 'abbr', + 'align', + 'axis', + 'bgcolor', + 'border', + 'cellpadding', + 'cellspacing', + 'char', + 'charoff', + 'charset', + 'clear', + 'coords', + 'frame', + 'frameborder', + 'hspace', + 'longdesc', + 'marginheight', + 'marginwidth', + 'rev', + 'scope', + 'scrolling', + 'shape', + 'size', + 'valign', + 'vspace', + ], + }, + ], + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-elements.md + * https://www.w3.org/TR/html5-diff/#obsolete-elements + */ + 'react/forbid-elements': [ + 'error', + { + forbid: [ + 'acronym', + 'applet', + 'basefont', + 'big', + 'center', + 'dir', + 'font', + 'frame', + 'frameset', + 'noframes', + 'isindex', + 'noframes', + 's', + 'strike', + 'tt', + 'u', + ], + }, + ], + + /* + * no prop types usage + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md + */ + 'react/forbid-foreign-prop-types': 'off', + + /* + * no prop types usage + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md + */ + 'react/forbid-prop-types': 'off', + + 'react/forward-ref-uses-ref': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md + 'react/function-component-definition': [ + 'error', + { + namedComponents: 'arrow-function', + unnamedComponents: 'arrow-function', + }, + ], + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/hook-use-state.md + 'react/hook-use-state': [ + 'error', + { + allowDestructuredState: true, + }, + ], + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/iframe-missing-sandbox.md + 'react/iframe-missing-sandbox': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-access-state-in-setstate.md + 'react/no-access-state-in-setstate': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-adjacent-inline-elements.md + 'react/no-adjacent-inline-elements': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md + 'react/no-array-index-key': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-arrow-function-lifecycle.md + 'react/no-arrow-function-lifecycle': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md + 'react/no-children-prop': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md + 'react/no-danger-with-children': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md + 'react/no-deprecated': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md + 'react/no-did-mount-set-state': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md + 'react/no-did-update-set-state': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md + 'react/no-direct-mutation-state': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md + 'react/no-find-dom-node': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-invalid-html-attribute.md + 'react/no-invalid-html-attribute': 'error', + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md + * https://reactjs.org/blog/2015/12/16/ismounted-antipattern.html + */ + 'react/no-is-mounted': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md + 'react/no-multi-comp': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-namespace.md + 'react/no-namespace': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-redundant-should-component-update.md + 'react/no-redundant-should-component-update': 'error', + + /* + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md + * using this return value is legacy and should be avoided because future versions of React may render + * components asynchronously in some cases. + */ + 'react/no-render-return-value': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-set-state.md + 'react/no-set-state': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-typos.md + 'react/no-typos': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md + 'react/no-string-refs': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-this-in-sfc.md + 'react/no-this-in-sfc': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md + 'react/no-unescaped-entities': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md + 'react/no-unknown-property': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unsafe.md + 'react/no-unsafe': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unstable-nested-components.md + 'react/no-unstable-nested-components': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-class-component-methods.md + 'react/no-unused-class-component-methods': 'error', + + /* + * no prop types usage + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md + */ + 'react/no-unused-prop-types': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-state.md + 'react/no-unused-state': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-will-update-set-state.md + 'react/no-will-update-set-state': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md + 'react/prefer-es6-class': ['error', 'always'], + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-exact-props.md + 'react/prefer-exact-props': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md + 'react/prefer-stateless-function': [ + 'error', + { + ignorePureComponents: true, + }, + ], + + /* + * no prop types usage + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md + */ + 'react/prop-types': 'off', + + /* + * off after update to 16.4 + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md + */ + 'react/react-in-jsx-scope': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-default-props.md + 'react/require-default-props': 'off', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-optimization.md + 'react/require-optimization': [ + 'error', + { + allowDecorators: ['pureComponentDecorator'], + }, + ], + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-render-return.md + 'react/require-render-return': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md + 'react/self-closing-comp': 'error', + + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md + 'react/sort-comp': [ + 'error', + { + order: [ + 'static-methods', + 'lifecycle', + '/^on.+$/', + 'getters', + 'setters', + 'instance-methods', + 'everything-else', + 'rendering', + ], + groups: { + lifecycle: [ + 'displayName', + 'propTypes', + 'contextTypes', + 'childContextTypes', + 'mixins', + 'statics', + 'defaultProps', + 'instance-variables', + 'constructor', + 'getDefaultProps', + 'state', + 'getInitialState', + 'getChildContext', + 'getDerivedStateFromProps', + 'componentWillMount', + 'UNSAFE_componentWillMount', + 'componentDidMount', + 'componentWillReceiveProps', + 'UNSAFE_componentWillReceiveProps', + 'shouldComponentUpdate', + 'componentWillUpdate', + 'UNSAFE_componentWillUpdate', + 'getSnapshotBeforeUpdate', + 'componentDidUpdate', + 'componentDidCatch', + 'componentWillUnmount', + ], + rendering: ['/^render.+$/', 'render'], }, - ], + }, + ], - /* - * no prop types usage - * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md - */ - 'react/sort-prop-types': 'off', + /* + * no prop types usage + * https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md + */ + 'react/sort-prop-types': 'off', - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md - 'react/style-prop-object': 'error', + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md + 'react/style-prop-object': 'error', - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md - 'react/void-dom-elements-no-children': 'error', + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md + 'react/void-dom-elements-no-children': 'error', - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md - 'react/state-in-constructor': ['error', 'always'], + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md + 'react/state-in-constructor': ['error', 'always'], - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md - 'react/static-property-placement': ['error', 'static public field'], - }, + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md + 'react/static-property-placement': ['error', 'static public field'], }; diff --git a/eslint-configs/eslint-config-seekingalpha-tests/CHANGELOG.md b/eslint-configs/eslint-config-seekingalpha-tests/CHANGELOG.md index f891a75a..f90f1bdc 100644 --- a/eslint-configs/eslint-config-seekingalpha-tests/CHANGELOG.md +++ b/eslint-configs/eslint-config-seekingalpha-tests/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 3.0.0 - 2025-03-09 + +- [breaking] migrate to ESM and make flat config default + ## 2.0.0 - 2025-03-06 - [new] expose flat config diff --git a/eslint-configs/eslint-config-seekingalpha-tests/README.md b/eslint-configs/eslint-config-seekingalpha-tests/README.md index dd4e4f6b..3f67a945 100644 --- a/eslint-configs/eslint-config-seekingalpha-tests/README.md +++ b/eslint-configs/eslint-config-seekingalpha-tests/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-tests --save-dev + npm install eslint-config-seekingalpha-tests@latest --save-dev ## Usage @@ -19,14 +19,21 @@ This configuration extended with following plugins: - [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) - [eslint-plugin-testing-library](https://github.com/testing-library/eslint-plugin-testing-library) -Simply [extend](https://eslint.org/docs/user-guide/configuring#extending-configuration-files) the relevant .eslintrc.js configuration in your project with `seekingalpha-tests` rules: +Simply [use](https://eslint.org/docs/latest/extend/shareable-configs) the eslint.config.js in your project with the configuration: ```javascript -{ - extends: [ - 'seekingalpha-tests' - ] -} +import testsConfig from 'eslint-config-seekingalpha-tests'; + +export default [ + { + plugins: { + ...testsConfig.plugins, + }, + rules: { + ...testsConfig.rules, + }, + }, +]; ``` ## License diff --git a/eslint-configs/eslint-config-seekingalpha-tests/flat.js b/eslint-configs/eslint-config-seekingalpha-tests/flat.js deleted file mode 100644 index 5df0a14a..00000000 --- a/eslint-configs/eslint-config-seekingalpha-tests/flat.js +++ /dev/null @@ -1,13 +0,0 @@ -import esLintPluginJestConfig from './rules/eslint-plugin-jest/flat.js'; -import esLintPluginTestingLibraryConfig from './rules/eslint-plugin-testing-library/flat.js'; - -export default { - plugins: { - ...esLintPluginJestConfig.plugins, - ...esLintPluginTestingLibraryConfig.plugins, - }, - rules: { - ...esLintPluginJestConfig.rules, - ...esLintPluginTestingLibraryConfig.rules, - }, -}; diff --git a/eslint-configs/eslint-config-seekingalpha-tests/index.js b/eslint-configs/eslint-config-seekingalpha-tests/index.js index 35dbb640..7884a386 100644 --- a/eslint-configs/eslint-config-seekingalpha-tests/index.js +++ b/eslint-configs/eslint-config-seekingalpha-tests/index.js @@ -1,18 +1,13 @@ -module.exports = { - extends: [ - // https://github.com/jest-community/eslint-plugin-jest - './rules/eslint-plugin-jest/index.js', +import esLintPluginJestConfig from './rules/eslint-plugin-jest/index.js'; +import esLintPluginTestingLibraryConfig from './rules/eslint-plugin-testing-library/index.js'; - // https://github.com/jest-community/eslint-plugin-jest - './rules/eslint-plugin-testing-library/index.js', - ], - - parserOptions: { - ecmaVersion: 12, - sourceType: 'module', - ecmaFeatures: { - impliedStrict: true, - globalReturn: false, - }, +export default { + plugins: { + ...esLintPluginJestConfig.plugins, + ...esLintPluginTestingLibraryConfig.plugins, + }, + rules: { + ...esLintPluginJestConfig.rules, + ...esLintPluginTestingLibraryConfig.rules, }, }; diff --git a/eslint-configs/eslint-config-seekingalpha-tests/package.json b/eslint-configs/eslint-config-seekingalpha-tests/package.json index 1e981a3b..0d6b1cb2 100644 --- a/eslint-configs/eslint-config-seekingalpha-tests/package.json +++ b/eslint-configs/eslint-config-seekingalpha-tests/package.json @@ -1,8 +1,9 @@ { "name": "eslint-config-seekingalpha-tests", - "version": "2.0.0", + "version": "3.0.0", "description": "SeekingAlpha's sharable testing 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-tests/rules/eslint-plugin-jest/flat.js b/eslint-configs/eslint-config-seekingalpha-tests/rules/eslint-plugin-jest/flat.js deleted file mode 100644 index cbeb8fc7..00000000 --- a/eslint-configs/eslint-config-seekingalpha-tests/rules/eslint-plugin-jest/flat.js +++ /dev/null @@ -1,11 +0,0 @@ -import pluginJest from 'eslint-plugin-jest'; - -import config from './index.js'; - -export default { - plugins: { - jest: pluginJest, - }, - - rules: config.rules, -}; diff --git a/eslint-configs/eslint-config-seekingalpha-tests/rules/eslint-plugin-jest/index.js b/eslint-configs/eslint-config-seekingalpha-tests/rules/eslint-plugin-jest/index.js index e6198e85..becd14a2 100644 --- a/eslint-configs/eslint-config-seekingalpha-tests/rules/eslint-plugin-jest/index.js +++ b/eslint-configs/eslint-config-seekingalpha-tests/rules/eslint-plugin-jest/index.js @@ -1,5 +1,9 @@ -module.exports = { - plugins: ['jest'], +import pluginJest from 'eslint-plugin-jest'; + +export default { + plugins: { + jest: pluginJest, + }, rules: { // Jest Plugin https://github.com/jest-community/eslint-plugin-jest diff --git a/eslint-configs/eslint-config-seekingalpha-tests/rules/eslint-plugin-testing-library/flat.js b/eslint-configs/eslint-config-seekingalpha-tests/rules/eslint-plugin-testing-library/flat.js deleted file mode 100644 index 0b77e098..00000000 --- a/eslint-configs/eslint-config-seekingalpha-tests/rules/eslint-plugin-testing-library/flat.js +++ /dev/null @@ -1,11 +0,0 @@ -import pluginTestingLibrary from 'eslint-plugin-testing-library'; - -import config from './index.js'; - -export default { - plugins: { - 'testing-library': pluginTestingLibrary, - }, - - rules: config.rules, -}; diff --git a/eslint-configs/eslint-config-seekingalpha-tests/rules/eslint-plugin-testing-library/index.js b/eslint-configs/eslint-config-seekingalpha-tests/rules/eslint-plugin-testing-library/index.js index 01b93f75..28d96fbc 100644 --- a/eslint-configs/eslint-config-seekingalpha-tests/rules/eslint-plugin-testing-library/index.js +++ b/eslint-configs/eslint-config-seekingalpha-tests/rules/eslint-plugin-testing-library/index.js @@ -1,5 +1,9 @@ -module.exports = { - plugins: ['testing-library'], +import pluginTestingLibrary from 'eslint-plugin-testing-library'; + +export default { + plugins: { + 'testing-library': pluginTestingLibrary, + }, rules: { // Testing Library Plugin https://github.com/testing-library/eslint-plugin-testing-library diff --git a/eslint-configs/eslint-config-seekingalpha-typescript/CHANGELOG.md b/eslint-configs/eslint-config-seekingalpha-typescript/CHANGELOG.md index b2e181e7..3ef6a04b 100644 --- a/eslint-configs/eslint-config-seekingalpha-typescript/CHANGELOG.md +++ b/eslint-configs/eslint-config-seekingalpha-typescript/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 7.0.0 - 2025-03-09 + +- [breaking] migrate to ESM and make flat config default + ## 6.0.0 - 2025-03-04 - [new] introduce flat config diff --git a/eslint-configs/eslint-config-seekingalpha-typescript/README.md b/eslint-configs/eslint-config-seekingalpha-typescript/README.md index 2d053b2b..73104b90 100644 --- a/eslint-configs/eslint-config-seekingalpha-typescript/README.md +++ b/eslint-configs/eslint-config-seekingalpha-typescript/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-typescript --save-dev + npm install eslint-config-seekingalpha-typescript@latest --save-dev ## Usage @@ -18,14 +18,24 @@ This shareable config includes all rules from following plugins: - [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint) -Simply [extend](https://eslint.org/docs/user-guide/configuring#extending-configuration-files) the relevant .eslintrc.js configuration in your project with `eslint-config-seekingalpha-typescript` rules: +Simply [use](https://eslint.org/docs/latest/extend/shareable-configs) the eslint.config.js in your project with the configuration: ```javascript -{ - extends: [ - 'eslint-config-seekingalpha-typescript' - ] -} +import tsConfig from 'eslint-config-seekingalpha-typescript'; + +export default [ + { + plugins: { + ...tsConfig.plugins, + }, + rules: { + ...tsConfig.rules, + }, + settings: { + ...tsConfig.settings, + }, + }, +]; ``` ## License diff --git a/eslint-configs/eslint-config-seekingalpha-typescript/flat.js b/eslint-configs/eslint-config-seekingalpha-typescript/flat.js deleted file mode 100644 index f549485f..00000000 --- a/eslint-configs/eslint-config-seekingalpha-typescript/flat.js +++ /dev/null @@ -1,18 +0,0 @@ -// eslint-disable-next-line import/no-unresolved -import typescriptEslint from 'typescript-eslint'; - -import disableConfig from './rules/disable-recommended-eslint-rules/index.js'; -import config from './rules/typescript-eslint/index.js'; - -export default { - plugins: { - '@typescript-eslint': typescriptEslint.plugin, - }, - rules: { - ...disableConfig.rules, - ...config.rules, - }, - languageOptions: { - parser: typescriptEslint.parser, - }, -}; diff --git a/eslint-configs/eslint-config-seekingalpha-typescript/index.js b/eslint-configs/eslint-config-seekingalpha-typescript/index.js index 1f17be9e..af6a46c9 100644 --- a/eslint-configs/eslint-config-seekingalpha-typescript/index.js +++ b/eslint-configs/eslint-config-seekingalpha-typescript/index.js @@ -1,17 +1,18 @@ -module.exports = { - extends: [ - './rules/disable-recommended-eslint-rules', +// eslint-disable-next-line import/no-unresolved +import typescriptEslint from 'typescript-eslint'; - // https://github.com/typescript-eslint/typescript-eslint - './rules/typescript-eslint/index.js', - ], +import disableConfig from './rules/disable-recommended-eslint-rules/index.js'; +import config from './rules/typescript-eslint/index.js'; - parserOptions: { - ecmaVersion: 12, - sourceType: 'module', - ecmaFeatures: { - impliedStrict: true, - globalReturn: false, - }, +export default { + plugins: { + '@typescript-eslint': typescriptEslint.plugin, + }, + rules: { + ...disableConfig, + ...config, + }, + languageOptions: { + parser: typescriptEslint.parser, }, }; diff --git a/eslint-configs/eslint-config-seekingalpha-typescript/package.json b/eslint-configs/eslint-config-seekingalpha-typescript/package.json index babf2e6c..13950078 100644 --- a/eslint-configs/eslint-config-seekingalpha-typescript/package.json +++ b/eslint-configs/eslint-config-seekingalpha-typescript/package.json @@ -1,8 +1,9 @@ { "name": "eslint-config-seekingalpha-typescript", - "version": "6.0.0", + "version": "7.0.0", "description": "SeekingAlpha's sharable typescript 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-typescript/rules/config.js b/eslint-configs/eslint-config-seekingalpha-typescript/rules/config.js index 00b9a3d8..3df57ea8 100644 --- a/eslint-configs/eslint-config-seekingalpha-typescript/rules/config.js +++ b/eslint-configs/eslint-config-seekingalpha-typescript/rules/config.js @@ -1,4 +1,4 @@ -module.exports = { +export default { indent: 2, maxParams: 4, }; diff --git a/eslint-configs/eslint-config-seekingalpha-typescript/rules/disable-recommended-eslint-rules/index.js b/eslint-configs/eslint-config-seekingalpha-typescript/rules/disable-recommended-eslint-rules/index.js index 824c9932..9811ffa2 100644 --- a/eslint-configs/eslint-config-seekingalpha-typescript/rules/disable-recommended-eslint-rules/index.js +++ b/eslint-configs/eslint-config-seekingalpha-typescript/rules/disable-recommended-eslint-rules/index.js @@ -1,63 +1,61 @@ -module.exports = { - rules: { - /* - * Disabled as per TS recommendation - * https://typescript-eslint.io/linting/troubleshooting#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors - */ - 'no-undef': 'off', +export default { + /* + * Disabled as per TS recommendation + * https://typescript-eslint.io/linting/troubleshooting#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors + */ + 'no-undef': 'off', - 'class-methods-use-this': 'off', + 'class-methods-use-this': 'off', - 'default-param-last': 'off', + 'default-param-last': 'off', - /* - * Requires TS - * 'dot-notation': 'off', - */ + /* + * Requires TS + * 'dot-notation': 'off', + */ - 'init-declarations': 'off', + 'init-declarations': 'off', - 'max-params': 'off', + 'max-params': 'off', - 'no-array-constructor': 'off', + 'no-array-constructor': 'off', - 'no-dupe-class-members': 'off', + 'no-dupe-class-members': 'off', - 'no-empty-function': 'off', + 'no-empty-function': 'off', - /* - * Requires TS - * 'no-implied-eval': 'off', - */ + /* + * Requires TS + * 'no-implied-eval': 'off', + */ - 'no-loop-func': 'off', + 'no-loop-func': 'off', - 'no-magic-numbers': 'off', + 'no-magic-numbers': 'off', - 'no-redeclare': 'off', + 'no-redeclare': 'off', - 'no-restricted-imports': 'off', + 'no-restricted-imports': 'off', - 'no-shadow': 'off', + 'no-shadow': 'off', - 'no-unused-expressions': 'off', + 'no-unused-expressions': 'off', - 'no-unused-vars': 'off', + 'no-unused-vars': 'off', - 'no-use-before-define': 'off', + 'no-use-before-define': 'off', - 'no-useless-constructor': 'off', + 'no-useless-constructor': 'off', - /* - * Requires TS - * 'prefer-destructuring': 'off', - */ + /* + * Requires TS + * 'prefer-destructuring': 'off', + */ - /* - * Requires TS - * 'require-await': 'off', - */ + /* + * Requires TS + * 'require-await': 'off', + */ - 'no-invalid-this': 'off', - }, + 'no-invalid-this': 'off', }; diff --git a/eslint-configs/eslint-config-seekingalpha-typescript/rules/typescript-eslint/index.js b/eslint-configs/eslint-config-seekingalpha-typescript/rules/typescript-eslint/index.js index 686b0bdc..168c299f 100644 --- a/eslint-configs/eslint-config-seekingalpha-typescript/rules/typescript-eslint/index.js +++ b/eslint-configs/eslint-config-seekingalpha-typescript/rules/typescript-eslint/index.js @@ -1,4 +1,4 @@ -const config = require('../config'); +import config from '../config'; const rulesRunTs = { '@typescript-eslint/require-await': 'off', @@ -118,237 +118,233 @@ const rulesRunTs = { '@typescript-eslint/no-unnecessary-type-parameters': 'off', }; -module.exports = { - plugins: ['@typescript-eslint/eslint-plugin'], +export default { + ...rulesRunTs, - rules: { - ...rulesRunTs, + '@typescript-eslint/adjacent-overload-signatures': 'error', - '@typescript-eslint/adjacent-overload-signatures': 'error', + '@typescript-eslint/no-restricted-types': 'off', - '@typescript-eslint/no-restricted-types': 'off', + '@typescript-eslint/ban-ts-comment': 'error', - '@typescript-eslint/ban-ts-comment': 'error', + '@typescript-eslint/ban-tslint-comment': 'error', - '@typescript-eslint/ban-tslint-comment': 'error', + '@typescript-eslint/class-methods-use-this': 'error', - '@typescript-eslint/class-methods-use-this': 'error', + '@typescript-eslint/class-literal-property-style': ['error', 'fields'], - '@typescript-eslint/class-literal-property-style': ['error', 'fields'], + '@typescript-eslint/consistent-generic-constructors': [ + 'error', + 'constructor', + ], - '@typescript-eslint/consistent-generic-constructors': [ - 'error', - 'constructor', - ], + '@typescript-eslint/consistent-indexed-object-style': ['error', 'record'], - '@typescript-eslint/consistent-indexed-object-style': ['error', 'record'], + '@typescript-eslint/consistent-type-assertions': [ + 'error', + { + assertionStyle: 'as', + objectLiteralTypeAssertions: 'allow', + }, + ], - '@typescript-eslint/consistent-type-assertions': [ - 'error', - { - assertionStyle: 'as', - objectLiteralTypeAssertions: 'allow', - }, - ], + '@typescript-eslint/consistent-type-definitions': ['error', 'type'], - '@typescript-eslint/consistent-type-definitions': ['error', 'type'], + '@typescript-eslint/consistent-type-imports': [ + 'error', + { + prefer: 'type-imports', + fixStyle: 'separate-type-imports', + }, + ], - '@typescript-eslint/consistent-type-imports': [ - 'error', - { - prefer: 'type-imports', - fixStyle: 'separate-type-imports', - }, - ], + '@typescript-eslint/default-param-last': 'error', - '@typescript-eslint/default-param-last': 'error', + '@typescript-eslint/init-declarations': ['off', 'always'], - '@typescript-eslint/init-declarations': ['off', 'always'], + '@typescript-eslint/max-params': ['error', { max: config.maxParams }], - '@typescript-eslint/max-params': ['error', { max: config.maxParams }], + '@typescript-eslint/member-ordering': 'error', - '@typescript-eslint/member-ordering': 'error', + '@typescript-eslint/method-signature-style': 'error', - '@typescript-eslint/method-signature-style': 'error', + '@typescript-eslint/no-array-constructor': 'error', - '@typescript-eslint/no-array-constructor': 'error', + '@typescript-eslint/no-confusing-non-null-assertion': 'error', - '@typescript-eslint/no-confusing-non-null-assertion': 'error', + '@typescript-eslint/no-dupe-class-members': 'error', - '@typescript-eslint/no-dupe-class-members': 'error', + '@typescript-eslint/no-duplicate-enum-values': 'error', - '@typescript-eslint/no-duplicate-enum-values': 'error', + '@typescript-eslint/no-dynamic-delete': 'error', - '@typescript-eslint/no-dynamic-delete': 'error', + '@typescript-eslint/no-empty-function': 'error', - '@typescript-eslint/no-empty-function': 'error', + '@typescript-eslint/no-empty-interface': 'error', - '@typescript-eslint/no-empty-interface': 'error', + '@typescript-eslint/no-empty-object-type': 'error', - '@typescript-eslint/no-empty-object-type': 'error', + '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-extra-non-null-assertion': 'error', - '@typescript-eslint/no-extra-non-null-assertion': 'error', + '@typescript-eslint/no-extraneous-class': 'error', - '@typescript-eslint/no-extraneous-class': 'error', + '@typescript-eslint/no-import-type-side-effects': 'error', - '@typescript-eslint/no-import-type-side-effects': 'error', + '@typescript-eslint/no-inferrable-types': 'error', - '@typescript-eslint/no-inferrable-types': 'error', + '@typescript-eslint/no-invalid-void-type': 'error', - '@typescript-eslint/no-invalid-void-type': 'error', + '@typescript-eslint/no-loop-func': 'error', - '@typescript-eslint/no-loop-func': 'error', + '@typescript-eslint/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, + ignoreEnums: true, + ignoreNumericLiteralTypes: true, + ignoreReadonlyClassProperties: true, + ignoreTypeIndexes: true, + }, + ], - '@typescript-eslint/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, - ignoreEnums: true, - ignoreNumericLiteralTypes: true, - ignoreReadonlyClassProperties: true, - ignoreTypeIndexes: true, - }, - ], + '@typescript-eslint/no-misused-new': 'error', - '@typescript-eslint/no-misused-new': 'error', + '@typescript-eslint/no-namespace': 'error', - '@typescript-eslint/no-namespace': 'error', + '@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error', - '@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error', + '@typescript-eslint/no-non-null-asserted-optional-chain': 'error', - '@typescript-eslint/no-non-null-asserted-optional-chain': 'error', + '@typescript-eslint/no-non-null-assertion': 'error', - '@typescript-eslint/no-non-null-assertion': 'error', + '@typescript-eslint/parameter-properties': 'error', - '@typescript-eslint/parameter-properties': 'error', + '@typescript-eslint/no-redeclare': 'error', - '@typescript-eslint/no-redeclare': 'error', + '@typescript-eslint/no-require-imports': 'error', - '@typescript-eslint/no-require-imports': 'error', + '@typescript-eslint/no-restricted-imports': 'error', - '@typescript-eslint/no-restricted-imports': 'error', + '@typescript-eslint/no-shadow': [ + 'error', + { + builtinGlobals: true, + hoist: 'all', + allow: [], + }, + ], - '@typescript-eslint/no-shadow': [ - 'error', - { - builtinGlobals: true, - hoist: 'all', - allow: [], - }, - ], + '@typescript-eslint/no-this-alias': 'error', - '@typescript-eslint/no-this-alias': 'error', + '@typescript-eslint/no-unnecessary-parameter-property-assignment': 'error', - '@typescript-eslint/no-unnecessary-parameter-property-assignment': 'error', + '@typescript-eslint/no-unnecessary-type-constraint': 'error', - '@typescript-eslint/no-unnecessary-type-constraint': 'error', + '@typescript-eslint/no-unsafe-declaration-merging': 'error', - '@typescript-eslint/no-unsafe-declaration-merging': 'error', + '@typescript-eslint/no-unsafe-function-type': 'error', - '@typescript-eslint/no-unsafe-function-type': 'error', + '@typescript-eslint/no-unused-expressions': [ + 'error', + { + allowShortCircuit: false, + allowTernary: false, + allowTaggedTemplates: false, + }, + ], - '@typescript-eslint/no-unused-expressions': [ - 'error', - { - allowShortCircuit: false, - allowTernary: false, - allowTaggedTemplates: false, - }, - ], - - '@typescript-eslint/no-unused-vars': [ - 'error', - { - args: 'after-used', - argsIgnorePattern: '[iI]gnored', - caughtErrors: 'all', - caughtErrorsIgnorePattern: '[iI]gnored', - ignoreRestSiblings: false, - vars: 'all', - varsIgnorePattern: '[iI]gnored', - }, - ], - - '@typescript-eslint/no-use-before-define': [ - 'error', - { - functions: true, - classes: true, - variables: true, - enums: true, - typedefs: true, - }, - ], + '@typescript-eslint/no-unused-vars': [ + 'error', + { + args: 'after-used', + argsIgnorePattern: '[iI]gnored', + caughtErrors: 'all', + caughtErrorsIgnorePattern: '[iI]gnored', + ignoreRestSiblings: false, + vars: 'all', + varsIgnorePattern: '[iI]gnored', + }, + ], - '@typescript-eslint/no-useless-constructor': 'error', + '@typescript-eslint/no-use-before-define': [ + 'error', + { + functions: true, + classes: true, + variables: true, + enums: true, + typedefs: true, + }, + ], - '@typescript-eslint/no-useless-empty-export': 'error', + '@typescript-eslint/no-useless-constructor': 'error', - '@typescript-eslint/no-var-requires': 'error', + '@typescript-eslint/no-useless-empty-export': 'error', - '@typescript-eslint/no-wrapper-object-types': 'error', + '@typescript-eslint/no-var-requires': 'error', - '@typescript-eslint/prefer-as-const': 'error', + '@typescript-eslint/no-wrapper-object-types': 'error', - '@typescript-eslint/prefer-enum-initializers': 'error', + '@typescript-eslint/prefer-as-const': 'error', - '@typescript-eslint/prefer-for-of': 'error', + '@typescript-eslint/prefer-enum-initializers': 'error', - '@typescript-eslint/prefer-function-type': 'error', + '@typescript-eslint/prefer-for-of': 'error', - '@typescript-eslint/prefer-literal-enum-member': 'error', + '@typescript-eslint/prefer-function-type': 'error', - '@typescript-eslint/prefer-namespace-keyword': 'error', + '@typescript-eslint/prefer-literal-enum-member': 'error', - '@typescript-eslint/sort-type-constituents': 'error', + '@typescript-eslint/prefer-namespace-keyword': 'error', - '@typescript-eslint/triple-slash-reference': 'error', + '@typescript-eslint/sort-type-constituents': 'error', - '@typescript-eslint/typedef': 'error', + '@typescript-eslint/triple-slash-reference': 'error', - '@typescript-eslint/unified-signatures': 'error', + '@typescript-eslint/typedef': 'error', - '@typescript-eslint/no-invalid-this': 'error', + '@typescript-eslint/unified-signatures': 'error', - '@typescript-eslint/array-type': [ - 'error', - { - default: 'generic', - readonly: 'generic', - }, - ], + '@typescript-eslint/no-invalid-this': 'error', - '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/array-type': [ + 'error', + { + default: 'generic', + readonly: 'generic', + }, + ], - '@typescript-eslint/explicit-member-accessibility': [ - 'error', - { - overrides: { - constructors: 'no-public', - }, - }, - ], - - '@typescript-eslint/explicit-module-boundary-types': 'off', - - '@typescript-eslint/no-type-alias': [ - 'error', - { - allowAliases: 'in-unions-and-intersections', - allowCallbacks: 'always', - allowConditionalTypes: 'always', - allowConstructors: 'never', - allowLiterals: 'always', - allowMappedTypes: 'always', - allowTupleTypes: 'always', - allowGenerics: 'always', + '@typescript-eslint/explicit-function-return-type': 'off', + + '@typescript-eslint/explicit-member-accessibility': [ + 'error', + { + overrides: { + constructors: 'no-public', }, - ], - }, + }, + ], + + '@typescript-eslint/explicit-module-boundary-types': 'off', + + '@typescript-eslint/no-type-alias': [ + 'error', + { + allowAliases: 'in-unions-and-intersections', + allowCallbacks: 'always', + allowConditionalTypes: 'always', + allowConstructors: 'never', + allowLiterals: 'always', + allowMappedTypes: 'always', + allowTupleTypes: 'always', + allowGenerics: 'always', + }, + ], }; diff --git a/eslint.config.js b/eslint.config.js index c3d3f4e8..51ee9fc9 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,6 +1,6 @@ import globals from 'globals'; -import baseConfig from 'eslint-config-seekingalpha-base/flat.js'; -import nodeConfig from 'eslint-config-seekingalpha-node/flat.js'; +import baseConfig from 'eslint-config-seekingalpha-base'; +import nodeConfig from 'eslint-config-seekingalpha-node'; export default { languageOptions: { diff --git a/package.json b/package.json index 57cd5c4a..28fd1f4b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "seekingalpha-javascript-style", - "version": "7.0.0", + "version": "7.1.0", "description": "Set of linting rules, guides and best practices for best Javascript code", "main": "index.js", "type": "module", @@ -47,8 +47,8 @@ "devDependencies": { "@seekingalpha/prettier-config-samw": "2.0.0", "eslint": "8.57.1", - "eslint-config-seekingalpha-base": "9.1.0", - "eslint-config-seekingalpha-node": "7.0.0", + "eslint-config-seekingalpha-base": "10.0.0", + "eslint-config-seekingalpha-node": "8.0.0", "eslint-plugin-array-func": "5.0.2", "eslint-plugin-import": "2.31.0", "eslint-plugin-n": "17.16.2",