Personal eslint config. Supports typeScript, react, vue, next.js.
pnpm add -D eslint eslint-config-like
module.exports = {
extends: ['like'],
}
with typescript
module.exports = {
extends: ['like/ts'],
}
module.exports = {
extends: ['like/react'],
}
with typescript
module.exports = {
extends: ['like/react-ts'],
}
with next.js
module.exports = {
extends: ['like/react', 'like/next'],
}
Default to vue3.
module.exports = {
extends: ['like/vue'],
}
with typescript
module.exports = {
extends: ['like/vue-ts'],
}
{
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"json",
"jsonc",
"json5",
"yml",
"yaml"
],
"[javascript][javascriptreact][typescript][typescriptreact]": {
"editor.formatOnSave": false,
"editor.formatOnPaste": false,
"editor.formatOnType": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
}
Sometimes, you may need add babel as parser for new language features. See babel-eslint-parser for more information.
module.exports = {
parser: '@babel/eslint-parser',
}
To enable typescript path resolvers in .js
files, you can add settings:
module.exports = {
settings: {
'import/resolver': {
typescript: {},
},
},
}
If you are using react 17, you don't need to import React for JSX. See https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#removing-unused-react-imports.
⚠ It is default after v4.