Skip to content

Commit

Permalink
snake_case + more metrics!
Browse files Browse the repository at this point in the history
  • Loading branch information
Bart Veneman committed Sep 15, 2023
1 parent f5b4e30 commit 9b68799
Show file tree
Hide file tree
Showing 12 changed files with 382 additions and 156 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"performance"
],
"engines": {
"node": ">=8"
"node": ">=18"
},
"scripts": {
"pretest": "npm run build",
Expand All @@ -48,4 +48,4 @@
"esbuild": "^0.16.17",
"uvu": "^0.5.6"
}
}
}
34 changes: 28 additions & 6 deletions src/__fixtures__/bol-dot-com.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,54 @@
───────────────────────────────────────────────────────────
Lines of Code │ Filesize │ Rules │ Selectors │ Declarations
17,818 │ 468.9KB │ 4,801 │ 6,664 │ 10,083
17,818 │ 468.9KB │ 4,801 │ 6,664 │ 10,083
───────────────────────────────────────────────────────────

Comments 0B (0 items)
Embedded Content 55.5KB (75 items)

Rulesets Most common Average Maximum
Selectors / rule 1 1.399 210
Declarations / rule 1 2.093 25
Selectors / rule 1 1.40 210
Declarations / rule 1 2.09 25
Empty rules 0

Selectors Most common Average Maximum
Complexity 1 2.369 13
Complexity 1 2.37 13
Specificity 0/1/0 0/1.4/0.4 0/7/1

Total Unique Ratio
All Selectors 6,664 4,298 64.5%
ID Selectors 0 0 0.0%
Accessibility 1 1 100.0%
Vendor prefixed 92 81 88.0%

AtRules Total Unique Unique %
@media 986 23 2.3%
@supports 5 3 60.0%
@font-face 6 6 100.0%
@import 0 0 0.0%
@keyframes 19 19 100.0%
@container 0 0 0.0%
@property 0 0 0.0%

Declarations Total Unique Unique %
Declarations 10,083 1,797 17.8%
All Declarations 10,083 1,797 17.8%
!important 1,589

Properties Total Unique Unique %
All Properties 10,083 156 1.5%
Custom Properties 0 0 0.0%
Vendor Prefixed 104 20 19.2%
Browserhacks 0 0 0.0%

Values Total Unique Unique %
Colors 1,151 89 7.7%
Gradients 6 5 83.3%
Font-sizes 276 60 21.7%
Font-families 46 8 17.4%
Line-heights 90 22 24.4%
Text-shadows 1 1 100.0%
Box-shadows 38 16 42.1%
Z-indexes 101 22 21.8%
Z-indexes 101 22 21.8%
Vendor Prefixed 7 5 71.4%
Browserhacks 0 0 0.0%
Units 3,474 9 0.3%
34 changes: 28 additions & 6 deletions src/__fixtures__/cnn.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,54 @@
───────────────────────────────────────────────────────────
Lines of Code │ Filesize │ Rules │ Selectors │ Declarations
23,399 │ 795.8KB │ 4,893 │ 8,889 │ 13,265
23,399 │ 795.8KB │ 4,893 │ 8,889 │ 13,265
───────────────────────────────────────────────────────────

Comments 2.7KB (93 items)
Embedded Content 0B (0 items)

Rulesets Most common Average Maximum
Selectors / rule 1 1.837 48
Declarations / rule 1 2.674 29
Selectors / rule 1 1.84 48
Declarations / rule 1 2.67 29
Empty rules 0

Selectors Most common Average Maximum
Complexity 5 5.674 18
Complexity 5 5.67 18
Specificity 0/3/0 0.0/3.3/0.3 2/2/1

Total Unique Ratio
All Selectors 8,889 6,593 74.2%
ID Selectors 298 197 66.1%
Accessibility 0 0 0.0%
Vendor prefixed 59 49 83.1%

AtRules Total Unique Unique %
@media 1,081 188 17.4%
@supports 0 0 0.0%
@font-face 45 45 100.0%
@import 0 0 0.0%
@keyframes 20 20 100.0%
@container 0 0 0.0%
@property 0 0 0.0%

Declarations Total Unique Unique %
Declarations 13,265 2,886 21.8%
All Declarations 13,265 2,886 21.8%
!important 132

Properties Total Unique Unique %
All Properties 13,265 217 1.6%
Custom Properties 0 0 0.0%
Vendor Prefixed 1,263 80 6.3%
Browserhacks 8 8 100.0%

Values Total Unique Unique %
Colors 1,370 126 9.2%
Gradients 66 57 86.4%
Font-sizes 1,293 319 24.7%
Font-families 398 19 4.8%
Line-heights 364 86 23.6%
Text-shadows 9 6 66.7%
Box-shadows 15 9 60.0%
Z-indexes 173 19 11.0%
Z-indexes 173 19 11.0%
Vendor Prefixed 274 75 27.4%
Browserhacks 0 0 0.0%
Units 4,402 10 0.2%
34 changes: 28 additions & 6 deletions src/__fixtures__/css-tricks.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,54 @@
───────────────────────────────────────────────────────────
Lines of Code │ Filesize │ Rules │ Selectors │ Declarations
4,218 │ 100.7KB │ 956 │ 1,498 │ 2,633
4,218 │ 100.7KB │ 956 │ 1,498 │ 2,633
───────────────────────────────────────────────────────────

Comments 212B (2 items)
Embedded Content 0B (0 items)

Rulesets Most common Average Maximum
Selectors / rule 1 1.577 32
Declarations / rule 1 2.731 36
Selectors / rule 1 1.58 32
Declarations / rule 1 2.73 36
Empty rules 0

Selectors Most common Average Maximum
Complexity 1 3.304 17
Complexity 1 3.30 17
Specificity 0/1/0 0.0/1.4/0.8 1/2/3

Total Unique Ratio
All Selectors 1,498 1,275 85.1%
ID Selectors 46 41 89.1%
Accessibility 2 2 100.0%
Vendor prefixed 31 31 100.0%

AtRules Total Unique Unique %
@media 63 15 23.8%
@supports 0 0 0.0%
@font-face 5 5 100.0%
@import 0 0 0.0%
@keyframes 7 7 100.0%
@container 0 0 0.0%
@property 0 0 0.0%

Declarations Total Unique Unique %
Declarations 2,633 1,132 43.0%
All Declarations 2,633 1,132 43.0%
!important 167

Properties Total Unique Unique %
All Properties 2,633 221 8.4%
Custom Properties 54 48 88.9%
Vendor Prefixed 88 40 45.5%
Browserhacks 2 2 100.0%

Values Total Unique Unique %
Colors 472 147 31.1%
Gradients 37 29 78.4%
Font-sizes 108 46 42.6%
Font-families 37 9 24.3%
Line-heights 34 18 52.9%
Text-shadows 2 2 100.0%
Box-shadows 19 13 68.4%
Z-indexes 32 13 40.6%
Z-indexes 32 13 40.6%
Vendor Prefixed 18 10 55.6%
Browserhacks 0 0 0.0%
Units 1,080 9 0.8%
30 changes: 26 additions & 4 deletions src/__fixtures__/small.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,54 @@
───────────────────────────────────────────────────────────
Lines of Code │ Filesize │ Rules │ Selectors │ Declarations
7 │ 173B │ 2 │ 2 │ 3
7 │ 173B │ 2 │ 2 │ 3
───────────────────────────────────────────────────────────

Comments 0B (0 items)
Embedded Content 0B (0 items)

Rulesets Most common Average Maximum
Selectors / rule 1 1 1
Declarations / rule 1.500 1.500 2
Declarations / rule 1.50 1.50 2
Empty rules 0

Selectors Most common Average Maximum
Complexity 1.500 1.500 2
Complexity 1.50 1.50 2
Specificity 0/0.5/1 0/0.5/1 0/1/0

Total Unique Ratio
All Selectors 2 2 100.0%
ID Selectors 0 0 0.0%
Accessibility 0 0 0.0%
Vendor prefixed 0 0 0.0%

AtRules Total Unique Unique %
@media 1 1 100.0%
@supports 1 1 100.0%
@font-face 0 0 0.0%
@import 0 0 0.0%
@keyframes 0 0 0.0%
@container 0 0 0.0%
@property 0 0 0.0%

Declarations Total Unique Unique %
Declarations 3 3 100.0%
All Declarations 3 3 100.0%
!important 1

Properties Total Unique Unique %
All Properties 3 3 100.0%
Custom Properties 0 0 0.0%
Vendor Prefixed 0 0 0.0%
Browserhacks 1 1 100.0%

Values Total Unique Unique %
Colors 1 1 100.0%
Gradients 0 0 0.0%
Font-sizes 0 0 0.0%
Font-families 0 0 0.0%
Line-heights 0 0 0.0%
Text-shadows 0 0 0.0%
Box-shadows 0 0 0.0%
Z-indexes 0 0 0.0%
Vendor Prefixed 0 0 0.0%
Browserhacks 0 0 0.0%
Units 0 0 0.0%
34 changes: 28 additions & 6 deletions src/__fixtures__/smashing-magazine.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,54 @@
───────────────────────────────────────────────────────────
Lines of Code │ Filesize │ Rules │ Selectors │ Declarations
18,239 │ 474.8KB │ 4,427 │ 5,748 │ 11,653
18,239 │ 474.8KB │ 4,427 │ 5,748 │ 11,653
───────────────────────────────────────────────────────────

Comments 418B (4 items)
Embedded Content 42.4KB (47 items)

Rulesets Most common Average Maximum
Selectors / rule 1 1.335 30
Declarations / rule 1 2.627 24
Selectors / rule 1 1.33 30
Declarations / rule 1 2.63 24
Empty rules 0

Selectors Most common Average Maximum
Complexity 1 2.985 13
Complexity 1 2.99 13
Specificity 0/1/0 0.0/1.6/0.5 1/4/0

Total Unique Ratio
All Selectors 5,748 3,955 68.8%
ID Selectors 15 13 86.7%
Accessibility 29 29 100.0%
Vendor prefixed 150 103 68.7%

AtRules Total Unique Unique %
@media 611 171 28.0%
@supports 11 3 27.3%
@font-face 7 7 100.0%
@import 0 0 0.0%
@keyframes 46 46 100.0%
@container 0 0 0.0%
@property 0 0 0.0%

Declarations Total Unique Unique %
Declarations 11,653 2,929 25.1%
All Declarations 11,653 2,929 25.1%
!important 284

Properties Total Unique Unique %
All Properties 11,653 228 2.0%
Custom Properties 78 20 25.6%
Vendor Prefixed 228 36 15.8%
Browserhacks 0 0 0.0%

Values Total Unique Unique %
Colors 1,793 242 13.5%
Gradients 82 48 58.5%
Font-sizes 462 101 21.9%
Font-families 308 18 5.8%
Line-heights 127 38 29.9%
Text-shadows 69 10 14.5%
Box-shadows 76 44 57.9%
Z-indexes 86 19 22.1%
Z-indexes 86 19 22.1%
Vendor Prefixed 162 20 12.3%
Browserhacks 0 0 0.0%
Units 5,037 12 0.2%
12 changes: 6 additions & 6 deletions src/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { join } from 'path'
import pc from 'picocolors'
import { Program } from './program'

async function getStdin() {
async function get_stdin() {
const { stdin } = process
if (stdin.isTTY) {
return ''
Expand All @@ -20,19 +20,19 @@ async function getStdin() {
return result
}

async function readFile(pathParam) {
const pathName = join(process.cwd(), pathParam)
async function read_file(path_param) {
const pathName = join(process.cwd(), path_param)
const content = await fsReadFile(pathName, 'utf-8')
return content
}

async function main() {
const stdin = await getStdin()
const stdin = await get_stdin()
return Program({
args: process.argv.slice(2),
stdin,
readFile,
terminalColors: pc,
read_file,
terminal_colors: pc,
})
}

Expand Down
Loading

0 comments on commit 9b68799

Please sign in to comment.