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
128
votes
5 answers

VSCode prettier adds `value` to imports in TypeScript React

After configuring prettier with the plugin in VSCode the format on save function adds weird value keywords to every non-default import in my React+TS code. Like this: import { value ApolloProvider } from '@apollo/client'; import { value…
Kibartas
  • 1,442
  • 2
  • 5
  • 14
126
votes
14 answers

ESLint: 'cy' is not defined (Cypress)

I've just started using Cypress with my React Typescript project. I've gotten some simple tests to run: describe('settings page', () => { beforeEach(() => { cy.visit('http://localhost:3000') }); it('starts in a waiting state, with no…
Jonathan Tuzman
  • 11,568
  • 18
  • 69
  • 129
126
votes
13 answers

Parsing Error The Keyword import is Reserved (SublimeLinter-contrib-eslint)

I have a problem with eslint, it gives me [Parsing Error The keyword import is reserve] this is only occur in sublime, in atom editor work well. I have eslint .eslintrc.js module.exports = { "extends": "airbnb", "plugins": [ …
pedro luis
  • 1,545
  • 2
  • 10
  • 8
125
votes
3 answers

What's the difference between plugins and extends in eslint?

I don't understand why we have plugins and extends. What is the difference between them and do I need one or the other?
jingteng
  • 2,331
  • 4
  • 13
  • 16
124
votes
8 answers

How to make WebStorm format code according to eslint?

I've specified eslint configuration for my WebStorm project. But it does not seem to apply to code reformat feature. For example, it continues to format import { something } from 'somewhere' as import {something} from 'somewhere'. Is there a way to…
SiberianGuy
  • 24,674
  • 56
  • 152
  • 266
120
votes
10 answers

Disable ESLint that create-react-app provides

create-react-app v3.0.0 is out. It supports TypeScript linting internally. (That's nice!) I think I understand the situation where TSLint is on, and am planning to replace it with ESLint, but it is not right now. How to disable that linting step in…
Ginpei
  • 2,958
  • 5
  • 15
  • 25
111
votes
12 answers

How can I fix this violation of this 'react/no-unescaped-entitie' of an ESLint rule?

This is my code: const func = () => { return (
you're free
)} Somehow ESLint flags the line "you're free" with error error HTML entities must be escaped react/no-unescaped-entities However, from what I can see,…
Anthony Kong
  • 37,791
  • 46
  • 172
  • 304
110
votes
2 answers

Cannot fix eslint rule on indenting case statements in switch statement

Here is a screenshot of my sublime text window showing the eslint error being thrown for the switch / case statement. I want to have to indent 4 spaces, as the code shows. and here are 4 different attempts to try to allow for an indent of 4 spaces,…
Canovice
  • 9,012
  • 22
  • 93
  • 211
107
votes
1 answer

How to disable warn about some unused params, but keep "@typescript-eslint/no-unused-vars" rule

I want to disable no unused params warning in some cases but keep "unused vars" rule. For example here I would want to leave arguments in place to see what is passed to resolver: const Query = objectType({ name: 'Query', definition(t) { …
ZiiMakc
  • 31,187
  • 24
  • 65
  • 105
104
votes
14 answers

My create-react-app is failing to compile due to ESLint error

I just created a fresh template with create-react-app with react v17 included, and I installed eslint dependencies as I used to before, here's my package.json file { "name": "gym-nation", "version": "0.1.0", "private": true, "dependencies":…
Ali Aljarah
  • 1,326
  • 2
  • 9
  • 16
104
votes
4 answers

describe is not defined when installing jest

I installed jest v24.7.1in my project with: npm install jest -D Then I start writing some test files, However I got these eslint errors: 'describe' is not defined. eslint (no-undef) 'it' is not defined. eslint (no-undef) 'expect' is not defined.…
Slim
  • 5,527
  • 13
  • 45
  • 81
102
votes
2 answers

Add space in self closing tags before in self closing tags

How do you include a space before the closing tags in self closing tags with WebStorm/IntelliJ-based products? Default settings turns to , which is against one of the rules (jsx-space-before-closing) in the commonly used…
Poyan
  • 6,243
  • 6
  • 28
  • 30
101
votes
5 answers

EditorConfig vs. ESLint vs. Prettier: Is it worthwhile to use them all?

I am trying to set up some tools to help maintain consistency in a codebase used by multiple developers. Is it necessary to use EditorConfig, ESLint and Prettier all together? As far as I understand, EditorConfig is used to set coding styles/rules,…
PBandJ
  • 2,537
  • 3
  • 21
  • 31
101
votes
8 answers

Expected 'this' to be used by class method

In my class, eslint is complaining "Expected 'this' to be used by class method 'getUrlParams' Here is my class: class PostSearch extends React.Component { constructor(props) { super(props); this.getSearchResults(); } …
Hinesh Patel
  • 1,161
  • 2
  • 7
  • 15
98
votes
6 answers

how ignore typescript errors with @ts-ignore?

I have a case where I'm importing a puraly JavaScript library within TypeScript project giving me the nagging Could not find a declaration file for module xxx message. So after reading I found I can supress that with a comment with @ts-ignore. Yet…
Seyed Abbas
  • 1,114
  • 1
  • 8
  • 8