Skip to content

Commit 0b8f320

Browse files
committed
chore: tweaks
1 parent 0619592 commit 0b8f320

31 files changed

Lines changed: 1126 additions & 965 deletions

.github/renovate.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
{
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3-
"extends": [
4-
"config:recommended",
5-
":prHourlyLimitNone",
6-
":prConcurrentLimitNone"
7-
],
3+
"extends": ["config:recommended", ":prHourlyLimitNone", ":prConcurrentLimitNone"],
84
"dependencyDashboard": true,
95
"schedule": ["every weekend"],
106
"packageRules": [

.husky/commit-msg

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
4-
pnpm commitlint --edit $1
1+
pnpm commitlint --edit $1

.husky/pre-commit

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
41
pnpm nano-staged

.oxfmtrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"ignorePatterns": []
4+
}

.oxlintrc.json

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"ignorePatterns": ["dist/**"],
4+
"categories": {
5+
"correctness": "error",
6+
"suspicious": "warn",
7+
"pedantic": "warn",
8+
"perf": "warn",
9+
"style": "warn",
10+
"restriction": "off"
11+
},
12+
"plugins": ["import", "unicorn", "oxc", "promise", "jsdoc", "vitest", "node"],
13+
"rules": {
14+
"catch-error-name": ["warn", { "name": "err" }],
15+
"curly": ["off", "multi-line"],
16+
"group-exports": "off",
17+
"id-length": "off",
18+
"init-declarations": "off",
19+
"max-dependencies": "off",
20+
"max-lines": "off",
21+
"max-lines-per-function": "off",
22+
"max-params": ["warn", 4],
23+
"no-continue": "off",
24+
"no-console": "warn",
25+
"no-duplicate-imports": "off",
26+
"no-magic-numbers": "off",
27+
// "no-magic-numbers": ["warn", { "ignore": [-1, 0, 1, 2] }],
28+
"no-nested-ternary": "off",
29+
"no-null": "off",
30+
"no-ternary": "off",
31+
"no-warning-comments": "off",
32+
"sort-imports": "off",
33+
"sort-keys": "off",
34+
35+
"import/exports-last": "off",
36+
// usually we just export vue components as default export without naming it
37+
"import/no-anonymous-default-export": "off",
38+
// a rule that shall not be enabled anyway
39+
"import/no-named-export": "off",
40+
"import/no-unassigned-import": ["error", { "allow": ["**/*.css", "**/*.scss"] }],
41+
// named export is preferred in our codebase
42+
"import/prefer-default-export": "off",
43+
"jsdoc/require-param": "off",
44+
"jsdoc/require-param-type": "off",
45+
"jsdoc/require-returns": "off",
46+
"jsdoc/require-returns-type": "off",
47+
"promise/always-return": "off",
48+
"promise/avoid-new": "off",
49+
"promise/prefer-await-to-then": "off",
50+
"unicorn/filename-case": "off",
51+
// toReversed can introduce memory overhead
52+
"unicorn/no-array-reverse": "off",
53+
// toSorted can introduce memory overhead
54+
"unicorn/no-array-sort": "off",
55+
"unicorn/no-nested-ternary": "off",
56+
// at is not supported by our target environments
57+
"unicorn/prefer-at": "off",
58+
"unicorn/prefer-global-this": "off",
59+
60+
// seems conflicts with prettier
61+
"number-literal-case": "off",
62+
"numeric-separators-style": "off",
63+
64+
// style rules
65+
"capitalized-comments": "off",
66+
"max-statements": ["warn", { "max": 30 }],
67+
"no-inline-comments": "off"
68+
},
69+
"overrides": [
70+
{
71+
"files": ["**/*.ts"],
72+
"plugins": ["typescript"],
73+
"rules": {
74+
// we make type casts only when necessary
75+
// "typescript/no-unsafe-type-assertion": "off",
76+
// skipping it for now, may enable it later
77+
// "typescript/switch-exhaustiveness-check": "off",
78+
// a lot of time we are just want to check existence
79+
// "typescript/strict-boolean-expressions": "off"
80+
}
81+
},
82+
{
83+
"files": ["**/__tests__/**"],
84+
"plugins": ["vitest"]
85+
}
86+
]
87+
}

.vscode/extensions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["oxc.oxc-vscode", "vitest.explorer"]
3+
}

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.defaultFormatter": "oxc.oxc-vscode"
3+
}

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,7 @@ export const compare: (
170170
* @param salt Salt length to generate or salt to use, default to 10
171171
* @returns Resulting hash
172172
*/
173-
export const hashSync: (
174-
contentString: string,
175-
salt?: string | number,
176-
) => string;
173+
export const hashSync: (contentString: string, salt?: string | number) => string;
177174
/**
178175
* Asynchronously generates a hash for the given string.
179176
*

__tests__/base64.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { describe, expect, it } from "vitest";
22

33
import { decodeBase64, encodeBase64 } from "../src/base64.js";
44

5-
describe("encodeBase64", () => {
5+
describe(encodeBase64, () => {
66
it("should encode byte array to base64 string", () => {
77
expect(
88
encodeBase64(
99
[
10-
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a,
11-
0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
10+
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
11+
0x0f, 0x10,
1212
],
1313
16,
1414
),
@@ -22,11 +22,11 @@ describe("encodeBase64", () => {
2222
});
2323
});
2424

25-
describe("decodeBase64", () => {
25+
describe(decodeBase64, () => {
2626
it("should decode base64 string to byte array", () => {
2727
expect(decodeBase64("..CA.uOD/eaGAOmJB.yMBv.", 16)).toEqual([
28-
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
29-
0x0c, 0x0d, 0x0e, 0x0f,
28+
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
29+
0x0f,
3030
]);
3131
});
3232

__tests__/compare.bench.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Eget ultricies potenti aptent augue eget quisque erat habitasse feugiat. Commodo
1414
Aliquet curae fames vel; purus dolor maecenas. Fermentum sagittis nulla ornare bibendum justo pellentesque lacinia, sem eleifend. Justo eleifend etiam suspendisse sagittis; fames ipsum. Sodales cras mus non metus sapien parturient maximus adipiscing blandit. Praesent amet risus; auctor molestie eros morbi. Torquent pulvinar sodales; a nisi cursus tempus. Dignissim ipsum placerat nisl litora auctor.
1515
`;
1616

17-
describe("compare", async () => {
17+
describe(compare, async () => {
1818
const hellow5Hash = await hash("hello", 5);
1919
const hellow10Hash = await hash("hello", 10);
2020
const lorenHash = await hash(lorem, 5);
@@ -44,7 +44,7 @@ describe("compare", async () => {
4444
);
4545
});
4646

47-
describe("compareSync", () => {
47+
describe(compareSync, () => {
4848
const hellow5Hash = hashSync("hello", 5);
4949
const hellow10Hash = hashSync("hello", 10);
5050
const lorenHash = hashSync(lorem, 5);

0 commit comments

Comments
 (0)