-
-
Notifications
You must be signed in to change notification settings - Fork 202
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
feat: Support Stylelint custom syntax object #937
feat: Support Stylelint custom syntax object #937
Conversation
commit: |
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 PR! Happy to merge, but please first see the feedback.
assert(issues.dependencies['package.json']['stylelint-order']); | ||
assert(issues.unresolved['stylelint.config.js']['stylelint-config-standard']); | ||
assert(issues.unlisted['stylelint.config.js']['stylelint-config-recommended']); | ||
assert(issues.unresolved['.stylelintrc.mjs']['stylelint-config-standard']); |
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.
The idea of most of the plugin tests is to not leave any issues, so only the processed
and total
counters should not be zero (0). In other words, the dependencies referenced in the plugin config files in the fixtures should also be listed in package.json
.
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.
Alright! Thanks
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!
Idea: if we'd remove the node_modules
folder in the fixture folder, would we still get the same test results? This is usually necessary to have in certain situations with binaries and such. If it's not doing much we might as well delete it.
@@ -1,5 +1,5 @@ | |||
export type BaseStyleLintConfig = { | |||
customSyntax?: string; | |||
customSyntax?: string | object; |
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.
Maybe unknown
would be better than object
here?
If we completely remove But I removed the ones that weren't necessary! |
Perfect, thank you! |
🚀 This pull request is included in v5.44.1. See Release 5.44.1 for release notes. Using Knip in a commercial project? Please consider becoming a sponsor. |
The
customSyntax
option in Stylelint config can accept a module name, but it can also accept a Syntax object:Some examples in the wild:
https://github.com/search?q=%22customSyntax%3A+require%28%22&type=code
Since Knip assumes that
config.customSyntax
can only be a string, running it with this kind of config results in the following error:I updated the Stylelint plugin to avoid trying to resolve syntax objects.
I also added tests for JS config files.