eslint-config-utility v2.0.1
eslint-config-utility
This is a utility config that provides a custom .eslintrc and .prettierrc config.
Getting started
Installation:
npm i -D eslint-config-utility@latestRun the following command and install packages provided as dev dependencies:
npm info "eslint-config-utility@latest" peerDependenciesUsage
This package exports three utility tools for use.
eslint-config-utility
The default export contains basic ESLint rules, which can be extended by adding additional rules.
Add "extends": "utility" to your .eslintrc.
module.exports = {
extends: ['utility'],
};If you are using typescript with @typescript-eslint rules then it's recommended to add path to tsconfig.json to parserOptions in .eslintrc file as follows:
module.exports = {
extends: ['utility'],
parserOptions: {
project: './tsconfig.json'
},
};Normally tsconfig.json is at the root of the project as above, except in few cases.
Then create a .eslintignore file and add the following files to ignore that applies to your project: node_modules, .eslintrc.json or .eslintrc.js, build/, coverage/, dist/, .env etc.
.eslintrc.json
.eslintrc.js
.env
node_modules/
build/
coverage/
dist/If you want, you can extend the rules, by adding additional rules, for example:
module.exports = {
extends: ['utility'],
parserOptions: {
project: './tsconfig.json'
},
rules: {
'no-console': 2,
},
};You can check that the package lints using:
npx eslint .or with the fix flag:
npx eslint . --fixeslint-config-utility/import
The import, helps sort and order imports, into files.
To use the import sort order, add "extends": ["utility", "utility/import"] to your .eslintrc.
module.exports = {
extends: ['utility', 'utility/import'],
parserOptions: {
project: './tsconfig.json'
},
};You can check that the imports are sorted and ordered using npx eslint . --fix.
npx eslint . --fixeslint-config-utility/prettier
The prettier helps with code formatting.
To use the prettier functionality, create a .prettierrc.js and import the prettier file. Add module.exports = require('eslint-config-utility/prettier.config'); to your .prettierrc.
module.exports = require('eslint-config-utility/prettier.config');Check that prettier formats the code using npx prettier . --write.
npx prettier . --writeMore information
See Github.