Questions tagged [eslint]

The pluggable linting utility for JavaScript and related frameworks.

ESLint is a JavaScript linting tool.

It differs from other linters in that every rule is a separate plugin and you can add more during runtime.

User interface

ESLint is a CLI tool and runs directly from a terminal/command prompt. It may be used as a standalone tool or integrated with an automated task runner such as Grunt (through plugins such as eslint-grunt and grunt-eslint). It can also be integrated with majority of modern editors that support JavaScript. For the list of integrations see ESLint site

Resources


See also

6637 questions
165
votes
2 answers

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 MyCustomComponent = ({onChange}) => { const…
Logan Wlv
  • 3,274
  • 5
  • 32
  • 54
162
votes
7 answers

How to disable JavaScript build error in Visual Studio 2017?

I just updated Visual Studio 2017 from RC to final. I didn’t get the following error but recently I get this error. In building the project, I get the following error and it prevents the web project to start: Severity Code Description Project…
Mohammad Dayyan
  • 21,578
  • 41
  • 164
  • 232
162
votes
13 answers

How to avoid no-param-reassign when setting a property on a DOM object

I have a method which's main purpose is to set a property on a DOM object function (el) { el.expando = {}; } I use AirBnB's code style which makes ESLint throw a no-param-reassign error: error Assignment to function parameter 'el' …
Lukas
  • 9,752
  • 15
  • 76
  • 120
158
votes
18 answers

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 me. The GitHub page for ESLint hasn't been of much…
Jon Hernandez
  • 1,650
  • 3
  • 6
  • 6
154
votes
2 answers

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 variable. However ESLint shows the global…
marco_sap
  • 1,739
  • 2
  • 12
  • 12
152
votes
8 answers

JSX not allowed in files with extension ' .js' with eslint-config-airbnb

I've installed eslint-config-airbnb that is supposed to pre configure ESLINT for React: Our default export contains all of our ESLint rules, including ECMAScript 6+ and React. It requires eslint, eslint-plugin-import, eslint-plugin-react, and…
Mendes
  • 17,489
  • 35
  • 150
  • 263
149
votes
11 answers

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": ["prettier"], "parserOptions": { "parser": "@typescript-eslint/parser", "ecmaVersion":…
Rins
  • 1,771
  • 2
  • 13
  • 13
147
votes
6 answers

Component definition is missing display name react/display-name

How do I add a display name to this? export default () => ;
David
  • 3,488
  • 2
  • 21
  • 21
146
votes
4 answers

How is ESLint integrated into Create React App?

When I run npx create-react-app ..., a bare-bone React project is being created for me. When I then peek into package.json, there seems to be some evidence of ESLint to be present, as there is this: "eslintConfig": { "extends":…
typeduke
  • 6,494
  • 6
  • 25
  • 34
145
votes
5 answers

ESLint dollar($) is not defined. (no-undef)

$("#ID").hide(); i add ESLint to my project . everything is fine, except symbol $. i get error: [eslint] '$' is not defined. (no-undef) my .eslintrc.json (note: it has additional rules set to disallow jquery functions when there's an equivalent…
spbsmile
  • 1,555
  • 2
  • 10
  • 9
144
votes
13 answers

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 import React, {…
Don P
  • 60,113
  • 114
  • 300
  • 432
140
votes
1 answer

Javascript re-assign let variable with destructuring

In my React app I am using airbnb's eslint style guide which will throw an error if I do not use destructuing. In the situation below, I first use let to assign the two variables latitude and longitude to the coordinates of the first item in an…
Phil Mok
  • 3,860
  • 6
  • 24
  • 36
136
votes
9 answers

How to disable ESLint react/prop-types rule in a file?

I'm using React and ESLint with eslint-plugin-react. I want to disable the prop-types rule in one file. var React = require('react'); var Model = require('./ComponentModel'); var Component = React.createClass({ /* eslint-disable react/prop-types…
cuadraman
  • 14,964
  • 7
  • 27
  • 32
133
votes
10 answers

'v-slot' directive doesn't support any modifier

I am using vuetify's datatable, i this we have different slots with some props for example below I…
Dhiraj Wakchaure
  • 2,596
  • 6
  • 21
  • 37
133
votes
4 answers

Disable typescript-eslint plugin rule (no-explicit-any) with inline comment

I have an eslint error that comes from the @typescript-eslint plugin. Unexpected any. Specify a different type.eslint(@typescript-eslint/no-explicit-any) This is the no-implicit-any rule. In just one file I want to disable that rule with a comment…
cham
  • 8,666
  • 9
  • 48
  • 69