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

Avoid import-lazy in formatters #7184

Merged
merged 3 commits into from Sep 20, 2023
Merged

Conversation

ybiquitous
Copy link
Member

@ybiquitous ybiquitous commented Sep 12, 2023

Which issue, if any, is this issue related to?

Related to #5291

Is there anything in the PR that needs further explanation?

This commit avoids using the import-lazy package in the formatters module.
As a result, formatters can be a pure ESM module, which means require is no longer needed.

In addition, this change accepts a Promise function as a custom formatter.

Note that import-lazy is still used:

$ git grep -w 'import-lazy' lib/
lib/rules/index.cjs:4:  const importLazy = require('import-lazy');
lib/rules/index.mjs:5:  import importLazy from 'import-lazy';

This commit avoids using the `import-lazy` package in the `formatters` module.
As a result, `formatters` can be a pure ESM module, which means `require` is no longer needed.

In addition, this change accepts a `Promise` function as a custom formatter.
@changeset-bot
Copy link

changeset-bot bot commented Sep 12, 2023

🦋 Changeset detected

Latest commit: 2fac227

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

This PR includes changesets to release 1 package
Name Type
stylelint Major

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

@ybiquitous ybiquitous marked this pull request as ready for review September 12, 2023 13:13
Copy link
Member

@mattxwang mattxwang left a comment

Choose a reason for hiding this comment

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

This looks good to me!

Are you aware of who our big downstream consumers of the stylelint.formatters API is? Perhaps we can let them know of this change in advance and solicit any feedback?

@Mouvedia Mouvedia self-requested a review September 18, 2023 09:50
Copy link
Member

@Mouvedia Mouvedia left a comment

Choose a reason for hiding this comment

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

Can you first consult the creator of the downstream plugins?

docs/migration-guide/to-16.md Show resolved Hide resolved
@@ -45,6 +45,15 @@ async function lint() {

If you use `stylelint.lint()` to lint files, the `code` property will always be `undefined`.

## Changed Node.js API returned `formatters` object
Copy link
Member

Choose a reason for hiding this comment

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

minor

…returned by the…

Copy link
Member Author

Choose a reason for hiding this comment

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

I followed the heading above:

## Changed Node.js API returned resolved object

https://github.com/stylelint/stylelint/pull/7184/files#diff-38349b678797293b4889d8dd738f084a2b19e1ba08b5de5cce31aa094f2b7a6eR26

But it seems they're not so good. Let me know if you have a better idea.

@ybiquitous
Copy link
Member Author

Thanks for the review, guys. I'm going to merge this to continue the migration to ESM. If necessary, we can revisit this change before shipping 16.0.0.

Note: @jeddy3 has been offline "until the start of November," as he commented in #7140 (comment).

@ybiquitous ybiquitous merged commit 53341fd into v16 Sep 20, 2023
12 checks passed
@ybiquitous ybiquitous deleted the avoid-import-lazy-in-formatters branch September 20, 2023 00:10
ybiquitous added a commit that referenced this pull request Sep 28, 2023
This commit avoids using the `import-lazy` package in the `formatters` module.
As a result, `formatters` can be a pure ESM module, which means `require` is no longer needed.

In addition, this change accepts a `Promise` function as a custom formatter.
ybiquitous added a commit that referenced this pull request Oct 19, 2023
This commit avoids using the `import-lazy` package in the `formatters` module.
As a result, `formatters` can be a pure ESM module, which means `require` is no longer needed.

In addition, this change accepts a `Promise` function as a custom formatter.
@jeddy3 jeddy3 removed their request for review November 5, 2023 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants