1 | # number-max-precision
|
2 |
|
3 | Limit the number of decimal places allowed in numbers.
|
4 |
|
5 |
|
6 | ```css
|
7 | a { top: 3.245634px; }
|
8 | /** ↑
|
9 | * This decimal place */
|
10 | ```
|
11 |
|
12 | ## Options
|
13 |
|
14 | `int`: Maximum number of decimal places allowed.
|
15 |
|
16 | For example, with `2`:
|
17 |
|
18 | The following patterns are considered violations:
|
19 |
|
20 |
|
21 | ```css
|
22 | a { top: 3.245px; }
|
23 | ```
|
24 |
|
25 |
|
26 | ```css
|
27 | a { top: 3.245634px; }
|
28 | ```
|
29 |
|
30 |
|
31 | ```css
|
32 | @media (min-width: 3.234em) {}
|
33 | ```
|
34 |
|
35 | The following patterns are _not_ considered violations:
|
36 |
|
37 |
|
38 | ```css
|
39 | a { top: 3.24px; }
|
40 | ```
|
41 |
|
42 |
|
43 | ```css
|
44 | @media (min-width: 3.23em) {}
|
45 | ```
|
46 |
|
47 | ## Optional secondary options
|
48 |
|
49 | ### `ignoreUnits: ["/regex/", /regex/, "string"]`
|
50 |
|
51 | Ignore the precision of numbers for values with the specified units.
|
52 |
|
53 | For example, with `2`.
|
54 |
|
55 | Given:
|
56 |
|
57 | ```
|
58 | ["/^my-/", "%"]
|
59 | ```
|
60 |
|
61 | The following patterns are considered violations:
|
62 |
|
63 |
|
64 | ```css
|
65 | a { top: 3.245px; }
|
66 | ```
|
67 |
|
68 |
|
69 | ```css
|
70 | a { top: 3.245634px; }
|
71 | ```
|
72 |
|
73 |
|
74 | ```css
|
75 | @media (min-width: 3.234em) {}
|
76 | ```
|
77 |
|
78 | The following patterns are _not_ considered violations:
|
79 |
|
80 |
|
81 | ```css
|
82 | a { top: 3.245%; }
|
83 | ```
|
84 |
|
85 |
|
86 | ```css
|
87 | @media (min-width: 3.23em) {}
|
88 | ```
|
89 |
|
90 |
|
91 | ```css
|
92 | a {
|
93 | width: 10.5432%;
|
94 | }
|
95 | ```
|
96 |
|
97 |
|
98 | ```css
|
99 | a { top: 3.245my-unit; }
|
100 | ```
|
101 |
|
102 |
|
103 | ```css
|
104 | a {
|
105 | width: 10.989my-other-unit;
|
106 | }
|
107 | ```
|