Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [eslint]

The pluggable linting utility for JavaScript and related frameworks.

857 votes
23 answers
1.2m views

How to fix missing dependency warning when using useEffect React Hook

With React 16.8.6 (it was good on previous version 16.8.3), I get this error when I attempt to prevent an infinite loop on a fetch request: ./src/components/BusinessesList.js Line 51: React Hook ...
russ's user avatar
  • 8,613
1984 votes
14 answers
1.6m views

Turning off eslint rule for a specific line

In order to turn off linting rule for a particular line in JSHint we use the following rule: /* jshint ignore:start*/ $scope.someVar = ConstructorFunction(); /* jshint ignore:end */ I have been ...
runtimeZero's user avatar
  • 27.5k
168 votes
14 answers
233k views

ESLint - Configuring "no-unused-vars" for TypeScript

I use ESLint in all of my TypeScript projects with the following settings: "extends": ["airbnb", "prettier", 'plugin:vue/recommended'], "plugins": ["...
Rins's user avatar
  • 1,971
190 votes
2 answers
195k views

Understanding the React Hooks 'exhaustive-deps' lint rule

I'm having a hard time understanding the 'exhaustive-deps' lint rule. I already read this post and this post but I could not find an answer. Here is a simple React component with the lint issue: const ...
Logan Wlv's user avatar
  • 3,594
327 votes
19 answers
672k views

ESLint Parsing error: Unexpected token

With this code: import React from 'react'; import { Link } from 'react-router'; import { View, NavBar } from 'amazeui-touch'; import * as Pages from '../components'; const { Home, ...Components } =...
DongYao's user avatar
  • 3,311
10 votes
2 answers
4k views

404 Not Found when trying to install ESLint 8.4.4 with create-react-app

Whenever I try to run npx create-react-app my-app, it shows the error: npm ERR! code E404 npm ERR! 404 Not Found - GET https://registry.npmjs.org/@types/eslint/-/eslint-8.4.4.tgz - Not found npm ERR! ...
Manh Huynh Duc's user avatar
159 votes
19 answers
102k views

Line 0: Parsing error: Cannot read property 'map' of undefined

Currently starting up the server on my client side, the error above is what I have been getting. I am using TypeScript, ReactJS, ESLint. I can't seem to go forward since this error has been haunting ...
Jon Hernandez's user avatar
150 votes
18 answers
217k views

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 ...
Don P's user avatar
  • 62.5k
803 votes
19 answers
713k views

Turning off eslint rule for a specific file

Is it possible to turn off the eslint rule for the whole file? Something such as: // eslint-disable-file no-use-before-define (Analogous to eslint-disable-line.) It happens to me quite often, that ...
Tomas Kulich's user avatar
  • 15.3k
382 votes
29 answers
464k views

"parserOptions.project" has been set for @typescript-eslint/parser

I created a new React Native project with --template typescript I deleted the template directory which came as part of the boilerplate. I then proceeded to add ESLint: module.exports = { parser: &...
Dan's user avatar
  • 8,544
245 votes
25 answers
537k views

React eslint error missing in props validation

I have the next code, eslint throw: react/prop-types onClickOut; is missing in props validation react/prop-types children; is missing in props validation propTypes was defined but eslint does not ...
cristian camilo cedeño gallego's user avatar
161 votes
2 answers
113k views

Global variables in Javascript and ESLint

I have got multiple javascript files and I have defined some global variable in a file which loads before the others. As a consequence all of the files loaded after the first have access to the global ...
marco_sap's user avatar
  • 1,809
90 votes
29 answers
136k views

Error when deploying react app and it keeps sayings << Plugin "react" was conflicted between "package.json » eslint-config-react-app » >>

I have been having a little bit of issues when deploying my create react app, as it fails to compile and tells me Plugin "react" was conflicted between "package.json » eslint-config-...
Ruben's user avatar
  • 925
78 votes
7 answers
36k views

How do I configure ESLint to allow fat arrow class methods

ESLint is throwing a Parsing error: Unexpected token = error when I try to lint my Es6 classes. What configuration parameter am I missing to enable fat arrow class methods in eslint? Sample class: ...
CodeOcelot's user avatar
  • 3,483
51 votes
8 answers
22k views

Omit property variable when using object destructuring

Here is an example: const initObject = { a: 0, b: 0, c: 0 } const { a, ...rest } = initObject We're omitting property a from the object, but then const a is assigned a value, but never used - ...
Alexander Kim's user avatar

15 30 50 per page
1
2 3 4 5
42