Skip to content

Commit

Permalink
Fix linting, using ShakaCode 13.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
justin808 committed Dec 25, 2016
1 parent 0f632e8 commit 924a7b0
Show file tree
Hide file tree
Showing 24 changed files with 49 additions and 43 deletions.
13 changes: 9 additions & 4 deletions docs/contributor-info/linters.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@ These linters support the [ShakaCode Style Guidelines](./style.md)

## Autofix!

If you haven't tried the autofix options for `jscs` and `rubocop`, you're seriously missing out!
If you haven't tried the autofix options for `eslint` and `rubocop`, you're seriously missing out!

1. Be **SURE** you have a clean git status, as you'll want to review what the autofix does to your code!
2. **Rubocop:** Be sure to be in the right directory where you have Ruby files, probably the top level of your Rails project.
```
rubocop -a
```

3. **JSCS:**: Be sure to be in the right directory where you have JS files.
3. **eslint:**: Be sure to be in the right directory where you have JS files.
```
jscs -x .
eslint --fix .
```

or

```
npm run lint -- --fix
```

Autofixing is a **HUGE** time saver!
Expand Down Expand Up @@ -60,5 +66,4 @@ You can disable all rules for a line or block, or only specific rules, as shown
* [ESLint quick start](http://untilfalse.com/eslint-quick-start/)
* [RuboCop](https://github.com/bbatsov/rubocop)
* [ESLint](http://eslint.org/)
* [JSCS](https://github.com/jscs-dev/node-jscs)

2 changes: 1 addition & 1 deletion docs/misc/doctrine.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Here's the chef's selection from the React on Rails community:

### JavaScript Tooling
* [Babel](https://babeljs.io/): Transpiler for ES6 into ES5 and much more.
* [EsLint](http://eslint.org/) and [Jsrc](http://jscs.info/): JavaScript linters.
* [EsLint](http://eslint.org/)
* [Webpack](http://webpack.github.io/): Generator of deployment assets and provider of hot module reloading.

By having a common set of tools, we can discuss what we should or shouldn't be using. Thus, this takes out the "JavaScript Fatigue" from having too many unclear choices in the JavaScript world.
Expand Down
1 change: 1 addition & 0 deletions node_package/tests/ComponentRegistry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* eslint-disable react/prefer-stateless-function */
/* eslint-disable react/jsx-filename-extension */
/* eslint-disable no-unused-vars */
/* eslint-disable import/extensions */

import test from 'tape';
import React from 'react';
Expand Down
3 changes: 0 additions & 3 deletions node_package/tests/buildConsoleReplay.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,11 @@ test('buildConsoleReplay wraps console replay in a script tag', (assert) => {
];
const actual = buildConsoleReplay();

// https://github.com/jscs-dev/node-jscs/issues/2137
// jscs:disable disallowSpacesInsideTemplateStringPlaceholders
const expected = `
<script>
console.log.apply(console, ["some message","{\\"a\\":1,\\"b\\":2}"]);
console.warn.apply(console, ["other message","{\\"c\\":3,\\"d\\":4}"]);
</script>`;

// jscs:enable disallowSpacesInsideTemplateStringPlaceholders
assert.equals(actual, expected, 'Unexpected value for console replay history');
});
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"babelify": "^7.3.0",
"blue-tape": "^1.0.0",
"eslint": "^3.12.2",
"eslint-config-shakacode": "^13.2.0",
"eslint-config-shakacode": "^13.2.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^3.0.2",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.8.0",
"flow-bin": "^0.37.4",
"jsdom": "^9.9.1",
Expand Down
4 changes: 0 additions & 4 deletions rakelib/docker.rake
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ namespace :docker do
sh "docker-compose run lint rake lint:eslint"
end

desc "Run jscs linter from docker"
task :jscs do
sh "docker-compose run lint rake lint:jscs"
end
desc "Run all linting from docker"
task :lint do
sh "docker-compose run lint rake lint"
Expand Down
1 change: 1 addition & 0 deletions spec/dummy/client/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ rules:
no-console: 0
import/no-unresolved: 0
import/no-extraneous-dependencies: 0
react/forbid-prop-types: 0
4 changes: 2 additions & 2 deletions spec/dummy/client/app/components/DeferredRender.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const DeferredRender = ({ children }) => (
<div>
<h1>Deferred Rendering</h1>
<p>
Here, we're testing async routes with server rendering.
Here, we&apos;re testing async routes with server rendering.
By deferring the initial render, we can prevent a client/server
checksum mismatch error.
</p>
Expand All @@ -21,7 +21,7 @@ const DeferredRender = ({ children }) => (
);

DeferredRender.propTypes = {
children: React.PropTypes.object,
children: React.PropTypes.node,
};

export default DeferredRender;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const DeferredRenderAsyncPage = () => (
<p>Noice! It works.</p>
<p>
Now, try reloading this page and looking at the developer console.
There shouldn't be any client/server mismatch error from React.
There shouldn&apos;t be any client/server mismatch error from React.
</p>
</div>
);
Expand Down
10 changes: 4 additions & 6 deletions spec/dummy/client/app/components/HelloWorld.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class HelloWorld extends React.Component {
name: PropTypes.string,
}).isRequired,
railsContext: PropTypes.object,

error: PropTypes.any,
};

// Not necessary if we only call super, but we'll need to initialize state, etc.
Expand All @@ -24,15 +22,15 @@ class HelloWorld extends React.Component {
this.handleChange = this.handleChange.bind(this);
}

setNameDomRef(nameDomNode) {
this.nameDomRef = nameDomNode;
}

handleChange() {
const name = this.nameDomRef.value;
this.setState({ name });
}

setNameDomRef(nameDomNode) {
this.nameDomRef = nameDomNode;
}

render() {
console.log('HelloWorld demonstrating a call to console.log in ' +
'spec/dummy/client/app/components/HelloWorld.jsx:18');
Expand Down
8 changes: 4 additions & 4 deletions spec/dummy/client/app/components/HelloWorldES5.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ const HelloWorldES5 = React.createClass({
return this.props.helloWorldData;
},

setNameDomRef(nameDomNode) {
this.nameDomRef = nameDomNode;
},

handleChange() {
const name = this.nameDomRef.value;
this.setState({ name });
},

setNameDomRef(nameDomNode) {
this.nameDomRef = nameDomNode;
},

render() {
const { name } = this.state;

Expand Down
8 changes: 4 additions & 4 deletions spec/dummy/client/app/components/HelloWorldRedux.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ export default class HelloWorldRedux extends React.Component {
this.handleChange = this.handleChange.bind(this);
}

setNameDomRef(nameDomNode) {
this.nameDomRef = nameDomNode;
}

handleChange() {
const name = this.nameDomRef.value;
this.props.actions.updateName(name);
}

setNameDomRef(nameDomNode) {
this.nameDomRef = nameDomNode;
}

render() {
const { data, railsContext } = this.props;
const { name } = data;
Expand Down
4 changes: 3 additions & 1 deletion spec/dummy/client/app/startup/ClientRouterApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ import { Router, browserHistory } from 'react-router';
import routes from '../routes/routes';

export default (props) => (
<Router history={browserHistory} children={routes} {...props} />
<Router history={browserHistory} {...props} >
{routes}
</Router>
);
6 changes: 3 additions & 3 deletions spec/dummy/client/app/startup/DeferredRenderAppRenderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { match, Router, browserHistory } from 'react-router';

import DeferredRender from '../components/DeferredRender';

const DeferredRenderAppRenderer = (props, railsContext, domNodeId) => {
const DeferredRenderAppRenderer = (_props, _railsContext, domNodeId) => {
const history = browserHistory;
const routes = {
path: '/deferred_render_with_server_rendering',
component: DeferredRender,
childRoutes: [{
path: '/deferred_render_with_server_rendering/async_page',
getComponent(nextState, callback) {
getComponent(_nextState, callback) {
require.ensure([], (require) => {
const component = require('../components/DeferredRenderAsyncPage').default;

Expand All @@ -26,7 +26,7 @@ const DeferredRenderAppRenderer = (props, railsContext, domNodeId) => {
// implements an asyncronous getComponent. Since we do server rendering for this
// component, immediately rendering a Router could cause a client/server
// checksum mismatch.
match({ history, routes }, (error, redirectionLocation, routerProps) => {
match({ history, routes }, (error, _redirectionLocation, routerProps) => {
if (error) {
throw error;
}
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/client/app/startup/DeferredRenderAppServer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { match, RouterContext } from 'react-router';
import DeferredRender from '../components/DeferredRender';
import DeferredRenderAsyncPage from '../components/DeferredRenderAsyncPage';

const DeferredRenderAppServer = (props, railsContext) => {
const DeferredRenderAppServer = (_props, railsContext) => {
let error;
let redirectLocation;
let routerProps;
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/client/app/startup/ManualRenderAppRenderer.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom';

export default (props, railsContext, domNodeId) => {
export default (_props, _railsContext, domNodeId) => {
const reactElement = (
<div>
<h1>Manual Render Example</h1>
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/client/app/startup/ServerRouterApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { match, RouterContext } from 'react-router';

import routes from '../routes/routes';

export default (props, railsContext) => {
export default (_props, railsContext) => {
let error;
let redirectLocation;
let routeProps;
Expand Down
4 changes: 2 additions & 2 deletions spec/dummy/client/app/stores/SharedReduxStore.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import reducers from '../reducers/reducersIndex';
*/
export default (props, railsContext) => {
const combinedReducer = combineReducers(reducers);
props.railsContext = railsContext;
return applyMiddleware(middleware)(createStore)(combinedReducer, props);
const newProps = { ...props, railsContext };
return applyMiddleware(middleware)(createStore)(combinedReducer, newProps);
};
6 changes: 4 additions & 2 deletions spec/dummy/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@
"babel-plugin-react-transform": "^2.0.2",
"body-parser": "^1.15.2",
"eslint": "^3.8.1",
"eslint-config-shakacode": "^6.0.0",
"eslint-plugin-react": "^6.4.1",
"eslint-config-shakacode": "^13.2.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.8.0",
"fbjs": "^0.8.5",
"jsdom": "^9.8.0",
"react-transform-hmr": "^1.0.4",
Expand Down
1 change: 1 addition & 0 deletions spec/dummy/client/server-rails-hot.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint no-var: 0, no-console: 0, import/no-extraneous-dependencies: 0 */
/* eslint-disable comma-dangle */

// This file is used by the npm script:
// "hot-assets": "babel-node server-rails-hot.js"
Expand Down
1 change: 0 additions & 1 deletion spec/dummy/client/tests

This file was deleted.

2 changes: 2 additions & 0 deletions spec/dummy/client/webpack.client.rails.build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// cd client && npm run build:client
// Note that Foreman (Procfile.dev) has also been configured to take care of this.

/* eslint-disable comma-dangle */

const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');

Expand Down
1 change: 1 addition & 0 deletions spec/dummy/client/webpack.client.rails.hot.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// rails s
// cd client && babel-node server-rails-hot.js
// Note that Foreman (Procfile.dev) has also been configured to take care of this.
/* eslint-disable comma-dangle */

const path = require('path');
const webpack = require('webpack');
Expand Down
1 change: 1 addition & 0 deletions spec/dummy/client/webpack.server.rails.build.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Common webpack configuration for server bundle
/* eslint-disable comma-dangle */

const webpack = require('webpack');
const path = require('path');
Expand Down

0 comments on commit 924a7b0

Please sign in to comment.