Skip to content

Commit

Permalink
feat: apply vue rules for all files
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Mar 22, 2023
1 parent 21e0f15 commit 7ab173d
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/vue.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { getPackageInfoSync } from 'local-pkg'
import vueParser from 'vue-eslint-parser'
import vuePlugin from 'eslint-plugin-vue'
import tsPlugin from '@typescript-eslint/eslint-plugin'
import { typescript } from './typescript.js'
import { GLOB_VUE } from './shared.js'

export { vueParser, vuePlugin }

Expand All @@ -16,6 +18,7 @@ export function getVueVersion() {
}
return 3
}
const isVue3 = getVueVersion() === 3

/** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
export const reactivityTransform = [
Expand All @@ -31,6 +34,9 @@ export const reactivityTransform = [
$customRef: 'readonly',
},
},
plugins: {
vue: vuePlugin,
},
rules: {
'vue/no-setup-props-destructure': 'off',
},
Expand Down Expand Up @@ -77,10 +83,10 @@ const vue2Rules = {
/** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
export const vue = [
{
files: ['**/*.vue'],
files: [GLOB_VUE],
plugins: {
vue: vuePlugin,
...typescript[0].plugins,
'@typescript-eslint': tsPlugin,
},
languageOptions: {
parser: vueParser,
Expand All @@ -95,9 +101,16 @@ export const vue = [
},
processor: vuePlugin.processors['.vue'],
rules: {
...(getVueVersion() === 3 ? vue3Rules : vue2Rules),
...typescript[0].rules,
},
},
{
plugins: {
vue: vuePlugin,
},
rules: {
...(isVue3 ? vue3Rules : vue2Rules),
},
},
...reactivityTransform,
]

0 comments on commit 7ab173d

Please sign in to comment.