|
| 1 | +const webpackConfigPath = require.resolve("@vue/cli-service/webpack.config.js"); |
| 2 | + |
| 3 | +module.exports = { |
| 4 | + root: true, |
| 5 | + env: { |
| 6 | + browser: true, |
| 7 | + node: true, |
| 8 | + es2020: true, |
| 9 | + }, |
| 10 | + parserOptions: { |
| 11 | + ecmaVersion: 2020, |
| 12 | + // parser: '@typescript-eslint/parser' |
| 13 | + }, |
| 14 | + extends: [ |
| 15 | + // Vue-specific defaults |
| 16 | + "plugin:vue/vue3-essential", |
| 17 | + // Vue-compatible JS defaults |
| 18 | + "@vue/airbnb", |
| 19 | + // Vue-compatible TS defaults |
| 20 | + "@vue/typescript/recommended", |
| 21 | + // Vue-compatible Prettier defaults |
| 22 | + "plugin:prettier-vue/recommended", |
| 23 | + // General Prettier defaults |
| 24 | + "prettier", |
| 25 | + ], |
| 26 | + settings: { |
| 27 | + // https://github.com/import-js/eslint-plugin-import#resolvers |
| 28 | + "import/resolver": { |
| 29 | + // `node` must be listed first! |
| 30 | + node: {}, |
| 31 | + webpack: { config: webpackConfigPath }, |
| 32 | + }, |
| 33 | + // https://github.com/meteorlxy/eslint-plugin-prettier-vue |
| 34 | + "prettier-vue": { |
| 35 | + // Use Prettier to format the HTML, CSS, and JS blocks of .vue single-file components |
| 36 | + SFCBlocks: { |
| 37 | + template: true, |
| 38 | + style: true, |
| 39 | + script: true, |
| 40 | + }, |
| 41 | + }, |
| 42 | + }, |
| 43 | + ignorePatterns: [ |
| 44 | + // Ignore generated directories |
| 45 | + "node_modules/", |
| 46 | + "dist/", |
| 47 | + "pkg/", |
| 48 | + "wasm/pkg/", |
| 49 | + // Don't ignore JS and TS dotfiles in this folder |
| 50 | + "!.*.js", |
| 51 | + "!.*.ts", |
| 52 | + ], |
| 53 | + rules: { |
| 54 | + // Standard ESLint config |
| 55 | + indent: "off", |
| 56 | + quotes: ["error", "double"], |
| 57 | + camelcase: ["error", { properties: "always" }], |
| 58 | + "linebreak-style": ["error", "unix"], |
| 59 | + "eol-last": ["error", "always"], |
| 60 | + "max-len": ["error", { code: 200, tabWidth: 4 }], |
| 61 | + "prefer-destructuring": "off", |
| 62 | + "no-console": "warn", |
| 63 | + "no-debugger": "warn", |
| 64 | + "no-param-reassign": ["error", { props: false }], |
| 65 | + "no-bitwise": "off", |
| 66 | + "no-shadow": "off", |
| 67 | + "no-use-before-define": "off", |
| 68 | + // TODO: Vetur cannot properly recognize paths using @ which contradicts this rule |
| 69 | + // "no-restricted-imports": ["error", { patterns: [".*", "!@/*"] }], |
| 70 | + |
| 71 | + // TypeScript plugin config |
| 72 | + "@typescript-eslint/indent": "off", |
| 73 | + "@typescript-eslint/camelcase": "off", |
| 74 | + "@typescript-eslint/no-use-before-define": "off", |
| 75 | + "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_", ignoreRestSiblings: true }], |
| 76 | + "@typescript-eslint/explicit-function-return-type": ["error"], |
| 77 | + |
| 78 | + // Import plugin config (used to intelligently validate module import statements) |
| 79 | + "import/prefer-default-export": "off", |
| 80 | + "import/no-relative-packages": "error", |
| 81 | + "import/order": [ |
| 82 | + "error", |
| 83 | + { |
| 84 | + alphabetize: { |
| 85 | + order: "asc", |
| 86 | + caseInsensitive: true, |
| 87 | + }, |
| 88 | + warnOnUnassignedImports: true, |
| 89 | + "newlines-between": "always-and-inside-groups", |
| 90 | + pathGroups: [ |
| 91 | + { |
| 92 | + pattern: "**/*.vue", |
| 93 | + group: "unknown", |
| 94 | + position: "after", |
| 95 | + }, |
| 96 | + ], |
| 97 | + }, |
| 98 | + ], |
| 99 | + |
| 100 | + // Prettier plugin config (used to enforce HTML, CSS, and JS formatting styles as an ESLint plugin, where fixes are reported to ESLint to be applied when linting) |
| 101 | + "prettier-vue/prettier": [ |
| 102 | + "error", |
| 103 | + { |
| 104 | + tabWidth: 4, |
| 105 | + tabs: true, |
| 106 | + printWidth: 200, |
| 107 | + }, |
| 108 | + ], |
| 109 | + |
| 110 | + // Vue plugin config (used to validate Vue single-file components) |
| 111 | + "vue/multi-word-component-names": "off", |
| 112 | + |
| 113 | + // Vue Accessibility plugin config (included by airbnb defaults but undesirable for a web app project) |
| 114 | + "vuejs-accessibility/form-control-has-label": "off", |
| 115 | + "vuejs-accessibility/label-has-for": "off", |
| 116 | + "vuejs-accessibility/click-events-have-key-events": "off", |
| 117 | + }, |
| 118 | + overrides: [ |
| 119 | + { |
| 120 | + files: ["*.js"], |
| 121 | + rules: { |
| 122 | + "@typescript-eslint/explicit-function-return-type": ["off"], |
| 123 | + }, |
| 124 | + }, |
| 125 | + ], |
| 126 | +}; |
0 commit comments