Skip to content

Commit b294e7c

Browse files
committed
add missing rules from eslint-plugin-react
1 parent fcd1c1d commit b294e7c

File tree

1 file changed

+35
-0
lines changed
  • packages/eslint-config-airbnb/rules

1 file changed

+35
-0
lines changed

packages/eslint-config-airbnb/rules/react.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ module.exports = {
55
'ecmaFeatures': {
66
'jsx': true
77
},
8+
// View link below for react rules documentation
9+
// https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules
810
'rules': {
911
// Prevent missing displayName in a React component definition
1012
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md
1113
'react/display-name': 0,
14+
// Forbid certain propTypes (any, array, object)
15+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md
16+
'react/forbid-prop-types': [0, {'forbid': ['any', 'array', 'object']}],
1217
// Enforce boolean attributes notation in JSX
1318
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
1419
'react/jsx-boolean-value': [2, 'never'],
@@ -18,18 +23,36 @@ module.exports = {
1823
// Enforce or disallow spaces inside of curly braces in JSX attributes
1924
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md
2025
'react/jsx-curly-spacing': 0,
26+
// Enforce event handler naming conventions in JSX
27+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md
28+
'react/jsx-handler-names': [0, {
29+
'eventHandlerPrefix': 'handle',
30+
'eventHandlerPropPrefix': 'on',
31+
}],
2132
// Validate props indentation in JSX
2233
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md
2334
'react/jsx-indent-props': [2, 2],
35+
// Validate JSX has key prop when in array or iterator
36+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md
37+
'react/jsx-key': 0,
38+
// Limit maximum of props on a single line in JSX
39+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md
40+
'react/jsx-max-props-per-line': [0, {'maximum': 1}],
2441
// Prevent usage of .bind() and arrow functions in JSX props
2542
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
2643
'react/jsx-no-bind': 2,
2744
// Prevent duplicate props in JSX
2845
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
2946
'react/jsx-no-duplicate-props': 0,
47+
// Prevent usage of unwrapped JSX strings
48+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md
49+
'react/jsx-no-literals': 0,
3050
// Disallow undeclared variables in JSX
3151
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md
3252
'react/jsx-no-undef': 2,
53+
// Enforce PascalCase for user-defined JSX components
54+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
55+
'react/jsx-pascal-case': 0,
3356
// Enforce propTypes declarations alphabetical sorting
3457
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-prop-types.md
3558
'react/jsx-sort-prop-types': 0,
@@ -45,18 +68,30 @@ module.exports = {
4568
// Prevent usage of dangerous JSX properties
4669
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger.md
4770
'react/no-danger': 0,
71+
// Prevent usage of deprecated methods
72+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md
73+
'react/no-deprecated': [1, {"react": "0.14.0"}],
4874
// Prevent usage of setState in componentDidMount
4975
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md
5076
'react/no-did-mount-set-state': [2, 'allow-in-func'],
5177
// Prevent usage of setState in componentDidUpdate
5278
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md
5379
'react/no-did-update-set-state': [2, 'allow-in-func'],
80+
// Prevent direct mutation of this.state
81+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md
82+
'react/no-direct-mutation-state': 0,
5483
// Prevent usage of isMounted
5584
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md
5685
'react/no-is-mounted': 2,
5786
// Prevent multiple component definition per file
5887
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md
5988
'react/no-multi-comp': 2,
89+
// Prevent usage of setState
90+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-set-state.md
91+
'react/no-set-state': 0,
92+
// Prevent using string references
93+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md
94+
'react/no-string-refs': 0,
6095
// Prevent usage of unknown DOM property
6196
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
6297
'react/no-unknown-property': 2,

0 commit comments

Comments
 (0)