@lark-apaas/coding-template-nestjs-react-fullstack 0.1.22 → 0.1.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/coding-template-nestjs-react-fullstack",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "NestJS + React fullstack template for miaoda coding",
5
5
  "type": "module",
6
6
  "files": [
@@ -63,13 +63,32 @@ function isStylelintTarget(filePath) {
63
63
  return filePath.endsWith('.css');
64
64
  }
65
65
 
66
+ const STYLELINT_CONFIG_FILES = [
67
+ '.stylelintrc',
68
+ '.stylelintrc.js',
69
+ '.stylelintrc.cjs',
70
+ '.stylelintrc.json',
71
+ 'stylelint.config.js',
72
+ ];
73
+
74
+ /**
75
+ * 老模板(fullstack-nestjs-template 1.x 时代)的应用没有 stylelint 配置,跑 stylelint 会以
76
+ * "ConfigurationError: No configuration provided" 挂掉、把 pre-commit 卡死。没配置就跳过。
77
+ */
78
+ function hasStylelintConfig() {
79
+ return STYLELINT_CONFIG_FILES.some(file => fs.existsSync(path.join(cwd, file)));
80
+ }
81
+
66
82
  async function runDefaultLint() {
67
- const code = await runCommand(getBinName('npx'), [
68
- 'concurrently',
69
- 'npm run eslint',
70
- 'npm run type:check',
71
- 'npm run stylelint',
72
- ]);
83
+ const commands = ['npm run eslint', 'npm run type:check'];
84
+
85
+ if (hasStylelintConfig()) {
86
+ commands.push('npm run stylelint');
87
+ } else {
88
+ console.warn('[lint] Skip stylelint: no stylelint config found');
89
+ }
90
+
91
+ const code = await runCommand(getBinName('npx'), ['concurrently', ...commands]);
73
92
  process.exit(code);
74
93
  }
75
94
 
@@ -107,7 +126,9 @@ async function runSelectiveLint(inputFiles) {
107
126
  tasks.push(runCommand(getBinName('npx'), ['eslint', '--quiet', ...eslintFiles]));
108
127
  }
109
128
 
110
- if (stylelintFiles.length > 0) {
129
+ if (stylelintFiles.length > 0 && !hasStylelintConfig()) {
130
+ console.warn('[lint] Skip stylelint: no stylelint config found');
131
+ } else if (stylelintFiles.length > 0) {
111
132
  tasks.push(runCommand(getBinName('npx'), ['stylelint', '--quiet', ...stylelintFiles]));
112
133
  }
113
134