You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/no-invalid-properties.md
+45-3Lines changed: 45 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,11 +44,31 @@ body {
44
44
}
45
45
```
46
46
47
-
### Limitations
47
+
##Options
48
48
49
-
When a variable is used in a property value, such as `var(--my-color)`, the rule can only properly be validated if the parser has already encountered the `--my-color` custom property. For example, this will validate correctly:
49
+
This rule accepts an option which is an object with the following property:
50
+
51
+
-`allowUnknownVariables` (default: `false`) - Ignore variables that cannot be traced to custom properties in the current file.
52
+
53
+
When a variable is used in a property value, such as `var(--my-color)`, the rule can only properly be validated if the parser has already encountered the `--my-color` custom property. With `{ allowUnknownVariables: false }`, unknown variables will result in a linting error. With `{ allowUnknownVariables: true }`, the property value will be ignored and only the property name will be validated.
54
+
55
+
Examples of **incorrect** code with `{ allowUnknownVariables: false }` (the default):
This code uses `var(--my-color)` before `--my-color` is defined, or whether it is defined in another CSS file. Therefore, `color: var(--my-color)` cannot be properly validated.
66
+
67
+
Examples of **correct** code with `{ allowUnknownVariables: false }`:
This code defines `--my-color` before it is used and therefore the rule can validate the `color` property. If `--my-color` was not defined before `var(--my-color)` was used, it results in a lint error because the validation cannot be completed.
62
82
63
-
If the custom property is defined in another file, it's recommended to create a dummy rule just to ensure proper validation.
83
+
Examples of **incorrect** code with `{ allowUnknownVariables: true }`:
0 commit comments