diff --git a/.eslintrc.js b/.eslintrc.js
index 62ea6a9..bdce118 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -1,17 +1,39 @@
module.exports = {
- root: true,
- parserOptions: {
- sourceType: "module"
+ env: {
+ browser: true,
+ es2021: true,
+ node: true
+ },
+ extends: [
+ 'plugin:vue/essential',
+ 'standard',
+ 'plugin:vue/vue3-recommended'
+ ],
+ parserOptions: {
+ ecmaVersion: 'latest',
+ parser: '@typescript-eslint/parser',
+ sourceType: 'module',
+ ecmaFeatures: {
+ modules: true
},
- parser: "vue-eslint-parser",
- extends: ["plugin:vue/vue3-essential","plugin:vue/vue3-strongly-recommended","plugin:vue/vue3-recommended"],
- env: {
- browser: true,
- node: true,
- es6: true
- },
- rules: {
- 'no-console': 'off',
- 'comma-dangle': [2,'never']
- }
-}
\ No newline at end of file
+ requireConfigFile: false
+ },
+ plugins: [
+ 'vue',
+ '@typescript-eslint'
+ ],
+ rules: {
+ semi: [2, 'never'], // 禁止尾部使用分号“ ; ”
+ 'no-var': 'error', // 禁止使用 var
+ indent: ['error', 2], // 缩进2格
+ 'no-mixed-spaces-and-tabs': 'error', // 不能空格与tab混用
+ quotes: [2, 'single'], // 使用单引号
+ 'vue/html-closing-bracket-newline': 'off', // 不强制换行
+ 'vue/singleline-html-element-content-newline': 'off', // 不强制换行
+ 'vue/max-attributes-per-line': ['error', {
+ singleline: { max: 5 },
+ multiline: { max: 5 }
+ }] // vue template模板元素第一行最多5个属性
+ // 其它的规则可以去eslint查看,根据自己需要进行添加
+ }
+}
diff --git a/package.json b/package.json
index 102ad90..afc0afb 100644
--- a/package.json
+++ b/package.json
@@ -16,13 +16,20 @@
},
"devDependencies": {
"@types/node": "^17.0.24",
+ "@typescript-eslint/eslint-plugin": "^5.19.0",
+ "@typescript-eslint/parser": "^5.19.0",
"@vitejs/plugin-vue": "^2.3.1",
- "eslint": "^8.13.0",
+ "eslint": "^7.32.0",
+ "eslint-config-standard": "^16.0.3",
+ "eslint-plugin-import": "^2.26.0",
+ "eslint-plugin-node": "^11.1.0",
+ "eslint-plugin-promise": "^5.2.0",
"eslint-plugin-vue": "^8.6.0",
"sass": "^1.50.0",
"sass-loader": "^12.6.0",
"typescript": "^4.5.4",
"vite": "^2.9.2",
+ "vite-plugin-eslint": "^1.4.0",
"vue-tsc": "^0.29.8"
}
}
diff --git a/src/App.vue b/src/App.vue
index 35eb5cc..3f2fbf3 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -3,8 +3,10 @@
-
-
+
+
+
+
\ No newline at end of file
+
diff --git a/src/views/tst/Home.vue b/src/views/tst/Home.vue
index 5f1d6de..f93c6f2 100644
--- a/src/views/tst/Home.vue
+++ b/src/views/tst/Home.vue
@@ -1,14 +1,13 @@
- {{name}}
+ {{ name }}
-
\ No newline at end of file
+
diff --git a/vite.config.ts b/vite.config.ts
index c902842..b05e377 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -1,9 +1,14 @@
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import {resolve} from "path";
+import eslintPlugin from 'vite-plugin-eslint'
+
// https://vitejs.dev/config/
export default defineConfig({
- plugins: [vue()],
+ plugins: [vue(),
+ eslintPlugin({
+ include: ['src/**/*.js', 'src/**/*.vue', 'src/*.js', 'src/*.vue']
+ })],
server: {
host: '0.0.0.0',
port: 3000,