Skip to content

Commit 5cbf303

Browse files
authored
Better react (#24)
* feat(react): support 6.8.0 * feat(react): second draft ruleset
1 parent d5aa706 commit 5cbf303

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
"devDependencies": {
3535
"chai": "^3.5.0",
3636
"eslint": "~3.12.1",
37-
"eslint-plugin-react": "^6.7.1",
37+
"eslint-plugin-react": "~6.8.0",
3838
"mocha": "^3.0.0"
3939
},
4040
"peerDependencies": {
41-
"eslint": ">=3.9.0",
42-
"eslint-plugin-react": "^6.7.1"
41+
"eslint": ">=3.12.1",
42+
"eslint-plugin-react": ">=6.8.0"
4343
}
4444
}

react.js

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,34 @@ module.exports = {
2727
'react/display-name': 1, // Prevent missing displayName in a React component definition
2828
'react/forbid-component-props': 0, // Forbid certain props on Components
2929
'react/forbid-prop-types': 0, // Forbid certain propTypes
30-
'react/no-children-prop': 0, // Prevent passing children as props
31-
'react/no-danger': 0, // Prevent usage of dangerous JSX properties
32-
'react/no-danger-with-children': 0, // Prevent problem with children and props.dangerouslySetInnerHTML
30+
'react/no-array-index-key': 1, // Prevent using Array index in `key` props
31+
'react/no-children-prop': 1, // Prevent passing children as props
32+
'react/no-danger': 1, // Prevent usage of dangerous JSX properties
33+
'react/no-danger-with-children': 1, // Prevent problem with children and props.dangerouslySetInnerHTML
3334
'react/no-deprecated': 1, // Prevent usage of deprecated methods
34-
'react/no-did-mount-set-state': 0, // Prevent usage of setState in componentDidMount
35-
'react/no-did-update-set-state': 0, // Prevent usage of setState in componentDidUpdate
36-
'react/no-direct-mutation-state': 1, // Prevent direct mutation of this.state
35+
'react/no-did-mount-set-state': 1, // Prevent usage of setState in componentDidMount
36+
'react/no-did-update-set-state': 1, // Prevent usage of setState in componentDidUpdate
37+
'react/no-direct-mutation-state': 2, // Prevent direct mutation of this.state
3738
'react/no-find-dom-node': 1, // Prevent usage of findDOMNode
3839
'react/no-is-mounted': 1, // Prevent usage of isMounted
39-
'react/no-multi-comp': 0, // Prevent multiple component definition per file
40+
'react/no-multi-comp': [1, { ignoreStateless: true }], // Prevent multiple component definition per file
4041
'react/no-render-return-value': 1, // Prevent usage of the return value of React.render
4142
'react/no-set-state': 0, // Prevent usage of setState
42-
'react/no-string-refs': 0, // Prevent using string references in ref attribute.
43+
'react/no-string-refs': 1, // Prevent using string references in ref attribute.
4344
'react/no-unescaped-entities': 0, // Prevent invalid characters from appearing in markup
4445
'react/no-unknown-property': 1, // Prevent usage of unknown DOM property (fixable)
45-
'react/no-unused-prop-types': 0, // Prevent definitions of unused prop types
46+
'react/no-unused-prop-types': 1, // Prevent definitions of unused prop types
4647
'react/prefer-es6-class': 0, // Enforce ES5 or ES6 class for React Components
47-
'react/prefer-stateless-function': 0, // Enforce stateless React Components to be written as a pure function
48-
'react/prop-types': 1, // Prevent missing props validation in a React component definition
49-
'react/react-in-jsx-scope': 1, // Prevent missing React when using JSX
48+
'react/prefer-stateless-function': 1, // Enforce stateless React Components to be written as a pure function
49+
'react/prop-types': 0, // Prevent missing props validation in a React component definition
50+
'react/react-in-jsx-scope': 1, // Prevent missing React when using JSX,
51+
'react/require-default-props': 1, // Enforce a defaultProps definition for every prop that is not a required prop
5052
'react/require-optimization': 0, // Enforce React components to have a shouldComponentUpdate method
5153
'react/require-render-return': 1, // Enforce ES5 or ES6 class for returning value in render function
52-
'react/self-closing-comp': 0, // Prevent extra closing tags for components without children (fixable)
54+
'react/self-closing-comp': 1, // Prevent extra closing tags for components without children (fixable)
5355
'react/sort-comp': 0, // Enforce component methods order
5456
'react/sort-prop-types': 0, // Enforce propTypes declarations alphabetical sorting
55-
'react/style-prop-object': 0, // Enforce style prop value being an object
57+
'react/style-prop-object': 1, // Enforce style prop value being an object
5658

5759
// JSX-specific rules
5860

@@ -61,24 +63,24 @@ module.exports = {
6163
'react/jsx-curly-spacing': 0, // Enforce or disallow spaces inside of curly braces in JSX attributes (fixable)
6264
'react/jsx-equals-spacing': 0, // Enforce or disallow spaces around equal signs in JSX attributes (fixable)
6365
'react/jsx-filename-extension': 0, // Restrict file extensions that may contain JSX
64-
'react/jsx-first-prop-new-line': 0, // Enforce position of the first prop in JSX (fixable)
66+
'react/jsx-first-prop-new-line': [1, 'multiline-multiprop'], // Enforce position of the first prop in JSX (fixable)
6567
'react/jsx-handler-names': 0, // Enforce event handler naming conventions in JSX
6668
'react/jsx-indent': 0, // Validate JSX indentation (fixable)
6769
'react/jsx-indent-props': 0, // Validate props indentation in JSX (fixable)
68-
'react/jsx-key': 0, // Validate JSX has key prop when in array or iterator
70+
'react/jsx-key': 1, // Validate JSX has key prop when in array or iterator
6971
'react/jsx-max-props-per-line': 0, // Limit maximum of props on a single line in JSX
7072
'react/jsx-no-bind': 0, // Prevent usage of .bind() and arrow functions in JSX props
71-
'react/jsx-no-comment-textnodes': 0, // Prevent comments from being inserted as text nodes
73+
'react/jsx-no-comment-textnodes': 1, // Prevent comments from being inserted as text nodes
7274
'react/jsx-no-duplicate-props': 1, // Prevent duplicate props in JSX
7375
'react/jsx-no-literals': 0, // Prevent usage of unwrapped JSX strings
74-
'react/jsx-no-target-blank': 0, // Prevent usage of unsafe target='_blank'
76+
'react/jsx-no-target-blank': 1, // Prevent usage of unsafe target='_blank'
7577
'react/jsx-no-undef': 1, // Disallow undeclared variables in JSX
76-
'react/jsx-pascal-case': 0, // Enforce PascalCase for user-defined JSX components
78+
'react/jsx-pascal-case': 1, // Enforce PascalCase for user-defined JSX components
7779
'react/jsx-sort-props': 0, // Enforce props alphabetical sorting
7880
'react/jsx-space-before-closing': 0, // Validate spacing before closing bracket in JSX (fixable)
79-
'react/jsx-tag-spacing': 0, // Validate whitespace in and around the JSX opening and closing brackets (fixable)
81+
'react/jsx-tag-spacing': 1, // Validate whitespace in and around the JSX opening and closing brackets (fixable)
8082
'react/jsx-uses-react': 1, // Prevent React to be incorrectly marked as unused
8183
'react/jsx-uses-vars': 1, // Prevent variables used in JSX to be incorrectly marked as unused
82-
'react/jsx-wrap-multilines': 0, // Prevent missing parentheses around multilines JSX (fixable)
84+
'react/jsx-wrap-multilines': 1, // Prevent missing parentheses around multilines JSX (fixable)
8385
}
8486
};

0 commit comments

Comments
 (0)