Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ jobs:
with:
node-version: 18
cache: "npm"
- run: npm install --ignore-scripts --no-audit
- run: npm test
- name: Install dependencies
run: npm install --ignore-scripts --no-audit
- name: Run unit tests
run: npm test
- name: Test types
run: npm run check
11 changes: 8 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-expect-error Typing of css-tree is incomplete
import parse from 'css-tree/parser'

const NEWLINE = '\n'
Expand Down Expand Up @@ -117,7 +118,9 @@ function print_simple_selector(node, css) {
}
case 'SelectorList': {
for (let grandchild of child.children) {
buffer += print_simple_selector(grandchild, css)
if (grandchild.type === 'Selector') {
buffer += print_simple_selector(grandchild, css)
}

if (grandchild !== child.children.last) {
buffer += ', '
Expand Down Expand Up @@ -155,6 +158,7 @@ function print_simple_selector(node, css) {

if (child.selector !== null) {
// `of .selector`
// @ts-expect-error Typing of child.selector is SelectorList, which doesn't seem to be correct
buffer += ' of ' + print_simple_selector(child.selector, css)
}
break
Expand Down Expand Up @@ -302,7 +306,7 @@ function print_declaration(node, indent_level, css) {
}

/**
* @param {import('css-tree').List} children
* @param {import('css-tree').List<import('css-tree').CssNode>} children
* @param {number} indent_level
* @param {string} css
*/
Expand Down Expand Up @@ -383,13 +387,14 @@ function print_unknown(node, indent_level, css) {
}

/**
* @param {import('css-tree').StyleSheet} node
* @param {import('css-tree').CssNode} node
* @param {number} indent_level
* @param {string} css
* @returns {string} A formatted Stylesheet
*/
function print(node, indent_level = 0, css) {
let buffer = ''
// @ts-expect-error Property 'children' does not exist on type 'AnPlusB', but we're never using that
let children = node.children

for (let child of children) {
Expand Down
Loading