forked from eslint-types/eslint-define-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugins-map.ts
110 lines (108 loc) · 2.55 KB
/
plugins-map.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import type { Plugin, PluginRules } from '../contracts';
/**
* Map of plugins for which the script will generate rule files.
*/
export const PLUGIN_REGISTRY: Readonly<Record<string, Plugin>> = {
deprecation: {
name: 'Deprecation',
module: 'eslint-plugin-deprecation',
},
eslint: {
name: 'Eslint',
module: 'eslint',
},
'typescript-eslint': {
name: 'TypeScript',
prefix: '@typescript-eslint',
module: '@typescript-eslint/eslint-plugin',
},
import: {
name: 'Import',
module: 'eslint-plugin-import',
},
'eslint-comments': {
name: 'EslintComments',
module: 'eslint-plugin-eslint-comments',
},
'graphql-eslint': {
name: 'GraphQL',
prefix: '@graphql-eslint',
module: '@graphql-eslint/eslint-plugin',
},
jsdoc: {
name: 'JSDoc',
prefix: 'jsdoc',
module: 'eslint-plugin-jsdoc',
},
jsonc: {
name: 'Jsonc',
module: 'eslint-plugin-jsonc',
},
mdx: {
name: 'Mdx',
module: 'eslint-plugin-mdx',
},
n: {
name: 'N',
module: 'eslint-plugin-n',
},
node: {
name: 'Node',
module: 'eslint-plugin-node',
},
promise: {
name: 'Promise',
module: 'eslint-plugin-promise',
},
react: {
name: 'React',
module: 'eslint-plugin-react',
},
'react-hooks': {
name: 'ReactHooks',
module: 'eslint-plugin-react-hooks',
},
sonarjs: {
name: 'SonarJS',
prefix: 'sonarjs',
module: 'eslint-plugin-sonarjs',
},
spellcheck: {
name: 'Spellcheck',
module: 'eslint-plugin-spellcheck',
},
unicorn: {
name: 'Unicorn',
module: 'eslint-plugin-unicorn',
},
vitest: {
name: 'Vitest',
module: 'eslint-plugin-vitest',
},
vue: {
name: 'Vue',
module: 'eslint-plugin-vue',
},
'vue-i18n': {
name: 'VueI18n',
prefix: '@intlify/vue-i18n',
module: '@intlify/eslint-plugin-vue-i18n',
},
'vue-pug': {
name: 'VuePug',
module: 'eslint-plugin-vue-pug',
},
} as const;
export async function loadPlugin(plugin: Plugin): Promise<Plugin> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const mod: any = await import(plugin.module);
const rules: PluginRules =
plugin.module === 'eslint'
? Object.fromEntries(
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
new mod.Linter().getRules().entries(),
)
: // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
mod.rules ?? mod.default.rules;
return { ...plugin, rules };
}