Prechádzať zdrojové kódy

chore: add eslint config

fanxingqiang 3 rokov pred
rodič
commit
e1200f2dbe
10 zmenil súbory, kde vykonal 396 pridanie a 3242 odobranie
  1. 14 0
      .editorconfig
  2. 3 0
      .eslintignore
  3. 16 0
      .eslintrc.js
  4. 16 1
      .gitignore
  5. 7 0
      .prettierrc.js
  6. 2 2
      build/utils.ts
  7. 3 3
      index.html
  8. 312 3231
      package-lock.json
  9. 21 3
      package.json
  10. 2 2
      src/plugins/element-plus/index.ts

+ 14 - 0
.editorconfig

@@ -0,0 +1,14 @@
+# http://editorconfig.org
+root = true
+
+[*]
+charset = utf-8
+indent_style = space
+indent_size = 2
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.md]
+insert_final_newline = false
+trim_trailing_whitespace = false

+ 3 - 0
.eslintignore

@@ -0,0 +1,3 @@
+public
+dist
+*.d.ts

+ 16 - 0
.eslintrc.js

@@ -0,0 +1,16 @@
+module.exports = {
+  root: true,
+  env: {
+    node: true
+  },
+  extends: [
+    'plugin:vue/vue3-essential',
+    'eslint:recommended',
+    '@vue/typescript/recommended',
+    '@vue/prettier',
+    '@vue/prettier/@typescript-eslint'
+  ],
+  parserOptions: {
+    ecmaVersion: 2020
+  }
+};

+ 16 - 1
.gitignore

@@ -1,3 +1,18 @@
 node_modules
-dist
 .DS_Store
+dist
+dist-ssr
+*.local
+
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+tests/**/coverage/
+
+# Editor directories and files
+.idea
+.vscode
+*.suo
+*.ntvs*
+*.njsproj
+*.sln

+ 7 - 0
.prettierrc.js

@@ -0,0 +1,7 @@
+module.exports = {
+  bracketSpacing: true,
+  jsxBracketSameLine: true,
+  singleQuote: true,
+  arrowParens: 'avoid',
+  trailingComma: 'all'
+};

+ 2 - 2
build/utils.ts

@@ -1,4 +1,4 @@
-import dotenv from 'dotenv';
+import * as dotenv from 'dotenv';
 
 export interface ViteEnv {
   VITE_PORT: number;
@@ -35,4 +35,4 @@ export function loadEnv(): ViteEnv {
     process.env[envName] = realName;
   }
   return ret;
-}
+}

+ 3 - 3
index.html

@@ -19,7 +19,7 @@
     <style>
       * {
         margin: 0;
-        pad: 0;
+        padding: 0;
         box-sizing: border-box;
       }
 
@@ -72,7 +72,7 @@
         50.1%,
         100% {
           background: #0f0;
-          box-sizing: 0 0 5px #0f0,
+          box-shadow: 0 0 5px #0f0,
             0 0 15px #0f0,
             0 0 30px #0f0,
             0 0 60px #0f0,
@@ -136,4 +136,4 @@
   <script type="module" src="/src/main.ts"></script>
 </body>
 
-</html>
+</html>

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 312 - 3231
package-lock.json


+ 21 - 3
package.json

@@ -7,11 +7,13 @@
     "serve": "cross-env --max_old_space_size=4096 vite",
     "build": "cross-env vite build",
     "preview": "vite preview",
-    "preview:build": "npm run build && vite preview"
+    "preview:build": "npm run build && vite preview",
+    "lint": "eslint --ext .js,.jsx,.vue,.ts,.tsx src"
   },
   "husky": {
     "hooks": {
-      "commit-msg": "node scripts/verify-commit.js"
+      "commit-msg": "node scripts/verify-commit.js",
+      "pre-commit": "lint-staged"
     }
   },
   "dependencies": {
@@ -53,21 +55,37 @@
     "@types/mockjs": "^1.0.3",
     "@types/node": "^14.14.14",
     "@types/nprogress": "^0.2.0",
+    "@typescript-eslint/eslint-plugin": "^4.28.1",
+    "@typescript-eslint/parser": "^4.28.1",
     "@vitejs/plugin-vue": "^1.2.4",
     "@vitejs/plugin-vue-jsx": "^1.1.6",
     "@vue/compiler-sfc": "^3.1.2",
+    "@vue/eslint-config-prettier": "^6.0.0",
+    "@vue/eslint-config-typescript": "^7.0.0",
     "autoprefixer": "^10.2.4",
     "babel-plugin-transform-remove-console": "^6.9.4",
     "chalk": "^2.4.2",
     "cross-env": "^7.0.3",
+    "eslint": "^7.30.0",
+    "eslint-plugin-prettier": "^3.4.0",
+    "eslint-plugin-vue": "^7.12.1",
     "husky": "^6.0.0",
+    "lint-staged": "^11.0.0",
     "postcss": "^8.2.6",
     "postcss-import": "^14.0.0",
+    "prettier": "^2.3.2",
     "sass": "^1.32.8",
     "sass-loader": "^11.0.1",
     "typescript": "^4.2.4",
     "vite": "^2.3.8",
     "vite-plugin-mock": "^2.8.0",
-    "vite-plugin-style-import": "^1.0.1"
+    "vite-plugin-style-import": "^1.0.1",
+    "vue-eslint-parser": "^7.7.2"
+  },
+  "lint-staged": {
+    "*.{js,jsx,vue,ts,tsx}": [
+      "npm run lint",
+      "git add"
+    ]
   }
 }

+ 2 - 2
src/plugins/element-plus/index.ts

@@ -1,4 +1,4 @@
-import { App } from "vue";
+import {App, Component} from "vue";
 import {
   ElAffix,
   ElSkeleton,
@@ -74,7 +74,7 @@ import zhLocale from "element-plus/lib/locale/lang/zh-cn";
 ElementLocale.use(zhLocale);
 
 export function useElementPlus(app: App) {
-  components.forEach((component) => {
+  components.forEach((component: Component) => {
     app.component(component.name, component);
   });
   plugins.forEach((plugin) => {

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov