synthesisui 0.16.375 → 0.16.376
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/dist/doctor/apply-fix.js +48 -1
- package/package.json +1 -1
package/dist/doctor/apply-fix.js
CHANGED
|
@@ -132,6 +132,39 @@ export function planFix(d, read) {
|
|
|
132
132
|
continue;
|
|
133
133
|
const idx = f.line - 1;
|
|
134
134
|
const current = body[idx];
|
|
135
|
+
/**
|
|
136
|
+
* A DECLARAÇÃO DE UM TOKEN NÃO É UM USO DELE - e trocar ali APAGA o token do app inteiro.
|
|
137
|
+
*
|
|
138
|
+
* O QUE ACONTECIA: `--color-brand-blue: #4f46e5;` é onde o token NASCE. O scan vê o literal, o
|
|
139
|
+
* sistema tem um nome para aquele valor - o próprio `--color-brand-blue` -, e a troca escrevia
|
|
140
|
+
* `--color-brand-blue: var(--color-brand-blue)`. Isso é um ciclo de custom property, e a regra do
|
|
141
|
+
* CSS é dura: a propriedade fica inválida no elemento E em todos os descendentes. Como esses
|
|
142
|
+
* tokens moram em `:root`, o app inteiro perde a cor.
|
|
143
|
+
*
|
|
144
|
+
* MEDIDO em 05/09, sobre uma cópia do repositório do dono: **26 declarações** viraram
|
|
145
|
+
* auto-referência numa passada. E cada uma delas é o destino de dezenas de trocas que o mesmo
|
|
146
|
+
* comando acabou de fazer - o conserto apagava aquilo que ele mesmo tinha acabado de apontar.
|
|
147
|
+
*
|
|
148
|
+
* É A MESMA FAMÍLIA DO CICLO DOS EASINGS que o dono encontrou em 04/09, e desta vez produzida
|
|
149
|
+
* pelo nosso comando de conserto. Sem erro no console: o navegador simplesmente descarta.
|
|
150
|
+
*
|
|
151
|
+
* A REGRA É ESTREITA DE PROPÓSITO. Apontar um token DELE para outro token DELE
|
|
152
|
+
* (`--brand-hover: #4f46e5` -> `var(--color-brand-blue)`) continua valendo e é bom. Só a
|
|
153
|
+
* auto-referência é fatal, e só ela é recusada.
|
|
154
|
+
*
|
|
155
|
+
* É GERAL: toda folha declara token com valor literal - 149 no repositório dele, 180 no
|
|
156
|
+
* frontend-hub.
|
|
157
|
+
*/
|
|
158
|
+
const declaring = /^\s*(--[a-z0-9-]+)\s*:/i.exec(current ?? "");
|
|
159
|
+
if (declaring && declaring[1] === name) {
|
|
160
|
+
skipped.push({
|
|
161
|
+
file: f.file,
|
|
162
|
+
line: f.line,
|
|
163
|
+
literal: f.literal,
|
|
164
|
+
because: "self-reference",
|
|
165
|
+
});
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
135
168
|
const swapped = current === undefined ? null : swap(current, f.literal, name);
|
|
136
169
|
if (swapped === null) {
|
|
137
170
|
/**
|
|
@@ -211,6 +244,8 @@ export function describeFix(result, dry) {
|
|
|
211
244
|
const moved = skipped.filter((s) => s.because === "moved").length;
|
|
212
245
|
/** O valor veio de forma abreviada - ver `not-written` em `planFix`. */
|
|
213
246
|
const notWritten = skipped.filter((s) => s.because === "not-written").length;
|
|
247
|
+
/** A linha declara o próprio token - ver `self-reference` em `planFix`. */
|
|
248
|
+
const selfRef = skipped.filter((s) => s.because === "self-reference").length;
|
|
214
249
|
const coincidence = skipped.filter((s) => s.because === "cross-family").length;
|
|
215
250
|
const unread = skipped.filter((s) => s.because === "unreadable").length;
|
|
216
251
|
const decisions = skipped.filter((s) => s.because === "no-token").length;
|
|
@@ -229,7 +264,13 @@ export function describeFix(result, dry) {
|
|
|
229
264
|
*/
|
|
230
265
|
notWritten > 0
|
|
231
266
|
? `Nothing to apply. All ${notWritten} findings are written as a shorthand - a utility class like \`duration-300\` carries the value in its name, so there is no literal on the line to replace. Changing them is a different rewrite.`
|
|
232
|
-
:
|
|
267
|
+
: /**
|
|
268
|
+
* E quando tudo o que havia eram as linhas onde os tokens nascem, "Nothing to apply."
|
|
269
|
+
* sozinho manda a pessoa procurar um defeito. O comando passou por ali de propósito.
|
|
270
|
+
*/
|
|
271
|
+
selfRef > 0
|
|
272
|
+
? `Nothing to apply. ${selfRef === 1 ? "The one finding is" : `All ${selfRef} findings are`} on the line where the token itself is declared - replacing there would point it at itself, and the browser would drop it.`
|
|
273
|
+
: "Nothing to apply.");
|
|
233
274
|
return lines;
|
|
234
275
|
}
|
|
235
276
|
lines.push(`${dry ? "Would replace" : "Replaced"} ${applied.length} hand-written value${applied.length === 1 ? "" : "s"} with the token your system already has, across ${result.files} file${result.files === 1 ? "" : "s"}.`);
|
|
@@ -269,6 +310,12 @@ export function describeFix(result, dry) {
|
|
|
269
310
|
* mudado: 13 de 13 eram `duration-300` e afins. Mandar rodar de novo não muda nada, e mandar
|
|
270
311
|
* alguém procurar uma edição que ela não fez é pior que calar.
|
|
271
312
|
*/
|
|
313
|
+
/**
|
|
314
|
+
* DITO, e não calado: é a linha onde o token NASCE, e a pessoa precisa saber que o comando passou
|
|
315
|
+
* por ali de propósito - senão ela procura por que aquele valor não foi trocado.
|
|
316
|
+
*/
|
|
317
|
+
if (selfRef > 0)
|
|
318
|
+
lines.push(` ${selfRef} ${selfRef === 1 ? "is" : "are"} the line where the token itself is declared - replacing there would point it at itself and the browser would drop it. Left alone.`);
|
|
272
319
|
if (notWritten > 0)
|
|
273
320
|
lines.push(` ${notWritten} more ${notWritten === 1 ? "is" : "are"} written as a shorthand - a utility class like \`duration-300\` carries the value in its name, so there is no literal on the line to replace. Changing ${notWritten === 1 ? "it" : "those"} is a different rewrite. Left alone.`);
|
|
274
321
|
if (moved > 0)
|
package/package.json
CHANGED