创建项目
yarn create vite
按照步骤提示安装或者直接一步安装
yarn create vite my-vue-app --template vue
按照 eslint-config-alloy 中的 typescript 说明安装依赖
package.json文件
"eslint": "^8.6.0",
"typescript": "^4.4.4",
"@typescript-eslint/parser": "^5.9.1",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"eslint-config-alloy": "^4.4.0",
"babel-eslint": "^10.1.0",
"vue-eslint-parser": "^8.0.1",
"eslint-plugin-vue": "^8.2.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.5.1",
在git的配置文档 TypeScript
配置完发现eslint不起作用,后续增加的配置如下:
parser: 'vue-eslint-parser', // 此项是用来指定eslint解析器的,解析器必须符合规则
parserOptions: {
parser: '@typescript-eslint/parser', // ESLint的解析器,用于解析typescript,从而检查和规范Typescript代码
ecmaVersion: 2022, // 以指定要使用的ECMAScript语法的版本
sourceType: 'module' // sourceType-设置为"script"(默认),或者"module"代码在ECMAScript模块中。
// ecmaFeatures: { // jsx-启用JSX
// jsx: true
// }
},