Repository navigation
[*] Documentation Update: Record that a Flow suppression's statement has to stay on one line for the www sync - #9567
Conversation
…pressed after the www sync formats it ## Description #9489 added a negative Flow test for `isMarkIDShown` as a single 86-character line with a `// $FlowExpectedError[incompatible-type]` comment above it. That checks here, because Prettier ignores `.js.flow` paths in this repository. The www sync does not: `scripts/www/transformFlowFileContents.mjs` runs the source through Prettier, which wraps the statement over four lines. Flow then reports the error inside the wrapped literal and the suppression above the statement no longer covers it, so the synced copy fails Flow on an error this repository's CI cannot see, and the Lexical -> www sync is blocked. Bind the number-taking filter to a name first, so the suppressed statement is 77 characters and Prettier leaves it on one line wherever it runs. AGENTS.md gains the rule, since the trap applies to every suppression in `packages/*/flow`. ## Test plan ### Before Flow over Meta's www root at the sync revision that imports #9489: ``` Error ------- html/shared/lexical/LexicalMark.flowtest.js.flow:90:25 Cannot assign object literal to `wrongFilter` because in property `isMarkIDShown` > the first parameter: `number` [1] is incompatible with `string` [2]. [incompatible-type] Found 1 error ``` ### After The same root and revision with this file's post-Prettier form replaced by the one in this commit, checked both ways to confirm the signal: ``` --- fixed: No errors! --- broken (sanity): Found 1 error --- refixed: No errors! ``` The repository's own checks were not run in this environment (its package manager is unavailable there); CI runs `pnpm run ci-check`.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
lexical
@lexical/a11y
@lexical/clipboard
@lexical/code
@lexical/code-core
@lexical/code-prism
@lexical/code-shiki
@lexical/compiler
@lexical/devtools-core
@lexical/dragon
@lexical/eslint-plugin
@lexical/extension
@lexical/fast-check
@lexical/file
@lexical/hashtag
@lexical/headless
@lexical/history
@lexical/html
@lexical/internal
@lexical/link
@lexical/list
@lexical/mark
@lexical/markdown
@lexical/mdast
@lexical/offset
@lexical/overflow
@lexical/plain-text
@lexical/react
@lexical/rich-text
@lexical/selection
@lexical/table
@lexical/tailwind
@lexical/text
@lexical/utils
@lexical/y
@lexical/yjs
commit: |
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Two small things on this PR, then an optional follow-up; the fix itself checks out (details at the end).
- Changeset section of the description.
flow/is published:copyFlowStubsIntoDistinscripts/build.mjs(lines 615–625) copies every*.js.flowfile inflow/, this flow test included, intodist/, which@lexical/markships, andscripts/changesets/coverage.mjscounts everyflow/*.js.flowas shipped — that is why the Changesets check warns about@lexical/markon this PR. The edit has no effect on people who use Lexical (nothing imports the test), so per "Changesets" in CONTRIBUTING.md theskip-changesetlabel is the right outcome rather than a changeset; the "flow/is not published" line should be corrected so it doesn't mislead the next contributor. - PR type (nit). AGENTS.md ("Commits and Pull Requests") says test-only and tooling changes are
Chore; a Flow test plus agent guidance fitsChorebetter thanBug Fixin the squash subject.
Follow-up to consider (not blocking): the new AGENTS.md rule is prose only. pnpm run flow checks the unformatted files and pnpm run build-www writes the transformed copies without type-checking them, so a later flow test can reintroduce this. A CI step that runs Flow over build-www's dist/*.js.flow output would turn the rule into a failing check, and would also cover declarations the rule cannot reshape: UnionToIntersection in packages/lexical/flow/Lexical.js.flow is a multi-line type with suppressions inside, and the transform moves its second $FlowFixMe[unclear-type] to the end of the ) extends line, where it still covers the any only because that lands on the next line.
The fix, checked: binding the number-taking filter to numFilter keeps the suppressed assignment in packages/lexical-mark/flow/LexicalMark.flowtest.js.flow at 77 columns, so the Prettier pass in scripts/www/transformFlowFileContents.mjs leaves it on the line its $FlowExpectedError covers. With the repository's own transform and flow-bin 0.333, the base file's transformed copy wraps the object literal over four lines and reports the incompatible-type error on the property line with the suppression unused; the head's transformed copy is clean, and removing its suppression brings the error back on the suppressed line, so the negative test still checks isMarkIDShown's parameter type. Every other packages/*/flow file also comes through the transform without a displaced suppression.
…ed the one-line form #9729 ("Keep the isMarkIDShown Flow expectation on one line in every formatter") made the same change this branch carried: bind the number-taking filter to a name so the suppressed statement fits on one line and survives the Prettier pass the www sync runs over `packages/*/flow`. Take main's copy of the file verbatim, so what is left here is the AGENTS.md rule that says why a suppressed statement has to stay on one line.
|
Heads up @etrepum: the diff here shrank rather than changed. #9729 landed the one-line form of the |
There was a problem hiding this comment.
Looks good. The new AGENTS.md bullet describes a real trap accurately. .prettierignore skips **/*.js.flow, but scripts/www/transformFlowFileContents.mjs prints these files through Prettier with the repository's .prettierrc (printWidth: 80). The original one-line isMarkIDShown expectation from #9489 wraps there and fails Flow on its formatted copy. The current 80-column form from #9729 comes through unchanged.
Optional, non-blocking suggestion (AGENTS.md lines 274-279): the bullet reads as if it covers every suppression. Several existing suppressions instead sit inside declarations that span lines, with the comment directly above the line Flow reports. Examples are flowLegacyNodeExport in packages/lexical/flow/Lexical.flowtest.js.flow, and Commands and UnionToIntersection in packages/lexical/flow/Lexical.js.flow. Those check fine after formatting, but someone following the bullet literally has no guidance for them, and might "fix" them. Two more points:
- In
UnionToIntersection, Prettier turns the second$FlowFixMe[unclear-type]into a trailing comment on) extends. It still works only because Flow applies a suppression to the line after the comment. - The 80-column limit is measured after Prettier, not in the source. An 80-column statement that is missing its semicolon wraps once Prettier adds one.
A wording that states the invariant would cover all of these; there is a suggestion inline. With it, the line under a suppression must be the line Flow reports after formatting, one line within 80 columns is the easy way to meet that, a wrapped declaration puts the comment directly above the erroring line, and pnpm run build-www shows the formatted copies in each package's dist/.
No changeset is needed for an AGENTS.md-only change (CONTRIBUTING.md, "Changesets").
| - Keep a statement under a `$FlowExpectedError` or `$FlowFixMe` suppression on | ||
| one line of at most 80 characters. Prettier ignores `.js.flow` here, but the | ||
| www sync (`scripts/www/transformFlowFileContents.mjs`) runs Prettier over | ||
| these files, and a statement it wraps moves the error off the line the | ||
| suppression covers — so the www copy fails Flow on an error that passes in | ||
| this repo. |
There was a problem hiding this comment.
Optional: several existing suppressions sit inside wrapped declarations, with the comment directly above the line Flow reports (flowLegacyNodeExport in Lexical.flowtest.js.flow, Commands and UnionToIntersection in Lexical.js.flow). They check fine after formatting, but this wording does not cover them. The 80 columns are also counted after Prettier: an 80-column statement without its semicolon wraps. Stating the invariant covers both cases:
| - Keep a statement under a `$FlowExpectedError` or `$FlowFixMe` suppression on | |
| one line of at most 80 characters. Prettier ignores `.js.flow` here, but the | |
| www sync (`scripts/www/transformFlowFileContents.mjs`) runs Prettier over | |
| these files, and a statement it wraps moves the error off the line the | |
| suppression covers — so the www copy fails Flow on an error that passes in | |
| this repo. | |
| - After Prettier formats a `.js.flow` file, the line directly under a | |
| `$FlowExpectedError` or `$FlowFixMe` comment must still be the line Flow | |
| reports. Prettier ignores `.js.flow` here, but the www sync | |
| (`scripts/www/transformFlowFileContents.mjs`) runs Prettier over these | |
| files, and a statement it wraps can move the error off the covered line, so | |
| the www copy fails Flow on an error that passes in this repo. Keep a | |
| suppressed statement on one line of at most 80 columns as Prettier prints it | |
| (semicolon included); where a declaration has to wrap, put the comment | |
| directly above the line that errors. `pnpm run build-www` writes the | |
| formatted copies to each package's `dist/`. |
Description
Rewritten after #9729. This branch carried two things: the one-line form
of the
isMarkIDShownnegative Flow test, and the rule behind it. #9729("Keep the isMarkIDShown Flow expectation on one line in every formatter")
landed the first one, so main's copy of
packages/lexical-mark/flow/LexicalMark.flowtest.js.flowis now takenverbatim here and the only change left is six lines in AGENTS.md.
The rule is worth writing down because nothing in this repository can catch
the mistake. Prettier ignores
.js.flowhere, so a suppressed statement ofany length checks locally and in CI. The www sync runs the same files through
Prettier (
scripts/www/transformFlowFileContents.mjs), and a statement itwraps moves the error off the line the suppression covers, so the synced copy
fails Flow on an error this repository cannot see — which is how #9489 blocked
a sync, and how #9729 came to exist.
Test plan
Documentation only; no code changes remain on this branch.