Commands |
|
---|
Table of Contents
Description
ESLint is the leading tool to lint JavaScript and, using plugins, to lint many flavors of it like TypeScript.
Linting
This preset comes with the Swissquote JavaScript Guideline.
Installation
crafty-prest-eslint
comes automatically with @swissquote/crafty-preset-babel
. Install this only if you only need the linter without the bundler.
npm install @swissquote/crafty-preset-eslint --save
module.exports = {
presets: ["@swissquote/crafty-preset-eslint"]
};
Configuration
Linting options
You can read about the linting options on the page about Read more
Commands
crafty jsLint
This linter will leverage ESLint to lint your JavaScript files with the Swissquote presets pre-configured. All ESLint CLI options are valid here.
The additions made by this command are:
- Pre-configured rules, defined by
eslint-plugin-swissquote
activated using--preset
. - Works for JavaScript and for TypeScript
there are four presets available for you :
-
format
Base formatting rules should work on any code (included inlegacy
andrecommended
) -
node
Adds environment information for Node.js -
legacy
For all your EcmaScript 5 code -
recommended
For all your EcmaScript 2015+ code, it also contains rules for React
You can enable those preset with the --preset {the_preset}
option on the command line
The order of the presets is essential as some rules might override previous ones.
For example:
crafty jsLint src/** --preset format --preset node --preset recommended
If you don’t specify any preset, we’ll default to recommended
.
If you pass the --fix
flag, it will fix all the errors it can and write them directly to the file.