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
241
votes
7 answers

ESLint: TypeError: this.libOptions.parse is not a function

I was getting started with Next.js on WebStorm 2022.2.1 Build #WS-222.3739.57. I created a new Next.js project with TypeScript enabled, and that's all. The error is shown below: TypeError: this.libOptions.parse is not a function TypeError:…
Thebluedragon
  • 2,564
  • 2
  • 4
  • 13
228
votes
6 answers

ESLint - "window" is not defined. How to allow global variables in package.json

I am assigning a property to the global window object, but when I run eslint, I get this: "window" is not defined I see this here in the eslint docs: the following defines window as a global variable for code that should not trigger the rule…
chevin99
  • 4,946
  • 7
  • 24
  • 32
219
votes
2 answers

How to disable multiple rules for eslint nextline

I have this code: const subTotal = orderInfo.details.reduce((acc, cv) => acc += Number(cv.price) * Number(cv.quantity), 0); I want to disable two ESLint types of checks for this line, no-return-assign and no-param-reassign. I tried it this way: /*…
shubham choudhary
  • 2,670
  • 5
  • 13
  • 16
208
votes
15 answers

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 recognize it. import React, { Component, PropTypes…
206
votes
1 answer

What's the difference between prettier-eslint, eslint-plugin-prettier and eslint-config-prettier?

I want to use Prettier and ESLint together, but I experienced some conflicts just by using them one after another. I see that there are these three packages that seem to allow them to be used in tandem: prettier-eslint eslint-plugin-prettier…
Yangshun Tay
  • 49,270
  • 33
  • 114
  • 141
201
votes
10 answers

ESLint - 'process' is not defined

I am using ESLinter for a simple node project. Below is the only code I have in index.js: const express = require('express'); const app = express(); app.get('/', (req, res) => { res.send({ hi: 'there' }); }); const PORT =…
ArunKolhapur
  • 5,805
  • 4
  • 18
  • 31
198
votes
35 answers

ESLint not working in VS Code?

ESLint is not working for me in VS Code. I have the plugin installed in VS Code, and ESLint itself as a developer dependency in my package.json, which I have installed as well. I modified the following option in the VS Code User Settings: { …
John Landon
  • 2,121
  • 2
  • 12
  • 11
195
votes
10 answers

Typescript eslint - Missing file extension "ts" import/extensions

I have a simple Node/Express app made with Typescript. And eslint give me the error Missing file extension "ts" for "./lib/env" import/extensions Here is my .eslintrc file { "extends": [ "airbnb", …
Nolat
  • 2,081
  • 2
  • 6
  • 8
195
votes
5 answers

ESLint Unexpected use of isNaN

I'm trying to use the isNaN global function inside an arrow function in a Node.js module but I'm getting this error: [eslint] Unexpected use of 'isNaN'. (no-restricted-globals) This is my code: const isNumber = value =>…
Elias Garcia
  • 6,772
  • 11
  • 34
  • 62
191
votes
13 answers

ESLint - Error: Must use import to load ES Module

I am currently setting up a boilerplate with React, TypeScript, styled components, Webpack, etc., and I am getting an error when trying to run ESLint: Error: Must use import to load ES Module Here is a more verbose version of the…
red house 87
  • 1,837
  • 9
  • 50
  • 99
188
votes
6 answers

module is not defined and process is not defined in eslint in visual studio code

I have installed eslint in my machine and i have used visual studio code i have certain modules and process to be exported When i try to use "module" or "process" it shows it was working fine before. [eslint] 'module' is not defined.…
MaTHwoG
  • 1,911
  • 2
  • 7
  • 11
186
votes
17 answers

'React' was used before it was defined

I am working with create-react-app + typescript + eslint application and during build have such error: Line 1:8: 'React' was used before it was defined @typescript-eslint/no-use-before-define Code in my component starts with: import React from…
Alexey Nazarov
  • 2,289
  • 2
  • 12
  • 13
174
votes
6 answers

Eslint says all enums in Typescript app are "already declared in the upper scope"

Starting a new application, I installed eslint and configured it with the following configs, but every time I create an enum it says it had already been defined. Even nonsense strings. Other variable types (const, var, let) don't have this issue. I…
Adam James
  • 3,833
  • 6
  • 28
  • 47
174
votes
6 answers

How to run eslint --fix from npm script

I am trying to add lint-fix in my package.json. My basic lint is "lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs" I did try "lint-fix": "eslint --fix --ext .js,.vue src test/unit/specs test/e2e/specs" but it is throwing my errors…
Marek Urbanowicz
  • 12,659
  • 16
  • 62
  • 87
168
votes
1 answer

ESLint couldn't find the config "prettier" to extend from

I am trying to format my code using eslint but when I run npm run lint -f I get this output: Oops! Something went wrong! :( ESLint: 6.8.0. ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is…
Reynier Rivero
  • 2,042
  • 2
  • 8
  • 12