ESLint is a tool which make code more consistent to follow common code style.
ESLint uses Espree for JavaScript parsing. ESLint uses an AST (Abstract Syntax Tree) to evaluate patterns in code. ESLint is completely pluggable, every single rule is a plugin and you can add more at runtime.
We need Node.js >=12.0.0
- You can install ESLint with npm or yarn undefined
or https://gist.github.com/496bf6659aaf0099b301838e2b544942
- run
eslint --init
and you'll have.eslintrc.{js,yml,json}
file in directory, where some rules configured as :
https://gist.github.com/438db996a22914e93712cdce068dd314
"space-in-parens"", "indent" ... are the names of rules
in ESLint. The first value is the error level of the rule and can be one of these values:
- "off" or 0 - turn the rule off
- "warn" or 1 - turn the rule on as a warning (doesn't affect exit code)
- "error" or 2 - turn the rule on as an error (exit code will be 1)
You can see more configuration details on configuration docs
We can use existing rules by
extends
, and this rules will be applied on.
https://gist.github.com/441cd8934cc0f71de82e1dd6bc80f51a
- run
./node_modules/.bin/eslint --fix 'file.ts'
to fix