Skip to content

Commit

Permalink
Update linters to conform to ShakaCode standards
Browse files Browse the repository at this point in the history
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
  • Loading branch information
robwise committed Nov 23, 2015
1 parent 4f5c51b commit 3573d80
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
@@ -1,3 +1,5 @@
node_modules
coverage
spec/react_on_rails/dummy-for-generators
spec/dummy
spec/dummy-react-013
35 changes: 33 additions & 2 deletions .eslintrc
Expand Up @@ -6,12 +6,43 @@ extends: eslint-config-airbnb
plugins:
- react

globals:
__DEBUG_SERVER_ERRORS__: true
__SERVER_ERRORS__: true

env:
browser: true
node: true
mocha: true

rules:
### Variables
no-undef: 2
no-unused-vars: [2, { vars: all, args: none }]

### Stylistic issues
indent: [1, 2, { SwitchCase: 1, VariableDeclarator: 2 }]
react/sort-comp: 0
react/jsx-quotes: 0
id-length: [1, { min: 2, exceptions: [_, e, i, k, v] }]

### React
jsx-quotes: [1, prefer-double]
react/display-name: 0
react/jsx-boolean-value: [1, always]
react/jsx-curly-spacing: [1, never]
react/jsx-no-duplicate-props: [2, { ignoreCase: true }]
react/jsx-no-undef: 2
react/jsx-sort-prop-types: 0
react/jsx-sort-props: 0
react/jsx-uses-react: 2
react/jsx-uses-vars: 2
react/no-danger: 0
react/no-did-mount-set-state: 1
react/no-did-update-set-state: 0
react/no-multi-comp: 2
react/no-unknown-property: 2
react/prop-types: 1
react/react-in-jsx-scope: 2
react/require-extension: [1, { extensions: [.js, .jsx] }]
react/self-closing-comp: 2
react/sort-comp: 0 # Should be 1. `statics` should be on top.
react/wrap-multilines: 2
27 changes: 23 additions & 4 deletions .jscsrc
@@ -1,7 +1,26 @@
{
"preset": "airbnb",
"fileExtensions": [".js", ".jsx"],
"excludeFiles": ["**/build/**", "**/node_modules/**", "**/generated/**", "**/docs/**", "**/tmp/**", "**/sample_generated/**", "**/coverage/**", "**/vendor/**", "**/dummy-for-generators/**"],
"requireTrailingComma": { "ignoreSingleValue": true, "ignoreSingleLine": true },
"validateQuoteMarks": false
"fileExtensions": [
".js",
".jsx"
],
"excludeFiles": [
"**/build/**",
"**/node_modules/**",
"**/generated/**",
"**/docs/**",
"**/tmp/**",
"**/sample_generated/**",
"**/coverage/**",
"**/vendor/**",
"**/dummy-for-generators/**",
"**/dummy/**",
"**/dummy-react-013/**"
],
"esprima": "babel-jscs",
"validateQuoteMarks": {
"mark": "'",
"escape": true,
"ignoreJSX": true
}
}
Expand Up @@ -76,8 +76,8 @@ if %w(development test).include? Rails.env
<%- end -%>

<%- enabled_linters = [] -%>
<%- enabled_linters << %i(rubocop ruby) if options.ruby_linters? -%>
<%- enabled_linters << %i(js scss) unless options.skip_js_linters? -%>
<%- enabled_linters << %i(rubocop ruby scss) if options.ruby_linters? -%>
<%- enabled_linters << %i(js) unless options.skip_js_linters? -%>
task lint: <%= enabled_linters.flatten %> do
puts "Completed all linting"
end
Expand Down
Expand Up @@ -6,12 +6,43 @@ extends: eslint-config-airbnb
plugins:
- react

globals:
__DEBUG_SERVER_ERRORS__: true
__SERVER_ERRORS__: true

env:
browser: true
node: true
mocha: true

rules:
### Variables
no-undef: 2
no-unused-vars: [2, { vars: all, args: none }]

### Stylistic issues
indent: [1, 2, { SwitchCase: 1, VariableDeclarator: 2 }]
react/sort-comp: 0
react/jsx-quotes: 1
id-length: [2, {"exceptions": ["e", "i", "_"]}]
id-length: [1, { min: 2, exceptions: [_, e, i, k, v] }]

### React
jsx-quotes: [1, prefer-double]
react/display-name: 0
react/jsx-boolean-value: [1, always]
react/jsx-curly-spacing: [1, never]
react/jsx-no-duplicate-props: [2, { ignoreCase: true }]
react/jsx-no-undef: 2
react/jsx-sort-prop-types: 0
react/jsx-sort-props: 0
react/jsx-uses-react: 2
react/jsx-uses-vars: 2
react/no-danger: 0
react/no-did-mount-set-state: 1
react/no-did-update-set-state: 0
react/no-multi-comp: 2
react/no-unknown-property: 2
react/prop-types: 1
react/react-in-jsx-scope: 2
react/require-extension: [1, { extensions: [.js, .jsx] }]
react/self-closing-comp: 2
react/sort-comp: 0 # Should be 1. `statics` should be on top.
react/wrap-multilines: 2
19 changes: 15 additions & 4 deletions lib/generators/react_on_rails/templates/js_linters/client/.jscsrc
@@ -1,7 +1,18 @@
{
"preset": "airbnb",
"fileExtensions": [".js", ".jsx"],
"excludeFiles": ["build/**", "node_modules/**"],

"validateQuoteMarks": null // Issue with JSX quotemarks: https://github.com/jscs-dev/babel-jscs/issues/12
"fileExtensions": [
".js",
".jsx"
],
"excludeFiles": [
"assets/**",
"build/**",
"node_modules/**"
],
"esprima": "babel-jscs",
"validateQuoteMarks": {
"mark": "'",
"escape": true,
"ignoreJSX": true
}
}
Expand Up @@ -31,7 +31,7 @@ export default class HelloWorldWidget extends React.Component {
</h3>
<p>
Say hello to:
<input type="text" ref="name" value={this.props.name} onChange={this._handleChange} />
<input type="text" value={this.props.name} onChange={this._handleChange} />
</p>
</div>
);
Expand Down
@@ -1,5 +1,4 @@
/* eslint no-console: 0 */
import _ from 'lodash';

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

0 comments on commit 3573d80

Please sign in to comment.