|
| 1 | +--- |
| 2 | +pageClass: "rule-details" |
| 3 | +sidebarDepth: 0 |
| 4 | +title: "@ota-meshi/svelte/no-unknown-style-directive-property" |
| 5 | +description: "disallow unknown `style:property`" |
| 6 | +--- |
| 7 | + |
| 8 | +# @ota-meshi/svelte/no-unknown-style-directive-property |
| 9 | + |
| 10 | +> disallow unknown `style:property` |
| 11 | +
|
| 12 | +- :exclamation: <badge text="This rule has not been released yet." vertical="middle" type="error"> **_This rule has not been released yet._** </badge> |
| 13 | +- :gear: This rule is included in `"plugin:@ota-meshi/svelte/recommended"`. |
| 14 | + |
| 15 | +## :book: Rule Details |
| 16 | + |
| 17 | +This rule reports an unknown CSS property in style directive. |
| 18 | + |
| 19 | +This rule was inspired by [Stylelint's property-no-unknown rule](https://stylelint.io/user-guide/rules/list/property-no-unknown/). |
| 20 | + |
| 21 | +Note that this rule only checks the `style:property` directive. If you want to check inside the `style` attribute and `style` element, consider introducing [Stylelint](https://stylelint.io/). |
| 22 | + |
| 23 | +<ESLintCodeBlock> |
| 24 | + |
| 25 | +<!--eslint-skip--> |
| 26 | + |
| 27 | +```svelte |
| 28 | +<script> |
| 29 | + /* eslint @ota-meshi/svelte/no-unknown-style-directive-property: "error" */ |
| 30 | + let red = "red" |
| 31 | + let color = red |
| 32 | +</script> |
| 33 | +
|
| 34 | +<!-- ✓ GOOD --> |
| 35 | +<div style:color={red}>...</div> |
| 36 | +<div style:color>...</div> |
| 37 | +
|
| 38 | +<!-- ✗ BAD --> |
| 39 | +<div style:unknown-color={red}>...</div> |
| 40 | +<div style:red>...</div> |
| 41 | +``` |
| 42 | + |
| 43 | +</ESLintCodeBlock> |
| 44 | + |
| 45 | +## :wrench: Options |
| 46 | + |
| 47 | +```json |
| 48 | +{ |
| 49 | + "@ota-meshi/svelte/no-unknown-style-directive-property": [ |
| 50 | + "error", |
| 51 | + { |
| 52 | + "ignoreProperties": [], |
| 53 | + "ignorePrefixed": true |
| 54 | + } |
| 55 | + ] |
| 56 | +} |
| 57 | +``` |
| 58 | + |
| 59 | +- `ignoreProperties` ... You can specify property names or patterns that you want to ignore from checking. |
| 60 | +- `ignorePrefixed` ... If `true`, ignores properties with vendor prefix from checking. Default is `true`. |
| 61 | + |
| 62 | +## :books: Further reading |
| 63 | + |
| 64 | +- [Stylelint - property-no-unknown] |
| 65 | + |
| 66 | +[stylelint - property-no-unknown]: https://stylelint.io/user-guide/rules/list/property-no-unknown/ |
| 67 | + |
| 68 | +## :mag: Implementation |
| 69 | + |
| 70 | +- [Rule source](https://github.com/ota-meshi/eslint-plugin-svelte/blob/main/src/rules/no-unknown-style-directive-property.ts) |
| 71 | +- [Test source](https://github.com/ota-meshi/eslint-plugin-svelte/blob/main/tests/src/rules/no-unknown-style-directive-property.ts) |
0 commit comments