safe-ts fix takes the fix that keeps the result; prefer-q off in files a Vite config elsewhere loads; added imports in the file's quotes #165
Loading…
Reference in a new issue
No description provided.
Delete branch "fix-ux-upgrade"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Three pieces of an adopter's feedback about quick fixes during the 0.5.1 upgrade. Each was reproduced on main (
b1e856ff) first.1.
safe-ts fix strict-truthinessskipped nearly every site ("several fixes")safe-ts fix <rule>skipped any site with more than one fix unless--fixpicked one. For strict-truthiness most sites have two, and for an optional string one of them keeps the meaning exactly:Changed:
fixing::picktakes, among several fixes, the one--fixpicks, else the only one whose title says(the same as now)(Fix::keeps_meaning,SAME_AS_NOWin lib.rs). That title is already the documented contract in docs/guide/quick-fixes.md, andtests/meaning.rsruns those fixes. The harness now also fails a title that says(the same as now)when itsFIXESentry isn'tSame, sosafe-ts fixcan't take a fix that doesn't keep the result. Where--fixpicks nothing at a site, the meaning-keeping fix is still taken. A site that is still skipped prints why:each fix changes the result for some input(a number: Compare with 0 (NaN counts as true), Test for a positive number) ormore than one fix keeps the result. The report ends with the--fixfor each kind of site left and how many sites offer it.--jsongives"skipped": "none-keeps-meaning" | "several-keep-meaning".Numbers are still skipped on purpose: no fix keeps
NaNcounting as false, so applying one without being asked would change behaviour silently.On the adopter's
apps/client(419 files):--fix "Compare with 0"The last row is the command the report now prints for 76 of the 80 sites left. The adopter's tree was type-checked with
tsc -p srcandtsc -p .on a copy, before and after both--writeruns. The set of errors is identical each time (82/83 errors, all from the copy's environment: two Vue copies, one missing optional module). So no fix adds a type error.2.
prefer-q's fix wroteqinto files Vite loads untransformedprefer-qalready isn't reported and offers noqin a file a Vite/Vitest config imports. ButProject::untransformed_byonly asked configs in the file's directory and the directories above it. A config in another directory was never asked:apps/web/vite.config.tsimporting../../scripts/reload.tsloads that file untransformed too.Fixed: after the configs above, every other Vite/Vitest config of the project is asked (
project_configs: a walk of the project root that skipsnode_modules,distand similar, reads at most 5000 directories, and is cached for 5 s like the other file lists). This reuses the previous attempt's patch, plus the bound on the walk.needs-transform, and the fixes that leave outqand the prelude, get the same answer. Still reported:prefer-map-errin that file, with help that namesmapErrand notq. New fixtureuntransformed/apps/web/vite.config.ts→untransformed/shared/reload.ts. On main it reportsprefer-qat line 13; here it reports onlyprefer-map-err.3.
prefer-is-over-tagimportsiswith double quotes in a prelude packageThe prelude half no longer reproduces on main. With
types: ["@evobug_com/safe-ts-prelude"](JSONC tsconfig withextends, as the adopter has), the fix writesis(...)without an import. That has been true since #93 (0.5.0), and the adopter saw it with 0.4.0. The quote half does reproduce: a file without imports got"and;by default, e.g.import { is as safeIs } from "…"where a parameter hides the prelude'sisin a single-quoted file.Fixed:
import_stylefalls back to the file's code when it has no import: the quote of its first string literal (not a JSX attribute's, not in a Vue template) and whether its first top-level declaration or expression statement ends with;. Every fix that adds a std import goes throughImportContext(ensure,ensure_type,local_for,import_line, loans'Mutimport), so they all follow it. strict-truthiness's""now follows the file's quotes too (''in a single-quoted file, in the fix and its title).Tests
cargo nextest run --workspace: all pass. New tests:fixing::tests::picking_the_fix_that_keeps_the_meaning, CLIthe_fix_that_keeps_the_meaning_is_taken_without_a_choice,fixes::an_added_import_follows_the_quotes_of_a_file_without_imports, and theuntransformedfixture.npm run test:rewrites(full): passes.misses.txt:miss prefer-map-err hoist-constgoes from 2 to 5. That is the new fixture'sprefer-map-errsite under the same knownhoist-constgap (the rule matches the shape where the value is written); no existing site moved.npm run test:soundness: 16 of 110 classes escape, exactlyescaping.txt.node scripts/docs-typecheck.mjs: only thedompurifyerrors this worktree's install lacks; vue-tsc not installed here, so the VitePress build was not run.Docs:
docs/guide/adoption.md(Applying one rule's quick fixes),docs/guide/quick-fixes.md,docs/rules/strict-truthiness.md,prefer-q.md,needs-transform.md,prefer-is-over-tag.md, README, CLI usage, and CHANGELOG (Changed + 2 Fixed).🤖 Generated with Claude Code
814533964db21a4bd430