Skip to content

Commit ea18fcf

Browse files
committed
Add type-aware oxlint checks
1 parent f7fac78 commit ea18fcf

File tree

6 files changed

+139
-35
lines changed

6 files changed

+139
-35
lines changed

package-lock.json

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

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
"types": "dist/index.d.mts",
2222
"scripts": {
2323
"build": "tsdown",
24-
"ci": "tsc --noEmit && oxlint --deny-warnings -f github",
24+
"ci": "oxlint --type-aware --type-check --deny-warnings -f github",
2525
"docs": "typedoc",
2626
"format": "oxfmt",
27-
"lint": "oxlint",
28-
"lint:fix": "oxlint --fix",
27+
"lint": "oxlint --type-aware",
28+
"lint:fix": "oxlint --type-aware --fix",
2929
"test": "tsc --noEmit && node --test",
3030
"test:coverage": "node --test --experimental-test-coverage",
3131
"prepublishOnly": "npm run build"
@@ -35,6 +35,7 @@
3535
"expect": "^30.2.0",
3636
"oxfmt": "^0.34.0",
3737
"oxlint": "^1.49.0",
38+
"oxlint-tsgolint": "^0.14.2",
3839
"tsdown": "^0.20.3",
3940
"typedoc": "^0.28.16"
4041
},

src/base62.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ import { expect } from "expect";
33

44
import { decode, decodeUnsafe, encode } from "./base62.ts";
55

6-
describe("base62 roundtrip", () => {
6+
void describe("base62 roundtrip", () => {
77
function encodeText(value: string): Uint8Array {
88
return new TextEncoder().encode(value);
99
}
1010

11-
describe("roundtrip", () => {
12-
test("empty string", () => {
11+
void describe("roundtrip", () => {
12+
void test("empty string", () => {
1313
const s = encode(new Uint8Array());
1414
expect(s).toEqual("");
1515
expect(decode(s)).toEqual(new Uint8Array());
1616
});
1717

18-
test("bytes 0..255", () => {
18+
void test("bytes 0..255", () => {
1919
const data = new Uint8Array(256);
2020
for (let i = 0; i < 256; ++i) {
2121
data[i] = i;
@@ -29,15 +29,15 @@ describe("base62 roundtrip", () => {
2929
expect(decode(s)).toEqual(data);
3030
});
3131

32-
test("encode simple text", () => {
32+
void test("encode simple text", () => {
3333
const data = encodeText("abc");
3434
const s = encode(data);
3535

3636
expect(s).toEqual("QmIN");
3737
expect(decode(s)).toEqual(data);
3838
});
3939

40-
test("encode zeros prefix", () => {
40+
void test("encode zeros prefix", () => {
4141
const data = new Uint8Array([0, 0, 1, 2, 3]);
4242
const s = encode(data);
4343

@@ -46,16 +46,16 @@ describe("base62 roundtrip", () => {
4646
});
4747
});
4848

49-
describe("parameter validation and exceptions", () => {
50-
test("encode rejects non-ArrayBufferView types", () => {
49+
void describe("parameter validation and exceptions", () => {
50+
void test("encode rejects non-ArrayBufferView types", () => {
5151
expect(() => encode("not a buffer" as unknown as Uint8Array)).toThrow(
5252
new Error(
5353
"`source` has non-supported type. Provide `Uint8Array` or `ArrayBufferView`.",
5454
),
5555
);
5656
});
5757

58-
test("encode accepts ArrayBufferView (DataView)", () => {
58+
void test("encode accepts ArrayBufferView (DataView)", () => {
5959
const buf = new ArrayBuffer(3);
6060
new Uint8Array(buf).set([1, 2, 3]);
6161

@@ -66,13 +66,13 @@ describe("base62 roundtrip", () => {
6666
expect(decode(s)).toEqual(new Uint8Array([1, 2, 3]));
6767
});
6868

69-
test("decodeUnsafe rejects non-string input", () => {
69+
void test("decodeUnsafe rejects non-string input", () => {
7070
expect(() => decodeUnsafe(123 as unknown as string)).toThrow(
7171
TypeError("Expected String"),
7272
);
7373
});
7474

75-
test("decode/decodeUnsafe handle invalid characters", () => {
75+
void test("decode/decodeUnsafe handle invalid characters", () => {
7676
expect(decodeUnsafe("!notbase62!")).toBeUndefined();
7777
expect(() => decode("!notbase62!")).toThrow(new Error("Failed to decode string"));
7878
});

src/crc32.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,56 @@ import { expect } from "expect";
33

44
import crc32 from "./crc32.ts";
55

6-
describe("crc32 smoke tests", () => {
6+
void describe("crc32 smoke tests", () => {
77
function encode(value: string): Uint8Array {
88
return new TextEncoder().encode(value);
99
}
1010

11-
test("empty string", () => {
11+
void test("empty string", () => {
1212
const data = new Uint8Array();
1313
expect(crc32(data)).toEqual(new Uint8Array([0x00, 0x00, 0x00, 0x00]));
1414
});
15-
test("The quick brown fox jumps over the lazy dog", () => {
15+
void test("The quick brown fox jumps over the lazy dog", () => {
1616
const data = encode("The quick brown fox jumps over the lazy dog");
1717
expect(crc32(data)).toEqual(new Uint8Array([0x41, 0x4f, 0xa3, 0x39]));
1818
});
1919

20-
test("The quick brown fox jumps over the lazy dog.", () => {
20+
void test("The quick brown fox jumps over the lazy dog.", () => {
2121
const data = encode("The quick brown fox jumps over the lazy dog.");
2222
expect(crc32(data)).toEqual(new Uint8Array([0x51, 0x90, 0x25, 0xe9]));
2323
});
2424

25-
test("abc", () => {
25+
void test("abc", () => {
2626
const data = encode("abc");
2727
expect(crc32(data)).toEqual(new Uint8Array([0x35, 0x24, 0x41, 0xc2]));
2828
});
2929

30-
test("123456789", () => {
30+
void test("123456789", () => {
3131
const data = encode("123456789");
3232
expect(crc32(data)).toEqual(new Uint8Array([0xcb, 0xf4, 0x39, 0x26]));
3333
});
3434

35-
test("a", () => {
35+
void test("a", () => {
3636
const data = encode("a");
3737
expect(crc32(data)).toEqual(new Uint8Array([0xe8, 0xb7, 0xbe, 0x43]));
3838
});
3939

40-
test("message digest", () => {
40+
void test("message digest", () => {
4141
const data = encode("message digest");
4242
expect(crc32(data)).toEqual(new Uint8Array([0x20, 0x15, 0x9d, 0x7f]));
4343
});
4444

45-
test("abcdefghijklmnopqrstuvwxyz", () => {
45+
void test("abcdefghijklmnopqrstuvwxyz", () => {
4646
const data = encode("abcdefghijklmnopqrstuvwxyz");
4747
expect(crc32(data)).toEqual(new Uint8Array([0x4c, 0x27, 0x50, 0xbd]));
4848
});
4949

50-
test("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", () => {
50+
void test("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", () => {
5151
const data = encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
5252
expect(crc32(data)).toEqual(new Uint8Array([0x1f, 0xc2, 0xe6, 0xd2]));
5353
});
5454

55-
test("bytes 0..255", () => {
55+
void test("bytes 0..255", () => {
5656
const data = new Uint8Array(256);
5757
for (let i = 0; i < 256; ++i) {
5858
data[i] = i;

src/index.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ afterEach(() => {
4040

4141
import { createTokenGenerator } from "./index.ts";
4242

43-
test("Instance creation smoke test", () => {
43+
void test("Instance creation smoke test", () => {
4444
createTokenGenerator({
4545
prefixWithoutUnderscore: "test",
4646
});
4747
});
4848

49-
describe("`prefixWithoutUnderscore` validation", () => {
50-
test("Instance creation expect prefix", () => {
49+
void describe("`prefixWithoutUnderscore` validation", () => {
50+
void test("Instance creation expect prefix", () => {
5151
// @ts-expect-error
5252
expect(() => createTokenGenerator({})).toThrow(
5353
new Error(
@@ -56,13 +56,13 @@ describe("`prefixWithoutUnderscore` validation", () => {
5656
);
5757
});
5858

59-
test("prefixWithoutUnderscore: allowed characters", () => {
59+
void test("prefixWithoutUnderscore: allowed characters", () => {
6060
expect(() => createTokenGenerator({ prefixWithoutUnderscore: "abc" })).not.toThrow();
6161
expect(() => createTokenGenerator({ prefixWithoutUnderscore: "ABC" })).not.toThrow();
6262
expect(() => createTokenGenerator({ prefixWithoutUnderscore: "aBc123" })).not.toThrow();
6363
});
6464

65-
test("prefixWithoutUnderscore: disallowed characters", () => {
65+
void test("prefixWithoutUnderscore: disallowed characters", () => {
6666
expect(() => createTokenGenerator({ prefixWithoutUnderscore: "" })).toThrow();
6767
expect(() => createTokenGenerator({ prefixWithoutUnderscore: "_" })).toThrow();
6868
expect(() => createTokenGenerator({ prefixWithoutUnderscore: "foo-bar" })).toThrow();
@@ -79,7 +79,7 @@ describe("`prefixWithoutUnderscore` validation", () => {
7979
});
8080
});
8181

82-
test("Instance creation expect proper byte count", () => {
82+
void test("Instance creation expect proper byte count", () => {
8383
expect(() =>
8484
createTokenGenerator({
8585
prefixWithoutUnderscore: "a",
@@ -112,20 +112,20 @@ test("Instance creation expect proper byte count", () => {
112112
});
113113
});
114114

115-
test("Roundtrip syntax check", () => {
115+
void test("Roundtrip syntax check", () => {
116116
const g = createTokenGenerator({ prefixWithoutUnderscore: "test" });
117117
const token = g.generateToken();
118118
expect(g.isTokenString(token)).toBe(true);
119119
});
120120

121-
test("Snapshot + default entropyBytes", () => {
121+
void test("Snapshot + default entropyBytes", () => {
122122
const g = createTokenGenerator({ prefixWithoutUnderscore: "test" });
123123
expect(g.generateToken()).toBe("test_1sSTYGlY7FpQhFcPUWjQcyfqQkW1oTDe5D");
124124
expect(g.generateToken()).toBe("test_1vEOLndpANaPr8bqfaSnP8yYUL3GZu1Kg9");
125125
expect(g.generateToken()).toBe("test_1y0J9KW6DVLP11bHqeCABJHGXvaVO2ngsf");
126126
});
127127

128-
test("Non-happy paths in isTokenString", () => {
128+
void test("Non-happy paths in isTokenString", () => {
129129
const g = createTokenGenerator({ prefixWithoutUnderscore: "test" });
130130

131131
// @ts-expect-error

src/parse.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect } from "expect";
33

44
import { parseTokenData, type TokenContents } from "./parse.ts";
55

6-
test("Parse token contents", () => {
6+
void test("Parse token contents", () => {
77
let contents: TokenContents | undefined;
88

99
contents = parseTokenData("");

0 commit comments

Comments
 (0)