@projectwallace/css-analyzer 5.0.0-alpha.1 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyzer.cjs +1 -1
- package/dist/analyzer.cjs.map +1 -1
- package/dist/analyzer.modern.js +2 -0
- package/dist/analyzer.modern.js.map +1 -0
- package/dist/analyzer.module.js +1 -1
- package/dist/analyzer.module.js.map +1 -1
- package/dist/analyzer.umd.js +1 -1
- package/dist/analyzer.umd.js.map +1 -1
- package/package.json +10 -10
- package/dist/analyzer.js +0 -2
- package/dist/analyzer.js.map +0 -1
- package/src/aggregate-collection.js +0 -113
- package/src/aggregate-collection.test.js +0 -47
- package/src/atrules/atrules.js +0 -76
- package/src/atrules/atrules.test.js +0 -289
- package/src/context-collection.js +0 -36
- package/src/countable-collection.js +0 -46
- package/src/declarations/declarations.js +0 -46
- package/src/declarations/declarations.test.js +0 -113
- package/src/index.js +0 -259
- package/src/index.test.js +0 -60
- package/src/properties/properties.js +0 -48
- package/src/properties/properties.test.js +0 -138
- package/src/rules/rules.js +0 -57
- package/src/rules/rules.test.js +0 -247
- package/src/selectors/complexity.test.js +0 -123
- package/src/selectors/selectors.js +0 -122
- package/src/selectors/selectors.test.js +0 -189
- package/src/selectors/specificity.js +0 -201
- package/src/selectors/specificity.test.js +0 -247
- package/src/smoke.test.js +0 -39
- package/src/stylesheet/stylesheet.test.js +0 -88
- package/src/values/animations.js +0 -53
- package/src/values/animations.test.js +0 -154
- package/src/values/box-shadows.test.js +0 -82
- package/src/values/colors.js +0 -192
- package/src/values/colors.test.js +0 -804
- package/src/values/font-families.js +0 -98
- package/src/values/font-families.test.js +0 -119
- package/src/values/font-sizes.js +0 -92
- package/src/values/font-sizes.test.js +0 -120
- package/src/values/text-shadows.test.js +0 -93
- package/src/values/units.test.js +0 -72
- package/src/values/values.js +0 -30
- package/src/values/vendor-prefix.js +0 -45
- package/src/values/vendor-prefix.test.js +0 -64
- package/src/values/z-index.test.js +0 -54
- package/src/vendor-prefix.js +0 -16
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { suite } from 'uvu'
|
|
2
|
-
import * as assert from 'uvu/assert'
|
|
3
|
-
import { analyze } from '../index.js'
|
|
4
|
-
|
|
5
|
-
const Animations = suite('Animations')
|
|
6
|
-
|
|
7
|
-
Animations('finds simple durations', () => {
|
|
8
|
-
const fixture = `
|
|
9
|
-
durations {
|
|
10
|
-
animation-duration: 1s;
|
|
11
|
-
animation-duration: 2ms;
|
|
12
|
-
transition-duration: 300ms;
|
|
13
|
-
}
|
|
14
|
-
`
|
|
15
|
-
const actual = analyze(fixture).values.animations.durations
|
|
16
|
-
const expected = {
|
|
17
|
-
total: 3,
|
|
18
|
-
totalUnique: 3,
|
|
19
|
-
unique: {
|
|
20
|
-
'1s': 1,
|
|
21
|
-
'2ms': 1,
|
|
22
|
-
'300ms': 1,
|
|
23
|
-
},
|
|
24
|
-
uniquenessRatio: 3 / 3
|
|
25
|
-
}
|
|
26
|
-
assert.equal(actual, expected)
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
Animations('finds simple timing functions', () => {
|
|
30
|
-
const fixture = `
|
|
31
|
-
timings {
|
|
32
|
-
animation-timing-function: linear;
|
|
33
|
-
animation-timing-function: cubic-bezier(0, 1, 0, 1);
|
|
34
|
-
|
|
35
|
-
transition-timing-function: steps(3);
|
|
36
|
-
transition-timing-function: cubic-bezier(0, 1, 0, 1);
|
|
37
|
-
}
|
|
38
|
-
`
|
|
39
|
-
const actual = analyze(fixture).values.animations.timingFunctions
|
|
40
|
-
const expected = {
|
|
41
|
-
total: 4,
|
|
42
|
-
totalUnique: 3,
|
|
43
|
-
unique: {
|
|
44
|
-
'linear': 1,
|
|
45
|
-
'cubic-bezier(0, 1, 0, 1)': 2,
|
|
46
|
-
'steps(3)': 1,
|
|
47
|
-
},
|
|
48
|
-
uniquenessRatio: 3 / 4
|
|
49
|
-
}
|
|
50
|
-
assert.equal(actual, expected)
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
Animations('finds shorthand durations', () => {
|
|
54
|
-
const fixture = `
|
|
55
|
-
durations {
|
|
56
|
-
animation: 1s ANIMATION_NAME linear;
|
|
57
|
-
animation: 2s ANIMATION_NAME cubic-bezier(0,1,0,1);
|
|
58
|
-
|
|
59
|
-
transition: all 3s;
|
|
60
|
-
transition: all 4s cubic-bezier(0,1,0,1);
|
|
61
|
-
transition: all 5s linear 5000ms;
|
|
62
|
-
}
|
|
63
|
-
`
|
|
64
|
-
const actual = analyze(fixture).values.animations.durations
|
|
65
|
-
const expected = {
|
|
66
|
-
total: 5,
|
|
67
|
-
totalUnique: 5,
|
|
68
|
-
unique: {
|
|
69
|
-
'1s': 1,
|
|
70
|
-
'2s': 1,
|
|
71
|
-
'3s': 1,
|
|
72
|
-
'4s': 1,
|
|
73
|
-
'5s': 1,
|
|
74
|
-
},
|
|
75
|
-
uniquenessRatio: 5 / 5
|
|
76
|
-
}
|
|
77
|
-
assert.equal(actual, expected)
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
Animations('finds shorthand timing functions', () => {
|
|
81
|
-
const fixture = `
|
|
82
|
-
durations {
|
|
83
|
-
animation: 1s ANIMATION_NAME linear;
|
|
84
|
-
animation: 2s ANIMATION_NAME cubic-bezier(0,1,0,1);
|
|
85
|
-
|
|
86
|
-
transition: all 3s;
|
|
87
|
-
transition: all 4s cubic-bezier(0,1,0,1);
|
|
88
|
-
transition: all 5s linear 5000ms;
|
|
89
|
-
}
|
|
90
|
-
`
|
|
91
|
-
const actual = analyze(fixture).values.animations.timingFunctions
|
|
92
|
-
const expected = {
|
|
93
|
-
total: 4,
|
|
94
|
-
totalUnique: 2,
|
|
95
|
-
unique: {
|
|
96
|
-
'linear': 2,
|
|
97
|
-
'cubic-bezier(0,1,0,1)': 2,
|
|
98
|
-
},
|
|
99
|
-
uniquenessRatio: 2 / 4
|
|
100
|
-
}
|
|
101
|
-
assert.equal(actual, expected)
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
Animations('analyzes animations/transitions with value lists', () => {
|
|
105
|
-
const fixture = `
|
|
106
|
-
multi-value {
|
|
107
|
-
animation: 1s ANIMATION_NAME linear, 2s ANIMATION_NAME linear;
|
|
108
|
-
animation: 3s ANIMATION_NAME ease 3ms, 4s ANIMATION_NAME ease-in-out 4ms;
|
|
109
|
-
transition: all 5s, color 6s;
|
|
110
|
-
transition: all 7s ease, all 8s linear;
|
|
111
|
-
transition: all 9s steps(4, step-end) 9ms, all 10s steps(2) 10ms;
|
|
112
|
-
transition: all 11s, font-size 12s 12ms, line-height 13ms, border 0.0014s;
|
|
113
|
-
}
|
|
114
|
-
`
|
|
115
|
-
const actual = analyze(fixture).values.animations
|
|
116
|
-
const expected = {
|
|
117
|
-
durations: {
|
|
118
|
-
total: 14,
|
|
119
|
-
totalUnique: 14,
|
|
120
|
-
unique: {
|
|
121
|
-
'1s': 1,
|
|
122
|
-
'2s': 1,
|
|
123
|
-
'3s': 1,
|
|
124
|
-
'4s': 1,
|
|
125
|
-
'5s': 1,
|
|
126
|
-
'6s': 1,
|
|
127
|
-
'7s': 1,
|
|
128
|
-
'8s': 1,
|
|
129
|
-
'9s': 1,
|
|
130
|
-
'10s': 1,
|
|
131
|
-
'11s': 1,
|
|
132
|
-
'12s': 1,
|
|
133
|
-
'13ms': 1,
|
|
134
|
-
'0.0014s': 1,
|
|
135
|
-
},
|
|
136
|
-
uniquenessRatio: 14 / 14
|
|
137
|
-
},
|
|
138
|
-
timingFunctions: {
|
|
139
|
-
total: 8,
|
|
140
|
-
totalUnique: 5,
|
|
141
|
-
unique: {
|
|
142
|
-
'linear': 3,
|
|
143
|
-
'ease': 2,
|
|
144
|
-
'ease-in-out': 1,
|
|
145
|
-
'steps(4, step-end)': 1,
|
|
146
|
-
'steps(2)': 1,
|
|
147
|
-
},
|
|
148
|
-
uniquenessRatio: 5 / 8
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
assert.equal(actual, expected)
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
Animations.run()
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { suite } from 'uvu'
|
|
2
|
-
import * as assert from 'uvu/assert'
|
|
3
|
-
import { analyze } from '../index.js'
|
|
4
|
-
|
|
5
|
-
const BoxShadows = suite('BoxShadows')
|
|
6
|
-
|
|
7
|
-
BoxShadows('finds simple values', () => {
|
|
8
|
-
const fixture = `
|
|
9
|
-
box-shadows-simple {
|
|
10
|
-
box-shadow: 1px 1px 2px black;
|
|
11
|
-
}
|
|
12
|
-
`
|
|
13
|
-
const actual = analyze(fixture).values.boxShadows
|
|
14
|
-
const expected = {
|
|
15
|
-
total: 1,
|
|
16
|
-
unique: {
|
|
17
|
-
'1px 1px 2px black': 1,
|
|
18
|
-
},
|
|
19
|
-
totalUnique: 1,
|
|
20
|
-
uniquenessRatio: 1
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
assert.equal(actual, expected)
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
BoxShadows('finds complex values', () => {
|
|
27
|
-
const fixture = `
|
|
28
|
-
box-shadows-complex {
|
|
29
|
-
box-shadow: 1px 1px 1px black,inset 2px 3px 5px rgba(0,0,0,0.3),inset -2px -3px 5px rgba(255,255,255,0.5);
|
|
30
|
-
}
|
|
31
|
-
`
|
|
32
|
-
const actual = analyze(fixture).values.boxShadows
|
|
33
|
-
const expected = {
|
|
34
|
-
total: 1,
|
|
35
|
-
unique: {
|
|
36
|
-
'1px 1px 1px black,inset 2px 3px 5px rgba(0,0,0,0.3),inset -2px -3px 5px rgba(255,255,255,0.5)': 1,
|
|
37
|
-
},
|
|
38
|
-
totalUnique: 1,
|
|
39
|
-
uniquenessRatio: 1
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
assert.equal(actual, expected)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
BoxShadows('finds vendor prefixed values', () => {
|
|
46
|
-
const fixture = `
|
|
47
|
-
box-shadows-vendor-prefixed {
|
|
48
|
-
-webkit-box-shadow: 1px 1px 2px black;
|
|
49
|
-
}
|
|
50
|
-
`
|
|
51
|
-
const actual = analyze(fixture).values.boxShadows
|
|
52
|
-
const expected = {
|
|
53
|
-
total: 1,
|
|
54
|
-
unique: {
|
|
55
|
-
'1px 1px 2px black': 1,
|
|
56
|
-
},
|
|
57
|
-
totalUnique: 1,
|
|
58
|
-
uniquenessRatio: 1
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
assert.equal(actual, expected)
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
BoxShadows('ignores keywords', () => {
|
|
65
|
-
const fixture = `
|
|
66
|
-
box-shadows-keyword {
|
|
67
|
-
box-shadow: initial;
|
|
68
|
-
box-shadow: none;
|
|
69
|
-
}
|
|
70
|
-
`
|
|
71
|
-
const actual = analyze(fixture).values.boxShadows
|
|
72
|
-
const expected = {
|
|
73
|
-
total: 0,
|
|
74
|
-
unique: {},
|
|
75
|
-
totalUnique: 0,
|
|
76
|
-
uniquenessRatio: 0
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
assert.equal(actual, expected)
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
BoxShadows.run()
|
package/src/values/colors.js
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
export const colorNames = {
|
|
2
|
-
// CSS Named Colors
|
|
3
|
-
// Spec: https://drafts.csswg.org/css-color/#named-colors
|
|
4
|
-
aliceblue: 1,
|
|
5
|
-
antiquewhite: 1,
|
|
6
|
-
aqua: 1,
|
|
7
|
-
aquamarine: 1,
|
|
8
|
-
azure: 1,
|
|
9
|
-
beige: 1,
|
|
10
|
-
bisque: 1,
|
|
11
|
-
black: 1,
|
|
12
|
-
blanchedalmond: 1,
|
|
13
|
-
blue: 1,
|
|
14
|
-
blueviolet: 1,
|
|
15
|
-
brown: 1,
|
|
16
|
-
burlywood: 1,
|
|
17
|
-
cadetblue: 1,
|
|
18
|
-
chartreuse: 1,
|
|
19
|
-
chocolate: 1,
|
|
20
|
-
coral: 1,
|
|
21
|
-
cornflowerblue: 1,
|
|
22
|
-
cornsilk: 1,
|
|
23
|
-
crimson: 1,
|
|
24
|
-
cyan: 1,
|
|
25
|
-
darkblue: 1,
|
|
26
|
-
darkcyan: 1,
|
|
27
|
-
darkgoldenrod: 1,
|
|
28
|
-
darkgray: 1,
|
|
29
|
-
darkgreen: 1,
|
|
30
|
-
darkgrey: 1,
|
|
31
|
-
darkkhaki: 1,
|
|
32
|
-
darkmagenta: 1,
|
|
33
|
-
darkolivegreen: 1,
|
|
34
|
-
darkorange: 1,
|
|
35
|
-
darkorchid: 1,
|
|
36
|
-
darkred: 1,
|
|
37
|
-
darksalmon: 1,
|
|
38
|
-
darkseagreen: 1,
|
|
39
|
-
darkslateblue: 1,
|
|
40
|
-
darkslategray: 1,
|
|
41
|
-
darkslategrey: 1,
|
|
42
|
-
darkturquoise: 1,
|
|
43
|
-
darkviolet: 1,
|
|
44
|
-
deeppink: 1,
|
|
45
|
-
deepskyblue: 1,
|
|
46
|
-
dimgray: 1,
|
|
47
|
-
dimgrey: 1,
|
|
48
|
-
dodgerblue: 1,
|
|
49
|
-
firebrick: 1,
|
|
50
|
-
floralwhite: 1,
|
|
51
|
-
forestgreen: 1,
|
|
52
|
-
fuchsia: 1,
|
|
53
|
-
gainsboro: 1,
|
|
54
|
-
ghostwhite: 1,
|
|
55
|
-
gold: 1,
|
|
56
|
-
goldenrod: 1,
|
|
57
|
-
gray: 1,
|
|
58
|
-
green: 1,
|
|
59
|
-
greenyellow: 1,
|
|
60
|
-
grey: 1,
|
|
61
|
-
honeydew: 1,
|
|
62
|
-
hotpink: 1,
|
|
63
|
-
indianred: 1,
|
|
64
|
-
indigo: 1,
|
|
65
|
-
ivory: 1,
|
|
66
|
-
khaki: 1,
|
|
67
|
-
lavender: 1,
|
|
68
|
-
lavenderblush: 1,
|
|
69
|
-
lawngreen: 1,
|
|
70
|
-
lemonchiffon: 1,
|
|
71
|
-
lightblue: 1,
|
|
72
|
-
lightcoral: 1,
|
|
73
|
-
lightcyan: 1,
|
|
74
|
-
lightgoldenrodyellow: 1,
|
|
75
|
-
lightgray: 1,
|
|
76
|
-
lightgreen: 1,
|
|
77
|
-
lightgrey: 1,
|
|
78
|
-
lightpink: 1,
|
|
79
|
-
lightsalmon: 1,
|
|
80
|
-
lightseagreen: 1,
|
|
81
|
-
lightskyblue: 1,
|
|
82
|
-
lightslategray: 1,
|
|
83
|
-
lightslategrey: 1,
|
|
84
|
-
lightsteelblue: 1,
|
|
85
|
-
lightyellow: 1,
|
|
86
|
-
lime: 1,
|
|
87
|
-
limegreen: 1,
|
|
88
|
-
linen: 1,
|
|
89
|
-
magenta: 1,
|
|
90
|
-
maroon: 1,
|
|
91
|
-
mediumaquamarine: 1,
|
|
92
|
-
mediumblue: 1,
|
|
93
|
-
mediumorchid: 1,
|
|
94
|
-
mediumpurple: 1,
|
|
95
|
-
mediumseagreen: 1,
|
|
96
|
-
mediumslateblue: 1,
|
|
97
|
-
mediumspringgreen: 1,
|
|
98
|
-
mediumturquoise: 1,
|
|
99
|
-
mediumvioletred: 1,
|
|
100
|
-
midnightblue: 1,
|
|
101
|
-
mintcream: 1,
|
|
102
|
-
mistyrose: 1,
|
|
103
|
-
moccasin: 1,
|
|
104
|
-
navajowhite: 1,
|
|
105
|
-
navy: 1,
|
|
106
|
-
oldlace: 1,
|
|
107
|
-
olive: 1,
|
|
108
|
-
olivedrab: 1,
|
|
109
|
-
orange: 1,
|
|
110
|
-
orangered: 1,
|
|
111
|
-
orchid: 1,
|
|
112
|
-
palegoldenrod: 1,
|
|
113
|
-
palegreen: 1,
|
|
114
|
-
paleturquoise: 1,
|
|
115
|
-
palevioletred: 1,
|
|
116
|
-
papayawhip: 1,
|
|
117
|
-
peachpuff: 1,
|
|
118
|
-
peru: 1,
|
|
119
|
-
pink: 1,
|
|
120
|
-
plum: 1,
|
|
121
|
-
powderblue: 1,
|
|
122
|
-
purple: 1,
|
|
123
|
-
rebeccapurple: 1,
|
|
124
|
-
red: 1,
|
|
125
|
-
rosybrown: 1,
|
|
126
|
-
royalblue: 1,
|
|
127
|
-
saddlebrown: 1,
|
|
128
|
-
salmon: 1,
|
|
129
|
-
sandybrown: 1,
|
|
130
|
-
seagreen: 1,
|
|
131
|
-
seashell: 1,
|
|
132
|
-
sienna: 1,
|
|
133
|
-
silver: 1,
|
|
134
|
-
skyblue: 1,
|
|
135
|
-
slateblue: 1,
|
|
136
|
-
slategray: 1,
|
|
137
|
-
slategrey: 1,
|
|
138
|
-
snow: 1,
|
|
139
|
-
springgreen: 1,
|
|
140
|
-
steelblue: 1,
|
|
141
|
-
tan: 1,
|
|
142
|
-
teal: 1,
|
|
143
|
-
thistle: 1,
|
|
144
|
-
tomato: 1,
|
|
145
|
-
turquoise: 1,
|
|
146
|
-
violet: 1,
|
|
147
|
-
wheat: 1,
|
|
148
|
-
white: 1,
|
|
149
|
-
whitesmoke: 1,
|
|
150
|
-
yellow: 1,
|
|
151
|
-
yellowgreen: 1,
|
|
152
|
-
|
|
153
|
-
// CSS System Colors
|
|
154
|
-
// Spec: https://drafts.csswg.org/css-color/#css-system-colors
|
|
155
|
-
canvas: 1,
|
|
156
|
-
canvastext: 1,
|
|
157
|
-
linktext: 1,
|
|
158
|
-
visitedtext: 1,
|
|
159
|
-
activetext: 1,
|
|
160
|
-
buttonface: 1,
|
|
161
|
-
buttontext: 1,
|
|
162
|
-
buttonborder: 1,
|
|
163
|
-
field: 1,
|
|
164
|
-
fieldtext: 1,
|
|
165
|
-
highlight: 1,
|
|
166
|
-
highlighttext: 1,
|
|
167
|
-
selecteditem: 1,
|
|
168
|
-
selecteditemtext: 1,
|
|
169
|
-
mark: 1,
|
|
170
|
-
marktext: 1,
|
|
171
|
-
graytext: 1,
|
|
172
|
-
|
|
173
|
-
// TODO: Deprecated CSS System colors
|
|
174
|
-
// Spec: https://drafts.csswg.org/css-color/#deprecated-system-colors
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export const colorFunctions = {
|
|
178
|
-
rgb: 1,
|
|
179
|
-
rgba: 1,
|
|
180
|
-
hsl: 1,
|
|
181
|
-
hsla: 1,
|
|
182
|
-
hwb: 1,
|
|
183
|
-
lab: 1,
|
|
184
|
-
lch: 1,
|
|
185
|
-
oklab: 1,
|
|
186
|
-
oklch: 1,
|
|
187
|
-
color: 1,
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export const analyzeColors = ({ colors }) => {
|
|
191
|
-
return colors.count()
|
|
192
|
-
}
|