Skip to content

Commit

Permalink
fix negative tw class names being reported as vendor prefixed selector (
Browse files Browse the repository at this point in the history
#371)

closes #348
  • Loading branch information
bartveneman authored Dec 29, 2023
1 parent fc42e8e commit 9c23fd8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/__fixtures__/gazelle-20231008.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"sourceLinesOfCode": 29224,
"linesOfCode": 45124,
"size": 846671,
"complexity": 97705,
"complexity": 97704,
"comments": {
"total": 4,
"size": 1678
Expand Down Expand Up @@ -76220,16 +76220,16 @@
"complexity": {
"min": 1,
"max": 19,
"mean": 3.9728714915986107,
"mean": 3.972777621327326,
"mode": 1,
"median": 3,
"range": 18,
"sum": 42323,
"sum": 42322,
"total": 10653,
"totalUnique": 19,
"unique": {
"1": 2665,
"2": 1132,
"1": 2666,
"2": 1131,
"3": 2178,
"4": 944,
"5": 1242,
Expand Down Expand Up @@ -86734,7 +86734,7 @@
2,
1,
1,
2,
1,
1,
1,
1,
Expand Down
10 changes: 7 additions & 3 deletions src/selectors/complexity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,20 @@ Complexity('calculates complexity', () => {

Complexity('calculates complexity with vendor prefixes', () => {
const actual = analyze(`
no-prefix,
fake-webkit,
input[type=text]::-webkit-input-placeholder,
::-webkit-scrollbar,
.site-header .main-nav:hover>ul>li:nth-child(1) svg,
:-moz-any(header, footer) {}
/* not vendor prefixed */
no-prefix,
fake-webkit,
.-mt-px,
.-space-x-1 {}
`).selectors.complexity

assert.equal(actual.unique, {
'1': 2,
'1': 4,
'5': 1,
'2': 1,
'12': 1,
Expand Down
4 changes: 1 addition & 3 deletions src/selectors/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ export function getComplexity(selector) {

complexity++

if (node.type === IdSelector
|| node.type === ClassSelector
|| node.type === PseudoElementSelector
if (node.type === PseudoElementSelector
|| node.type === TypeSelector
|| node.type === PseudoClassSelector
) {
Expand Down

0 comments on commit 9c23fd8

Please sign in to comment.