Skip to content

Commit 26f9b4f

Browse files
committed
fix remaining checks
1 parent eba1dc6 commit 26f9b4f

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"lint": "oxlint && oxfmt --check"
4242
},
4343
"dependencies": {
44-
"@projectwallace/css-parser": "~0.14.2"
44+
"@projectwallace/css-parser": "~0.14.1"
4545
},
4646
"devDependencies": {
4747
"@codecov/rollup-plugin": "^1.9.1",

src/lib/index.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
parse,
3-
NODE_TYPES as NODE,
43
is_function,
54
is_dimension,
65
is_parenthesis,
@@ -32,6 +31,9 @@ import {
3231
is_nth_selector,
3332
is_nth_of_selector,
3433
is_lang_selector,
34+
is_declaration,
35+
is_rule,
36+
is_atrule,
3537
} from '@projectwallace/css-parser'
3638

3739
const SPACE = ' '
@@ -171,7 +173,7 @@ export function format(
171173

172174
if (!is_operator(node)) {
173175
if (node.has_next) {
174-
if (node.next_sibling?.type !== NODE.OPERATOR) {
176+
if (!is_operator(node.next_sibling)) {
175177
parts.push(SPACE)
176178
}
177179
}
@@ -259,7 +261,7 @@ export function format(
259261
let name = node.name.toLowerCase()
260262

261263
// Legacy pseudo-elements or actual pseudo-elements use double colon
262-
if (name === 'before' || name === 'after' || node.type === NODE.PSEUDO_ELEMENT_SELECTOR) {
264+
if (name === 'before' || name === 'after' || is_pseudo_element_selector(node)) {
263265
parts.push(COLON)
264266
}
265267

@@ -387,18 +389,17 @@ export function format(
387389
}
388390
}
389391

390-
let is_last = child.next_sibling?.type !== NODE.DECLARATION
391-
392-
if (child.type === NODE.DECLARATION) {
392+
if (is_declaration(child)) {
393+
let is_last = !child.has_next || !is_declaration(child.next_sibling)
393394
let declaration = print_declaration(child)
394395
let semi = is_last ? LAST_SEMICOLON : SEMICOLON
395396
lines.push(indent(depth) + declaration + semi)
396-
} else if (child.type === NODE.STYLE_RULE) {
397+
} else if (is_rule(child)) {
397398
if (prev_end !== undefined && lines.length !== 0) {
398399
lines.push(EMPTY_STRING)
399400
}
400401
lines.push(print_rule(child))
401-
} else if (child.type === NODE.AT_RULE) {
402+
} else if (is_atrule(child)) {
402403
if (prev_end !== undefined && lines.length !== 0) {
403404
lines.push(EMPTY_STRING)
404405
}
@@ -517,9 +518,9 @@ export function format(
517518
}
518519
}
519520

520-
if (child.type === NODE.STYLE_RULE) {
521+
if (is_rule(child)) {
521522
lines.push(print_rule(child))
522-
} else if (child.type === NODE.AT_RULE) {
523+
} else if (is_atrule(child)) {
523524
lines.push(print_atrule(child))
524525
}
525526

0 commit comments

Comments
 (0)