Skip to content

Commit

Permalink
install and run prettier (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartveneman authored Jul 26, 2024
1 parent 85c0ac2 commit 7e16739
Show file tree
Hide file tree
Showing 11 changed files with 368 additions and 337 deletions.
333 changes: 165 additions & 168 deletions index.js

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions package-lock.json

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

14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
"build": "vite build",
"test": "c8 --reporter=lcov uvu",
"check": "tsc",
"lint": "oxlint -D perf"
"lint": "oxlint -D perf",
"prettier": "prettier --check index.js test/**/*.js"
},
"devDependencies": {
"@codecov/vite-plugin": "^0.0.1-beta.8",
"@codspeed/tinybench-plugin": "^3.1.0",
"@types/css-tree": "^2.3.4",
"c8": "^9.1.0",
"oxlint": "^0.2.8",
"prettier": "^3.3.3",
"tinybench": "^2.8.0",
"typescript": "^5.3.3",
"uvu": "^0.5.6",
Expand All @@ -46,5 +48,11 @@
"prettifier",
"pretty",
"prettier"
]
}
],
"prettier": {
"semi": false,
"useTabs": true,
"printWidth": 140,
"singleQuote": true
}
}
17 changes: 13 additions & 4 deletions test/atrules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ test('@media prelude formatting', () => {
[`@media (min-width:1000px){}`, `@media (min-width: 1000px) {}`],
[`@media (min-width : 1000px) {}`, `@media (min-width: 1000px) {}`],
[`@media all and (transform-3d) {}`, `@media all and (transform-3d) {}`],
[`@media only screen and (min-width: 1024px)and (max-width: 1439px), only screen and (min-width: 768px)and (max-width: 1023px) {}`, `@media only screen and (min-width: 1024px) and (max-width: 1439px), only screen and (min-width: 768px) and (max-width: 1023px) {}`],
[
`@media only screen and (min-width: 1024px)and (max-width: 1439px), only screen and (min-width: 768px)and (max-width: 1023px) {}`,
`@media only screen and (min-width: 1024px) and (max-width: 1439px), only screen and (min-width: 768px) and (max-width: 1023px) {}`,
],
[`@media (min-width: 1024px)or (max-width: 1439px) {}`, `@media (min-width: 1024px) or (max-width: 1439px) {}`],
[`@media all and (transform-3d), (-webkit-transform-3d) {}`, `@media all and (transform-3d), (-webkit-transform-3d) {}`],
[`@media screen or print {}`, `@media screen or print {}`],
Expand All @@ -71,8 +74,14 @@ test('@media prelude formatting', () => {
[`@layer tbody,thead;`, `@layer tbody, thead;`],
[`@supports (display:grid){}`, `@supports (display: grid) {}`],
[`@supports (-webkit-appearance: none) {}`, `@supports (-webkit-appearance: none) {}`],
[`@media all and (-moz-images-in-menus:0) and (min-resolution:.001dpcm) {}`, `@media all and (-moz-images-in-menus: 0) and (min-resolution: .001dpcm) {}`],
[`@media all and (-webkit-min-device-pixel-ratio: 10000),not all and (-webkit-min-device-pixel-ratio: 0) {}`, `@media all and (-webkit-min-device-pixel-ratio: 10000), not all and (-webkit-min-device-pixel-ratio: 0) {}`],
[
`@media all and (-moz-images-in-menus:0) and (min-resolution:.001dpcm) {}`,
`@media all and (-moz-images-in-menus: 0) and (min-resolution: .001dpcm) {}`,
],
[
`@media all and (-webkit-min-device-pixel-ratio: 10000),not all and (-webkit-min-device-pixel-ratio: 0) {}`,
`@media all and (-webkit-min-device-pixel-ratio: 10000), not all and (-webkit-min-device-pixel-ratio: 0) {}`,
],
['@supports selector([popover]:open) {}', '@supports selector([popover]:open) {}'],
]

Expand Down Expand Up @@ -246,4 +255,4 @@ test.skip('preserves comments', () => {
assert.is(actual, expected)
})

test.run();
test.run()
8 changes: 4 additions & 4 deletions test/comments.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { suite } from "uvu"
import * as assert from "uvu/assert"
import { format } from "../index.js"
import { suite } from 'uvu'
import * as assert from 'uvu/assert'
import { format } from '../index.js'

let test = suite("Comments")
let test = suite('Comments')

test.skip('regular comment before rule', () => {
let actual = format(`
Expand Down
30 changes: 15 additions & 15 deletions test/declarations.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { suite } from "uvu";
import * as assert from "uvu/assert";
import { format } from "../index.js";
import { suite } from 'uvu'
import * as assert from 'uvu/assert'
import { format } from '../index.js'

let test = suite("Declarations");
let test = suite('Declarations')

test("Declarations end with a semicolon (;)", () => {
test('Declarations end with a semicolon (;)', () => {
let actual = format(`
@font-face {
src: url('test');
Expand All @@ -28,7 +28,7 @@ test("Declarations end with a semicolon (;)", () => {
}
}
}
`);
`)
let expected = `@font-face {
src: url('test');
font-family: Test;
Expand All @@ -50,18 +50,18 @@ css {
property1: value5;
}
}
}`;
}`

assert.equal(actual, expected);
});
assert.equal(actual, expected)
})

test("lowercases properties", () => {
let actual = format(`a { COLOR: green }`);
test('lowercases properties', () => {
let actual = format(`a { COLOR: green }`)
let expected = `a {
color: green;
}`;
assert.is(actual, expected);
});
}`
assert.is(actual, expected)
})

test('does not lowercase custom properties', () => {
let actual = format(`a {
Expand All @@ -85,4 +85,4 @@ test.skip('preserves comments', () => {
assert.is(actual, expected)
})

test.run();
test.run()
16 changes: 8 additions & 8 deletions test/minify.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { suite } from "uvu"
import * as assert from "uvu/assert"
import { minify } from "../index.js"
import { suite } from 'uvu'
import * as assert from 'uvu/assert'
import { minify } from '../index.js'

let test = suite("Minify")
let test = suite('Minify')

test('empty rule', () => {
let actual = minify(`a {}`)
Expand All @@ -28,17 +28,17 @@ test('empty atrule', () => {
assert.equal(actual, expected)
})

test("formats multiline values on a single line", () => {
test('formats multiline values on a single line', () => {
let actual = minify(`
a {
background: linear-gradient(
red,
10% blue,
20% green,100% yellow);
}
`);
let expected = `a{background:linear-gradient(red,10% blue,20% green,100% yellow)}`;
assert.equal(actual, expected);
`)
let expected = `a{background:linear-gradient(red,10% blue,20% green,100% yellow)}`
assert.equal(actual, expected)
})

test('correctly minifies operators', () => {
Expand Down
Loading

0 comments on commit 7e16739

Please sign in to comment.