How to use eslintignore

In this article, you are going to know about eslintignore.ESLint is a tool that inspects your ECMAScript/JavaScript code and points out issues based on some…

The post How to use eslintignore appeared first on CodeSource.io.

In this article, you are going to know about eslintignore.
ESLint is a tool that inspects your ECMAScript/JavaScript code and points out issues based on some pre-defined rules. It focused on make the code more consistent and avoid unwanted bugs.

Sometimes you need to ignore a file. If you want a particular file not to be inspected by ESLint then you can simply ignore that file. ESLint lets you perform this type of action by creating a .eslintignore file. It is as similar as .gitignore file. Lets assume you want to ignore the playground.js file, all you need to complete is add the particular line to .eslintignore:

playground.js 

Before determining which files to lint, ESLint scans in the present working directory when it is run and It simply ignores linting if this file is found.

If you want you can comment on the .eslintignore file. To do so you have to use # before the text and .eslintignore will consider it as a comment and do not affect the ignoring patterns. Follow the example below:

# This file will ignore to linting
playground.js 

# ESLint will not recognize the file
\\src\\*.js

You can ignore files from linting in the package.json file. ESLint will look in package.json for an eslintIgnore key to check for files to ignore.

//package.json
{
  "name": "index",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \\"Error: no test specified\\" && exit 1"
  },
  "eslintIgnore": ["playground.js", "test.js"],
  "keywords": [],
  "author": "",
  "license": "ISC"
}

ESLint also lets you disable individual lint rules. All you need to do is just add a comment before the particular lines you want to disable from linting. For example:

alert('foo'); // eslint-disable-line

// eslint-disable-next-line
alert('foo');

or

/* eslint-disable-next-line */
alert('foo');

alert('foo'); /* eslint-disable-line */

Note: In ESLint, ignore patterns that behave according to the .gitignore specification.This is all about eslintignore and you can get an overview from this.

The post How to use eslintignore appeared first on CodeSource.io.


Print Share Comment Cite Upload Translate
APA
Deven | Sciencx (2024-03-29T11:39:22+00:00) » How to use eslintignore. Retrieved from https://www.scien.cx/2021/10/18/how-to-use-eslintignore/.
MLA
" » How to use eslintignore." Deven | Sciencx - Monday October 18, 2021, https://www.scien.cx/2021/10/18/how-to-use-eslintignore/
HARVARD
Deven | Sciencx Monday October 18, 2021 » How to use eslintignore., viewed 2024-03-29T11:39:22+00:00,<https://www.scien.cx/2021/10/18/how-to-use-eslintignore/>
VANCOUVER
Deven | Sciencx - » How to use eslintignore. [Internet]. [Accessed 2024-03-29T11:39:22+00:00]. Available from: https://www.scien.cx/2021/10/18/how-to-use-eslintignore/
CHICAGO
" » How to use eslintignore." Deven | Sciencx - Accessed 2024-03-29T11:39:22+00:00. https://www.scien.cx/2021/10/18/how-to-use-eslintignore/
IEEE
" » How to use eslintignore." Deven | Sciencx [Online]. Available: https://www.scien.cx/2021/10/18/how-to-use-eslintignore/. [Accessed: 2024-03-29T11:39:22+00:00]
rf:citation
» How to use eslintignore | Deven | Sciencx | https://www.scien.cx/2021/10/18/how-to-use-eslintignore/ | 2024-03-29T11:39:22+00:00
https://github.com/addpipe/simple-recorderjs-demo