|
| 1 | +module.exports = { |
| 2 | + env: { |
| 3 | + browser: true, |
| 4 | + es2021: true, |
| 5 | + }, |
| 6 | + extends: [ |
| 7 | + '@antfu/eslint-config-vue', |
| 8 | + 'plugin:vue/vue3-recommended', |
| 9 | + 'plugin:import/recommended', |
| 10 | + 'plugin:import/typescript', |
| 11 | + 'plugin:promise/recommended', |
| 12 | + 'plugin:sonarjs/recommended', |
| 13 | + 'plugin:@typescript-eslint/recommended', |
| 14 | + 'plugin:case-police/recommended', |
| 15 | + |
| 16 | + // 'plugin:unicorn/recommended', |
| 17 | + ], |
| 18 | + parser: 'vue-eslint-parser', |
| 19 | + parserOptions: { |
| 20 | + ecmaVersion: 13, |
| 21 | + parser: '@typescript-eslint/parser', |
| 22 | + sourceType: 'module', |
| 23 | + }, |
| 24 | + plugins: [ |
| 25 | + 'vue', |
| 26 | + '@typescript-eslint', |
| 27 | + 'regex', |
| 28 | + ], |
| 29 | + ignorePatterns: ['plugins/iconify/*.js', 'node_modules', 'dist', '*.d.ts', 'vendor'], |
| 30 | + rules: { |
| 31 | + 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', |
| 32 | + 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', |
| 33 | + |
| 34 | + // indentation (Already present in TypeScript) |
| 35 | + 'comma-spacing': ['error', { before: false, after: true }], |
| 36 | + 'key-spacing': ['error', { afterColon: true }], |
| 37 | + 'n/prefer-global/process': ['off'], |
| 38 | + 'sonarjs/cognitive-complexity': ['off'], |
| 39 | + |
| 40 | + 'vue/first-attribute-linebreak': ['error', { |
| 41 | + singleline: 'beside', |
| 42 | + multiline: 'below', |
| 43 | + }], |
| 44 | + |
| 45 | + 'antfu/top-level-function': 'off', |
| 46 | + '@typescript-eslint/no-explicit-any': 'off', |
| 47 | + |
| 48 | + // indentation (Already present in TypeScript) |
| 49 | + 'indent': ['error', 2], |
| 50 | + |
| 51 | + // Enforce trailing comma (Already present in TypeScript) |
| 52 | + 'comma-dangle': ['error', 'always-multiline'], |
| 53 | + |
| 54 | + // Enforce consistent spacing inside braces of object (Already present in TypeScript) |
| 55 | + 'object-curly-spacing': ['error', 'always'], |
| 56 | + |
| 57 | + // Enforce camelCase naming convention |
| 58 | + 'camelcase': 'error', |
| 59 | + |
| 60 | + // Disable max-len |
| 61 | + 'max-len': 'off', |
| 62 | + |
| 63 | + // we don't want it |
| 64 | + 'semi': ['error', 'never'], |
| 65 | + |
| 66 | + 'quotes': 'off', |
| 67 | + 'quote-props': ['error', 'consistent'], |
| 68 | + |
| 69 | + // add parens ony when required in arrow function |
| 70 | + 'arrow-parens': ['error', 'as-needed'], |
| 71 | + |
| 72 | + // add new line above comment |
| 73 | + 'newline-before-return': 'error', |
| 74 | + |
| 75 | + // add new line above comment |
| 76 | + 'lines-around-comment': [ |
| 77 | + 'error', |
| 78 | + { |
| 79 | + beforeBlockComment: true, |
| 80 | + beforeLineComment: true, |
| 81 | + allowBlockStart: true, |
| 82 | + allowClassStart: true, |
| 83 | + allowObjectStart: true, |
| 84 | + allowArrayStart: true, |
| 85 | + |
| 86 | + // We don't want to add extra space above closing SECTION |
| 87 | + ignorePattern: '!SECTION', |
| 88 | + }, |
| 89 | + ], |
| 90 | + |
| 91 | + // Ignore _ as unused variable |
| 92 | + '@typescript-eslint/no-unused-vars': ['error', { varsIgnorePattern: '^_+$', argsIgnorePattern: '^_+$' }], |
| 93 | + |
| 94 | + '@typescript-eslint/quotes': 'error', |
| 95 | + |
| 96 | + 'array-element-newline': ['error', 'consistent'], |
| 97 | + 'array-bracket-newline': ['error', 'consistent'], |
| 98 | + |
| 99 | + 'vue/multi-word-component-names': 'off', |
| 100 | + |
| 101 | + 'padding-line-between-statements': [ |
| 102 | + 'error', |
| 103 | + { blankLine: 'always', prev: 'expression', next: 'const' }, |
| 104 | + { blankLine: 'always', prev: 'const', next: 'expression' }, |
| 105 | + { blankLine: 'always', prev: 'multiline-const', next: '*' }, |
| 106 | + { blankLine: 'always', prev: '*', next: 'multiline-const' }, |
| 107 | + ], |
| 108 | + |
| 109 | + // Plugin: eslint-plugin-import |
| 110 | + 'import/prefer-default-export': 'off', |
| 111 | + 'import/newline-after-import': ['error', { count: 1 }], |
| 112 | + 'no-restricted-imports': ['error', 'vuetify/components', { |
| 113 | + name: 'vue3-apexcharts', |
| 114 | + message: 'apexcharts are autoimported', |
| 115 | + }], |
| 116 | + |
| 117 | + // For omitting extension for ts files |
| 118 | + 'import/extensions': [ |
| 119 | + 'error', |
| 120 | + 'ignorePackages', |
| 121 | + { |
| 122 | + js: 'never', |
| 123 | + jsx: 'never', |
| 124 | + ts: 'never', |
| 125 | + tsx: 'never', |
| 126 | + }, |
| 127 | + ], |
| 128 | + |
| 129 | + // ignore virtual files |
| 130 | + 'import/no-unresolved': [2, { |
| 131 | + ignore: [ |
| 132 | + '~pages$', |
| 133 | + 'virtual:generated-layouts', |
| 134 | + |
| 135 | + // Ignore vite's ?raw imports |
| 136 | + '.*\?raw', |
| 137 | + |
| 138 | + // Ignore nuxt auth in nuxt version |
| 139 | + '#auth$', |
| 140 | + ], |
| 141 | + }], |
| 142 | + |
| 143 | + // Thanks: https://stackoverflow.com/a/63961972/10796681 |
| 144 | + 'no-shadow': 'off', |
| 145 | + '@typescript-eslint/no-shadow': ['error'], |
| 146 | + |
| 147 | + '@typescript-eslint/consistent-type-imports': 'error', |
| 148 | + |
| 149 | + // Plugin: eslint-plugin-promise |
| 150 | + 'promise/always-return': 'off', |
| 151 | + 'promise/catch-or-return': 'off', |
| 152 | + |
| 153 | + // ESLint plugin vue |
| 154 | + 'vue/block-tag-newline': 'error', |
| 155 | + 'vue/component-api-style': 'error', |
| 156 | + 'vue/component-name-in-template-casing': ['error', 'PascalCase', { registeredComponentsOnly: false, ignores: ['/^swiper-/'] }], |
| 157 | + 'vue/custom-event-name-casing': ['error', 'camelCase', { |
| 158 | + ignores: [ |
| 159 | + '/^(click):[a-z]+((\d)|([A-Z0-9][a-z0-9]+))*([A-Z])?/', |
| 160 | + ], |
| 161 | + }], |
| 162 | + 'vue/define-macros-order': 'error', |
| 163 | + 'vue/html-comment-content-newline': 'error', |
| 164 | + 'vue/html-comment-content-spacing': 'error', |
| 165 | + 'vue/html-comment-indent': 'error', |
| 166 | + 'vue/match-component-file-name': 'error', |
| 167 | + 'vue/no-child-content': 'error', |
| 168 | + 'vue/require-default-prop': 'off', |
| 169 | + |
| 170 | + 'vue/no-duplicate-attr-inheritance': 'error', |
| 171 | + 'vue/no-empty-component-block': 'error', |
| 172 | + 'vue/no-multiple-objects-in-class': 'error', |
| 173 | + 'vue/no-reserved-component-names': 'error', |
| 174 | + 'vue/no-template-target-blank': 'error', |
| 175 | + 'vue/no-useless-mustaches': 'error', |
| 176 | + 'vue/no-useless-v-bind': 'error', |
| 177 | + 'vue/padding-line-between-blocks': 'error', |
| 178 | + 'vue/prefer-separate-static-class': 'error', |
| 179 | + 'vue/prefer-true-attribute-shorthand': 'error', |
| 180 | + 'vue/v-on-function-call': 'error', |
| 181 | + 'vue/no-restricted-class': ['error', '/^(p|m)(l|r)-/'], |
| 182 | + 'vue/valid-v-slot': ['error', { |
| 183 | + allowModifiers: true, |
| 184 | + }], |
| 185 | + |
| 186 | + // -- Extension Rules |
| 187 | + 'vue/no-irregular-whitespace': 'error', |
| 188 | + 'vue/template-curly-spacing': 'error', |
| 189 | + |
| 190 | + // -- Sonarlint |
| 191 | + 'sonarjs/no-duplicate-string': 'off', |
| 192 | + 'sonarjs/no-nested-template-literals': 'off', |
| 193 | + |
| 194 | + // -- Unicorn |
| 195 | + // 'unicorn/filename-case': 'off', |
| 196 | + // 'unicorn/prevent-abbreviations': ['error', { |
| 197 | + // replacements: { |
| 198 | + // props: false, |
| 199 | + // }, |
| 200 | + // }], |
| 201 | + |
| 202 | + // https://github.com/gmullerb/eslint-plugin-regex |
| 203 | + 'regex/invalid': [ |
| 204 | + 'error', |
| 205 | + [ |
| 206 | + { |
| 207 | + regex: '@/assets/images', |
| 208 | + replacement: '@images', |
| 209 | + message: 'Use \'@images\' path alias for image imports', |
| 210 | + }, |
| 211 | + { |
| 212 | + regex: '@/assets/styles', |
| 213 | + replacement: '@styles', |
| 214 | + message: 'Use \'@styles\' path alias for importing styles from \'assets/styles\'', |
| 215 | + }, |
| 216 | + |
| 217 | + { |
| 218 | + id: 'Disallow icon of icon library', |
| 219 | + regex: '(mdi|tabler)-\\w', |
| 220 | + message: 'Only \'remix\' icons are allowed', |
| 221 | + }, |
| 222 | + |
| 223 | + { |
| 224 | + regex: '@core/\\w', |
| 225 | + message: 'You can\'t use @core when you are in @layouts module', |
| 226 | + files: { |
| 227 | + inspect: '@layouts/.*', |
| 228 | + }, |
| 229 | + }, |
| 230 | + { |
| 231 | + regex: 'useLayouts\\(', |
| 232 | + message: '`useLayouts` composable is only allowed in @layouts & @core directory. Please use `useThemeConfig` composable instead.', |
| 233 | + files: { |
| 234 | + inspect: '^(?!.*(@core|@layouts)).*', |
| 235 | + }, |
| 236 | + }, |
| 237 | + ], |
| 238 | + |
| 239 | + // Ignore files |
| 240 | + '\.eslintrc\.cjs', |
| 241 | + ], |
| 242 | + }, |
| 243 | + override: [ |
| 244 | + { |
| 245 | + files: ['*.json'], |
| 246 | + rules: { |
| 247 | + '@typescript-eslint/quotes': 'off', |
| 248 | + }, |
| 249 | + }, |
| 250 | + ], |
| 251 | + settings: { |
| 252 | + 'import/resolver': { |
| 253 | + node: true, |
| 254 | + typescript: { |
| 255 | + project: './.nuxt/tsconfig.json', |
| 256 | + }, |
| 257 | + }, |
| 258 | + }, |
| 259 | +} |
0 commit comments