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 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.