Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[*] Chore: Fix all new lint warnings, plus manual exports clean-up #5979

Merged
merged 28 commits into from
May 10, 2024

Conversation

etrepum
Copy link
Collaborator

@etrepum etrepum commented Apr 27, 2024

Description

  • Runs @lexical/eslint-plugin over the source to resolve all new warnings
  • Manually fix up names that were shadowed
  • Manually fix up invariants, flow types, and docs for renamed and deprecated public API
  • Manually fix up internal usage of newly deprecated APIs

Newly deprecated APIs (exports still available):

  • @lexical/link toggleLink - renamed to $toggleLink
  • @lexical/offset createChildrenArray - renamed to $createChildrenArray
  • @lexical/selection trimTextContentFromAnchor - renamed to $trimTextContentFromAnchor

Test Plan

  • Manually verify that the public API is stable in code review, either through no change or through a @deprecated alias
  • Manually verify that the flow types for any renamed or added public APIs are changed accordingly
  • All tests still pass

Review notes:

This is a really big PR if you read through the automated stuff. It could be reviewed in pieces:

  • Configuration change (first commit) - updateEditor is basically editor.update and should be considered a lexical provider
  • Automated npm run lint -- --fix (second commit) - this is completely automated and probably does not need close review
  • Manual fix-ups (almost everything after the second commit) - worth a close look
  • Doc improvements (last relevant commit) - adds {@link $newName} around deprecations for better typedoc ux, and removes unused markdown partial plugin
  • Flaky collab test mitigation? (not so relevant commit) adds some stuff to maybe help address collab tests that seem flaky. It seemed to help a bit locally, hard to tell whether it it's an solid improvement in CI or not until a lot of test runs have happened.

Copy link

vercel bot commented Apr 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 10, 2024 1:32pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 10, 2024 1:32pm

@facebook-github-bot facebook-github-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 Apr 27, 2024
@etrepum etrepum force-pushed the lexical-eslint-plugin-autofixes branch from 095502e to 92f416e Compare May 5, 2024 20:24
@etrepum etrepum changed the title [NO MERGE] Lexical eslint plugin autofixes [NO MERGE] Lexical eslint plugin lint fixes May 5, 2024
@etrepum etrepum force-pushed the lexical-eslint-plugin-autofixes branch from 92f416e to c9613e7 Compare May 5, 2024 21:13
@etrepum etrepum changed the title [NO MERGE] Lexical eslint plugin lint fixes [NO MERGE] [all] Chore: Fix all new lint warnings, plus manual exports clean-up May 5, 2024
@etrepum etrepum changed the title [NO MERGE] [all] Chore: Fix all new lint warnings, plus manual exports clean-up [*] Chore: Fix all new lint warnings, plus manual exports clean-up May 5, 2024
@etrepum etrepum marked this pull request as ready for review May 5, 2024 21:28
Comment on lines -479 to -500
export function $createChildrenArray(
element: ElementNode,
nodeMap: null | NodeMap,
): Array<NodeKey> {
const children = [];
let nodeKey = element.__first;
while (nodeKey !== null) {
const node =
nodeMap === null ? $getNodeByKey(nodeKey) : nodeMap.get(nodeKey);
if (node === null || node === undefined) {
invariant(false, 'createChildrenArray: node does not exist in nodeMap');
}
children.push(nodeKey);
nodeKey = node.__next;
}
return children;
}
/** @deprecated renamed to $createChildrenArray by @lexical/eslint-plugin rules-of-lexical */
export const createChildrenArray = $createChildrenArray;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a dupe of the same function from @lexical/offset which is already a dependency of @lexical/yjs

@etrepum
Copy link
Collaborator Author

etrepum commented May 6, 2024

Pretty sure the test failure is just a flaky test, I can't repro locally on my mac and the tests succeeded earlier

This is the end of the output of my local CI=true npm run test-e2e-collab-ci-firefox

[1]   1) [firefox] › packages/lexical-playground/__tests__/regression/4697-repeated-table-selection.spec.mjs:21:3 › Regression test #4697 › repeated table selection results in table selection 
[1] 
[1]     Error: expect(received).toEqual(expected) // deep equality
[1] 
[1]     Expected: 1
[1]     Received: 2
[1] 
[1]        at packages/lexical-playground/__tests__/utils/index.mjs:267
[1] 
[1]       265 |     }
[1]       266 |     if (coordinates.anchor.y !== undefined) {
[1]     > 267 |       expect(_anchor.y).toEqual(coordinates.anchor.y);
[1]           |                         ^
[1]       268 |     }
[1]       269 |   }
[1]       270 |   if (coordinates.focus) {
[1] 
[1]         at assertTableSelectionCoordinates (/Users/bob/src/lexical/packages/lexical-playground/__tests__/utils/index.mjs:267:25)
[1]         at /Users/bob/src/lexical/packages/lexical-playground/__tests__/regression/4697-repeated-table-selection.spec.mjs:49:5
[1] 
[1]   Slow test file: [firefox] › packages/lexical-playground/__tests__/e2e/Markdown.spec.mjs (1.6m)
[1]   Slow test file: [firefox] › packages/lexical-playground/__tests__/e2e/Tables.spec.mjs (1.5m)
[1]   Slow test file: [firefox] › packages/lexical-playground/__tests__/e2e/List.spec.mjs (1.2m)
[1]   Slow test file: [firefox] › packages/lexical-playground/__tests__/e2e/Links.spec.mjs (1.1m)
[1]   Slow test file: [firefox] › packages/lexical-playground/__tests__/e2e/Navigation.spec.mjs (59.1s)
[1]   Consider splitting slow test files to speed up parallel execution
[1]   1 flaky
[1]     [firefox] › packages/lexical-playground/__tests__/regression/4697-repeated-table-selection.spec.mjs:21:3 › Regression test #4697 › repeated table selection results in table selection 
[1]   79 skipped
[1]   362 passed (4.1m)
[1] npm run test-e2e-collab-firefox exited with code 0

@etrepum
Copy link
Collaborator Author

etrepum commented May 10, 2024

@ivailop7 as long as it happens in the morning, afternoon is no longer available. Just rebased.

@etrepum etrepum closed this May 10, 2024
@etrepum etrepum reopened this May 10, 2024
@ivailop7
Copy link
Collaborator

Which one should be the go to PR, this one or the #6078

@etrepum
Copy link
Collaborator Author

etrepum commented May 10, 2024

@ivailop7 they are the same but I don't know why the checks are not running and created another PR to try and figure it out. They are still not running, I don't know what to do here.

@etrepum
Copy link
Collaborator Author

etrepum commented May 10, 2024

@ivailop7 I don't think it's related to this changeset because it doesn't touch workflows and other PRs from today are affected (#6076, #6077 at least)

@etrepum
Copy link
Collaborator Author

etrepum commented May 10, 2024

@ivailop7 I have updated the links in the PR description to point to the current commits, so you could review it even though the tests are not running. They were all passing before the rebase. I will run them locally as a sanity check.

@etrepum
Copy link
Collaborator Author

etrepum commented May 10, 2024

Unit test suites are passing locally

$ git rev-parse HEAD
58a94e6e8d59343d194bf48d794558a5c6b8ae01
$ npm run test-unit
[…]
Test Suites: 50 passed, 50 total
Tests:       2 skipped, 1367 passed, 1369 total
Snapshots:   0 total
Time:        86.149 s
Ran all test suites.

@etrepum
Copy link
Collaborator Author

etrepum commented May 10, 2024

e2e suite runs with mac+chromium

$ npm run clean && CI=true npm run test-e2e-ci-chromium
  […]
  1 flaky
    [chromium] › packages/lexical-playground/__tests__/e2e/Links.spec.mjs:1959:3 › Links › Can handle pressing Enter inside a Link containing multiple TextNodes 
  19 skipped
  428 passed (2.0m)

I'll do a prod collab suite next but given the nature of these changes I don't expect that a rename could make a difference to any of that.

@etrepum
Copy link
Collaborator Author

etrepum commented May 10, 2024

@ivailop7 mac collab prod chromium is good to go as well, I have full confidence that there are no new regressions in this rebase.

$ npm run clean && CI=true npm run test-e2e-collab-prod-ci-chromium
[…]
[1]   2 flaky
[1]     [chromium] › packages/lexical-playground/__tests__/e2e/Links.spec.mjs:1959:3 › Links › Can handle pressing Enter inside a Link containing multiple TextNodes 
[1]     [chromium] › packages/lexical-playground/__tests__/e2e/Tables.spec.mjs:1267:3 › Tables › Grid selection: can select multiple cells and insert an image 
[1]   65 skipped
[1]   381 passed (2.8m)

@etrepum
Copy link
Collaborator Author

etrepum commented May 10, 2024

ah also ci-check passes

$ npm run ci-check
[…]
$ echo $?
0

@ivailop7
Copy link
Collaborator

@etrepum ok, game time

@ivailop7 ivailop7 merged commit 081188c into facebook:main May 10, 2024
4 checks passed
etrepum added a commit to etrepum/lexical that referenced this pull request May 10, 2024
etrepum added a commit to etrepum/lexical that referenced this pull request May 10, 2024
@etrepum etrepum deleted the lexical-eslint-plugin-autofixes branch May 11, 2024 06:45
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.

3 participants