Skip to content

Commit a8316df

Browse files
Web-Go-ToWeb-Go-To
authored andcommitted
Update linters to conform to ShakaCode standards
This change is in parallel with the change made for the webpack tutorial. See shakacode/react-webpack-rails-tutorial#159 - Fix generator linters templating logic for scss task - Remove unnecessary lodash import in generated loggerMiddleware - Exclude dummy apps from linting - Remove unnecessary 'refs' attribute in generated component - Add dummy apps to eslintignore
1 parent 63c7a89 commit a8316df

File tree

8 files changed

+110
-17
lines changed

8 files changed

+110
-17
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
node_modules
22
coverage
33
spec/react_on_rails/dummy-for-generators
4+
spec/dummy
5+
spec/dummy-react-013

.eslintrc

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,43 @@ extends: eslint-config-airbnb
66
plugins:
77
- react
88

9+
globals:
10+
__DEBUG_SERVER_ERRORS__: true
11+
__SERVER_ERRORS__: true
12+
913
env:
1014
browser: true
1115
node: true
16+
mocha: true
1217

1318
rules:
19+
### Variables
20+
no-undef: 2
21+
no-unused-vars: [2, { vars: all, args: none }]
22+
23+
### Stylistic issues
1424
indent: [1, 2, { SwitchCase: 1, VariableDeclarator: 2 }]
15-
react/sort-comp: 0
16-
react/jsx-quotes: 0
1725
id-length: [1, { min: 2, exceptions: [_, e, i, k, v] }]
26+
27+
### React
28+
jsx-quotes: [1, prefer-double]
29+
react/display-name: 0
30+
react/jsx-boolean-value: [1, always]
31+
react/jsx-curly-spacing: [1, never]
32+
react/jsx-no-duplicate-props: [2, { ignoreCase: true }]
33+
react/jsx-no-undef: 2
34+
react/jsx-sort-prop-types: 0
35+
react/jsx-sort-props: 0
36+
react/jsx-uses-react: 2
37+
react/jsx-uses-vars: 2
38+
react/no-danger: 0
39+
react/no-did-mount-set-state: 1
40+
react/no-did-update-set-state: 0
41+
react/no-multi-comp: 2
42+
react/no-unknown-property: 2
43+
react/prop-types: 1
44+
react/react-in-jsx-scope: 2
45+
react/require-extension: [1, { extensions: [.js, .jsx] }]
46+
react/self-closing-comp: 2
47+
react/sort-comp: 0 # Should be 1. `statics` should be on top.
48+
react/wrap-multilines: 2

.jscsrc

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
11
{
22
"preset": "airbnb",
3-
"fileExtensions": [".js", ".jsx"],
4-
"excludeFiles": ["**/build/**", "**/node_modules/**", "**/generated/**", "**/docs/**", "**/tmp/**", "**/sample_generated/**", "**/coverage/**", "**/vendor/**", "**/dummy-for-generators/**"],
5-
"requireTrailingComma": { "ignoreSingleValue": true, "ignoreSingleLine": true },
6-
"validateQuoteMarks": false
3+
"fileExtensions": [
4+
".js",
5+
".jsx"
6+
],
7+
"excludeFiles": [
8+
"**/build/**",
9+
"**/node_modules/**",
10+
"**/generated/**",
11+
"**/docs/**",
12+
"**/tmp/**",
13+
"**/sample_generated/**",
14+
"**/coverage/**",
15+
"**/vendor/**",
16+
"**/dummy-for-generators/**",
17+
"**/dummy/**",
18+
"**/dummy-react-013/**"
19+
],
20+
"esprima": "babel-jscs",
21+
"validateQuoteMarks": {
22+
"mark": "'",
23+
"escape": true,
24+
"ignoreJSX": true
25+
}
726
}

lib/generators/react_on_rails/templates/base/base/lib/tasks/linters.rake.tt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ if %w(development test).include? Rails.env
7676
<%- end -%>
7777

7878
<%- enabled_linters = [] -%>
79-
<%- enabled_linters << %i(rubocop ruby) if options.ruby_linters? -%>
80-
<%- enabled_linters << %i(js scss) unless options.skip_js_linters? -%>
79+
<%- enabled_linters << %i(rubocop ruby scss) if options.ruby_linters? -%>
80+
<%- enabled_linters << %i(js) unless options.skip_js_linters? -%>
8181
task lint: <%= enabled_linters.flatten %> do
8282
puts "Completed all linting"
8383
end

lib/generators/react_on_rails/templates/js_linters/client/.eslintrc

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,43 @@ extends: eslint-config-airbnb
66
plugins:
77
- react
88

9+
globals:
10+
__DEBUG_SERVER_ERRORS__: true
11+
__SERVER_ERRORS__: true
12+
913
env:
1014
browser: true
1115
node: true
16+
mocha: true
1217

1318
rules:
19+
### Variables
20+
no-undef: 2
21+
no-unused-vars: [2, { vars: all, args: none }]
22+
23+
### Stylistic issues
1424
indent: [1, 2, { SwitchCase: 1, VariableDeclarator: 2 }]
15-
react/sort-comp: 0
16-
react/jsx-quotes: 1
17-
id-length: [2, {"exceptions": ["e", "i", "_"]}]
25+
id-length: [1, { min: 2, exceptions: [_, e, i, k, v] }]
26+
27+
### React
28+
jsx-quotes: [1, prefer-double]
29+
react/display-name: 0
30+
react/jsx-boolean-value: [1, always]
31+
react/jsx-curly-spacing: [1, never]
32+
react/jsx-no-duplicate-props: [2, { ignoreCase: true }]
33+
react/jsx-no-undef: 2
34+
react/jsx-sort-prop-types: 0
35+
react/jsx-sort-props: 0
36+
react/jsx-uses-react: 2
37+
react/jsx-uses-vars: 2
38+
react/no-danger: 0
39+
react/no-did-mount-set-state: 1
40+
react/no-did-update-set-state: 0
41+
react/no-multi-comp: 2
42+
react/no-unknown-property: 2
43+
react/prop-types: 1
44+
react/react-in-jsx-scope: 2
45+
react/require-extension: [1, { extensions: [.js, .jsx] }]
46+
react/self-closing-comp: 2
47+
react/sort-comp: 0 # Should be 1. `statics` should be on top.
48+
react/wrap-multilines: 2
Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
{
22
"preset": "airbnb",
3-
"fileExtensions": [".js", ".jsx"],
4-
"excludeFiles": ["build/**", "node_modules/**"],
5-
6-
"validateQuoteMarks": null // Issue with JSX quotemarks: https://github.com/jscs-dev/babel-jscs/issues/12
3+
"fileExtensions": [
4+
".js",
5+
".jsx"
6+
],
7+
"excludeFiles": [
8+
"assets/**",
9+
"build/**",
10+
"node_modules/**"
11+
],
12+
"esprima": "babel-jscs",
13+
"validateQuoteMarks": {
14+
"mark": "'",
15+
"escape": true,
16+
"ignoreJSX": true
17+
}
718
}

lib/generators/react_on_rails/templates/no_redux/base/client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default class HelloWorldWidget extends React.Component {
3131
</h3>
3232
<p>
3333
Say hello to:
34-
<input type="text" ref="name" value={this.props.name} onChange={this._handleChange} />
34+
<input type="text" value={this.props.name} onChange={this._handleChange} />
3535
</p>
3636
</div>
3737
);

lib/generators/react_on_rails/templates/redux/base/client/app/lib/middlewares/loggerMiddleware.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint no-console: 0 */
2-
import _ from 'lodash';
32

43
// This logger should be configured not to run in a production environment.
54
// See https://github.com/petehunt/webpack-howto#6-feature-flags for you might turn this off for production.

0 commit comments

Comments
 (0)