Skip to content

Commit 7ac20d6

Browse files
committed
Merge pull request airbnb#346 from justjake/jake/eslint-react
add eslint rules for JSX style from issue airbnb#345
2 parents 874fb87 + f87ddc0 commit 7ac20d6

2 files changed

Lines changed: 51 additions & 1 deletion

File tree

linters/.eslintrc

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"parser": "babel-eslint",
3+
"plugins": [
4+
"react"
5+
],
36
"env": {
47
"browser": true,
58
"node": true
@@ -164,6 +167,46 @@
164167
"space-before-function-paren": [2, "never"], // http://eslint.org/docs/rules/space-before-function-paren
165168
"space-infix-ops": 2, // http://eslint.org/docs/rules/space-infix-ops
166169
"space-return-throw-case": 2, // http://eslint.org/docs/rules/space-return-throw-case
167-
"spaced-line-comment": 2 // http://eslint.org/docs/rules/spaced-line-comment
170+
"spaced-line-comment": 2, // http://eslint.org/docs/rules/spaced-line-comment
171+
172+
/**
173+
* JSX style
174+
*/
175+
"react/display-name": 0,
176+
"react/jsx-boolean-value": 2,
177+
"react/jsx-quotes": [2, "double"],
178+
"react/jsx-no-undef": 2,
179+
"react/jsx-sort-props": 0,
180+
"react/jsx-sort-prop-types": 0,
181+
"react/jsx-uses-react": 2,
182+
"react/jsx-uses-vars": 2,
183+
"react/no-did-mount-set-state": [2, "allow-in-func"],
184+
"react/no-did-update-set-state": 2,
185+
"react/no-multi-comp": 2,
186+
"react/no-unknown-property": 2,
187+
"react/prop-types": 2,
188+
"react/react-in-jsx-scope": 2,
189+
"react/self-closing-comp": 2,
190+
"react/wrap-multilines": 2,
191+
"react/sort-comp": [2, {
192+
"order": [
193+
"displayName",
194+
"mixins",
195+
"statics",
196+
"propTypes",
197+
"getDefaultProps",
198+
"getInitialState",
199+
"componentWillMount",
200+
"componentDidMount",
201+
"componentWillReceiveProps",
202+
"shouldComponentUpdate",
203+
"componentWillUpdate",
204+
"componentWillUnmount",
205+
"/^on.+$/",
206+
"/^get.+$/",
207+
"/^render.+$/",
208+
"render"
209+
]
210+
}]
168211
}
169212
}

linters/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## `.eslintrc`
2+
3+
Our `.eslintrc` requires the following NPM packages packages:
4+
5+
- `eslint`
6+
- `babel-eslint`
7+
- `eslint-plugin-react`

0 commit comments

Comments
 (0)