From 8f5b37250c83379db6fe2804c30fa09a7bc69c49 Mon Sep 17 00:00:00 2001 From: sBouzols Date: Mon, 29 Sep 2025 16:25:07 +0200 Subject: [PATCH 1/2] chore(): Add vite config to set `lintOnStart` to a new script `npm run start:lint` Signed-off-by: sBouzols --- package.json | 1 + vite.config-lint.ts | 30 ++++++++++++++++++++++++++++++ vite.config.ts | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 vite.config-lint.ts diff --git a/package.json b/package.json index 83d645d..ad60815 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ }, "scripts": { "start": "vite", + "start:lint": "vite --config vite.config-lint.ts", "start:open": "vite --open", "build": "tsc && vite build", "serve": "vite preview", diff --git a/vite.config-lint.ts b/vite.config-lint.ts new file mode 100644 index 0000000..0f43e4c --- /dev/null +++ b/vite.config-lint.ts @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2024, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +import { defineConfig, mergeConfig } from 'vite'; +import defaultConfig from './vite.config.ts'; +import react from '@vitejs/plugin-react'; +// @ts-expect-error See https://github.com/gxmari007/vite-plugin-eslint/issues/79 +import eslint from 'vite-plugin-eslint'; +import svgr from 'vite-plugin-svgr'; +import tsconfigPaths from 'vite-tsconfig-paths'; + +export default defineConfig((configEnv) => { + const baseConfig = defaultConfig(configEnv); + baseConfig.plugins = []; // remove existing plugins + return mergeConfig(baseConfig, { + plugins: [ + react(), + eslint({ + failOnWarning: true, + lintOnStart: true, + }), + svgr(), // works on every import with the pattern "**/*.svg?react" + tsconfigPaths(), // to resolve absolute path via tsconfig cf https://stackoverflow.com/a/68250175/5092999 + ], + }); +}); diff --git a/vite.config.ts b/vite.config.ts index 44b2877..8171633 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -33,7 +33,7 @@ export default defineConfig((config) => ({ react(), eslint({ failOnWarning: config.mode !== 'development', - lintOnStart: true, + lintOnStart: false, }), svgr(), // works on every import with the pattern "**/*.svg?react" tsconfigPaths(), // to resolve absolute path via tsconfig cf https://stackoverflow.com/a/68250175/5092999 From 95f450038ebef823f3c5b4dd02ac9d6522f05faf Mon Sep 17 00:00:00 2001 From: sBouzols Date: Fri, 3 Oct 2025 14:34:38 +0200 Subject: [PATCH 2/2] remove vite.config-lint file keep it simple Signed-off-by: sBouzols --- package.json | 1 - vite.config-lint.ts | 30 ------------------------------ vite.config.ts | 1 - 3 files changed, 32 deletions(-) delete mode 100644 vite.config-lint.ts diff --git a/package.json b/package.json index ad60815..83d645d 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ }, "scripts": { "start": "vite", - "start:lint": "vite --config vite.config-lint.ts", "start:open": "vite --open", "build": "tsc && vite build", "serve": "vite preview", diff --git a/vite.config-lint.ts b/vite.config-lint.ts deleted file mode 100644 index 0f43e4c..0000000 --- a/vite.config-lint.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2024, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -import { defineConfig, mergeConfig } from 'vite'; -import defaultConfig from './vite.config.ts'; -import react from '@vitejs/plugin-react'; -// @ts-expect-error See https://github.com/gxmari007/vite-plugin-eslint/issues/79 -import eslint from 'vite-plugin-eslint'; -import svgr from 'vite-plugin-svgr'; -import tsconfigPaths from 'vite-tsconfig-paths'; - -export default defineConfig((configEnv) => { - const baseConfig = defaultConfig(configEnv); - baseConfig.plugins = []; // remove existing plugins - return mergeConfig(baseConfig, { - plugins: [ - react(), - eslint({ - failOnWarning: true, - lintOnStart: true, - }), - svgr(), // works on every import with the pattern "**/*.svg?react" - tsconfigPaths(), // to resolve absolute path via tsconfig cf https://stackoverflow.com/a/68250175/5092999 - ], - }); -}); diff --git a/vite.config.ts b/vite.config.ts index 8171633..06de9f6 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -33,7 +33,6 @@ export default defineConfig((config) => ({ react(), eslint({ failOnWarning: config.mode !== 'development', - lintOnStart: false, }), svgr(), // works on every import with the pattern "**/*.svg?react" tsconfigPaths(), // to resolve absolute path via tsconfig cf https://stackoverflow.com/a/68250175/5092999