最近在工作中使用到vue和ts,新搭建的项目,看了网上许多eslint相关的配置,一股脑东拼西凑整到一起,还是有很多warn信息,以及各种问题,搞得人头皮发麻。于是好好地了解学习了下eslint,下面是自己摸索实验得到的一份配置信息,试了下没啥问题了,暂时先用着,之后再补充。
搞懂 ESLint 和 Prettier - 乃乎的文章 - 知乎
.eslintrc.js
module.exports = {
root: true,
env: {
node: true,
},
extends: [
"plugin:vue/essential",
"eslint:recommended",
"@vue/typescript/recommended",
"@vue/prettier",
"@vue/prettier/@typescript-eslint",
],
parserOptions: {
ecmaVersion: 2020,
},
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
"prettier/prettier": "off",
},
};
.prettierrc.js
module.exports = {
printWidth: 140,
tabWidth: 4,
useTabs: true,
singleQuote: true,
semi: true,
trailingComma: 'none',
bracketSpacing: true,
jsxBracketSameLine: true,
};
|