Inline repo
This commit is contained in:
145
packages/eslint-define-config/scripts/plugins-map.ts
Normal file
145
packages/eslint-define-config/scripts/plugins-map.ts
Normal file
@ -0,0 +1,145 @@
|
||||
import type { Plugin, PluginRules } from './utils';
|
||||
|
||||
/**
|
||||
* Map of plugins for which the script will generate rule files.
|
||||
*/
|
||||
export const PLUGIN_REGISTRY: Plugin[] = [
|
||||
{
|
||||
id: 'deprecation',
|
||||
name: 'Deprecation',
|
||||
module: () => import('eslint-plugin-deprecation'),
|
||||
},
|
||||
{
|
||||
id: 'eslint',
|
||||
name: 'ESLint',
|
||||
module: () => import('eslint'),
|
||||
},
|
||||
{
|
||||
id: 'typescript-eslint',
|
||||
name: 'TypeScript',
|
||||
prefix: '@typescript-eslint',
|
||||
module: () => import('@typescript-eslint/eslint-plugin'),
|
||||
},
|
||||
{
|
||||
id: 'import',
|
||||
name: 'Import',
|
||||
module: () => import('eslint-plugin-import'),
|
||||
},
|
||||
{
|
||||
id: 'eslint-comments',
|
||||
name: 'EslintComments',
|
||||
module: () => import('eslint-plugin-eslint-comments'),
|
||||
},
|
||||
{
|
||||
id: 'graphql-eslint',
|
||||
name: 'GraphQL',
|
||||
prefix: '@graphql-eslint',
|
||||
module: () => import('@graphql-eslint/eslint-plugin'),
|
||||
},
|
||||
{
|
||||
id: 'jsdoc',
|
||||
name: 'JSDoc',
|
||||
prefix: 'jsdoc',
|
||||
module: () => import('eslint-plugin-jsdoc'),
|
||||
},
|
||||
{
|
||||
id: 'jsonc',
|
||||
name: 'Jsonc',
|
||||
module: () => import('eslint-plugin-jsonc'),
|
||||
},
|
||||
{
|
||||
id: 'jsx-a11y',
|
||||
name: 'JsxA11y',
|
||||
module: () => import('eslint-plugin-jsx-a11y'),
|
||||
},
|
||||
{
|
||||
id: 'mdx',
|
||||
name: 'Mdx',
|
||||
module: () => import('eslint-plugin-mdx'),
|
||||
},
|
||||
{
|
||||
id: 'n',
|
||||
name: 'N',
|
||||
module: () => import('eslint-plugin-n'),
|
||||
},
|
||||
{
|
||||
id: 'node',
|
||||
name: 'Node',
|
||||
module: () => import('eslint-plugin-node'),
|
||||
},
|
||||
{
|
||||
id: 'promise',
|
||||
name: 'Promise',
|
||||
module: () => import('eslint-plugin-promise'),
|
||||
},
|
||||
{
|
||||
id: 'react',
|
||||
name: 'React',
|
||||
module: () => import('eslint-plugin-react'),
|
||||
},
|
||||
{
|
||||
id: 'react-hooks',
|
||||
name: 'ReactHooks',
|
||||
module: () => import('eslint-plugin-react-hooks'),
|
||||
},
|
||||
{
|
||||
id: 'sonarjs',
|
||||
name: 'SonarJS',
|
||||
prefix: 'sonarjs',
|
||||
module: () => import('eslint-plugin-sonarjs'),
|
||||
},
|
||||
{
|
||||
id: 'spellcheck',
|
||||
name: 'Spellcheck',
|
||||
module: () => import('eslint-plugin-spellcheck'),
|
||||
},
|
||||
{
|
||||
id: 'testing-library',
|
||||
name: 'TestingLibrary',
|
||||
module: () => import('eslint-plugin-testing-library'),
|
||||
},
|
||||
{
|
||||
id: 'unicorn',
|
||||
name: 'Unicorn',
|
||||
module: () => import('eslint-plugin-unicorn'),
|
||||
},
|
||||
{
|
||||
id: 'vitest',
|
||||
name: 'Vitest',
|
||||
module: () => import('eslint-plugin-vitest'),
|
||||
},
|
||||
{
|
||||
id: 'vue',
|
||||
name: 'Vue',
|
||||
module: () => import('eslint-plugin-vue'),
|
||||
},
|
||||
{
|
||||
id: 'vue-i18n',
|
||||
name: 'VueI18n',
|
||||
prefix: '@intlify/vue-i18n',
|
||||
module: () => import('@intlify/eslint-plugin-vue-i18n'),
|
||||
},
|
||||
{
|
||||
id: 'vue-pug',
|
||||
name: 'VuePug',
|
||||
module: () => import('eslint-plugin-vue-pug'),
|
||||
},
|
||||
{
|
||||
id: 'yml',
|
||||
name: 'Yml',
|
||||
module: () => import('eslint-plugin-yml'),
|
||||
},
|
||||
] as const;
|
||||
|
||||
export async function loadPlugin(plugin: Plugin): Promise<Plugin> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const mod: any = await plugin.module();
|
||||
const rules: PluginRules =
|
||||
plugin.name === 'ESLint'
|
||||
? Object.fromEntries(
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||
new mod.Linter().getRules().entries(),
|
||||
)
|
||||
: mod.rules ?? mod.default.rules;
|
||||
return { ...plugin, rules };
|
||||
}
|
Reference in New Issue
Block a user