321 lines
9.4 KiB
JavaScript
321 lines
9.4 KiB
JavaScript
import react from 'eslint-plugin-react';
|
|
import importConfig from '../.eslint-import.js';
|
|
import jsBaseConfig from '../.eslint-js.js';
|
|
|
|
const { rules: importRules, settings: importSettings } = importConfig;
|
|
const { rules: baseRules } = jsBaseConfig;
|
|
|
|
export default {
|
|
name: 'react',
|
|
languageOptions: {
|
|
parserOptions: {
|
|
ecmaFeatures: {
|
|
jsx: true,
|
|
},
|
|
ecmaVersion: 'latest',
|
|
},
|
|
},
|
|
plugins: {
|
|
react,
|
|
},
|
|
rules: {
|
|
'class-methods-use-this': [baseRules['class-methods-use-this'][0], {
|
|
...baseRules['class-methods-use-this'][1],
|
|
exceptMethods: [
|
|
...baseRules['class-methods-use-this'][1].exceptMethods,
|
|
'render',
|
|
'getInitialState',
|
|
'getDefaultProps',
|
|
'getChildContext',
|
|
'componentWillMount',
|
|
'UNSAFE_componentWillMount',
|
|
'componentDidMount',
|
|
'componentWillReceiveProps',
|
|
'UNSAFE_componentWillReceiveProps',
|
|
'shouldComponentUpdate',
|
|
'componentWillUpdate',
|
|
'UNSAFE_componentWillUpdate',
|
|
'componentDidUpdate',
|
|
'componentWillUnmount',
|
|
'componentDidCatch',
|
|
'getSnapshotBeforeUpdate',
|
|
],
|
|
}],
|
|
'import/extensions': [importRules['import/extensions'][0],
|
|
importRules['import/extensions'][1],
|
|
{
|
|
...importRules['import/extensions'][2],
|
|
jsx: 'never',
|
|
}],
|
|
'import/no-nodejs-modules': 'error',
|
|
'react/boolean-prop-naming': ['off', {
|
|
propTypeNames: [
|
|
'bool',
|
|
'mutuallyExclusiveTrueProps',
|
|
],
|
|
rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+',
|
|
message: '',
|
|
}],
|
|
'react/button-has-type': ['error', {
|
|
button: true,
|
|
submit: true,
|
|
reset: false,
|
|
}],
|
|
'react/checked-requires-onchange-or-readonly': ['error', {
|
|
ignoreMissingProperties: false,
|
|
ignoreExclusiveCheckedAttribute: false,
|
|
}],
|
|
'react/default-props-match-prop-types': ['error', {
|
|
allowRequiredDefaults: false,
|
|
}],
|
|
'react/destructuring-assignment': ['error', 'always'],
|
|
'react/display-name': ['off', {
|
|
ignoreTranspilerName: false,
|
|
}],
|
|
'react/forbid-component-props': ['off', {
|
|
forbid: [],
|
|
}],
|
|
'react/forbid-dom-props': ['off', {
|
|
forbid: [],
|
|
}],
|
|
'react/forbid-elements': ['off', {
|
|
forbid: [],
|
|
}],
|
|
'react/forbid-foreign-prop-types': ['warn', {
|
|
allowInPropTypes: true,
|
|
}],
|
|
'react/forbid-prop-types': ['error', {
|
|
forbid: [
|
|
'any',
|
|
'array',
|
|
'object',
|
|
],
|
|
checkContextTypes: true,
|
|
checkChildContextTypes: true,
|
|
}],
|
|
'react/function-component-definition': ['error', {
|
|
namedComponents: 'arrow-function',
|
|
unnamedComponents: 'arrow-function',
|
|
}],
|
|
'react/hook-use-state': 'error',
|
|
'react/iframe-missing-sandbox': 'error',
|
|
'react/jsx-boolean-value': ['error',
|
|
'never',
|
|
{
|
|
always: [],
|
|
}],
|
|
'react/jsx-child-element-spacing': 'off',
|
|
'react/jsx-closing-bracket-location': 'off',
|
|
'react/jsx-closing-tag-location': 'off',
|
|
'react/jsx-curly-brace-presence': 'off',
|
|
'react/jsx-curly-newline': 'off',
|
|
'react/jsx-curly-spacing': 'off',
|
|
'react/jsx-equals-spacing': 'off',
|
|
'react/jsx-filename-extension': ['error', {
|
|
extensions: [
|
|
'.jsx',
|
|
'.js',
|
|
],
|
|
}],
|
|
'react/jsx-first-prop-new-line': 'off',
|
|
'react/jsx-fragments': ['error', 'syntax'],
|
|
'react/jsx-handler-names': ['off', {
|
|
eventHandlerPrefix: 'handle',
|
|
eventHandlerPropPrefix: 'on',
|
|
}],
|
|
'react/jsx-indent': 'off',
|
|
'react/jsx-indent-props': 'off',
|
|
'react/jsx-key': 'error',
|
|
'react/jsx-max-depth': 'off',
|
|
'react/jsx-max-props-per-line': 'off',
|
|
'react/jsx-newline': 'off',
|
|
'react/jsx-no-bind': ['error', {
|
|
ignoreRefs: true,
|
|
allowArrowFunctions: true,
|
|
allowFunctions: false,
|
|
allowBind: false,
|
|
ignoreDOMComponents: true,
|
|
}],
|
|
'react/jsx-no-comment-textnodes': 'error',
|
|
'react/jsx-no-constructed-context-values': 'error',
|
|
'react/jsx-no-duplicate-props': ['error', {
|
|
ignoreCase: false,
|
|
}],
|
|
'react/jsx-no-leaked-render': 'error',
|
|
'react/jsx-no-literals': 'off',
|
|
'react/jsx-no-script-url': ['error', [
|
|
{
|
|
name: 'Link',
|
|
props: [
|
|
'to',
|
|
],
|
|
},
|
|
]],
|
|
'react/jsx-no-target-blank': ['error', {
|
|
enforceDynamicLinks: 'always',
|
|
}],
|
|
'react/jsx-no-undef': 'error',
|
|
'react/jsx-no-useless-fragment': 'error',
|
|
'react/jsx-one-expression-per-line': 'off',
|
|
'react/jsx-pascal-case': ['error', {
|
|
allowAllCaps: true,
|
|
ignore: [],
|
|
}],
|
|
'react/jsx-props-no-multi-spaces': 'off',
|
|
'react/jsx-props-no-spreading': 'off',
|
|
'react/jsx-sort-props': 'off',
|
|
'react/jsx-tag-spacing': 'off',
|
|
'react/jsx-uses-react': 'error',
|
|
'react/jsx-uses-vars': 'error',
|
|
'react/jsx-wrap-multilines': ['error', {
|
|
declaration: 'parens-new-line',
|
|
assignment: 'parens-new-line',
|
|
return: 'parens-new-line',
|
|
arrow: 'parens-new-line',
|
|
condition: 'parens-new-line',
|
|
logical: 'parens-new-line',
|
|
prop: 'parens-new-line',
|
|
}],
|
|
'react/no-access-state-in-setstate': 'error',
|
|
'react/no-adjacent-inline-elements': 'off',
|
|
'react/no-array-index-key': 'error',
|
|
'react/no-arrow-function-lifecycle': 'error',
|
|
'react/no-children-prop': 'error',
|
|
'react/no-danger': 'error',
|
|
'react/no-danger-with-children': 'error',
|
|
'react/no-deprecated': 'error',
|
|
'react/no-did-mount-set-state': 'off',
|
|
'react/no-did-update-set-state': 'error',
|
|
'react/no-direct-mutation-state': 'error',
|
|
'react/no-find-dom-node': 'error',
|
|
'react/no-invalid-html-attribute': 'error',
|
|
'react/no-is-mounted': 'error',
|
|
'react/no-multi-comp': 'off',
|
|
'react/no-namespace': 'error',
|
|
'react/no-object-type-as-default-prop': 'off',
|
|
'react/no-redundant-should-component-update': 'error',
|
|
'react/no-render-return-value': 'error',
|
|
'react/no-set-state': 'off',
|
|
'react/no-string-refs': 'error',
|
|
'react/no-this-in-sfc': 'error',
|
|
'react/no-typos': 'error',
|
|
'react/no-unescaped-entities': 'error',
|
|
'react/no-unknown-property': 'error',
|
|
'react/no-unsafe': 'off',
|
|
'react/no-unstable-nested-components': 'error',
|
|
'react/no-unused-class-component-methods': 'error',
|
|
'react/no-unused-prop-types': ['error', {
|
|
customValidators: [],
|
|
skipShapeProps: true,
|
|
}],
|
|
'react/no-unused-state': 'error',
|
|
'react/no-will-update-set-state': 'error',
|
|
'react/prefer-es6-class': ['error', 'always'],
|
|
'react/prefer-exact-props': 'error',
|
|
'react/prefer-read-only-props': 'off',
|
|
'react/prefer-stateless-function': ['error', {
|
|
ignorePureComponents: true,
|
|
}],
|
|
'react/prop-types': ['error', {
|
|
ignore: [],
|
|
customValidators: [],
|
|
skipUndeclared: false,
|
|
}],
|
|
'react/react-in-jsx-scope': 'off',
|
|
'react/require-default-props': ['error', {
|
|
forbidDefaultForRequired: true,
|
|
functions: 'ignore',
|
|
}],
|
|
'react/require-optimization': ['off', {
|
|
allowDecorators: [],
|
|
}],
|
|
'react/require-render-return': 'error',
|
|
'react/self-closing-comp': 'off',
|
|
'react/sort-comp': ['error', {
|
|
order: [
|
|
'static-variables',
|
|
'static-methods',
|
|
'instance-variables',
|
|
'lifecycle',
|
|
'/^handle.+$/',
|
|
'/^on.+$/',
|
|
'getters',
|
|
'setters',
|
|
'/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/',
|
|
'instance-methods',
|
|
'everything-else',
|
|
'rendering',
|
|
],
|
|
groups: {
|
|
lifecycle: [
|
|
'displayName',
|
|
'propTypes',
|
|
'contextTypes',
|
|
'childContextTypes',
|
|
'mixins',
|
|
'statics',
|
|
'defaultProps',
|
|
'constructor',
|
|
'getDefaultProps',
|
|
'getInitialState',
|
|
'state',
|
|
'getChildContext',
|
|
'getDerivedStateFromProps',
|
|
'componentWillMount',
|
|
'UNSAFE_componentWillMount',
|
|
'componentDidMount',
|
|
'componentWillReceiveProps',
|
|
'UNSAFE_componentWillReceiveProps',
|
|
'shouldComponentUpdate',
|
|
'componentWillUpdate',
|
|
'UNSAFE_componentWillUpdate',
|
|
'getSnapshotBeforeUpdate',
|
|
'componentDidUpdate',
|
|
'componentDidCatch',
|
|
'componentWillUnmount',
|
|
],
|
|
rendering: [
|
|
'/^render.+$/',
|
|
'render',
|
|
],
|
|
},
|
|
}],
|
|
'react/sort-default-props': ['error', {
|
|
ignoreCase: false,
|
|
}],
|
|
'react/sort-prop-types': 'off',
|
|
'react/state-in-constructor': ['error', 'always'],
|
|
'react/static-property-placement': ['error', 'property assignment', {
|
|
childContextTypes: 'property assignment',
|
|
contextTypes: 'property assignment',
|
|
contextType: 'static public field',
|
|
defaultProps: 'property assignment',
|
|
displayName: 'property assignment',
|
|
propTypes: 'property assignment',
|
|
}],
|
|
'react/style-prop-object': 'error',
|
|
'react/void-dom-elements-no-children': 'error',
|
|
'react/jsx-props-no-spread-multi': 'error',
|
|
},
|
|
settings: {
|
|
'import/extensions': [
|
|
...importSettings['import/extensions'],
|
|
'.jsx',
|
|
],
|
|
'import/resolver': {
|
|
...importSettings['import/resolver'],
|
|
node: {
|
|
...importSettings['import/resolver'].node,
|
|
extensions: [
|
|
...importSettings['import/resolver'].node.extensions,
|
|
'.jsx',
|
|
],
|
|
},
|
|
},
|
|
react: {
|
|
pragma: 'React',
|
|
version: 'detect',
|
|
},
|
|
},
|
|
};
|