Closes #27451 --------- Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com> Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
149 lines
4.4 KiB
TypeScript
149 lines
4.4 KiB
TypeScript
import { fixupPluginRules } from '@eslint/compat';
|
|
import * as importPlugin from 'eslint-plugin-import';
|
|
import globals from 'globals';
|
|
import tseslint from 'typescript-eslint';
|
|
|
|
/**
|
|
* This configuration is intended to be applied to ALL files within a React
|
|
* project in an Nx workspace.
|
|
*
|
|
* It should therefore NOT contain any rules or plugins which are specific
|
|
* to one particular variant, e.g. TypeScript vs JavaScript, .js vs .jsx etc
|
|
*
|
|
* This configuration is intended to be combined with other configs from this
|
|
* package.
|
|
*/
|
|
|
|
/**
|
|
* Rule set originally adapted from:
|
|
* https://github.com/facebook/create-react-app/blob/567f36c9235f1e1fd4a76dc6d1ae00be754ca047/packages/eslint-config-react-app/index.js
|
|
*/
|
|
export default tseslint.config({
|
|
plugins: { import: fixupPluginRules(importPlugin) },
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.browser,
|
|
...globals.commonjs,
|
|
...globals.es2015,
|
|
...globals.jest,
|
|
...globals.node,
|
|
},
|
|
},
|
|
rules: {
|
|
/**
|
|
* Standard ESLint rule configurations
|
|
* https://eslint.org/docs/rules
|
|
*/
|
|
'array-callback-return': 'warn',
|
|
'dot-location': ['warn', 'property'],
|
|
eqeqeq: ['warn', 'smart'],
|
|
'new-parens': 'warn',
|
|
'no-caller': 'warn',
|
|
'no-cond-assign': ['warn', 'except-parens'],
|
|
'no-const-assign': 'warn',
|
|
'no-control-regex': 'warn',
|
|
'no-delete-var': 'warn',
|
|
'no-dupe-args': 'warn',
|
|
'no-dupe-keys': 'warn',
|
|
'no-duplicate-case': 'warn',
|
|
'no-empty-character-class': 'warn',
|
|
'no-empty-pattern': 'warn',
|
|
'no-eval': 'warn',
|
|
'no-ex-assign': 'warn',
|
|
'no-extend-native': 'warn',
|
|
'no-extra-bind': 'warn',
|
|
'no-extra-label': 'warn',
|
|
'no-fallthrough': 'warn',
|
|
'no-func-assign': 'warn',
|
|
'no-implied-eval': 'warn',
|
|
'no-invalid-regexp': 'warn',
|
|
'no-iterator': 'warn',
|
|
'no-label-var': 'warn',
|
|
'no-labels': ['warn', { allowLoop: true, allowSwitch: false }],
|
|
'no-lone-blocks': 'warn',
|
|
'no-loop-func': 'warn',
|
|
'no-mixed-operators': [
|
|
'warn',
|
|
{
|
|
groups: [
|
|
['&', '|', '^', '~', '<<', '>>', '>>>'],
|
|
['==', '!=', '===', '!==', '>', '>=', '<', '<='],
|
|
['&&', '||'],
|
|
['in', 'instanceof'],
|
|
],
|
|
allowSamePrecedence: false,
|
|
},
|
|
],
|
|
'no-multi-str': 'warn',
|
|
'no-native-reassign': 'warn',
|
|
'no-negated-in-lhs': 'warn',
|
|
'no-new-func': 'warn',
|
|
'no-new-object': 'warn',
|
|
'no-new-symbol': 'warn',
|
|
'no-new-wrappers': 'warn',
|
|
'no-obj-calls': 'warn',
|
|
'no-octal': 'warn',
|
|
'no-octal-escape': 'warn',
|
|
'no-redeclare': 'warn',
|
|
'no-regex-spaces': 'warn',
|
|
'no-restricted-syntax': ['warn', 'WithStatement'],
|
|
'no-script-url': 'warn',
|
|
'no-self-assign': 'warn',
|
|
'no-self-compare': 'warn',
|
|
'no-sequences': 'warn',
|
|
'no-shadow-restricted-names': 'warn',
|
|
'no-sparse-arrays': 'warn',
|
|
'no-template-curly-in-string': 'warn',
|
|
'no-this-before-super': 'warn',
|
|
'no-throw-literal': 'warn',
|
|
'no-restricted-globals': ['error', ...require('confusing-browser-globals')],
|
|
'no-unexpected-multiline': 'warn',
|
|
'no-unreachable': 'warn',
|
|
'no-unused-expressions': 'off',
|
|
'no-unused-labels': 'warn',
|
|
'no-useless-computed-key': 'warn',
|
|
'no-useless-concat': 'warn',
|
|
'no-useless-escape': 'warn',
|
|
'no-useless-rename': [
|
|
'warn',
|
|
{
|
|
ignoreDestructuring: false,
|
|
ignoreImport: false,
|
|
ignoreExport: false,
|
|
},
|
|
],
|
|
'no-with': 'warn',
|
|
'no-whitespace-before-property': 'warn',
|
|
'require-yield': 'warn',
|
|
'rest-spread-spacing': ['warn', 'never'],
|
|
strict: ['warn', 'never'],
|
|
'unicode-bom': ['warn', 'never'],
|
|
'use-isnan': 'warn',
|
|
'valid-typeof': 'warn',
|
|
'no-restricted-properties': [
|
|
'error',
|
|
{
|
|
object: 'require',
|
|
property: 'ensure',
|
|
message:
|
|
'Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting',
|
|
},
|
|
{
|
|
object: 'System',
|
|
property: 'import',
|
|
message:
|
|
'Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting',
|
|
},
|
|
],
|
|
'getter-return': 'warn',
|
|
|
|
/**
|
|
* Import rule configurations
|
|
* https://github.com/benmosher/eslint-plugin-import
|
|
*/
|
|
'import/first': 'error',
|
|
'import/no-amd': 'error',
|
|
'import/no-webpack-loader-syntax': 'error',
|
|
},
|
|
});
|