Skip to content

refactor: migrate worker.js to worker.mjs #736

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

Merged
merged 4 commits into from
May 5, 2025

Conversation

yashtech00
Copy link
Contributor

@yashtech00 yashtech00 commented May 5, 2025

This PR changes worker.js to worker.mjs

close #732


Important

Renamed worker.js to worker.mjs and updated import/export syntax to ECMAScript module format.

  • File Renaming:
    • Rename worker.js to worker.mjs.
  • Import/Export Changes:
    • Change require to import for runAsWorker in worker.mjs.
  • Configuration Updates:
    • Update require.resolve('./worker') to require.resolve('./worker.mjs') in eslint-plugin-prettier.js.
    • Update package.json to include worker.mjs instead of worker.js in the files array.

This description was created by Ellipsis for 4e8ef1f. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

Summary by CodeRabbit

  • Chores
    • Updated internal module format from CommonJS (.js) to ES module (.mjs) for improved compatibility.
    • Adjusted package contents to include the updated worker file.

Copy link

changeset-bot bot commented May 5, 2025

🦋 Changeset detected

Latest commit: 99bac6f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-prettier Minor

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

Copy link

coderabbitai bot commented May 5, 2025

Walkthrough

The changes transition the worker script for Prettier formatting from a CommonJS module (worker.js) to an ES module (worker.mjs). This involves updating import syntax in the worker file, changing references to the worker script in both the main plugin code and the package.json file, and ensuring the correct module type is used throughout. No changes are made to the logic, error handling, or public APIs.

Changes

File(s) Change Summary
eslint-plugin-prettier.js Updated worker script path in createSyncFn from './worker' to './worker.mjs'.
package.json Changed "files" entry from "worker.js" to "worker.mjs".
worker.mjs Replaced CommonJS require with ES module import for runAsWorker and prettier; removed dynamic import.
.changeset/eight-hornets-approve.md Added changeset documenting the migration from worker.js to worker.mjs.

Suggested labels

internal, ci

Poem

A worker once dressed in ".js" attire,
Now dons ".mjs" for what we require.
Imports are modern, syntax is neat,
Prettier formatting—no CommonJS defeat!
With modules aligned and changes so small,
This rabbit approves—hopping for all! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9e4dc52 and 99bac6f.

📒 Files selected for processing (1)
  • worker.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • worker.mjs
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

pkg-pr-new bot commented May 5, 2025

Open in StackBlitz

npm i https://pkg.pr.new/eslint-plugin-prettier@736

commit: 99bac6f

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to 4e8ef1f in 1 minute and 5 seconds. Click for details.
  • Reviewed 42 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 7 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. eslint-plugin-prettier.js:175
  • Draft comment:
    Updated worker file reference to 'worker.mjs'. Ensure that synckit supports resolving ESM modules with require.resolve in your Node versions.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
2. package.json:35
  • Draft comment:
    Replaced 'worker.js' with 'worker.mjs' in files. This update looks correct.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
3. worker.mjs:14
  • Draft comment:
    Properly using ESM import for 'synckit'; code looks fine.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
4. eslint-plugin-prettier.js:175
  • Draft comment:
    Ensure that require.resolve('./worker.mjs') works in a CommonJS context across supported Node versions.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
5. package.json:35
  • Draft comment:
    The worker file reference has been updated to 'worker.mjs'. Make sure related docs/scripts are also updated.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
6. worker.mjs:42
  • Draft comment:
    Dynamic import of 'prettier' is used here; verify that the returned module exposes the expected named exports (e.g., format, resolveConfig) without needing destructuring.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
7. worker.mjs:112
  • Draft comment:
    Typographical issue: In the 'graphql' case, the string passed to startsWith is 'ESLintPluginGraphQLFile`' with a stray backtick at the end. Likely, this should be corrected to 'ESLintPluginGraphQLFile' (remove the trailing backtick) to avoid potential confusion.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_mYaZdH81y3yM6tWs

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@JounQin JounQin requested a review from Copilot May 5, 2025 10:16
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR renames the worker file from CommonJS (.js) to ES module (.mjs) and updates the import/export syntax accordingly.

  • Updated worker.mjs to use ES module import syntax instead of CommonJS require.
  • Modified eslint-plugin-prettier.js to reference the newly named worker.mjs.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
worker.mjs Changed require to import for ES module compatibility.
eslint-plugin-prettier.js Updated worker file reference from worker.js to worker.mjs.
Files not reviewed (1)
  • package.json: Language not supported

Copy link
Member

@JounQin JounQin left a comment

Choose a reason for hiding this comment

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

@yashtech00 Thanks for your contribution first!

We can also migrate the following statement:

prettier = await import('prettier');

into:

import prettier from 'prettier';

And the related jsdoc can be removed then.

@yashtech00
Copy link
Contributor Author

I've pushed the requested changes. Please review. 🙌

@JounQin JounQin changed the title fix: migrate worker.js to worker.mjs reactor: migrate worker.js to worker.mjs May 5, 2025
@JounQin
Copy link
Member

JounQin commented May 5, 2025

Thanks @yashtech00.

Please remember to use GitHub keywords like close, fix, etc in thr PR description next time. See also https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests

@JounQin JounQin merged commit baa7236 into prettier:main May 5, 2025
12 checks passed
@JounQin JounQin changed the title reactor: migrate worker.js to worker.mjs refactor: migrate worker.js to worker.mjs May 5, 2025
JounQin added a commit that referenced this pull request May 5, 2025
Co-authored-by: JounQin <admin@1stg.me>
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request May 10, 2025
| datasource | package                | from  | to    |
| ---------- | ---------------------- | ----- | ----- |
| npm        | eslint-plugin-prettier | 5.2.3 | 5.4.0 |


## [v5.4.0](https://github.com/prettier/eslint-plugin-prettier/blob/HEAD/CHANGELOG.md#540)

##### Minor Changes

-   [#736](prettier/eslint-plugin-prettier#736) [`59a0cae`](prettier/eslint-plugin-prettier@59a0cae) Thanks [@yashtech00](https://github.com/yashtech00)! - refactor: migrate `worker.js` to `worker.mjs`


## [v5.3.1](https://github.com/prettier/eslint-plugin-prettier/blob/HEAD/CHANGELOG.md#531)

##### Patch Changes

-   [#734](prettier/eslint-plugin-prettier#734) [`dcf2c80`](prettier/eslint-plugin-prettier@dcf2c80) Thanks [@JounQin](https://github.com/JounQin)! - ci: enable `NPM_CONFIG_PROVENANCE` env


## [v5.3.0](https://github.com/prettier/eslint-plugin-prettier/blob/HEAD/CHANGELOG.md#530)

##### Minor Changes

-   [#674](prettier/eslint-plugin-prettier#674) [`6fe0c90`](prettier/eslint-plugin-prettier@6fe0c90) Thanks [@irsooti](https://github.com/irsooti)! - feat(types): prefer `Config` over `FlatConfig` when they're equal


## [v5.2.6](https://github.com/prettier/eslint-plugin-prettier/blob/HEAD/CHANGELOG.md#526)

##### Patch Changes

-   [#723](prettier/eslint-plugin-prettier#723) [`1451176`](prettier/eslint-plugin-prettier@1451176) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): bump `synckit` to `v0.11.0`


## [v5.2.5](https://github.com/prettier/eslint-plugin-prettier/blob/HEAD/CHANGELOG.md#525)

##### Patch Changes

-   [#721](prettier/eslint-plugin-prettier#721) [`4f5513d`](prettier/eslint-plugin-prettier@4f5513d) Thanks [@JounQin](https://github.com/JounQin)! - fix: clarify correct `eslint-config-prettier` peer range


## [v5.2.4](https://github.com/prettier/eslint-plugin-prettier/blob/HEAD/CHANGELOG.md#524)

##### Patch Changes

-   [#715](prettier/eslint-plugin-prettier#715) [`b8cfe56`](prettier/eslint-plugin-prettier@b8cfe56) Thanks [@JounQin](https://github.com/JounQin)! - chore: hourcekeeping, bump all (dev) deps
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request May 10, 2025
| datasource | package                | from  | to    |
| ---------- | ---------------------- | ----- | ----- |
| npm        | eslint-plugin-prettier | 5.2.3 | 5.4.0 |


## [v5.4.0](https://github.com/prettier/eslint-plugin-prettier/blob/HEAD/CHANGELOG.md#540)

##### Minor Changes

-   [#736](prettier/eslint-plugin-prettier#736) [`59a0cae`](prettier/eslint-plugin-prettier@59a0cae) Thanks [@yashtech00](https://github.com/yashtech00)! - refactor: migrate `worker.js` to `worker.mjs`


## [v5.3.1](https://github.com/prettier/eslint-plugin-prettier/blob/HEAD/CHANGELOG.md#531)

##### Patch Changes

-   [#734](prettier/eslint-plugin-prettier#734) [`dcf2c80`](prettier/eslint-plugin-prettier@dcf2c80) Thanks [@JounQin](https://github.com/JounQin)! - ci: enable `NPM_CONFIG_PROVENANCE` env


## [v5.3.0](https://github.com/prettier/eslint-plugin-prettier/blob/HEAD/CHANGELOG.md#530)

##### Minor Changes

-   [#674](prettier/eslint-plugin-prettier#674) [`6fe0c90`](prettier/eslint-plugin-prettier@6fe0c90) Thanks [@irsooti](https://github.com/irsooti)! - feat(types): prefer `Config` over `FlatConfig` when they're equal


## [v5.2.6](https://github.com/prettier/eslint-plugin-prettier/blob/HEAD/CHANGELOG.md#526)

##### Patch Changes

-   [#723](prettier/eslint-plugin-prettier#723) [`1451176`](prettier/eslint-plugin-prettier@1451176) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): bump `synckit` to `v0.11.0`


## [v5.2.5](https://github.com/prettier/eslint-plugin-prettier/blob/HEAD/CHANGELOG.md#525)

##### Patch Changes

-   [#721](prettier/eslint-plugin-prettier#721) [`4f5513d`](prettier/eslint-plugin-prettier@4f5513d) Thanks [@JounQin](https://github.com/JounQin)! - fix: clarify correct `eslint-config-prettier` peer range


## [v5.2.4](https://github.com/prettier/eslint-plugin-prettier/blob/HEAD/CHANGELOG.md#524)

##### Patch Changes

-   [#715](prettier/eslint-plugin-prettier#715) [`b8cfe56`](prettier/eslint-plugin-prettier@b8cfe56) Thanks [@JounQin](https://github.com/JounQin)! - chore: hourcekeeping, bump all (dev) deps
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request May 11, 2025
| datasource | package                | from  | to    |
| ---------- | ---------------------- | ----- | ----- |
| npm        | eslint-plugin-prettier | 5.2.3 | 5.4.0 |


## [v5.4.0](https://github.com/prettier/eslint-plugin-prettier/blob/HEAD/CHANGELOG.md#540)

##### Minor Changes

-   [#736](prettier/eslint-plugin-prettier#736) [`59a0cae`](prettier/eslint-plugin-prettier@59a0cae) Thanks [@yashtech00](https://github.com/yashtech00)! - refactor: migrate `worker.js` to `worker.mjs`


## [v5.3.1](https://github.com/prettier/eslint-plugin-prettier/blob/HEAD/CHANGELOG.md#531)

##### Patch Changes

-   [#734](prettier/eslint-plugin-prettier#734) [`dcf2c80`](prettier/eslint-plugin-prettier@dcf2c80) Thanks [@JounQin](https://github.com/JounQin)! - ci: enable `NPM_CONFIG_PROVENANCE` env


## [v5.3.0](https://github.com/prettier/eslint-plugin-prettier/blob/HEAD/CHANGELOG.md#530)

##### Minor Changes

-   [#674](prettier/eslint-plugin-prettier#674) [`6fe0c90`](prettier/eslint-plugin-prettier@6fe0c90) Thanks [@irsooti](https://github.com/irsooti)! - feat(types): prefer `Config` over `FlatConfig` when they're equal


## [v5.2.6](https://github.com/prettier/eslint-plugin-prettier/blob/HEAD/CHANGELOG.md#526)

##### Patch Changes

-   [#723](prettier/eslint-plugin-prettier#723) [`1451176`](prettier/eslint-plugin-prettier@1451176) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): bump `synckit` to `v0.11.0`


## [v5.2.5](https://github.com/prettier/eslint-plugin-prettier/blob/HEAD/CHANGELOG.md#525)

##### Patch Changes

-   [#721](prettier/eslint-plugin-prettier#721) [`4f5513d`](prettier/eslint-plugin-prettier@4f5513d) Thanks [@JounQin](https://github.com/JounQin)! - fix: clarify correct `eslint-config-prettier` peer range


## [v5.2.4](https://github.com/prettier/eslint-plugin-prettier/blob/HEAD/CHANGELOG.md#524)

##### Patch Changes

-   [#715](prettier/eslint-plugin-prettier#715) [`b8cfe56`](prettier/eslint-plugin-prettier@b8cfe56) Thanks [@JounQin](https://github.com/JounQin)! - chore: hourcekeeping, bump all (dev) deps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate worker.js to worker.mjs
2 participants