Skip to content

Commit 9c23fd8

Browse files
authored
fix negative tw class names being reported as vendor prefixed selector (#371)
closes #348
1 parent fc42e8e commit 9c23fd8

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

src/__fixtures__/gazelle-20231008.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"sourceLinesOfCode": 29224,
44
"linesOfCode": 45124,
55
"size": 846671,
6-
"complexity": 97705,
6+
"complexity": 97704,
77
"comments": {
88
"total": 4,
99
"size": 1678
@@ -76220,16 +76220,16 @@
7622076220
"complexity": {
7622176221
"min": 1,
7622276222
"max": 19,
76223-
"mean": 3.9728714915986107,
76223+
"mean": 3.972777621327326,
7622476224
"mode": 1,
7622576225
"median": 3,
7622676226
"range": 18,
76227-
"sum": 42323,
76227+
"sum": 42322,
7622876228
"total": 10653,
7622976229
"totalUnique": 19,
7623076230
"unique": {
76231-
"1": 2665,
76232-
"2": 1132,
76231+
"1": 2666,
76232+
"2": 1131,
7623376233
"3": 2178,
7623476234
"4": 944,
7623576235
"5": 1242,
@@ -86734,7 +86734,7 @@
8673486734
2,
8673586735
1,
8673686736
1,
86737-
2,
86737+
1,
8673886738
1,
8673986739
1,
8674086740
1,

src/selectors/complexity.test.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,20 @@ Complexity('calculates complexity', () => {
4949

5050
Complexity('calculates complexity with vendor prefixes', () => {
5151
const actual = analyze(`
52-
no-prefix,
53-
fake-webkit,
5452
input[type=text]::-webkit-input-placeholder,
5553
::-webkit-scrollbar,
5654
.site-header .main-nav:hover>ul>li:nth-child(1) svg,
5755
:-moz-any(header, footer) {}
56+
57+
/* not vendor prefixed */
58+
no-prefix,
59+
fake-webkit,
60+
.-mt-px,
61+
.-space-x-1 {}
5862
`).selectors.complexity
5963

6064
assert.equal(actual.unique, {
61-
'1': 2,
65+
'1': 4,
6266
'5': 1,
6367
'2': 1,
6468
'12': 1,

src/selectors/utils.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ export function getComplexity(selector) {
116116

117117
complexity++
118118

119-
if (node.type === IdSelector
120-
|| node.type === ClassSelector
121-
|| node.type === PseudoElementSelector
119+
if (node.type === PseudoElementSelector
122120
|| node.type === TypeSelector
123121
|| node.type === PseudoClassSelector
124122
) {

0 commit comments

Comments
 (0)