Setting up ESLint in React

Ross Whitehouse
Apr 13, 2018 · 5 min read

Starting a New React App

Installing ESLint

import React from 'react';
import Header from './components/Header';
const App = () => {
return (
<div>
<Header />
</div>
);
};
export default App;
1:8  warning  'React' is defined but never used   no-unused-vars
2:8 warning 'Header' is defined but never used no-unused-vars

Linting a React App

"extends": [
"eslint:recommended",
"plugin:react/recommended"
]
import Blank from './';
3:8  warning  'Blank' is defined but never used  no-unused-vars

Bonus Ball #1: npm script

"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"lint": "eslint src/**/*.js src/**/*.jsx"
}

Bonus Ball #2: ESLint Rules

Going Forward

Ross Whitehouse

Written by

Web Developer. Into podcasts, punk music, movies and video games.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade