Skip to content

add docs for stylelint rule syntax #849

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions plugins/postcss-conditional-values/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,25 @@ color: csstools-if(--a-condition yellow else red);
csstools-if(<custom-property-name> <declaration-value> else <declaration-value>);
```

#### [Stylelint](https://stylelint.io/user-guide/rules/declaration-property-value-no-unknown/#propertiessyntax--property-syntax-)

Stylelint is able to check for unknown property values.
Setting the correct configuration for this rule makes it possible to check even non-standard syntax.

```js
// Disallow unknown values for properties within declarations.
'declaration-property-value-no-unknown': [
true,
{
propertiesSyntax: {
color: '| csstools-if( <custom-property-name> <\'color\'> else <\'color\'> )',
'background-color': '| csstools-if( <custom-property-name> <\'background-color\'> else <\'background-color\'> )',
// ... more properties ...
},
},
],
```

### `true` and `false` keywords

The `true` and `false` keywords are syntactic sugar for `initial` and `<space>`.
Expand Down
19 changes: 19 additions & 0 deletions plugins/postcss-conditional-values/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,25 @@ color: csstools-if(--a-condition yellow else red);
csstools-if(<custom-property-name> <declaration-value> else <declaration-value>);
```

#### [Stylelint](https://stylelint.io/user-guide/rules/declaration-property-value-no-unknown/#propertiessyntax--property-syntax-)

Stylelint is able to check for unknown property values.
Setting the correct configuration for this rule makes it possible to check even non-standard syntax.

```js
// Disallow unknown values for properties within declarations.
'declaration-property-value-no-unknown': [
true,
{
propertiesSyntax: {
color: '| csstools-if( <custom-property-name> <\'color\'> else <\'color\'> )',
'background-color': '| csstools-if( <custom-property-name> <\'background-color\'> else <\'background-color\'> )',
Comment on lines +87 to +88
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 hope the repetition makes it clear what is going here.

I don't think we can or should try to document the CSS value syntax notation. So I am only providing a hint for users who already know enough to use this correctly.

// ... more properties ...
},
},
],
```

### `true` and `false` keywords

The `true` and `false` keywords are syntactic sugar for `initial` and `<space>`.
Expand Down
21 changes: 21 additions & 0 deletions plugins/postcss-design-tokens/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,27 @@ design-token() = design-token( <token-path> [ to <unit> ]? )
The plugin can convert `px` to `rem` and `rem` to `px` via the [`unitsandvalues`](#unitsandvalues) plugin options.
When a design token is unit-less any `unit` can be assigned with `to`.

#### [Stylelint](https://stylelint.io/user-guide/rules/declaration-property-value-no-unknown/#propertiessyntax--property-syntax-)

Stylelint is able to check for unknown property values.
Setting the correct configuration for this rule makes it possible to check even non-standard syntax.

```js
// Disallow unknown values for properties within declarations.
'declaration-property-value-no-unknown': [
true,
{
propertiesSyntax: {
color: '| <design-token()>',
// ... more properties ...
},
typesSyntax: {
'<design-token()>': 'design-token( <string> [ to <ident> ]? )',
},
},
],
```

## Further reading

- [Why we think PostCSS Design Tokens is needed]
Expand Down
21 changes: 21 additions & 0 deletions plugins/postcss-design-tokens/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,27 @@ design-token() = design-token( <token-path> [ to <unit> ]? )
The plugin can convert `px` to `rem` and `rem` to `px` via the [`unitsandvalues`](#unitsandvalues) plugin options.
When a design token is unit-less any `unit` can be assigned with `to`.

#### [Stylelint](https://stylelint.io/user-guide/rules/declaration-property-value-no-unknown/#propertiessyntax--property-syntax-)

Stylelint is able to check for unknown property values.
Setting the correct configuration for this rule makes it possible to check even non-standard syntax.

```js
// Disallow unknown values for properties within declarations.
'declaration-property-value-no-unknown': [
true,
{
propertiesSyntax: {
color: '| <design-token()>',
// ... more properties ...
},
typesSyntax: {
'<design-token()>': 'design-token( <string> [ to <ident> ]? )',
},
},
],
```

## Further reading

- [Why we think PostCSS Design Tokens is needed]
Expand Down