Skip to content

[*] Documentation Update: Record that a Flow suppression's statement has to stay on one line for the www sync - #9567

Merged
potatowagon merged 2 commits into
mainfrom
flowtest-suppression-survives-www-prettier
Nov 6, 2026
Merged

potatowagon merged 2 commits into
mainfrom
flowtest-suppression-survives-www-prettier

Conversation

@potatowagon

@potatowagon potatowagon commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

Rewritten after #9729. This branch carried two things: the one-line form
of the isMarkIDShown negative 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.flow is now taken
verbatim 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.flow here, so a suppressed statement of
any length checks locally and in CI. The www sync runs the same files through
Prettier (scripts/www/transformFlowFileContents.mjs), and a statement it
wraps 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.

$ git diff origin/main --stat
 AGENTS.md | 6 ++++++
 1 file changed, 6 insertions(+)

…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`.
@vercel

vercel Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
lexical Ready Ready Preview Nov 3, 2026 7:50am UTC
lexical-playground Ready Ready Preview Nov 3, 2026 7:50am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 30, 2026
@pkg-pr-new

pkg-pr-new Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
lexical

npm i https://pkg.pr.new/lexical@9567

@lexical/a11y

npm i https://pkg.pr.new/@lexical/a11y@9567

@lexical/clipboard

npm i https://pkg.pr.new/@lexical/clipboard@9567

@lexical/code

npm i https://pkg.pr.new/@lexical/code@9567

@lexical/code-core

npm i https://pkg.pr.new/@lexical/code-core@9567

@lexical/code-prism

npm i https://pkg.pr.new/@lexical/code-prism@9567

@lexical/code-shiki

npm i https://pkg.pr.new/@lexical/code-shiki@9567

@lexical/compiler

npm i https://pkg.pr.new/@lexical/compiler@9567

@lexical/devtools-core

npm i https://pkg.pr.new/@lexical/devtools-core@9567

@lexical/dragon

npm i https://pkg.pr.new/@lexical/dragon@9567

@lexical/eslint-plugin

npm i https://pkg.pr.new/@lexical/eslint-plugin@9567

@lexical/extension

npm i https://pkg.pr.new/@lexical/extension@9567

@lexical/fast-check

npm i https://pkg.pr.new/@lexical/fast-check@9567

@lexical/file

npm i https://pkg.pr.new/@lexical/file@9567

@lexical/hashtag

npm i https://pkg.pr.new/@lexical/hashtag@9567

@lexical/headless

npm i https://pkg.pr.new/@lexical/headless@9567

@lexical/history

npm i https://pkg.pr.new/@lexical/history@9567

@lexical/html

npm i https://pkg.pr.new/@lexical/html@9567

@lexical/internal

npm i https://pkg.pr.new/@lexical/internal@9567

@lexical/link

npm i https://pkg.pr.new/@lexical/link@9567

@lexical/list

npm i https://pkg.pr.new/@lexical/list@9567

@lexical/mark

npm i https://pkg.pr.new/@lexical/mark@9567

@lexical/markdown

npm i https://pkg.pr.new/@lexical/markdown@9567

@lexical/mdast

npm i https://pkg.pr.new/@lexical/mdast@9567

@lexical/offset

npm i https://pkg.pr.new/@lexical/offset@9567

@lexical/overflow

npm i https://pkg.pr.new/@lexical/overflow@9567

@lexical/plain-text

npm i https://pkg.pr.new/@lexical/plain-text@9567

@lexical/react

npm i https://pkg.pr.new/@lexical/react@9567

@lexical/rich-text

npm i https://pkg.pr.new/@lexical/rich-text@9567

@lexical/selection

npm i https://pkg.pr.new/@lexical/selection@9567

@lexical/table

npm i https://pkg.pr.new/@lexical/table@9567

@lexical/tailwind

npm i https://pkg.pr.new/@lexical/tailwind@9567

@lexical/text

npm i https://pkg.pr.new/@lexical/text@9567

@lexical/utils

npm i https://pkg.pr.new/@lexical/utils@9567

@lexical/y

npm i https://pkg.pr.new/@lexical/y@9567

@lexical/yjs

npm i https://pkg.pr.new/@lexical/yjs@9567

commit: 294ac1b

@meta-code-review

meta-code-review Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 3, 2026, 8:02 AM UTC

@meta-code-review meta-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small things on this PR, then an optional follow-up; the fix itself checks out (details at the end).

  1. Changeset section of the description. flow/ is published: copyFlowStubsIntoDist in scripts/build.mjs (lines 615–625) copies every *.js.flow file in flow/, this flow test included, into dist/, which @lexical/mark ships, and scripts/changesets/coverage.mjs counts every flow/*.js.flow as shipped — that is why the Changesets check warns about @lexical/mark on this PR. The edit has no effect on people who use Lexical (nothing imports the test), so per "Changesets" in CONTRIBUTING.md the skip-changeset label 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.
  2. PR type (nit). AGENTS.md ("Commits and Pull Requests") says test-only and tooling changes are Chore; a Flow test plus agent guidance fits Chore better than Bug Fix in 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.
@potatowagon potatowagon changed the title [lexical-mark] Bug Fix: Keep the isMarkIDShown negative Flow test suppressed after the www sync formats it [*] Documentation Update: Record that a Flow suppression's statement has to stay on one line for the www sync Nov 3, 2026
@potatowagon

Copy link
Copy Markdown
Contributor Author

Heads up @etrepum: the diff here shrank rather than changed. #9729 landed the one-line form of the isMarkIDShown expectation, so I merged main and took its copy of LexicalMark.flowtest.js.flow verbatim; no code change is left. What remains is six lines in AGENTS.md recording why a suppressed statement has to stay on one line — Prettier ignores .js.flow here, but the www sync runs these files through it, and a wrapped statement moves the error off the suppressed line. Re-review is one file.

@meta-code-review meta-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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").

Comment thread AGENTS.md
Comment on lines +274 to +279
- 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
- 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/`.

@potatowagon
potatowagon added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit b645135 Nov 6, 2026
57 checks passed

This branch was successfully deployed

2 active deployments
Preview – lexical — 294ac1b7 Deployed Nov 3, 2026 by vercel[bot]
Preview – lexical-playground — 294ac1b7 Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants