Skip to content

Commit cea0f17

Browse files
authored
use === consistently instead of sometimes == (#313)
1 parent 5a5f817 commit cea0f17

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ const analyze = (css) => {
150150

151151
node.block.children.forEach(descriptor => {
152152
// Ignore 'Raw' nodes in case of CSS syntax errors
153-
if (descriptor.type == 'Declaration') {
153+
if (descriptor.type === 'Declaration') {
154154
descriptors[descriptor.property] = stringifyNode(descriptor.value)
155155
}
156156
})

src/selectors/utils.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,18 @@ export function isAccessibility(selector) {
5656
let isA11y = false
5757

5858
walk(selector, function (node) {
59-
if (node.type == 'AttributeSelector') {
59+
if (node.type === 'AttributeSelector') {
6060
if (strEquals('role', node.name.name) || startsWith('aria-', node.name.name)) {
6161
isA11y = true
6262
return this.break
6363
}
6464
}
6565
// Test for [aria-] or [role] inside :is()/:where() and friends
66-
else if (node.type == 'PseudoClassSelector') {
66+
else if (node.type === 'PseudoClassSelector') {
6767
if (isPseudoFunction(node.name)) {
6868
const list = analyzeList(node, isAccessibility)
6969

70-
if (list.some(b => b == true)) {
70+
if (list.some(b => b === true)) {
7171
isA11y = true
7272
return this.skip
7373
}
@@ -90,23 +90,23 @@ export function getComplexity(selector) {
9090
let isPrefixed = false
9191

9292
walk(selector, function (node) {
93-
if (node.type == 'Selector' || node.type == 'Nth') return
93+
if (node.type === 'Selector' || node.type === 'Nth') return
9494

9595
complexity++
9696

97-
if (node.type == 'IdSelector'
98-
|| node.type == 'ClassSelector'
99-
|| node.type == 'PseudoElementSelector'
100-
|| node.type == 'TypeSelector'
101-
|| node.type == 'PseudoClassSelector'
97+
if (node.type === 'IdSelector'
98+
|| node.type === 'ClassSelector'
99+
|| node.type === 'PseudoElementSelector'
100+
|| node.type === 'TypeSelector'
101+
|| node.type === 'PseudoClassSelector'
102102
) {
103103
if (hasVendorPrefix(node.name)) {
104104
isPrefixed = true
105105
complexity++
106106
}
107107
}
108108

109-
if (node.type == 'AttributeSelector') {
109+
if (node.type === 'AttributeSelector') {
110110
if (Boolean(node.value)) {
111111
complexity++
112112
}
@@ -117,7 +117,7 @@ export function getComplexity(selector) {
117117
return this.skip
118118
}
119119

120-
if (node.type == 'PseudoClassSelector') {
120+
if (node.type === 'PseudoClassSelector') {
121121
if (isPseudoFunction(node.name)) {
122122
const list = analyzeList(node, getComplexity)
123123

@@ -126,7 +126,7 @@ export function getComplexity(selector) {
126126

127127
list.forEach(([c, p]) => {
128128
complexity += c
129-
if (p == true) isPrefixed = true
129+
if (p === true) isPrefixed = true
130130
})
131131
return this.skip
132132
}

src/stylesheet/stylesheet.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Stylesheet('reports embed size correctly when there are duplicates', () => {
167167
total: 2,
168168
totalUnique: 1,
169169
unique: {
170-
// .length == 459
170+
// .length === 459
171171
'data:image/svg+xml,%3Csvg%20id%3D%22Layer_1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20195.6%20107.8%22%3E%3Cpath%20fill%3D%22%23B5B5B5%22%20class%3D%22st0%22%20d%3D%22M97.8%20107.8c-2.6%200-5.1-1-7.1-2.9L2.9%2017.1C-1%2013.2-1%206.8%202.9%202.9%206.8-1%2013.2-1%2017.1%202.9l80.7%2080.7%2080.7-80.7c3.9-3.9%2010.2-3.9%2014.1%200%203.9%203.9%203.9%2010.2%200%2014.1l-87.8%2087.8c-1.9%202-4.4%203-7%203z%22%2F%3E%3C%2Fsvg%3E': 2,
172172
},
173173
uniquenessRatio: 1 / 2,

src/values/destructure-font-shorthand.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ export function destructure(value, stringifyNode) {
4646
// any node that comes before the '/' is the font-size
4747
if (
4848
item.next &&
49-
item.next.data.type == 'Operator' &&
50-
item.next.data.value.charCodeAt(0) == SLASH
49+
item.next.data.type === 'Operator' &&
50+
item.next.data.value.charCodeAt(0) === SLASH
5151
) {
5252
font_size = stringifyNode(node)
5353
return
@@ -56,8 +56,8 @@ export function destructure(value, stringifyNode) {
5656
// any node that comes after '/' is the line-height
5757
if (
5858
item.prev &&
59-
item.prev.data.type == 'Operator' &&
60-
item.prev.data.value.charCodeAt(0) == SLASH
59+
item.prev.data.type === 'Operator' &&
60+
item.prev.data.value.charCodeAt(0) === SLASH
6161
) {
6262
line_height = stringifyNode(node)
6363
return
@@ -66,8 +66,8 @@ export function destructure(value, stringifyNode) {
6666
// any node that's followed by ',' is a font-family
6767
if (
6868
item.next &&
69-
item.next.data.type == 'Operator' &&
70-
item.next.data.value.charCodeAt(0) == COMMA &&
69+
item.next.data.type === 'Operator' &&
70+
item.next.data.value.charCodeAt(0) === COMMA &&
7171
!font_family[0]
7272
) {
7373
font_family[0] = node
@@ -84,7 +84,7 @@ export function destructure(value, stringifyNode) {
8484
node.type === 'Dimension' &&
8585
item.prev &&
8686
item.prev.data.type === 'Identifier' &&
87-
item.prev.data.name == 'oblique'
87+
item.prev.data.name === 'oblique'
8888
) {
8989
// put in the correct amount of whitespace between `oblique` and `<angle>`
9090
font_style +=
@@ -95,12 +95,12 @@ export function destructure(value, stringifyNode) {
9595

9696
// any node that's a number and not previously caught by line-height or font-size is the font-weight
9797
// (oblique <angle> will not be caught here, because that's a Dimension, not a Number)
98-
if (node.type == 'Number') {
98+
if (node.type === 'Number') {
9999
return
100100
}
101101

102102
// last node always ends the font-family
103-
if (item.next == null) {
103+
if (item.next === null) {
104104
font_family[1] = node
105105

106106
// if, at the last node, we don;t have a size yet, it *must* be the previous node
@@ -113,7 +113,7 @@ export function destructure(value, stringifyNode) {
113113
}
114114

115115
// Any remaining identifiers can be font-size, font-style, font-stretch, font-variant or font-weight
116-
if (node.type == 'Identifier') {
116+
if (node.type === 'Identifier') {
117117
if (SIZE_KEYWORDS.has(node.name)) {
118118
font_size = node.name
119119
return

0 commit comments

Comments
 (0)