Skip to content

Commit c393ded

Browse files
authored
Switch from prettier to dprint (#52)
1 parent b001a0f commit c393ded

12 files changed

+261
-101
lines changed

.prettierignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.prettierrc.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

dprint.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"typescript": {
3+
"semiColons": "asi",
4+
"lineWidth": 120,
5+
"trailingCommas": "never"
6+
},
7+
"json": {
8+
"trailingCommas": "never"
9+
},
10+
"markdown": {
11+
"textWrap": "always"
12+
},
13+
"markup": {},
14+
"yaml": {},
15+
"excludes": ["dist/", "node_modules", "package-lock.json"],
16+
"plugins": [
17+
"https://plugins.dprint.dev/typescript-0.94.0.wasm",
18+
"https://plugins.dprint.dev/json-0.20.0.wasm",
19+
"https://plugins.dprint.dev/markdown-0.18.0.wasm",
20+
"https://plugins.dprint.dev/g-plane/markup_fmt-v0.19.0.wasm",
21+
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.0.wasm"
22+
]
23+
}

eslint.config.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ export default [
1313
globals: {
1414
console: "readonly",
1515
module: "readonly",
16-
process: "readonly",
16+
process: "readonly"
1717
},
1818
parser: tsParser,
1919
parserOptions: {
20-
project: "./tsconfig.json",
20+
project: "./tsconfig.json"
2121
},
22-
sourceType: "module",
22+
sourceType: "module"
2323
},
2424
plugins: {
25-
"@typescript-eslint": tslintPlugin,
25+
"@typescript-eslint": tslintPlugin
2626
},
2727
rules: {
2828
...tslintPlugin.configs.recommended.rules,
2929
"no-empty-function": "error",
30-
"prefer-const": "error",
31-
},
30+
"prefer-const": "error"
31+
}
3232
},
33-
perfectionist.configs["recommended-natural"],
33+
perfectionist.configs["recommended-natural"]
3434
]

package-lock.json

Lines changed: 149 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"clean": "rm -rf dist",
1919
"coverage": "node --test --import tsx --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=lcov.info -- test/*.test.ts",
2020
"doc": "text-runner",
21-
"fix": "prettier --write . && eslint --fix && sort-package-json",
22-
"lint": "eslint && prettier --list-different . && tsc --noEmit && sort-package-json --check",
21+
"fix": "dprint fmt && eslint --fix && sort-package-json",
22+
"lint": "eslint && dprint check && tsc --noEmit && sort-package-json --check",
2323
"prepublishOnly": "tsc",
2424
"setup": "npm install",
2525
"test": "npm run lint && npm run unit && npm run doc",
@@ -35,9 +35,9 @@
3535
"@types/diff": "5.0.0",
3636
"@types/node": "22.13.10",
3737
"@typescript-eslint/eslint-plugin": "8.26.1",
38+
"dprint": "0.49.0",
3839
"eslint": "9.22.0",
3940
"eslint-plugin-perfectionist": "4.10.1",
40-
"prettier": "2.3.1",
4141
"sort-package-json": "1.57.0",
4242
"strip-ansi": "6.0.0",
4343
"text-runner": "7.1.0",

src/index.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import * as diff from "diff"
55
* Checks the two given strings character-by-character for equality.
66
* If there are any differences, it throws an exception with a Bash-colored diff as the error message.
77
*/
8-
export function chars(actual: string, expected: string, message = "mismatching strings"): void {
8+
export function chars(
9+
actual: string,
10+
expected: string,
11+
message = "mismatching strings"
12+
) {
913
if (actual == null) {
1014
throw new Error("AssertNoDiff: actual value not provided")
1115
}
@@ -26,7 +30,7 @@ export function json(
2630
actual: Record<string, unknown> | string[],
2731
expected: Record<string, unknown> | string[],
2832
message = "mismatching objects"
29-
): void {
33+
) {
3034
if (!actual) {
3135
throw new Error("AssertNoDiff: actual value not provided")
3236
}
@@ -44,7 +48,11 @@ export function json(
4448
* Extra whitespace is ignored.
4549
* If there are any differences, it throws an exception with a Bash-colored diff as the error message.
4650
*/
47-
export function trimmedLines(actual: string, expected: string, message = "mismatching lines"): void {
51+
export function trimmedLines(
52+
actual: string,
53+
expected: string,
54+
message = "mismatching lines"
55+
) {
4856
if (actual == null) {
4957
throw new Error("AssertNoDiff: actual value not provided")
5058
}
@@ -61,7 +69,11 @@ export function trimmedLines(actual: string, expected: string, message = "mismat
6169
* Checks the two given strings word-by-word for equality treating whitespace as significant.
6270
* If there are any differences, it throws an exception with a Bash-colored diff as the error message.
6371
*/
64-
export function wordsWithSpace(actual: string, expected: string, message = "mismatching words"): void {
72+
export function wordsWithSpace(
73+
actual: string,
74+
expected: string,
75+
message = "mismatching words"
76+
) {
6577
if (actual == null) {
6678
throw new Error("AssertNoDiff: actual value not provided")
6779
}

test/chars.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1+
import chalk from "chalk"
12
import assert from "node:assert/strict"
23
import { suite, test } from "node:test"
3-
import chalk from "chalk"
44
import stripAnsi from "strip-ansi"
55
import * as assertNoDiff from "../src/index"
66

7-
suite("assertNoDiff.chars()", function () {
8-
test("matching data", function () {
7+
suite("assertNoDiff.chars()", function() {
8+
test("matching data", function() {
99
const data = "Jean-Luc Picard"
1010
assertNoDiff.chars(data, data)
1111
})
1212

13-
test("mismatching data", function () {
13+
test("mismatching data", function() {
1414
const obj1 = "Jean-Luc Picard"
1515
const obj2 = "Captain Picard"
1616
const expected = chalk`mismatching strings:
1717
1818
{red Je}{green C}{grey a}{green ptai}{grey n}{red -Luc}{grey Picard}`
1919
assert.throws(
20-
function () {
20+
function() {
2121
assertNoDiff.chars(obj2, obj1)
2222
},
2323
new Error(expected),
2424
"should throw color-coded diff"
2525
)
2626
})
2727

28-
test("no expected value", function () {
29-
assert.throws(function () {
28+
test("no expected value", function() {
29+
assert.throws(function() {
3030
// @ts-ignore: intentional call without second argument
3131
assertNoDiff.chars("foo")
3232
}, new Error("AssertNoDiff: expected value not provided"))
3333
})
3434

35-
test("no actual value", function () {
36-
assert.throws(function () {
35+
test("no actual value", function() {
36+
assert.throws(function() {
3737
// @ts-ignore: intentional call without arguments
3838
assertNoDiff.chars()
3939
}, new Error("AssertNoDiff: actual value not provided"))
4040
})
4141

42-
test("providing a custom message", function () {
42+
test("providing a custom message", function() {
4343
try {
4444
assertNoDiff.chars("one", "two", "custom message")
4545
} catch (e) {
@@ -50,7 +50,7 @@ suite("assertNoDiff.chars()", function () {
5050
throw new Error("assertNoDiff.chars didn't throw")
5151
})
5252

53-
test("diffing against empty strings", function () {
53+
test("diffing against empty strings", function() {
5454
assertNoDiff.chars("", "")
5555
})
5656
})

0 commit comments

Comments
 (0)