eslint-stylistic-airbnb
Version:
Airbnb config for eslint using ESlint Stylistic formatting
172 lines (169 loc) • 5.64 kB
JavaScript
;
// https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb/rules/react.js
module.exports = {
name: 'airbnb:addon-react',
rules: {
'class-methods-use-this': ['error', {
exceptMethods: [
'render',
'getInitialState',
'getDefaultProps',
'getChildContext',
'componentWillMount',
'UNSAFE_componentWillMount',
'componentDidMount',
'componentWillReceiveProps',
'UNSAFE_componentWillReceiveProps',
'shouldComponentUpdate',
'componentWillUpdate',
'UNSAFE_componentWillUpdate',
'componentDidUpdate',
'componentWillUnmount',
'componentDidCatch',
'getSnapshotBeforeUpdate'
],
}],
'react/forbid-prop-types': ['error', {
forbid: ['any', 'array', 'object'],
checkContextTypes: true,
checkChildContextTypes: true,
}],
'react/jsx-boolean-value': ['error', 'never', { always: [] }],
'react/jsx-no-bind': ['error', {
ignoreRefs: true,
allowArrowFunctions: true,
allowFunctions: false,
allowBind: false,
ignoreDOMComponents: true,
}],
'react/jsx-no-duplicate-props': ['error', { ignoreCase: true }],
'react/jsx-no-undef': 'error',
'react/jsx-uses-react': 'error',
'react/jsx-uses-vars': 'error',
'react/no-danger': 'warn',
'react/no-deprecated': 'error',
'react/no-did-update-set-state': 'error',
'react/no-will-update-set-state': 'error',
'react/no-is-mounted': 'error',
'react/no-string-refs': 'error',
'react/no-unknown-property': 'error',
'react/prefer-es6-class': ['error', 'always'],
'react/prefer-stateless-function': ['error', { ignorePureComponents: true }],
'react/prop-types': ['error', {
ignore: [],
customValidators: [],
skipUndeclared: false
}],
'react/react-in-jsx-scope': 'error',
'react/require-render-return': 'error',
'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/jsx-no-target-blank': ['error', { enforceDynamicLinks: 'always' }],
'react/jsx-filename-extension': ['error', { extensions: ['.jsx', '.tsx'] }],
'react/jsx-no-comment-textnodes': 'error',
'react/no-render-return-value': 'error',
'react/no-find-dom-node': 'error',
'react/no-danger-with-children': 'error',
'react/no-unused-prop-types': ['error', {
customValidators: [
],
skipShapeProps: true,
}],
'react/style-prop-object': 'error',
'react/no-unescaped-entities': 'error',
'react/no-children-prop': 'error',
'react/no-array-index-key': 'error',
'react/require-default-props': ['error', {
forbidDefaultForRequired: true,
}],
'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }],
'react/void-dom-elements-no-children': 'error',
'react/default-props-match-prop-types': ['error', { allowRequiredDefaults: false }],
'react/no-redundant-should-component-update': 'error',
'react/no-unused-state': 'error',
'react/no-typos': 'error',
'react/destructuring-assignment': ['error', 'always'],
'react/no-access-state-in-setstate': 'error',
'react/button-has-type': ['error', {
button: true,
submit: true,
reset: false,
}],
'react/no-this-in-sfc': 'error',
'react/jsx-fragments': ['error', 'syntax'],
'react/state-in-constructor': ['error', 'always'],
'react/static-property-placement': ['error', 'property assignment'],
'react/jsx-props-no-spreading': ['error', {
html: 'enforce',
custom: 'enforce',
explicitSpread: 'ignore',
exceptions: [],
}],
'react/jsx-no-script-url': ['error', [
{
name: 'Link',
props: ['to'],
},
]],
'react/jsx-no-useless-fragment': 'error',
'react/function-component-definition': ['error', {
namedComponents: ['function-declaration', 'function-expression'],
unnamedComponents: 'function-expression',
}],
'react/jsx-no-constructed-context-values': 'error',
'react/no-unstable-nested-components': 'error',
'react/no-namespace': 'error',
'react/prefer-exact-props': 'error',
'react/no-arrow-function-lifecycle': 'error',
'react/no-invalid-html-attribute': 'error',
'react/no-unused-class-component-methods': 'error',
'react/hook-use-state': 'error',
}
}