JavaScript Setup
To detect and fix problems in JavaScript code we use ESLint and Prettier.
This setup extends the Airbnb’s base setup, since we have decided to follow the Airbnb styleguide.
Step 1
Install required node packages by running the commands:
npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier
npx install-peerdeps -D eslint-config-airbnb-base
Step 2
Create .eslintrc.js file(in your projects root directory) with the following content:
module.exports = {
env: {
es2021: true,
node: true,
},
plugins: ['prettier'],
extends: ['airbnb-base', 'prettier'],
parserOptions: {
ecmaVersion: 12,
},
rules: {
'prettier/prettier': 'error',
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'import/prefer-default-export': 'off',
'no-mixed-spaces-and-tabs': 'error',
'no-tabs': 0,
indent: [2, 'tab', { SwitchCase: 1 }],
},
};Step 3
Create .prettierrc file(in your projects root directory) with the following content:
{
"semi": true,
"printWidth": 100,
"singleQuote": true,
"useTabs": true,
"trailingComma": "es5"
}Step 4
Create .prettierignore file(in your projects root directory) with the following content:
package.json
package-lock.json