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

Add quiet option to Node.js API #5542

Merged
merged 5 commits into from Sep 17, 2021
Merged

Add quiet option to Node.js API #5542

merged 5 commits into from Sep 17, 2021

Conversation

hudochenkov
Copy link
Member

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

Related to #5529, but not closes it.

Is there anything in the PR that needs further explanation?

Refactored as much as possible to async-await in core. Also noticed some improvements to code.

Accidentally found that quite flag in Node.js API didn't work. It's probably worked only in CLI only for a long time, even thought stylelint have it since v2.0.0. This option wasn't even documented. I fixed it and added tests. UPD: found that there is an issue #4476 :)

}

if (stylelint._options.syntax) {
return Promise.reject(
Copy link
Member Author

Choose a reason for hiding this comment

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

When throw and error in async function it is converted to rejected Promise. So for being more explicit I converted all throw into return Promise.reject() through this PR.

@ybiquitous
Copy link
Member

This option wasn't even documented. I fixed it and added tests.

Great! Does it make sense to add the documentation fix to this PR title?

lib/cli.js Show resolved Hide resolved
jeddy3 referenced this pull request Sep 17, 2021
Copy link
Member

@m-allanson m-allanson left a comment

Choose a reason for hiding this comment

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

I love it 😆

}

fileList = fileList.map((entry) => {
let fileList = [files].flat().map((entry) => {
Copy link
Member

Choose a reason for hiding this comment

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

[files].flat() is a neat replacement for if (typeof fileList === 'string') {, I haven't seen that before.

const absoluteFilepath = !path.isAbsolute(filePath)
? path.join(cwd, filePath)
: path.normalize(filePath);
if (filePaths.length) {
Copy link
Member

Choose a reason for hiding this comment

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

This is a nice unravelling of some nested ifs.

lib/lintSource.js Show resolved Hide resolved
Copy link
Member

@jeddy3 jeddy3 left a comment

Choose a reason for hiding this comment

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

Fantastic. So much cleaner and more understandable!

This option wasn't even documented. I fixed it and added tests. UPD: found that there is an issue #4476 :)

Let's rename the pull request to:

"Add quiet option to Node.js API"

(with the refactoring being an amazing icing on the cake!)

Closes #4476

@hudochenkov hudochenkov changed the title Refactoring to async-await Add quiet option to Node.js API Sep 17, 2021
Copy link
Member

@ybiquitous ybiquitous left a comment

Choose a reason for hiding this comment

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

LGTM! 👍🏼

And, sorry for the conflict by #5544 merged... 🙇🏼

Copy link
Member

@ybiquitous ybiquitous left a comment

Choose a reason for hiding this comment

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

Thank you 👍🏼

@jeddy3 jeddy3 merged commit c0383e9 into v14 Sep 17, 2021
@jeddy3 jeddy3 deleted the async-await branch September 17, 2021 11:37
@jeddy3
Copy link
Member

jeddy3 commented Sep 17, 2021

  • Added: quiet option to Node.js API (#5542).

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

4 participants