Update
This commit is contained in:
25
src/env.ts
25
src/env.ts
@ -6,39 +6,48 @@ import { tailwind } from './presets/tailwind';
|
||||
import { reactQuery } from './presets/misc';
|
||||
import { testingLibrary } from './presets/testing-library';
|
||||
|
||||
const middlewares = {
|
||||
react,
|
||||
reactRefresh,
|
||||
tailwind,
|
||||
storybook,
|
||||
reactQuery,
|
||||
testingLibrary,
|
||||
};
|
||||
|
||||
export const envs: {
|
||||
dependency: string;
|
||||
eslintPlugin?: string;
|
||||
middleware: Middleware;
|
||||
middleware: keyof typeof middlewares;
|
||||
}[] = [
|
||||
{
|
||||
dependency: 'react',
|
||||
middleware: react,
|
||||
middleware: 'react',
|
||||
},
|
||||
{
|
||||
dependency: '@vitejs/plugin-react',
|
||||
eslintPlugin: 'eslint-plugin-react-refresh',
|
||||
middleware: reactRefresh,
|
||||
middleware: 'reactRefresh',
|
||||
},
|
||||
{
|
||||
dependency: 'tailwindcss',
|
||||
eslintPlugin: 'eslint-plugin-tailwindcss',
|
||||
middleware: tailwind,
|
||||
middleware: 'tailwind',
|
||||
},
|
||||
{
|
||||
dependency: 'storybook',
|
||||
eslintPlugin: 'eslint-plugin-storybook',
|
||||
middleware: storybook,
|
||||
middleware: 'storybook',
|
||||
},
|
||||
{
|
||||
dependency: '@tanstack/react-query',
|
||||
eslintPlugin: '@tanstack/eslint-plugin-query',
|
||||
middleware: reactQuery,
|
||||
middleware: 'reactQuery',
|
||||
},
|
||||
{
|
||||
dependency: '@testing-library/react',
|
||||
eslintPlugin: 'eslint-plugin-testing-library',
|
||||
middleware: testingLibrary,
|
||||
middleware: 'testingLibrary',
|
||||
},
|
||||
];
|
||||
|
||||
@ -64,7 +73,7 @@ export function* checkEnv(): Generator<Middleware> {
|
||||
|
||||
for (const { dependency, eslintPlugin, middleware } of envs) {
|
||||
if (deps.has(dependency) && (!eslintPlugin || deps.has(eslintPlugin))) {
|
||||
yield middleware;
|
||||
yield middlewares[middleware];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ interface MiddlewareFunctions {
|
||||
*/
|
||||
export function extendConfig(
|
||||
of: InputConfig & {
|
||||
middlewares: Middleware[];
|
||||
middlewares?: Middleware[];
|
||||
} = {
|
||||
middlewares: [],
|
||||
},
|
||||
|
@ -9,11 +9,7 @@ const packages = uniq(
|
||||
.map(_ => _.eslintPlugin!),
|
||||
);
|
||||
|
||||
console.log('Installing missing ESLint plugins:');
|
||||
for (const pkg of packages) {
|
||||
console.log(`- ${pkg}`);
|
||||
}
|
||||
console.log();
|
||||
console.log('Installing missing ESLint plugins.\n');
|
||||
|
||||
void installPackage(packages, {
|
||||
silent: false,
|
||||
|
Reference in New Issue
Block a user