In VS Code, install the ESLint and Prettier extensions.
Set Prettier global settings. Open the command pallet.
Search for 'format on save' and enable it.
Search for 'prettier'. Enable Single Quote.
Create package.json file.
npm init -yInstall developer dependencies.
npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier eslint-plugin-node eslint-config-nodeInstall the Airbnb ESLint configurations.
For Node without React. More details at eslint-config-airbnb-base.
npx install-peerdeps --dev eslint-config-airbnb-baseFor Node and React. More details at eslint-config-airbnb.
npx install-peerdeps --dev eslint-config-airbnbCreate file .prettierrc. Go to Configure Prettier Options for rule definitions.
{
"singleQuote": true
}In the package.json file add the following lines.
Install ESLint globally if not already installed.
sudo npm i -g eslintGenerate the ESLint configuration file.
eslint --initA series of selections are used to determine how ESLint is used.
Edit the .eslintrc.json file to something like the following.
{
"env": {
"es2021": true
},
"extends": [
"airbnb-base",
"prettier",
"plugin:node/recommended"
],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error",
"no-unused-vars": "error",
"no-console": "off",
}
}See A list of awesome ESLint configs, plugins, etc..
Install ESLint TypeScript
Install TypeScript.
npm i D typescriptCreate a TypeScript configuration file.
tsc --initIn the tsconfig.json file uncomment and change the outDir and rootDir properties.
"outDir": "./lib",
"rootDir": "./src",From VSCode, F1, cmd+shift+p (Mac), ctrl+shift+p (Linux).
Type "reload window", select to execute.