@pplancq/react-template 2.3.16 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## @pplancq/react-template [2.4.0](https://github.com/pplancq/dev-tools/compare/@pplancq/react-template@2.3.16...@pplancq/react-template@2.4.0) (2025-04-23)
2
+
3
+ ### Features
4
+
5
+ * **react-template:** enhance Vite migration by adding public path configuration and build options ([4bfa14a](https://github.com/pplancq/dev-tools/commit/4bfa14a8f1765f02281742f2d3f189e74460b4e3))
6
+ * **react-template:** improve plugin configuration and update ESLint settings ([a311045](https://github.com/pplancq/dev-tools/commit/a31104522edeeccd252a498348c9fb8d4df2d125))
7
+ * **react-template:** migrate configuration files to ES module syntax and update related scripts ([b9d9bd0](https://github.com/pplancq/dev-tools/commit/b9d9bd04a42a024b276254772765b3ecfeda4415))
8
+ * **react-template:** update file paths and remove obsolete configurations ([d48bbe0](https://github.com/pplancq/dev-tools/commit/d48bbe042c304bc8a708bd0d741613601d0ee9cf))
9
+ * **react-template:** update package scripts for Vite integration and add mock environment support ([e534e40](https://github.com/pplancq/dev-tools/commit/e534e40e5dbcf2c14231b7e6d400b8591ecdffd2))
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update dependency react-router to ^7.5.1 ([ae0c0e5](https://github.com/pplancq/dev-tools/commit/ae0c0e579612faf1371644ce3a6d7fa40883993a))
14
+ * **deps:** update react-query mono repo to ^5.74.4 ([8c56b6b](https://github.com/pplancq/dev-tools/commit/8c56b6be39c9e3e932b1a8d994dc676c5068efad))
15
+ * **react-template:** update tsconfig to replace webpack config with vite ([68b87e2](https://github.com/pplancq/dev-tools/commit/68b87e2ce031f771efc0c0f087362242afc3ec73))
16
+
17
+
18
+ ### Dependencies
19
+
20
+ * **@pplancq/eslint-config:** upgraded to 4.0.20
21
+ * **@pplancq/webpack-config:** upgraded to 1.9.11
22
+
1
23
  ## @pplancq/react-template [2.3.16](https://github.com/pplancq/dev-tools/compare/@pplancq/react-template@2.3.15...@pplancq/react-template@2.3.16) (2025-04-14)
2
24
 
3
25
  ### Bug Fixes
@@ -0,0 +1,3 @@
1
+ export default {
2
+ extends: ['@pplancq/commitlint-config'],
3
+ };
package/eslint.config.mjs CHANGED
@@ -11,5 +11,12 @@ export default defineConfig({
11
11
  'import/no-extraneous-dependencies': 'off',
12
12
  },
13
13
  },
14
+ {
15
+ files: ['**/*.config.{js,cjs,mjs,ts,cts,mts}'],
16
+ rules: {
17
+ 'import/no-default-export': 'off',
18
+ 'import/no-extraneous-dependencies': 'off',
19
+ },
20
+ },
14
21
  ],
15
22
  });
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  '*.{js,jsx,mjs,ts,tsx}': 'eslint --fix',
3
3
  '*.{ts,tsx}': 'tsc-files --noEmit',
4
4
  '*.{scss,css}': 'stylelint --fix',
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@pplancq/react-template",
3
- "version": "2.3.16",
3
+ "version": "2.4.0",
4
4
  "license": "MIT",
5
5
  "description": "react template",
6
6
  "author": "pplancq <paul.plancq@outlook.fr>",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/pplancq/dev-tools",
10
- "directory": "packages/webpack-config"
9
+ "url": "git+https://github.com/pplancq/dev-tools.git",
10
+ "directory": "packages/react-template"
11
11
  },
12
+ "type": "module",
12
13
  "scripts": {
13
14
  "start": "webpack serve",
14
15
  "start:mock": "webpack serve --env FRONT_MOCK_ENABLE=true",
@@ -24,8 +25,8 @@
24
25
  "lint:prettier:fix": "prettier \"{mocks,public,src}/**/*.!(js|jsx|mjs|ts|tsx|scss|css)\" --write --ignore-unknown",
25
26
  "lint:tsc": "tsc --noEmit",
26
27
  "package:check": "npm exec --yes package-lock-utd@1.1.3",
27
- "remove:demo": "node ./scripts/removeDemo.js",
28
- "migrate:vite": "node ./scripts/migrateToVite.js",
28
+ "remove:demo": "node ./scripts/removeDemo.cjs",
29
+ "migrate:vite": "node ./scripts/migrateToVite.cjs",
29
30
  "_prepare": "husky",
30
31
  "_postinstall": "msw init"
31
32
  },
@@ -38,12 +39,12 @@
38
39
  ],
39
40
  "dependencies": {
40
41
  "@hookform/resolvers": "^5.0.1",
41
- "@tanstack/react-query": "^5.72.2",
42
- "@tanstack/react-query-devtools": "^5.72.2",
42
+ "@tanstack/react-query": "^5.74.4",
43
+ "@tanstack/react-query-devtools": "^5.74.4",
43
44
  "react": "^19.1.0",
44
45
  "react-dom": "^19.1.0",
45
46
  "react-hook-form": "^7.55.0",
46
- "react-router": "^7.5.0",
47
+ "react-router": "^7.5.1",
47
48
  "yup": "^1.6.1"
48
49
  },
49
50
  "devDependencies": {
@@ -57,17 +58,17 @@
57
58
  "@testing-library/jest-dom": "^6.6.3",
58
59
  "@testing-library/react": "^16.3.0",
59
60
  "@testing-library/user-event": "^14.6.1",
60
- "@types/react": "^19.1.0",
61
+ "@types/react": "^19.1.2",
61
62
  "@types/react-dom": "^19.1.2",
62
- "@vitejs/plugin-react-swc": "^3.8.1",
63
+ "@vitejs/plugin-react-swc": "^3.9.0",
63
64
  "@vitest/coverage-v8": "^3.1.1",
64
65
  "concurrently": "^9.1.2",
65
66
  "eslint": "^9.24.0",
66
67
  "eslint-plugin-prettier": "^5.2.6",
67
68
  "husky": "^9.1.7",
68
- "jsdom": "^26.0.0",
69
- "lint-staged": "^15.5.0",
70
- "msw": "^2.7.3",
69
+ "jsdom": "^26.1.0",
70
+ "lint-staged": "^15.5.1",
71
+ "msw": "^2.7.4",
71
72
  "prettier": "^3.5.3",
72
73
  "stylelint": "^16.18.0",
73
74
  "stylelint-prettier": "^5.0.3",
@@ -0,0 +1,5 @@
1
+ import defaultConfig from '@pplancq/postcss-config';
2
+
3
+ export default {
4
+ ...defaultConfig,
5
+ };
@@ -0,0 +1,5 @@
1
+ import defaultConfig from '@pplancq/prettier-config';
2
+
3
+ export default {
4
+ ...defaultConfig,
5
+ };
package/scripts/lint.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // eslint-disable-next-line import/no-extraneous-dependencies
2
- const concurrently = require('concurrently');
2
+ import concurrently from 'concurrently';
3
3
 
4
4
  const { result } = concurrently(['npm:lint:eslint', 'npm:lint:tsc', 'npm:lint:stylelint', 'npm:lint:prettier'], {
5
5
  prefixColors: 'auto',
@@ -40,58 +40,104 @@ runCommand(
40
40
  writeFileSync(
41
41
  resolve(__dirname, '../vite.config.mts'),
42
42
  `import react from '@vitejs/plugin-react-swc'
43
- import { resolve } from 'path'
44
43
  import { defineConfig, loadEnv } from 'vite'
45
44
  import eslintPlugin from 'vite-plugin-eslint2'
46
45
  import stylelintPlugin from 'vite-plugin-stylelint'
47
46
  import svgr from 'vite-plugin-svgr'
48
47
  import viteTsconfigPaths from 'vite-tsconfig-paths'
48
+ import packageJson from './package.json'
49
+
50
+ const resolveModule = (module: string) => {
51
+ try {
52
+ require.resolve(module);
53
+ return true;
54
+ } catch {
55
+ return false;
56
+ }
57
+ };
49
58
 
50
59
  export default defineConfig(({ mode }) => {
51
60
  const env = loadEnv(mode, process.cwd(), '')
52
61
 
62
+ const disableStyleLintPlugin =
63
+ (env.DISABLE_STYLELINT_PLUGIN ?? 'false') === 'true' || !resolveModule('stylelint');
64
+ const disableEsLintPlugin =
65
+ (env.DISABLE_ESLINT_PLUGIN ?? 'false') === 'true' || !resolveModule('eslint');
66
+ const publicUrl = env.PUBLIC_URL ?? packageJson.homepage ?? '/';
67
+ const publicPath = mode === 'development'
68
+ ? '/'
69
+ : new URL(publicUrl.endsWith('/') ? publicUrl : \`\${publicUrl}/\`, 'http://localhost').pathname;
70
+
53
71
  return {
54
72
  plugins: [
55
73
  react(),
56
74
  viteTsconfigPaths(),
57
75
  svgr(),
58
- eslintPlugin({
76
+ !disableEsLintPlugin && eslintPlugin({
59
77
  emitErrorAsWarning: true,
60
78
  cache: false
61
79
  }),
62
- stylelintPlugin({
80
+ !disableStyleLintPlugin && stylelintPlugin({
63
81
  emitErrorAsWarning: true,
64
82
  cache: false
65
83
  })
66
- ],
84
+ ].filter(Boolean),
67
85
  envPrefix: env.ENV_PREFIX ?? 'FRONT_',
86
+ base: publicPath,
68
87
  server: {
69
- port: parseInt(process.env.PORT ?? '3000', 10),
70
- open: (process.env.BROWSER ?? 'false') === 'true'
71
- },
72
- root: resolve(__dirname, 'public'),
73
- publicDir: resolve(__dirname, 'public'),
74
- resolve: {
75
- alias: { '/src': resolve(__dirname, 'src') }
88
+ port: parseInt(env.PORT ?? '3000', 10),
89
+ open: (env.BROWSER ?? 'false') === 'true'
76
90
  },
77
91
  build: {
78
- outDir: resolve(__dirname, 'build')
79
- }
92
+ sourcemap: (env.DISABLE_SOURCE_MAP ?? 'false') !== 'true',
93
+ outDir: 'build',
94
+ },
80
95
  }
81
96
  })
82
97
  `,
83
98
  { encoding: 'utf-8' },
84
99
  );
85
100
 
101
+ let tsconfig = readFileSync(resolve(__dirname, '../tsconfig.json'), { encoding: 'utf-8' });
102
+ tsconfig = tsconfig.replace('@pplancq/webpack-config', 'vite/client');
103
+ writeFileSync(resolve(__dirname, '../tsconfig.json'), tsconfig, { encoding: 'utf-8' });
104
+
86
105
  const packagesJson = JSON.parse(readFileSync(resolve(__dirname, '../package.json'), { encoding: 'utf-8' }));
87
- const { start, build, 'migrate:vite': _, ...scripts } = packagesJson.scripts;
88
- packagesJson.scripts = { start: 'vite', build: 'vite build', preview: 'vite preview', ...scripts };
106
+ const { start, build, 'migrate:vite': a, 'start:mock': b, ...scripts } = packagesJson.scripts;
107
+ packagesJson.scripts = {
108
+ start: 'vite',
109
+ build: 'vite build',
110
+ preview: 'vite preview',
111
+ 'start:mock': 'vite --mode mock',
112
+ ...scripts,
113
+ };
89
114
  writeFileSync(resolve(__dirname, '../package.json'), JSON.stringify(packagesJson, null, 2), { encoding: 'utf-8' });
90
115
 
91
116
  let indexHTML = readFileSync(resolve(__dirname, '../public/index.html'), { encoding: 'utf-8' });
92
117
  indexHTML = indexHTML.replace(' </body>', ' <script type="module" src="/src/main.ts"></script>\n </body>');
93
- writeFileSync(resolve(__dirname, '../public/index.html'), indexHTML, { encoding: 'utf-8' });
118
+ writeFileSync(resolve(__dirname, '../index.html'), indexHTML, { encoding: 'utf-8' });
119
+ rmSync(resolve(__dirname, '../public/index.html'));
120
+
121
+ let envFile = readFileSync(resolve(__dirname, '../.env'), { encoding: 'utf-8' });
122
+ envFile = envFile.replace(
123
+ `
124
+
125
+ # Specify the type of configuration to use with ESLint.
126
+ # - 'eslintrc' is the classic configuration format available in most ESLint versions.
127
+ # - 'flat' is the new format introduced in ESLint 8.21.0.
128
+ # Default is 'eslintrc'
129
+ ESLINT_CONFIG_TYPE='flat'`,
130
+ '',
131
+ );
132
+ writeFileSync(resolve(__dirname, '../.env'), envFile, { encoding: 'utf-8' });
133
+
134
+ writeFileSync(
135
+ resolve(__dirname, '../.env.mock'),
136
+ `FRONT_MOCK_ENABLE=true
137
+ `,
138
+ { encoding: 'utf-8' },
139
+ );
94
140
 
95
- rmSync(resolve(__dirname, '../scripts/migrateToVite.js'));
141
+ rmSync(resolve(__dirname, '../scripts/migrateToVite.cjs'));
96
142
 
97
143
  console.info('\nThe application has been migrate to vite');
@@ -83,6 +83,6 @@ const { 'remove:demo': _, ...scripts } = packagesJson.scripts;
83
83
  packagesJson.scripts = { ...scripts };
84
84
  writeFileSync(resolve(__dirname, '../package.json'), JSON.stringify(packagesJson, null, 2), { encoding: 'utf-8' });
85
85
 
86
- rmSync(resolve(__dirname, '../scripts/removeDemo.js'));
86
+ rmSync(resolve(__dirname, '../scripts/removeDemo.cjs'));
87
87
 
88
88
  console.info('\nThe demo application has been removed\n');
@@ -0,0 +1,3 @@
1
+ export default {
2
+ extends: ['@pplancq/stylelint-config/prettier'],
3
+ };
package/.commitlintrc.js DELETED
@@ -1 +0,0 @@
1
- module.exports = { extends: ['@pplancq/commitlint-config'] };
package/.postcssrc.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('@pplancq/postcss-config');
package/.prettierrc.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('@pplancq/prettier-config');
package/.stylelintrc.js DELETED
@@ -1 +0,0 @@
1
- module.exports = { extends: ['@pplancq/stylelint-config/prettier'] };
File without changes