-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add eslint-plugin-vuetify support
- Loading branch information
Showing
10 changed files
with
192 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,6 @@ export * from './unicorn'; | |
|
||
export * from './vue'; | ||
|
||
export * from './vuetify'; | ||
|
||
export * from './yaml'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import globals from 'globals'; | ||
import { ensurePackages, interopDefault } from '../utils'; | ||
import { GLOB_SRC, GLOB_VUE } from '../globs'; | ||
import type { FlatConfigItem, OptionsFiles, OptionsHasTypeScript, OptionsOverrides } from '../types'; | ||
|
||
export async function vuetify(options: OptionsOverrides & OptionsHasTypeScript & OptionsFiles = {}): Promise<FlatConfigItem[]> { | ||
const { | ||
files = [GLOB_SRC, GLOB_VUE], | ||
overrides = { }, | ||
} = options; | ||
|
||
await ensurePackages(['eslint-plugin-vuetify']); | ||
|
||
const [pluginVuetify, parserVue] = await Promise.all([ | ||
interopDefault(import('eslint-plugin-vuetify')), | ||
interopDefault(import('vue-eslint-parser')), | ||
] as const); | ||
|
||
return [ | ||
{ | ||
plugins: { | ||
vuetify: pluginVuetify, | ||
}, | ||
}, | ||
{ | ||
files, | ||
languageOptions: { | ||
globals: { | ||
...globals.browser, | ||
...globals.es2015, | ||
}, | ||
parser: parserVue, | ||
parserOptions: { | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
ecmaVersion: 2022, | ||
extraFileExtensions: ['.vue'], | ||
parser: options.typescript | ||
? await interopDefault(import('@typescript-eslint/parser')) as any | ||
: null, | ||
sourceType: 'module', | ||
}, | ||
}, | ||
rules: { | ||
...pluginVuetify.configs.base.rules, | ||
...pluginVuetify.configs.recommended.rules, | ||
...overrides, | ||
}, | ||
}, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { RuleConfig } from '@antfu/eslint-define-config'; | ||
|
||
export type ValidVLostConfiguration = [{ | ||
allowModifiers?: boolean; | ||
}]; | ||
|
||
export interface VuetifyRules { | ||
'vue/valid-v-slot': RuleConfig<ValidVLostConfiguration>; | ||
|
||
'vuetify/no-deprecated-classes': RuleConfig<[]>; | ||
'vuetify/no-deprecated-colors': RuleConfig<[]>; | ||
'vuetify/no-deprecated-components': RuleConfig<[]>; | ||
'vuetify/no-deprecated-events': RuleConfig<[]>; | ||
'vuetify/no-deprecated-props': RuleConfig<[]>; | ||
'vuetify/no-deprecated-slots': RuleConfig<[]>; | ||
|
||
'vuetify/grid-unknown-attributes': RuleConfig<[]>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Types are based on v2.x of vuetify plugin. | ||
* Not paying to much attention to it since we are going to use the | ||
* recommended anyway. | ||
*/ | ||
declare module 'eslint-plugin-vuetify' { | ||
import type { ValidVLostConfiguration, VuetifyRules } from './rules/vuetify'; | ||
import type { RuleConfig } from '@antfu/eslint-define-config'; | ||
|
||
const baseRules = { | ||
'vue/valid-v-slot': ['error' as const, { | ||
allowModifiers: true, | ||
}] satisfies RuleConfig<ValidVLostConfiguration>, | ||
|
||
'vuetify/no-deprecated-classes': 'error' as const, | ||
'vuetify/no-deprecated-colors': 'error' as const, // v2.x | ||
'vuetify/no-deprecated-components': 'error' as const, | ||
'vuetify/no-deprecated-events': 'error' as const, // v2.x | ||
'vuetify/no-deprecated-props': 'error' as const, | ||
'vuetify/no-deprecated-slots': 'error' as const, // v2.x | ||
}; | ||
|
||
const baseConfig = { | ||
plugins: ['vuetify'], | ||
rules: baseRules, | ||
}; | ||
|
||
export const vuetify: { | ||
rules: VuetifyRules; | ||
configs: { | ||
base: typeof baseConfig; | ||
recommended: typeof baseConfig & { | ||
rules: { | ||
'vuetify/grid-unknown-attributes': 'error'; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default vuetify; | ||
} |