So now that we have ES6 and JSX, our JSHint linter no longer works and throws all sortes of crazy errors. However, there is something called ESLint we can use instead.
To install this in Atom (do this part once):
- First disable JSHint if you installed it. Go to settings (
CMD
+,
) -> Packages -> search for JSHint and click "Disable" - In the console, run the command
apm install linter
- In the console, run the command
apm install linter-eslint
For each project (as far as I can tell):
- In the console run,
npm i --save-dev eslint eslint-plugin-react eslint-config-google
- Copy the .eslintrc.json file provided to the root folder. (Note: This file can be edited to change the options for how the linter works and what it throws flags for.)
- Quit Atom and restart. (Note: Quitting Atom may not always be necessary. I've had some success with just closing and reopening the file or saving the file to initiate linting)
- Is a single line ok, but still giving your problems? Add
// eslint-disable-line
after the offending line. For example, I keep getting a lint error forimport React from 'react';
because we never use the variableReact
. Making the line like this:import React from 'react'; // eslint-disable-line
gets rid of the error.