Skip to content

Commit 8f5b372

Browse files
committed
chore(): Add vite config to set lintOnStart to a new script npm run start:lint
Signed-off-by: sBouzols <[email protected]>
1 parent b2afa56 commit 8f5b372

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
},
4444
"scripts": {
4545
"start": "vite",
46+
"start:lint": "vite --config vite.config-lint.ts",
4647
"start:open": "vite --open",
4748
"build": "tsc && vite build",
4849
"serve": "vite preview",

vite.config-lint.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright (c) 2024, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
8+
import { defineConfig, mergeConfig } from 'vite';
9+
import defaultConfig from './vite.config.ts';
10+
import react from '@vitejs/plugin-react';
11+
// @ts-expect-error See https://github.com/gxmari007/vite-plugin-eslint/issues/79
12+
import eslint from 'vite-plugin-eslint';
13+
import svgr from 'vite-plugin-svgr';
14+
import tsconfigPaths from 'vite-tsconfig-paths';
15+
16+
export default defineConfig((configEnv) => {
17+
const baseConfig = defaultConfig(configEnv);
18+
baseConfig.plugins = []; // remove existing plugins
19+
return mergeConfig(baseConfig, {
20+
plugins: [
21+
react(),
22+
eslint({
23+
failOnWarning: true,
24+
lintOnStart: true,
25+
}),
26+
svgr(), // works on every import with the pattern "**/*.svg?react"
27+
tsconfigPaths(), // to resolve absolute path via tsconfig cf https://stackoverflow.com/a/68250175/5092999
28+
],
29+
});
30+
});

vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default defineConfig((config) => ({
3333
react(),
3434
eslint({
3535
failOnWarning: config.mode !== 'development',
36-
lintOnStart: true,
36+
lintOnStart: false,
3737
}),
3838
svgr(), // works on every import with the pattern "**/*.svg?react"
3939
tsconfigPaths(), // to resolve absolute path via tsconfig cf https://stackoverflow.com/a/68250175/5092999

0 commit comments

Comments
 (0)