瀏覽代碼

build(frontend): 修改eslint配置

Signed-off-by: Myon <[email protected]>
Myon 3 年之前
父節點
當前提交
732fa1946d

+ 1 - 71
frontend/.eslintrc.js

@@ -4,75 +4,5 @@ module.exports = {
   // Remove this if you have an higher level ESLint config file (it usually happens into a monorepos)
   root: true,
 
-  parserOptions: {
-    parser: '@babel/eslint-parser',
-    ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
-    sourceType: 'module', // Allows for the use of imports
-  },
-
-  env: {
-    browser: true,
-  },
-
-  // Rules order is important, please avoid shuffling them
-  extends: [
-    // Base ESLint recommended rules
-    // 'eslint:recommended',
-
-    // Uncomment any of the lines below to choose desired strictness,
-    // but leave only one uncommented!
-    // See https://eslint.vuejs.org/rules/#available-rules
-    'plugin:vue/vue3-essential', // Priority A: Essential (Error Prevention)
-    // 'plugin:vue/vue3-strongly-recommended', // Priority B: Strongly Recommended (Improving Readability)
-    // 'plugin:vue/vue3-recommended', // Priority C: Recommended (Minimizing Arbitrary Choices and Cognitive Overhead)
-
-    'airbnb-base',
-    'prettier',
-  ],
-
-  plugins: [
-    // https://eslint.vuejs.org/user-guide/#why-doesn-t-it-work-on-vue-file
-    // required to lint *.vue files
-    'vue',
-  ],
-
-  globals: {
-    ga: 'readonly', // Google Analytics
-    cordova: 'readonly',
-    __statics: 'readonly',
-    __QUASAR_SSR__: 'readonly',
-    __QUASAR_SSR_SERVER__: 'readonly',
-    __QUASAR_SSR_CLIENT__: 'readonly',
-    __QUASAR_SSR_PWA__: 'readonly',
-    process: 'readonly',
-    Capacitor: 'readonly',
-    chrome: 'readonly',
-  },
-
-  // add your custom rules here
-  rules: {
-    'no-param-reassign': 'off',
-    'no-void': 'off',
-    'no-nested-ternary': 'off',
-    'max-classes-per-file': 'off',
-
-    'import/first': 'off',
-    'import/named': 'error',
-    'import/namespace': 'error',
-    'import/default': 'error',
-    'import/export': 'error',
-    'import/extensions': 'off',
-    'import/no-unresolved': 'off',
-    'import/no-extraneous-dependencies': 'off',
-    'import/prefer-default-export': 'off',
-    'prefer-promise-reject-errors': 'off',
-
-    semi: 'off',
-    'comma-dangle': 'off',
-    'object-curly-spacing': 'off',
-    'max-len': ['error', { code: 120 }],
-
-    // allow debugger during development only
-    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
-  },
+  extends: ['@imyon/eslint-config-preset'],
 };

+ 1 - 7
frontend/.prettierrc.js

@@ -1,9 +1,3 @@
 module.exports = {
-  printWidth: 120, // 最大行宽
-  tabWidth: 2, // tab距离
-  trailingComma: 'es5', // 多行时,尽可能打印尾随逗号
-  semi: true, // 行尾自动加分号
-  singleQuote: true, // 使用单引号替代双引号
-  bracketSpacing: true, // 对象{}之间自动加空格,如{ foo: bar }
-  endOfLine: 'lf', // 使用lf换行符
+  ...require('@imyon/eslint-config-prettier'),
 };

文件差異過大導致無法顯示
+ 618 - 171
frontend/package-lock.json


+ 3 - 4
frontend/package.json

@@ -29,13 +29,12 @@
   },
   "devDependencies": {
     "@babel/eslint-parser": "^7.13.14",
+    "@imyon/eslint-config-preset": "^0.0.3",
+    "@imyon/eslint-config-prettier": "^0.0.2",
     "@quasar/app": "^3.0.0",
     "dotenv": "^10.0.0",
     "eslint": "^7.14.0",
-    "eslint-config-airbnb-base": "^14.2.1",
-    "eslint-config-prettier": "^8.3.0",
-    "eslint-plugin-import": "^2.23.4",
-    "eslint-plugin-vue": "^7.20.0",
+    "eslint-plugin-vue": "^8.4.1",
     "eslint-webpack-plugin": "^2.4.0",
     "husky": "^6.0.0",
     "lint-staged": "^11.0.0",

+ 3 - 2
frontend/src-pwa/custom-service-worker.js

@@ -4,7 +4,8 @@
  * quasar.conf > pwa > workboxPluginMode is set to "InjectManifest"
  */
 
-import { precacheAndRoute } from 'workbox-precaching'
+import { precacheAndRoute } from 'workbox-precaching';
 
 // Use with precache injection
-precacheAndRoute(self.__WB_MANIFEST)
+// eslint-disable-next-line no-restricted-globals,no-underscore-dangle
+precacheAndRoute(self.__WB_MANIFEST);

+ 6 - 6
frontend/src-ssr/production-export.js

@@ -7,12 +7,12 @@
  * This file is used ONLY on production.
  */
 
-import { ssrProductionExport } from 'quasar/wrappers'
+import { ssrProductionExport } from 'quasar/wrappers';
 
-export default ssrProductionExport(({ app, port, isReady }) => {
-  return isReady().then(() => {
+export default ssrProductionExport(({ app, port, isReady }) =>
+  isReady().then(() => {
     app.listen(port, () => {
-      console.log('Server listening at port ' + port)
-    })
+      console.log(`Server listening at port ${port}`);
+    });
   })
-})
+);

+ 1 - 0
frontend/src/router/index.js

@@ -11,6 +11,7 @@ import routes from './routes';
  * async/await or return a Promise which resolves
  * with the Router instance.
  */
+// eslint-disable-next-line no-nested-ternary
 const createHistory = process.env.SERVER
   ? createMemoryHistory
   : process.env.VUE_ROUTER_MODE === 'history'

部分文件因文件數量過多而無法顯示