Skip to content

Conversation

@silverwind
Copy link
Contributor

@silverwind silverwind commented Nov 8, 2025

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

Closes #8833

Is there anything in the PR that needs further explanation?

Typescript types are already correct because type interface matches function.

@changeset-bot
Copy link

changeset-bot bot commented Nov 8, 2025

🦋 Changeset detected

Latest commit: 5b90cc0

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

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

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
Member

@ryo-manba ryo-manba left a comment

Choose a reason for hiding this comment

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

@silverwind
Copy link
Contributor Author

silverwind commented Nov 9, 2025

I think essentially postcss-html is in violation of the postcss plugin spec, but I guess depending on definition, a function is also an object in JS because it has properties. I will update the docs.

@romainmenke
Copy link
Member

I am unsure of we should update the documentation and error message.
As noted postcss-html isn't strictly following the PostCSS API while at the same time any function is also an object in JavaScript.

I think it would be fine to only change this line:

if (typeof customSyntax === 'object' || typeof customSyntax === 'function') {

Then Stylelint is a bit more graceful in what it accepts but without promoting further proliferation of this pattern that goes outside the documented PostCSS API.

@silverwind
Copy link
Contributor Author

Okay, changeset is minimal now, just the typeof change and the test.

Copy link
Member

@ryo-manba ryo-manba left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@silverwind
Copy link
Contributor Author

BTW I guess the reason why it worked when passing string to customSyntax must be because the code that loads the npm module must not be doing the same valdiation that is done when a object-like is passed. I guess ideally those code paths should be unified to perform the same validation.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 10, 2025

This PR is packaged and the instant preview is available (5b90cc0). View the demo website.

Install it locally:

npm i -D https://pkg.pr.new/stylelint@5b90cc0

@ryo-manba
Copy link
Member

@silverwind
Can you add lib/getPostcssResult.cjs?

@silverwind
Copy link
Contributor Author

Done, sorry I forgot this repo had generated files checked into source control.

@jeddy3 jeddy3 changed the title Support customSyntax with function export Add support for customSyntax with function export Nov 10, 2025
@jeddy3 jeddy3 mentioned this pull request Nov 10, 2025
4 tasks
Copy link
Member

@romainmenke romainmenke 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. LGTM 👍

@jeddy3 jeddy3 merged commit 2ba1898 into stylelint:main Nov 13, 2025
17 checks passed
@silverwind silverwind deleted the funccustomstyntax branch November 13, 2025 17:07
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Nov 22, 2025
| datasource | package   | from    | to      |
| ---------- | --------- | ------- | ------- |
| npm        | stylelint | 16.25.0 | 16.26.0 |


## [v16.26.0](https://github.com/stylelint/stylelint/blob/HEAD/CHANGELOG.md#16260---2025-11-21)

It adds 1 feature and fixes 2 bugs.

- Added: support for `customSyntax` with function export ([#8834](stylelint/stylelint#8834)) ([@silverwind](https://github.com/silverwind)).
- Fixed: `custom-property-no-missing-var-function` false positives for style query in `if()` function ([#8813](stylelint/stylelint#8813)) ([@sajdakabir](https://github.com/sajdakabir)).
- Fixed: `media-feature-range-notation` false positives for multiple queries and `except: exact-value` ([#8832](stylelint/stylelint#8832)) ([@jeddy3](https://github.com/jeddy3)).
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Nov 22, 2025
| datasource | package   | from    | to      |
| ---------- | --------- | ------- | ------- |
| npm        | stylelint | 16.25.0 | 16.26.0 |


## [v16.26.0](https://github.com/stylelint/stylelint/blob/HEAD/CHANGELOG.md#16260---2025-11-21)

It adds 1 feature and fixes 2 bugs.

- Added: support for `customSyntax` with function export ([#8834](stylelint/stylelint#8834)) ([@silverwind](https://github.com/silverwind)).
- Fixed: `custom-property-no-missing-var-function` false positives for style query in `if()` function ([#8813](stylelint/stylelint#8813)) ([@sajdakabir](https://github.com/sajdakabir)).
- Fixed: `media-feature-range-notation` false positives for multiple queries and `except: exact-value` ([#8832](stylelint/stylelint#8832)) ([@jeddy3](https://github.com/jeddy3)).
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.

Add support for customSyntax as function type

4 participants