代码检测工具: Eslint
代码格式化工具: Prettier
prettier能够在保留代码时,让代码合乎ESLint规范
- 在VSCode中装置prettier插件
- 在我的项目根目录创立.prettierrc.js文件
配置prettier
module.exports = {semi: true,singleQuote: true,trailingComma: 'none'}
- 在VSCode设置中勾选
Format On Save
,formatter中Default Formatter
抉择Prettier-Code formatter
- 在VSCode设置中批改
Tab Size
为2,将一个tab改为两个空格 在.eslintrc.js中解决ESLint和Prettier之间的抵触
module.exports = { root: true, env: { node: true }, extends: [ 'plugin:vue/vue3-essential', '@vue/standard' ], parserOptions: { parser: 'babel-eslint' }, rules: { 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'space-before-function-paren': 0 }}