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
13 changes: 11 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ on:
branches: [main]

jobs:
lint:
name: Lint JS
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Lint JS
run: npx --yes oxlint@latest -D perf

test:
name: Unit tests
runs-on: ubuntu-latest
Expand All @@ -23,9 +32,9 @@ jobs:
- 18

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
Expand Down
202 changes: 202 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@
"types": "./dist/index.d.ts",
"scripts": {
"test": "uvu",
"lint": "oxlint",
"build": "microbundle"
},
"dependencies": {
"@projectwallace/css-analyzer": "^5.14.0"
},
"devDependencies": {
"microbundle": "^0.15.1",
"oxlint": "^0.2.13",
"uvu": "^0.5.6"
}
}
}
12 changes: 6 additions & 6 deletions src/complexity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ const Complexity = suite('Complexity')

Complexity('should deduct points for a lot of Selectors more complex than most common Complexity', () => {
const fixture = `
${new Array(1000)
${Array.from({ length: 1000 })
.fill('')
.map(_ => `selector { }`)
.join('')
}

${new Array(500)
${Array.from({ length: 500 })
.fill('')
.map(_ => `:where(selector) { }`)
.join('')
Expand All @@ -25,21 +25,21 @@ Complexity('should deduct points for a lot of Selectors more complex than most c
id: 'MoreThanMostCommonSelectorComplexity',
score: 5,
value: 1 / 3,
actuals: (new Array(1000).fill(1)).concat(new Array(500).fill(2)),
actuals: (Array.from({ length: 1000 }).fill(1)).concat(Array.from({ length: 500 }).fill(2)),
}
])
assert.is(actual.complexity.score, 95)
})

Complexity('should deduct points for a lot of Selectors more complex than most common Specificity', () => {
const fixture = `
${new Array(500)
${Array.from({ length: 500 })
.fill('')
.map(_ => `selector1 { }`)
.join('')
}

${new Array(200)
${Array.from({ length: 200 })
.fill('')
.map(_ => `.selector { }`)
.join('')
Expand All @@ -52,7 +52,7 @@ Complexity('should deduct points for a lot of Selectors more complex than most c
id: 'MoreThanMostCommonSelectorSpecificity',
score: 2,
value: 200 / 700,
actuals: (new Array(500).fill([0, 0, 1])).concat(new Array(200).fill([0, 1, 0])),
actuals: (Array.from({ length: 500 }).fill([0, 0, 1])).concat(Array.from({ length: 200 }).fill([0, 1, 0])),
}
])
assert.is(actual.complexity.score, 98)
Expand Down
Loading