180 lines
5.3 KiB
JavaScript
180 lines
5.3 KiB
JavaScript
module.exports = {
|
|
env: {
|
|
browser: true,
|
|
es2021: true,
|
|
},
|
|
extends: [
|
|
'@antfu/eslint-config-vue',
|
|
'plugin:vue/vue3-recommended',
|
|
'plugin:import/recommended',
|
|
'plugin:import/typescript',
|
|
'plugin:promise/recommended',
|
|
'plugin:sonarjs/recommended',
|
|
'plugin:@typescript-eslint/recommended',
|
|
'plugin:case-police/recommended',
|
|
'plugin:regexp/recommended',
|
|
|
|
// 'plugin:unicorn/recommended',
|
|
],
|
|
parser: 'vue-eslint-parser',
|
|
parserOptions: {
|
|
ecmaVersion: 13,
|
|
parser: '@typescript-eslint/parser',
|
|
sourceType: 'module',
|
|
},
|
|
plugins: [
|
|
'vue',
|
|
'@typescript-eslint',
|
|
'regex',
|
|
'regexp',
|
|
],
|
|
ignorePatterns: ['node_modules', 'dist', '*.d.ts', 'vendor', '*.json'],
|
|
rules: {
|
|
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
'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 }],
|
|
'n/prefer-global/process': ['off'],
|
|
'sonarjs/cognitive-complexity': ['off'],
|
|
|
|
'vue/first-attribute-linebreak': ['error', {
|
|
singleline: 'beside',
|
|
multiline: 'below',
|
|
}],
|
|
|
|
'antfu/top-level-function': 'off',
|
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
|
|
// indentation (Already present in TypeScript)
|
|
'indent': ['error', 2],
|
|
|
|
// Enforce trailing comma (Already present in TypeScript)
|
|
'comma-dangle': ['error', 'always-multiline'],
|
|
|
|
// Enforce consistent spacing inside braces of object (Already present in TypeScript)
|
|
'object-curly-spacing': ['error', 'always'],
|
|
|
|
// Enforce camelCase naming convention
|
|
'camelcase': 'off',
|
|
|
|
// 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', { varsIgnorePattern: '^_+$', 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',
|
|
{
|
|
js: 'never',
|
|
jsx: 'never',
|
|
ts: 'never',
|
|
tsx: 'never',
|
|
},
|
|
],
|
|
|
|
// 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/block-tag-newline': 'error',
|
|
'vue/component-api-style': 'error',
|
|
'vue/component-name-in-template-casing': ['error', 'PascalCase', { registeredComponentsOnly: false, ignores: ['/^swiper-/'] }],
|
|
'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',
|
|
|
|
'vue/no-duplicate-attr-inheritance': 'error',
|
|
'vue/no-empty-component-block': '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': 'off',
|
|
'vue/v-on-function-call': 'error',
|
|
'vue/no-restricted-class': ['error', '/^(p|m)(l|r)-/'],
|
|
'vue/valid-v-slot': ['error', {
|
|
allowModifiers: true,
|
|
}],
|
|
|
|
// -- Extension Rules
|
|
'vue/no-irregular-whitespace': 'error',
|
|
'vue/template-curly-spacing': 'error',
|
|
|
|
// -- Sonarlint
|
|
'sonarjs/no-duplicate-string': 'off',
|
|
'sonarjs/no-nested-template-literals': 'off',
|
|
'vue/no-v-html': 'off',
|
|
'vue/no-v-text-v-html-on-component': 'off',
|
|
},
|
|
settings: {
|
|
'import/resolver': {
|
|
node: true,
|
|
typescript: {},
|
|
},
|
|
},
|
|
}
|