Skip to content
Advertisement

ESLint with React gives `no-unused-vars` errors

I’ve setup eslint & eslint-plugin-react.

When I run ESLint, the linter returns no-unused-vars errors for each React component.

I’m assuming it’s not recognizing that I’m using JSX or React syntax. Any ideas?

Example:

app.js

JavaScript

Linter Errors:

JavaScript

Here is my .eslintrc.json file:

JavaScript

Advertisement

Answer

First, install the following module npm install --save-dev eslint-plugin-react.

Then, in your .eslintrc.json, under extends, include the following plugin:

JavaScript

Source

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement