ESLint is a static code analysis tool for identifying problematic patterns found in JavaScript code.
Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.
npx eslint --init
npm install prettier
npm install eslint-plugin-prettier eslint-config-prettier
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true
}
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
'airbnb-base',
'prettier'
],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['prettier'],
rules: {
'prettier/prettier': 'error',
},
};
"editor.codeActionsOnSave" : {
"source.fixAll.eslint" : true
},
"editor.formatOnSave" : false,
"eslint.validate" : [
"javascript",
"typescript",
"javascriptreact",
"typescriptreact"
],
"eslint.alwaysShowStatus": true,
{
"files.eol": "\n",
}
{
"files.eol": "\r\n",
}
rules: {
'prettier/prettier': 'error',
'import/prefer-default-export': 'off',
'import/extensions': 'off',
},