create-linkdesk-plugin 0.1.8 → 0.1.9

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": "create-linkdesk-plugin",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "LinkDesk 插件脚手架——`npm create linkdesk-plugin@latest my-cool-plugin` 一行生成你的第一个插件项目(对标 yo code)。",
5
5
  "type": "module",
6
6
  "bin": {
@@ -127,29 +127,38 @@ if (report) process.stdout.write(renderPluginLintReport(report) + "\n");
127
127
  * 但必须响亮打印——静默放过才是真问题。
128
128
  */
129
129
  const RULE_NOT_FOUND_RE = /^Definition for rule '.*' was not found/;
130
- /** 按腿取偏离数(label 与 lint.ts 的 legs 一致) */
131
- const legCount = (label) => report?.legs.find((l) => l.label === label)?.violations.length ?? 0;
132
130
 
133
131
  const allRows = report?.eslintRows ?? [];
134
132
  const ruleNotFound = allRows.filter((r) => RULE_NOT_FOUND_RE.test(r.message));
135
133
  const strictEslintRows = allRows.filter((r) => !RULE_NOT_FOUND_RE.test(r.message));
136
- /** 判红的三样:真 eslint 偏离 + css 硬编码腿(硬约束 1 的 .css 半边,eslint 到不了 .css)+ 见下 ②③④⑤ */
137
- const cssLegViolations = legCount("check-css-hardcode");
138
- const strictLintViolations = strictEslintRows.length + cssLegViolations;
139
- /** 只报告不拦的两条腿:字号度量与 4px 节奏——属「审美校准」,存量偏离多且修它们要动插件源码 */
140
- const advisoryLintViolations = legCount("check-font-scale") + legCount("check-spacing-grid");
134
+ /**
135
+ * 判红的两样:真 eslint 偏离 + check 腿偏离(见下 ②③④⑤)。
136
+ * 🔴 **严格腿 = 除「报表档」外的全部腿**(fail-closed):SDK 新增一条腿(如 check-css-namespace)
137
+ * 自动进严格档——想放宽必须把腿名写进 ADVISORY_LEGS 并说明理由,不许默默不查。
138
+ */
139
+ const ADVISORY_LEGS = new Set(["check-font-scale", "check-spacing-grid"]);
140
+ const reportLegs = report?.legs ?? [];
141
+ const strictLegs = reportLegs.filter((l) => !ADVISORY_LEGS.has(l.label));
142
+ const strictLegViolations = strictLegs.reduce((sum, l) => sum + l.violations.length, 0);
143
+ const strictLintViolations = strictEslintRows.length + strictLegViolations;
144
+ /** 报表档:字号度量与 4px 节奏——属「审美校准」,存量偏离多且修它们要动插件源码 */
145
+ const advisoryLintViolations = reportLegs
146
+ .filter((l) => ADVISORY_LEGS.has(l.label))
147
+ .reduce((sum, l) => sum + l.violations.length, 0);
141
148
 
142
149
  if (lintNoObject) {
143
150
  line(`⏭ ① lint 严格腿:${lintNoObject}——本仓**无对象**(不是「绿」,是「没有可查的东西」)。`);
144
151
  } else if (strictLintViolations > 0) {
145
152
  fail(
146
- `① lint 严格腿:${strictLintViolations} 处偏离(eslint ${strictEslintRows.length} + css 硬编码腿 ${cssLegViolations})` +
147
- `——SDK 的 \`npm run lint\` 只报告不拦,**CI 拦**。逐条见上方报告。`,
153
+ `① lint 严格腿:${strictLintViolations} 处偏离(eslint ${strictEslintRows.length} + ` +
154
+ strictLegs.map((l) => `${l.label} ${l.violations.length}`).join(" + ") +
155
+ `)——SDK 的 \`npm run lint\` 只报告不拦,**CI 拦**。逐条见上方报告。`,
148
156
  );
149
157
  } else {
150
158
  line(
151
- `✅ ① lint 严格腿:eslint 规则腿 ${report.files} 文件 + css 硬编码腿 零偏离` +
152
- `(本段判红的是「硬约束 1/2 那一档」)。`,
159
+ `✅ ① lint 严格腿:eslint 规则腿 ${report.files} 文件 + ` +
160
+ strictLegs.map((l) => `${l.label} 零偏离`).join(" + ") +
161
+ `(本段判红的是「硬约束」那一档)。`,
153
162
  );
154
163
  }
155
164
  if (ruleNotFound.length > 0) {
@@ -161,9 +170,12 @@ if (ruleNotFound.length > 0) {
161
170
  }
162
171
  if (advisoryLintViolations > 0) {
163
172
  line(
164
- ` ⚠ 附加腿(**报告不拦**):font-scale ${legCount("check-font-scale")} 处 / ` +
165
- `spacing-grid ${legCount("check-spacing-grid")} 处——字号度量与 4px 节奏属审美校准档` +
166
- `,逐条见上方报告;确属有意的用标准 disable 注释写明理由。`,
173
+ ` ⚠ 附加腿(**报告不拦**):` +
174
+ reportLegs
175
+ .filter((l) => ADVISORY_LEGS.has(l.label))
176
+ .map((l) => `${l.label.replace("check-", "")} ${l.violations.length} 处`)
177
+ .join(" / ") +
178
+ `——字号度量与 4px 节奏属审美校准档,逐条见上方报告;确属有意的用标准 disable 注释写明理由。`,
167
179
  );
168
180
  }
169
181