UNPKG

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