|
module.exports = { |
|
root: true, |
|
env: { |
|
browser: true, |
|
node: true, |
|
}, |
|
parser: 'vue-eslint-parser', |
|
parserOptions: { |
|
parser: '@typescript-eslint/parser', |
|
sourceType: 'module', |
|
}, |
|
extends: [ |
|
'eslint:recommended', |
|
'plugin:vue/vue3-recommended', |
|
'plugin:prettier/recommended', |
|
'plugin:import/recommended', |
|
'plugin:import/typescript', |
|
], |
|
rules: { |
|
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/order.md |
|
'import/order': [ |
|
'error', |
|
{ |
|
pathGroups: [ |
|
{ |
|
pattern: '@/**', |
|
group: 'internal', |
|
}, |
|
], |
|
'newlines-between': 'always', |
|
groups: ['builtin', 'external', 'internal', 'index', 'sibling', 'parent', 'object', 'type'], |
|
}, |
|
], |
|
// https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/newline-after-import.md |
|
'import/newline-after-import': [ |
|
'error', |
|
{ |
|
count: 1, |
|
}, |
|
], |
|
|
|
/* Disable some repeated and low performance rules https://github.com/typescript-eslint/typescript-eslint/blob/f335c504bcf75623d2d671e2e784b047e5e186b9/docs/getting-started/linting/FAQ.md#eslint-plugin-import */ |
|
'import/named': 'off', |
|
'import/namespace': 'off', |
|
'import/default': 'off', |
|
'import/no-named-as-default-member': 'off', |
|
'import/no-unused-modules': 'off', |
|
'import/no-named-as-default': 'off', |
|
'import/no-cycle': 'off', |
|
'import/no-deprecated': 'off', |
|
|
|
// https://eslint.vuejs.org/rules/padding-line-between-blocks.html#vue-padding-line-between-blocks |
|
'vue/padding-line-between-blocks': ['error', 'always'], |
|
|
|
// https://eslint.vuejs.org/rules/html-self-closing.html#vue-html-self-closing |
|
'vue/html-self-closing': [ |
|
'error', |
|
{ |
|
html: { |
|
void: 'always', |
|
normal: 'never', |
|
component: 'always', |
|
}, |
|
svg: 'always', |
|
math: 'always', |
|
}, |
|
], |
|
|
|
// https://eslint.vuejs.org/rules/block-lang.html#vue-block-lang |
|
'vue/block-lang': [ |
|
'error', |
|
{ |
|
script: { |
|
lang: 'ts', |
|
}, |
|
}, |
|
], |
|
|
|
// https://eslint.vuejs.org/rules/new-line-between-multi-line-property.html#vue-new-line-between-multi-line-property |
|
'vue/new-line-between-multi-line-property': [ |
|
'error', |
|
{ |
|
minLineOfMultilineProperty: 2, |
|
}, |
|
], |
|
|
|
// https://eslint.vuejs.org/rules/no-undef-properties.html#vue-no-undef-properties |
|
'vue/no-undef-properties': [ |
|
'error', |
|
{ |
|
ignores: ['/^\\$/'], |
|
}, |
|
], |
|
|
|
// https://eslint.vuejs.org/rules/no-useless-v-bind.html#vue-no-useless-v-bind |
|
'vue/no-useless-v-bind': [ |
|
'error', |
|
{ |
|
ignoreIncludesComment: true, |
|
ignoreStringEscape: true, |
|
}, |
|
], |
|
|
|
// https://eslint.vuejs.org/rules/prefer-true-attribute-shorthand.html#vue-prefer-true-attribute-shorthand |
|
'vue/prefer-true-attribute-shorthand': ['error', 'always'], |
|
|
|
// https://eslint.vuejs.org/rules/no-unused-properties.html#vue-no-unused-properties |
|
'vue/no-unused-properties': [ |
|
'error', |
|
{ |
|
groups: ['props', 'data', 'computed', 'methods', 'setup'], |
|
deepData: false, |
|
ignorePublicMembers: true, |
|
}, |
|
], |
|
|
|
// https://eslint.vuejs.org/rules/component-name-in-template-casing.html#vue-component-name-in-template-casing |
|
'vue/component-name-in-template-casing': [ |
|
'error', |
|
'PascalCase', |
|
{ |
|
registeredComponentsOnly: false, |
|
ignores: ['/^component|client-only|keep-alive|router-view|router-link|i18n$/'], |
|
}, |
|
], |
|
|
|
// https://eslint.vuejs.org/rules/component-api-style.html |
|
'vue/component-api-style': [ |
|
'error', |
|
['script-setup', 'composition'], // "script-setup", "composition", "composition-vue2", or "options" |
|
], |
|
|
|
// https://eslint.vuejs.org/rules/custom-event-name-casing.html |
|
'vue/custom-event-name-casing': [ |
|
'error', |
|
'kebab-case', // 'camelCase' | 'kebab-case' |
|
{ |
|
ignores: [], |
|
}, |
|
], |
|
|
|
// https://eslint.vuejs.org/rules/define-emits-declaration#vue-define-emits-declaration |
|
'vue/define-emits-declaration': ['error', 'type-literal'], |
|
|
|
// https://eslint.vuejs.org/rules/match-component-file-name.html |
|
'vue/match-component-file-name': [ |
|
'error', |
|
{ |
|
extensions: ['vue'], |
|
shouldMatchCase: true, |
|
}, |
|
], |
|
|
|
// https://eslint.vuejs.org/rules/next-tick-style.html |
|
'vue/next-tick-style': ['error', 'promise'], |
|
|
|
// https://eslint.vuejs.org/rules/no-duplicate-attr-inheritance.html |
|
'vue/no-duplicate-attr-inheritance': ['error'], |
|
|
|
// https://eslint.vuejs.org/rules/no-required-prop-with-default.html |
|
'vue/no-required-prop-with-default': [ |
|
'error', |
|
{ |
|
autofix: false, |
|
}, |
|
], |
|
|
|
// https://eslint.vuejs.org/rules/no-useless-mustaches.html#vue-no-useless-mustaches |
|
'vue/no-useless-mustaches': [ |
|
'error', |
|
{ |
|
ignoreIncludesComment: false, |
|
ignoreStringEscape: true, |
|
}, |
|
], |
|
|
|
// https://eslint.vuejs.org/rules/prefer-define-options.html |
|
'vue/prefer-define-options': ['error'], |
|
|
|
// https://eslint.vuejs.org/rules/require-macro-variable-name.html |
|
'vue/require-macro-variable-name': [ |
|
'error', |
|
{ |
|
defineProps: 'props', |
|
defineEmits: 'emit', |
|
defineSlots: 'slots', |
|
useSlots: 'slots', |
|
useAttrs: 'attrs', |
|
}, |
|
], |
|
|
|
// https://eslint.vuejs.org/rules/valid-define-options.html |
|
'vue/valid-define-options': ['error'], |
|
|
|
/* |
|
* Below are rules that is more depends on personal preference |
|
* and may not be suitable for all projects |
|
*/ |
|
|
|
// https://eslint.vuejs.org/rules/component-tags-order.html#vue-component-tags-order |
|
'vue/block-order': [ |
|
'error', |
|
{ |
|
order: ['template', 'script', 'style'], |
|
}, |
|
], |
|
|
|
// https://eslint.vuejs.org/rules/require-emit-validator.html#vue-require-emit-validator |
|
'vue/require-emit-validator': ['error'], |
|
|
|
// https://eslint.vuejs.org/rules/v-on-handler-style.html |
|
'vue/v-on-handler-style': [ |
|
'error', |
|
['method', 'inline-function'], // ["method", "inline-function"] | ["method", "inline"] | "inline-function" | "inline" |
|
{ |
|
ignoreIncludesComment: false, |
|
}, |
|
], |
|
|
|
// https://eslint.vuejs.org/rules/no-ref-object-reactivity-loss.html |
|
'vue/no-ref-object-reactivity-loss': ['error'], |
|
|
|
// https://eslint.vuejs.org/rules/define-macros-order.html |
|
'vue/define-macros-order': [ |
|
'error', |
|
{ |
|
order: ['defineOptions', 'defineModel', 'defineProps', 'defineEmits', 'defineSlots'], |
|
defineExposeLast: true, |
|
}, |
|
], |
|
|
|
// https://eslint.vuejs.org/rules/define-props-declaration.html |
|
'vue/define-props-declaration': ['error', 'type-based'], |
|
|
|
// https://eslint.vuejs.org/rules/match-component-import-name.html |
|
'vue/match-component-import-name': ['error'], |
|
|
|
// https://eslint.vuejs.org/rules/no-static-inline-styles.html |
|
'vue/no-static-inline-styles': [ |
|
'error', |
|
{ |
|
allowBinding: false, |
|
}, |
|
], |
|
}, |
|
}; |