To use linting in any project, create an .eslintrc.js
(stand for "eslint runtime config") file in root directory, with following minimum code:
module.exports = {
extends: 'pirashield'
};
Then install these 3 dependencies:
npm install --save-dev eslint eslint-config-pirashield eslint-plugin-import
This loads rules for some common rules about best-practices and style that should be used in all PiraShield JavaScript repos.
There is an additional file for React config. The separation is to avoid downloading unnecessary rules for projects that, for example, aren't front end and wouldn't use React. For these rules, use the following .eslintrc.js
file
module.exports = {
extends: [
'pirashield',
'pirashield/react'
],
};
Then, you must install following 4 dependencies (note there is one extra plugin eslint-plugin-react
)
npm install --save-dev eslint eslint-config-pirashield eslint-plugin-import eslint-plugin-react
To add custom rules to a project/override, add rules
property to .eslintrc.json
, like so:
module.exports = {
extends: [
'pirashield',
'pirashield/react',
],
rules: {
'import/no-extraneous-dependencies': 'off',
'arrow-body-style': 'warn',
'some-other-rule': 'error'
}
}
See all available rules on the Eslint docs.