123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- module.exports = {
- env: {
- browser: true,
- es2021: true,
- },
- extends: [
- '@antfu/eslint-config-vue',
- 'plugin:vue/vue3-recommended',
- 'plugin:import/recommended',
- 'plugin:import/typescript',
- 'plugin:sonarjs/recommended',
- 'plugin:@typescript-eslint/recommended',
- // 'plugin:unicorn/recommended',
- ],
- parser: 'vue-eslint-parser',
- parserOptions: {
- ecmaVersion: 13,
- parser: '@typescript-eslint/parser',
- sourceType: 'module',
- },
- plugins: [
- 'vue',
- '@typescript-eslint',
- 'regex',
- ],
- ignorePatterns: ['src/@iconify/*.js', 'node_modules', 'dist', '*.d.ts'],
- rules: {
- 'vue/no-v-html': 'off',
- 'vue/block-tag-newline': 'off',
- // eslint-disable-next-line n/prefer-global/process
- 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
- // eslint-disable-next-line n/prefer-global/process
- 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
- // indentation (Already present in TypeScript)
- 'comma-spacing': ['error', {
- before: false,
- after: true,
- }],
- 'key-spacing': ['error', {afterColon: true}],
- 'vue/first-attribute-linebreak': ['error', {
- singleline: 'beside',
- multiline: 'below',
- }],
- 'antfu/top-level-function': 'off',
- // Enforce trailing comma (Already present in TypeScript)
- 'comma-dangle': ['error', 'always-multiline'],
- // Disable max-len
- 'max-len': 'off',
- // we don't want it
- 'semi': ['error', 'never'],
- // add parens ony when required in arrow function
- 'arrow-parens': ['error', 'as-needed'],
- // add new line above comment
- 'newline-before-return': 'error',
- // add new line above comment
- 'lines-around-comment': [
- 'error',
- {
- beforeBlockComment: true,
- beforeLineComment: true,
- allowBlockStart: true,
- allowClassStart: true,
- allowObjectStart: true,
- allowArrayStart: true,
- },
- ],
- // Ignore _ as unused variable
- '@typescript-eslint/no-unused-vars': ['error', {argsIgnorePattern: '^_+$'}],
- 'array-element-newline': ['error', 'consistent'],
- 'array-bracket-newline': ['error', 'consistent'],
- 'vue/multi-word-component-names': 'off',
- 'padding-line-between-statements': [
- 'error',
- {
- blankLine: 'always',
- prev: 'expression',
- next: 'const',
- },
- {
- blankLine: 'always',
- prev: 'const',
- next: 'expression',
- },
- {
- blankLine: 'always',
- prev: 'multiline-const',
- next: '*',
- },
- {
- blankLine: 'always',
- prev: '*',
- next: 'multiline-const',
- },
- ],
- // Plugin: eslint-plugin-import
- 'import/prefer-default-export': 'off',
- 'import/newline-after-import': ['error', {count: 1}],
- 'no-restricted-imports': ['error', 'vuetify/components'],
- // For omitting extension for ts files
- 'import/extensions': [
- 'error',
- 'ignorePackages',
- {
- mjs: 'never',
- js: 'never',
- jsx: 'never',
- ts: 'never',
- tsx: 'never',
- },
- ],
- // ignore virtual files
- 'import/no-unresolved': [2, {
- ignore: [
- '~pages$',
- 'virtual:generated-layouts',
- // Ignore vite's ?raw imports
- '.*\?raw',
- ],
- }],
- // Thanks: https://stackoverflow.com/a/63961972/10796681
- 'no-shadow': 'off',
- '@typescript-eslint/no-shadow': ['error'],
- '@typescript-eslint/consistent-type-imports': 'error',
- // Plugin: eslint-plugin-promise
- 'promise/always-return': 'off',
- 'promise/catch-or-return': 'off',
- // ESLint plugin vue
- 'vue/component-api-style': 'error',
- 'vue/component-name-in-template-casing': ['error', 'PascalCase', {registeredComponentsOnly: false}],
- 'vue/custom-event-name-casing': ['error', 'camelCase', {
- ignores: [
- '/^(click):[a-z]+((\d)|([A-Z0-9][a-z0-9]+))*([A-Z])?/',
- ],
- }],
- 'vue/define-macros-order': 'error',
- 'vue/html-comment-content-newline': 'error',
- 'vue/html-comment-content-spacing': 'error',
- 'vue/html-comment-indent': 'error',
- 'vue/match-component-file-name': 'error',
- 'vue/no-child-content': 'error',
- 'vue/require-default-prop': 'off',
- // NOTE this rule only supported in SFC, Users of the unplugin-vue-define-options should disable that rule: https://github.com/vuejs/eslint-plugin-vue/issues/1886
- // 'vue/no-duplicate-attr-inheritance': 'error',
- 'vue/no-multiple-objects-in-class': 'error',
- 'vue/no-reserved-component-names': 'error',
- 'vue/no-template-target-blank': 'error',
- 'vue/no-useless-mustaches': 'error',
- 'vue/no-useless-v-bind': 'error',
- 'vue/padding-line-between-blocks': 'error',
- 'vue/prefer-separate-static-class': 'error',
- 'vue/prefer-true-attribute-shorthand': 'error',
- 'vue/v-on-function-call': 'error',
- 'vue/valid-v-slot': ['error', {
- allowModifiers: true,
- }],
- // -- Extension Rules
- 'vue/no-irregular-whitespace': 'error',
- // -- Sonarlint
- 'sonarjs/no-duplicate-string': 'off',
- 'sonarjs/no-nested-template-literals': 'off',
- // -- Unicorn
- // 'unicorn/filename-case': 'off',
- // 'unicorn/prevent-abbreviations': ['error', {
- // replacements: {
- // props: false,
- // },
- // }],
- // https://github.com/gmullerb/eslint-plugin-regex
- 'regex/invalid': [
- 'error',
- [
- {
- regex: '@/assets/images',
- replacement: '@images',
- message: 'Use \'@images\' path alias for image imports',
- },
- {
- regex: '@/styles',
- replacement: '@styles',
- message: 'Use \'@styles\' path alias for importing styles from \'src/styles\'',
- },
- // {
- // id: 'Disallow icon of icon library',
- // regex: 'tabler-\\w',
- // message: 'Only \'mdi\' icons are allowed',
- // },
- {
- regex: '@core/\\w',
- message: 'You can\'t use @core when you are in @layouts module',
- files: {
- inspect: '@layouts/.*',
- },
- },
- {
- regex: 'useLayouts\\(',
- message: '`useLayouts` composable is only allowed in @layouts & @core directory. Please use `useThemeConfig` composable instead.',
- files: {
- inspect: '^(?!.*(@core|@layouts)).*',
- },
- },
- ],
- // Ignore files
- '\.eslintrc\.js',
- ],
- },
- settings: {
- 'import/resolver': {
- node: {
- extensions: ['.ts', '.js', '.tsx', '.jsx', '.mjs', '.png', '.jpg'],
- },
- typescript: {},
- alias: {
- map: [
- ['@', './src'],
- ],
- },
- },
- },
- overrides: [
- {
- files: ['*.json'],
- rules: {
- 'no-invalid-meta': 'off',
- },
- },
- ],
- }
|