[pull] main from tldraw:main#568
Merged
Merged
Conversation
In order to actually enforce `tldraw/no-exported-arrow-const` everywhere
it was originally intended, this PR removes the three `.oxlintrc.json`
overrides that turned it off for `packages/editor`, `packages/tldraw`,
`packages/utils`, `apps/examples`, and `templates`, and converts the 50
violations those overrides were hiding.
The pattern is mechanical: `export const fn = (args) => {...}` becomes
`export function fn(args) {...}`. Async functions get `export async
function`. For React component aliases like `const X:
TLErrorFallbackComponent = (...) =>` the form becomes `export const X:
TLErrorFallbackComponent = function X(...) {...}` — a named function
expression keeps the type alias visible to api-extractor (the rule only
fires on arrows, not function expressions). No behavior changes.
### Affected directories
| Directory | Files | Violations |
| --- | ---: | ---: |
| `packages/tldraw` | 14 | 19 |
| `apps/examples` | 8 | 16 |
| `packages/editor` | 10 | 11 |
| `packages/utils` | 4 | 4 |
| **Total** | **36** | **50** |
### Background
Relates to #7572. The rule was added in #8258 along with the JS plugin,
but with these overrides in place it has never fired in the packages it
most needed to apply to. The plugin itself works correctly — see commit
history for the exploration that confirmed that.
### API changes
The shift to function declarations changes how api-extractor renders the
affected exports — `const X: (args) => Y` becomes `function X(args): Y`.
No call-site changes required; the public signatures are equivalent.
Specifically affected `@public` exports:
- `@tldraw/editor`: `DefaultSvgDefs`, `isSafeFloat`,
`stopEventPropagation`
- `@tldraw/tldraw`: `handleNativeOrMenuCopy`,
`TldrawUiContextualToolbar`, `TldrawUiToolbarToggleGroup`,
`TldrawUiToolbarToggleItem`, `truncateStringWithEllipsis`,
`useSelectedShapesAnnouncer`, `interpolateSegments`
- `@tldraw/utils`: `Image`, `noop`, `safeParseUrl`, `isAvifAnimated`
`DefaultErrorFallback` keeps its `TLErrorFallbackComponent` alias in the
api-report — typed as `export const DefaultErrorFallback:
TLErrorFallbackComponent = function DefaultErrorFallback(...) {...}` so
the alias survives.
### Change type
- [x] `improvement`
### Test plan
- `yarn oxlint .` — 0 errors.
- `yarn typecheck` — passes.
- `yarn test run` in `packages/editor`, `packages/tldraw`,
`packages/utils` — all green.
- `yarn api-check` — passes (api reports are regenerated).
- [ ] Unit tests
- [ ] End to end tests
### Code changes
| Section | LOC change |
| --------------- | ---------- |
| Core code | +97 / -88 |
| Automated files | +12 / -12 |
| Documentation | +24 / -18 |
| Config/tooling | +0 / -3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )