Skip to content

Commit 23caee3

Browse files
authored
fix: enforce valid allow* values in prefer-logical-properties rule (#311)
1 parent adaa397 commit 23caee3

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

docs/rules/prefer-logical-properties.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,30 @@ This rule accepts an option object with the following properties:
3838
- `allowProperties` (default: `[]`) - Specify an array of physical properties that are allowed to be used.
3939
- `allowUnits` (default: `[]`) - Specify an array of physical units that are allowed to be used.
4040

41+
#### `allowProperties`
42+
43+
Examples of **correct** code with `{ allowProperties: ["margin-left"] }`:
44+
45+
```css
46+
/* eslint css/prefer-logical-properties: ["error", { allowProperties: ["margin-left"] }] */
47+
48+
a {
49+
margin-left: 10px;
50+
}
51+
```
52+
53+
#### `allowUnits`
54+
55+
Examples of **correct** code with `{ allowUnits: ["vw"] }`:
56+
57+
```css
58+
/* eslint css/prefer-logical-properties: ["error", { allowUnits: ["vw"] }] */
59+
60+
a {
61+
margin: 10vw;
62+
}
63+
```
64+
4165
## When Not to Use It
4266

4367
If you aren't concerned with the use of logical properties, then you can safely disable this rule.

src/rules/prefer-logical-properties.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ export default {
152152
allowProperties: {
153153
type: "array",
154154
items: {
155-
type: "string",
155+
enum: Array.from(propertiesReplacements.keys()),
156156
},
157157
uniqueItems: true,
158158
},
159159
allowUnits: {
160160
type: "array",
161161
items: {
162-
type: "string",
162+
enum: Array.from(unitReplacements.keys()),
163163
},
164164
uniqueItems: true,
165165
},

src/rules/relative-font-units.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ export default {
6969
type: "array",
7070
items: {
7171
enum: relativeFontUnits,
72-
uniqueItems: true,
7372
},
73+
uniqueItems: true,
7474
},
7575
},
7676
additionalProperties: false,

0 commit comments

Comments
 (0)