Defines set of Amity ESLint rules based on Airbnb eslint rules extended by Prettier plugin.
The package provides 2 sets of rules:
eko
- eslint, import ruleseko/react
-eko
+ react, react-hook, jsx-a11y rules
{
"tabWidth": 2,
"printWidth": 100,
"useTabs": false,
"singleQuote": true,
"trailingComma": "all",
"quoteProps": "as-needed",
"arrowParens": "avoid",
"embeddedLanguageFormatting": "auto"
}
Make sure that you do not change configuration or you will run in a bunch of conflicts between Prettier and ESLint.
npm@6
npx install-peerdeps --dev [email protected] --extra-args "--save-exact"
npm@7
npm install --save-dev --save-exact --save-peer [email protected]
npm install --save-dev --save-exact [email protected] [email protected] [email protected] [email protected]
Only base set of rules
"extends": ["eko"]
Base + React set of rules
"extends": ["eko/react"]
Step 5. If required. To properly support eslint-plugin-import
please check resolvers docs.
npm i --save-dev husky lint-staged
In package.json:
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"linters": {
"*.{js,jsx}": [
"eslint --fix",
"git add --force"
],
"*.{json,md}": [
"prettier --write",
"git add --force"
]
}
},
In case you encounter slow eslint execution on your project try to use ESLint built-in CLI method to track performance of individual rules.
TIMING=1 eslint lib
If you want to use root synonyms like:
// from
import Example from '../../../some/example.js';
// to
import Example from '~/some/example.js';
Install eslint-import-resolver-webpack
npm install --save-dev eslint-import-resolver-webpack
Add this to your webpack configuration:
resolve: {
alias: {
// pattern
'~': '<full_path_to_project_folder>',
// example 1
'~': path.resolve(process.cwd(), '<project_folder>'),
// example 2
'~': path.resolve(__dirname, '<project_folder>'),
},
},
Add this to your eslint configuration:
// For more options check https://www.npmjs.com/package/eslint-import-resolver-webpack
settings: {
'import/resolver': {
webpack: {
config: '<path_to_webpack',
},
},
},
Run:
npm i --save-dev babel-plugin-root-import eslint-import-resolver-babel-plugin-root-import
Add to .babelrc
:
"plugins": [
[
"babel-plugin-root-import",
{
"rootPathPrefix": "~",
"rootPathSuffix": "app"
}
]
]
Add to .eslintrc
:
"settings": {
"import/resolver": "babel-plugin-root-import"
},
- Make sure that this is not disabled by
eslint-config-prettier
. If you re-enable it then prettier and eslint might run into conflict. - Provide reference to documentation.
- Provide Airbnb declaration (and they reasoning).
- Provide explanation why the decision to alter a rule was made.