1、创建vue项目 vue create test,取消选中cli中自带的linter/formatter,等安装完成之后手动安装,然后下一步下一步完成项目创建。 2、cd到项目目录,npm run serve,成功启动项目 3、安装eslint相关包 npm install eslint eslint-plugin-jsx-a11y eslint-plugin-vue @vue/eslint-config-airbnb eslint-plugin-vuej...
//parser指定解析器,默认的为espree,可选的还有Esprima、Babel-ESLint。 //babel-eslint is a wrapper around the Babel parser that makes it compatible with ESLint. //babel-eslint是一个Babel parser的包装器,这个包装器使得Babel parser可以和ESLint协调工作 "parser": "babel-eslint", "parserOptions":...
一、Eslint:用于检测代码 安装eslint相关依赖 yarn add eslint eslint-plugin-vue @typescript-eslint/parser @typescript-eslint/eslint-plugin -D eslint-plugin-vue:仅支持vue,提供的规则可以支持 .vue\js\jsx\ts\tsx 文件校验 @typescript-eslint/parser:解析器,让ESLint拥有规范TypeScript代码的能力 @ty...
安装eslint-plugin-prettier.调用prettier 格式化代码,然后与格式化前对比,如果不一致,这个地方就会被prettier 进行标记。 1) 可以将prettier的规则设置为eslint的规则,对不符合规则的进行提示。(与eslint-plugin-vue相同)github link. 2) 使用 ESLint 与 eslint-plugin-prettier 的结果是最终得到的代码是充分尊重 Pr...
Official ESLint plugin for Vue.js. Latest version: 10.1.0, last published: a month ago. Start using eslint-plugin-vue in your project by running `npm i eslint-plugin-vue`. There are 3661 other projects in the npm registry using eslint-plugin-vue.
Official ESLint plugin for Vue.js. Latest version: 4.2.0, last published: 7 years ago. Start using @vue/eslint-plugin in your project by running `npm i @vue/eslint-plugin`. There are 3 other projects in the npm registry using @vue/eslint-plugin.
使用Webpack等工具创建的Vue项目 假设我们现在有一个使用Webpack或其他工具创建的Vue项目,那我们就没法享有Vue CLI带给我们的便利。不过,实现的思路都是一样的,实现起来也很简单,下面以Webpack工具为例。 配置Eslint 参考Vue Eslint官方文档,首先我们需要安装Eslint插件 ...
我们的项目需要支持vue 和 ts,所以这里我们直接用官方推荐的插件和配置就行了,前面初始化eslint 选项的时候,就已经自动安装了相关依赖包 [eslint-plugin-vue] 和@typescript-eslint/parser { parser: 'vue-eslint-parser', extends: [ 'plugin:vue/vue3-recommended', ...
vue-eslint-parser provides a few useful parser services to help traverse the produced AST and access template tokens: context.parserServices.defineTemplateBodyVisitor(visitor, scriptVisitor) context.parserServices.getTemplateBodyTokenStore() Check out an example rule to see usage of these services. Be...
"@typescript-eslint/eslint-plugin": "^5.28.0", "@typescript-eslint/parser": "^5.28.0", .eslint.js配置 module.exports = { root: true, env: { node: true }, extends: [ 'plugin:vue/vue3-strongly-recommended', 'plugin:@typescript-eslint/recommended' ...