-
-
Notifications
You must be signed in to change notification settings - Fork 266
feat: upgrade to prettier v3.2 #2255
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
Conversation
🦋 Changeset detectedLatest commit: ad56e5b The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@ocavue - I know the prettier v3 update was attempted before and then reverted, but I've taken a different approach here (async formatting). Would you be willing to review? In PR #2256 (that depends on this one), I've introduced a storybook entry where you can test the updated formatter. |
whawker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR make sense from a concept point of view, however I think we'd need to refactor to use the DelayedCommand interface to fit in with the rest of the ecosystem.
Happy to assist with this of course.
| * The formatter runs asynchronously. This should not be immediately followed | ||
| * by additional commands. It is not yet possible to track completion of this | ||
| * command; it is best to use as a standalone response to a user action. | ||
| * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is an async command, we should use the DelayedCommand interface instead, as this supports promises.
There's an example of its usage here
This should mean the command is chainable, but if that's not the case we could alternatively
@command({
disableChaining: true,
})There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the example. I followed it pretty closely for the changes in 5a498ef. I'm not familiar with best/worst practices in this project, so I'm curious about whether it's ok to pass an EditorState to the promise as I've done in this commit.
While working on these changes, I think I may have fixed a bug here. A pos parameter is allowed to be passed into the format function to identify a different code block than currently selected, but then the current selection was used to find the code block anyways (i.e. pos was ignored). Let me know if you agree with the change I made here to utilize pos if provided.
Finally, my changes in packages/remirror__extension-code-block/__tests__/code-block-extension.spec.ts remain because I'm not sure how else to wait for the command to signal completion before checking the updated doc. Let me know if there's a mechanism for this.
| let parser: BuiltInParserName; | ||
|
|
||
| switch (language) { | ||
| case 'typescript': | ||
| case 'ts': | ||
| case 'tsx': | ||
| parser = 'typescript'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we pull this out into a separate helper function, then use return instead of break?
i.e.
switch (language) {
case 'typescript':
case 'ts':
case 'tsx':
return 'typescript';There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in 673b388
- Extract code language string to parser name identification into its own function.
- Use DelayedCommand to generate command formatCodeBlock and make the command generator available via the extension store. - Refactor formatCodeBlockFactory into formatCode that only returns information about document updates to be applied instead of also dispatching transactions itself.
whawker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work here!
I've made some suggestions which are mainly a clarification of arguments vs command function props.
packages/remirror__extension-code-block/src/code-block-utils.ts
Outdated
Show resolved
Hide resolved
packages/remirror__extension-code-block/src/code-block-utils.ts
Outdated
Show resolved
Hide resolved
packages/remirror__extension-code-block/src/code-block-utils.ts
Outdated
Show resolved
Hide resolved
packages/remirror__extension-code-block/src/code-block-extension.ts
Outdated
Show resolved
Hide resolved
packages/remirror__extension-code-block/src/code-block-extension.ts
Outdated
Show resolved
Hide resolved
packages/remirror__extension-code-block/src/code-block-extension.ts
Outdated
Show resolved
Hide resolved
packages/remirror__extension-code-block/src/code-block-utils.ts
Outdated
Show resolved
Hide resolved
packages/remirror__extension-code-block/src/code-block-utils.ts
Outdated
Show resolved
Hide resolved
- Revisions from review
|
@whawker - Thanks for reviewing. I believe all feedback has been addressed in 20479ec. Happy to revise more if you see anything else. Could you help with the included changeset? I'm pretty sure it's inaccurate. I know |
|
Thanks for highlighting the issue on the changeset, if we update the code block extension itself (and the I have opted to use the It also seems this change also means |
Thanks for cleaning this up.
For what it's worth, it wasn't a mock formatter. Rather, there was a spy wrapping a real formatter to ensure it ran the correct number of times and it enabled a means of more tightly tracking the completion of the format command than arbitrary waits. It was more complicated, though, I'll admit.
Thank you for following-up on this; it was a miss on my part since you suggested the possibility earlier. |
* feat(core): decouple Lingui from core, move into optional `@remirror/i18n` (#2128) * fix(react-components): remove unnecessary dependency from @remirror/react-components * BREAKING: decouple Lingui from core, move into optional @remirror/i18n * feat(messages): extract the messages into JSON files * docs(storybook): add examples using different i18n libraries * fix: try to resolve isExternal error * fix: remove @lingui/core from @remirror/messages * fix: remove @remirror/i18n from @remirror/react-core * test(react-core): ensure the i18nFormat function is provided by hook * fix: revert lingui extract to be done from the root folder * docs(core-types): add descriptions for the new types * chore: update changeset * feat: use stage-3 ES decorator (#2166) * chore: run pnpm fix * chore: enter v3 beta release * chore: fix cyclic dependency (#2168) * chore: skip storybook-react when building packages * chore(ci): enable turbo remote cache (#2171) * chore: clean changeset * chore: update .eslintignore * chore(changeset): version update (beta) (#2170) * chore(ci): try to fix ci test * chore: cache more output files * chore: build jest-prosemirror * chore: increase size-limit * chore: run pnpm dedupe * chore: build testing * chore: fix test * chore(ci): increase timeout-minutes * chore: run pnpm fix * chore: fix publish-v3 name * chore: set publish branch to v3 * chore: fix the build script for @remirror/messages and @remirror/theme * chore: fix the build script for @remirror/react * chore: add script `build:packages:force` * fix(pm): update ProseMirror dependencies to latest versions (#2192) * feat(mention-atom): add leaf text for mention atom nodes (#2190) * chore: fix `watch:skip-build` script * feat: extract MUI react components into `@remirror/react-ui` (#2193) * feat: extract MUI react components into a new optional package `@remirror/react-ui` * docs: add custom mui theme example * feat: make `extension` decorator backwards compatible when called as function (#2191) * chore(core): remove deprecated extensionDecorator * fix(core): make extension decorator backward compatible (when called as function) * docs: tidy up (#2196) * docs: remove beta notice from file extension * fix: remove incorrect usage statement from `@remirror/react-ui` readme * docs: add orphaned extension docs to the index page * chore(changeset): version update (beta) (#2194) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: downgrade build target (#2197) * chore: downgrade build target * chore(changeset): version update (beta) (#2198) * chore: downgrade build target to support browsers since 2017 (#2199) * chore: downgrade build target to support browsers since 2017 * fix: increase size limit on some packages * chore(changeset): version update (beta) (#2200) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * fix: bump all packages to rebuild for browsers since 2017 (#2201) * chore(changeset): version update (beta) (#2202) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: remove deprecated items (#2208) * chore(theme): remove deprecated functions * chore(types): remove deprecated types * chore(jest-remirror): remove deprecated start and end values * chore(jest-prosemirror): remove deprecated jumpTo function * chore(core-constants): remove deprecated error code * chore(core): remove deprecated `getRemirrorJSON` helper * chore: remove deprecated `isEnabled` command helper * chore(events): remove deprecated types * chore(react-hooks): remove deprecated useSuggester alias * fix: reorganise changeset severity * fix(react-ui): language selector should be a component, not an extension (#2203) * fix(react-ui): language selector should be a component, not an extension * feat(find): remove deprecated `SearchExtension`, add `FindButton` component (#2213) * feat(preset-wysiwyg): remove deprecated search extension, replace with find extension * feat(react-ui): add find button and ability to toggle replace * chore(changeset): version update (beta) (#2210) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Merge remote-tracking branch 'origin/main' into v3 * fix: bump to an version of esbuild that supports decorators * chore: add changeset * chore: bump all packages for next beta * fix: audit errors * fix: actually fix audit error * fix: run pnpm fix * fix: support older environments * fix: override typescript version used in build * chore: add satisfies to custom extension docs * fix: update formatjs version to trigger typescript change * chore: try to specific typescript version in cli * fix: output type definitions correctly * chore(changeset): version update (beta) (#2271) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: forward-port validate property removal * chore(changeset): version update (beta) (#2274) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: remove React Tables extension from `@remirror/react` * chore: remove YjsExtension from `remirror/extensions` * chore: remove CodemirrorExtension from `remirror/extensions` * fix: missing tsconfig reference * chore: export cx from core-helpers using clsx * fix: actually fix tsconfig for markdown ext * chore(changeset): version update (beta) (#2276) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * feat: upgrade to prettier v3.2 (#2255) * feat: Upgrade to prettier v3.2 * (Revisions) feat: Upgrade to prettier v3.2 - Extract code language string to parser name identification into its own function. * (Revisions) feat: Upgrade to prettier v3.2 - Use DelayedCommand to generate command formatCodeBlock and make the command generator available via the extension store. - Refactor formatCodeBlockFactory into formatCode that only returns information about document updates to be applied instead of also dispatching transactions itself. * (Revisions) feat: Upgrade to prettier v3.2 - Revisions from review * fix: formatCodeBlock cannot be chained * test: use exposed formatter in unit tests * chore: update changeset * test: use a more realistic custom formatter --------- Co-authored-by: William Hawker <w.hawker@hotmail.co.uk> * fix: update loglevel arg in helper script (#2278) * feat: add code block formatter to react-ui (#2256) * feat: add code formatter button extension * feat: add button for code block formatting Introduce CodeBlockTools component in react-ui that positions components with a code block Introduce a CodeBlockFormatButton component that formats code blocks using the provided formatter --------- Co-authored-by: William Hawker <w.hawker@hotmail.co.uk> * chore: switch to release candidate builds * chore(changeset): version update (rc) (#2277) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * fix: do not exit formatting if `onClick` provided * chore: update styled-components to v6 (#2280) * chore: update styled-components to v6 - styled-components is a peer dependency, so other projects rely on remirror keeping it up to date or they can be blocked from updating it themselves (without overrides); bump to v6. - Remove @types/styled-components since types are bundled with v6. Fixes #2279 * fix: remove incorrect type declarations from styles While typing exported variables is generally good practice, the types applied to style constants were nothing more than an attempt to derive the return type of the function being called, and they were incorrect. Assign the values and let the type inference do its magic. Fix the order of imports in styled-components.tsx so that when the file is regenerated its imports agree with lint rules. --------- Co-authored-by: William Hawker <w.hawker@hotmail.co.uk> * chore: exit pre-release mode * chore: remove references to obsolete extensions --------- Co-authored-by: ocavue <ocavue@gmail.com> Co-authored-by: William Hawker <w.hawker@hotmail.co.uk> Co-authored-by: Matt Mower <mdmower@cmphys.com>
Description
^3.2.0.fix:prettiernpm script to use--log-levelargument.packages/remirror__clisince it is used directly in source.packages/remirror__extension-code-blockto run formatter asynchronously.formatterextension inpackages/remirror__extension-code-blockto use prettier v3.support/scripts/src/linaria.tsto fix prettier config resolution which needs to be based on file path, not directory.Breaking change
This PR is categorized as feat: because it introduces a breaking change on the
formatterprop that is accepted by the code block extension. The signature changed fromto
Checklist
pnpm fixcompleted successfully.pnpm test.Screenshots
No user facing changes. A new code formatter entry in the storybook is introduced in separate PR #2256 that depends on this PR. Screenshots of the formatter in action are available there.
Fixes #2250