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
1890
votes
14 answers

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 trying to locate the equivalent of the above for…
runtimeZero
  • 26,466
  • 27
  • 73
  • 126
799
votes
23 answers

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 useEffect has a missing dependency:…
russ
  • 8,023
  • 3
  • 8
  • 8
742
votes
19 answers

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 in a certain file, I'm breaking a specific rule on…
Tomas Kulich
  • 14,388
  • 4
  • 30
  • 35
370
votes
21 answers

Eslint: How to disable "unexpected console statement" in Node.js?

I'm using eslint with Sublime Text 3 and I am writing gulpfile.js. /*eslint-env node*/ var gulp = require('gulp'); gulp.task('default', function(){ console.log('default task'); }); But eslint keeps showing error : "Error: Unexpected console…
Jean Y.C. Yang
  • 4,382
  • 4
  • 18
  • 27
364
votes
13 answers

How to use ESLint with Jest

I'm attempting to use the ESLint linter with the Jest testing framework. Jest tests run with some globals like jest, which I'll need to tell the linter about; but the tricky thing is the directory structure, with Jest the tests are embedded with…
Retsam
  • 30,909
  • 11
  • 68
  • 90
354
votes
27 answers

"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: "@typescript-eslint/parser", plugins:…
Dan
  • 8,041
  • 8
  • 41
  • 72
347
votes
21 answers

Using eslint with typescript - Unable to resolve path to module

I have this import in my file app.spec.ts: import app from './app'; Which causes this Typescript error 2:17 error Unable to resolve path to module './app' import/no-unresolved ./app.ts does exist, but I have not compiled the .ts file into a .js…
Maxime Dupré
  • 5,319
  • 7
  • 38
  • 72
336
votes
10 answers

ESLint: "error Parsing error: The keyword 'const' is reserved"

I am getting this error from ESLint: error Parsing error: The keyword 'const' is reserved from this code: const express = require('express'); const app = express(); const _ = require('underscore'); I've tried removing node_modules and…
opike
  • 7,053
  • 14
  • 68
  • 95
314
votes
22 answers

Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style

When using eslint in the gulp project i have encountered a problem with error like this Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style and I am using Windows environment for the running gulp and the entire error log is given below …
SaiKiran
  • 6,244
  • 11
  • 43
  • 76
313
votes
17 answers

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 } = Pages; I get this eslint error: 7:16 error …
DongYao
  • 3,171
  • 2
  • 10
  • 4
309
votes
4 answers

Disable eslint rules for folder

Is there a way to disable specific rules for a folder? For example, I don't want to have required JSDoc comments for all my test files in the test folder. Is there a way to do this?
DevNebulae
  • 4,566
  • 3
  • 16
  • 27
274
votes
9 answers

No restricted globals

I am using React and Redux to develop a webapp and when I started up my project I got this: Line 13: Unexpected use of 'location' no-restricted-globals Search for the keywords to learn more about each error. I search a lot about how to resolve…
Martin Nordström
  • 5,779
  • 11
  • 30
  • 64
272
votes
10 answers

TSLint extension throwing errors in my Angular application running in Visual Studio Code

I recently started seeing, what seems like, TSLint errors. They look like this: Not using the local TSLint version found for '/Users/myname/myproject/client/src/app/likes/likee/likee.component.ts'. To enable code execution from the current…
chuckd
  • 13,460
  • 29
  • 152
  • 331
258
votes
7 answers

Object.hasOwnProperty() yields the ESLint 'no-prototype-builtins' error: how to fix?

I am using the following logic to get the i18n string of the given key. export function i18n(key) { if (entries.hasOwnProperty(key)) { return entries[key]; } else if (typeof (Canadarm) !== 'undefined') { try { throw Error(); }…
booYah
  • 2,589
  • 2
  • 10
  • 4
257
votes
13 answers

Parsing error: Cannot read file '.../tsconfig.json'.eslint

The error Parsing error: Cannot read file '.../tsconfig.json'.eslint shows in all .ts files in the src folder including index.ts. I have no idea how to set up configs. The issue just shows a red line and makes the file red. However, everything…
darren z
  • 3,051
  • 3
  • 13
  • 28
1
2 3
99 100