Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
57 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,16 +51,50 @@ If you want to continue using Stylelint to enforce stylistic consistency, you ca | |
|
||
### Added `declaration-property-value-no-unknown` rule | ||
|
||
We added the [`declaration-property-value-no-unknown`](../../lib/rules/declaration-property-value-no-unknown/README.md) rule and turned it on in our [recommended](https://www.npmjs.com/package/stylelint-config-recommended) and [standard](https://www.npmjs.com/package/stylelint-config-standard) configs. | ||
We added the [`declaration-property-value-no-unknown`](../../lib/rules/declaration-property-value-no-unknown/README.md) rule. It will flag property-value pairs that are unknown in the CSS specifications, for example: | ||
|
||
The rule checks for unknown property-value pairs in declarations. If you use values that aren't in the CSS specifications, you can use the rule's secondary options to make the rule more permissive. You can either: | ||
```css | ||
a { | ||
top: red; | ||
} | ||
``` | ||
|
||
The `top` property accepts either a `<length>`, `<percentage>` or the `auto` keyword. The rule will flag `red` as it's a `<color>`. | ||
|
||
Many of you have requested this rule, and we plan to add more like it to help you [avoid errors](../user-guide/rules.md#avoid-errors) in your CSS. | ||
|
||
To turn it on in your configuration object: | ||
|
||
```diff json | ||
{ | ||
"extends": ["stylelint-config-standard"], | ||
"rules" { | ||
+ "declaration-property-value-no-unknown": true | ||
.. | ||
} | ||
} | ||
``` | ||
|
||
The rule uses [CSSTree](https://github.com/csstree/csstree) and its [syntax dictionary](https://csstree.github.io/docs/syntax/) of 604 properties, 386 types and 130 functions. You can help identify and plug any gaps in its dictionary by either updating [mdn-data](https://github.com/mdn/data/) or [CSSTree's patch file](https://github.com/csstree/csstree/blob/master/data/patch.json). | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jeddy3
Author
Member
|
||
|
||
If you use values that aren't in the CSS specifications, you can use the rule's secondary options to make the rule more permissive. You can either: | ||
|
||
- ignore properties or values outright | ||
- extend the properties and values syntaxes | ||
|
||
The latter is a powerful approach that ensures only specific exceptions are allowed. | ||
The latter ensures only specific exceptions are allowed. | ||
|
||
If you currently use the [`stylelint-csstree-validator`](https://www.npmjs.com/package/stylelint-csstree-validator) plugin, you can continue to use it alongside the new rule by limiting the plugin to check only at-rule names and preludes. | ||
|
||
We hope to add more rules like this to Stylelint that help you [avoid errors](../user-guide/rules.md#avoid-errors) in your code. | ||
```diff json | ||
{ | ||
"rules" { | ||
"csstree/validator": [true, { | ||
+ "ignoreProperties": ["/.+/"] | ||
}] | ||
} | ||
} | ||
``` | ||
|
||
## Breaking changes | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nit
will require to be updated quite often. What about
instead?