First, we need to know which pattern you’re going to use, but come on.
Create the . eslintrc file globally
AS:
Linux: root@USERNAME
> code .eslintrc.json
Windows:C:\users\USERNAME\document(o?)s ou C:\users\USERNAME
echo "">.eslintrc.json
With, for example, the following very simple content:
{
"extends": ["eslint:recommended"],
"rules": {
// enable additional rules
"indent": ["error", 4],
"linebreak-style": ["error", "unix"],
"quotes": ["error", "double"],
"semi": ["error", "always"],
// override default options for rules from base configurations
"comma-dangle": ["error", "always"],
"no-cond-assign": ["error", "always"],
// disable rules from base configurations
"no-console": "off"
}
}
Install the packages globally
npm install -g eslint-config-prettier eslint-config-standard eslint-plugin-import eslint-plugin-node eslint-plugin-prettier eslint-plugin-promise eslint-plugin-react eslint-plugin-standard prettier
Install the editor extension, in the case of VS Code, this:
Eslint 2.1.14 (Integrates Eslint Javascript Into VS Code) Author: Dirk Baeumer
Restart the VS Code.
Don’t forget to take a look at the links below. They are from the official documentation itself.
REFERENCE:
https://eslint.org/docs/user-guide/configuring#Extending-Configuration-files
https://eslint.org/docs/user-guide/command-line-interface#-resolve-plugins-relative-to
https://medium.com/wearelaika/javascript-eslint-global-configuration-setup-vscode-599cbfc81eb5
https://medium.com/medvine/install-eslint-global-with-airbnb-style-guide-and-use-it-in-vscode-d752dfa40b21
You need to install as a development dependency so that anyone working on the project has these dependencies. In addition, you can have your own settings with VS Code extensions but the ideal is to have everything in the Eslint and Prettier configuration files because then you share with everyone on the team without conflict of rules, and copy these files from one project to another. If applicable, you can make configuration packages like Airbnb
– Rafael Tavares