Skip to content

Commit 0429a6f

Browse files
Copilotfengmk2
andcommitted
fix: resolve lint errors by adding rule overrides to .oxlintrc.json
Co-authored-by: fengmk2 <156269+fengmk2@users.noreply.github.com>
1 parent 2543bf4 commit 0429a6f

15 files changed

Lines changed: 39 additions & 38 deletions

.oxlintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"jsdoc/check-tag-names": "allow",
4848
"jsdoc/no-defaults": "allow",
4949
"max-statements": "allow",
50+
"capitalized-comments": "allow",
5051
"no-inline-comments": "allow",
5152
"no-param-reassign": "allow",
5253
"no-shadow": "allow",

src/array.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ export function randomSlice<T = any>(arr: T[], num?: number): T[] {
2525
export function spliceOne<T = any>(arr: T[], index: number): T[] {
2626
if (index < 0) {
2727
index = arr.length + index;
28-
// Still negative, not found element
28+
// still negative, not found element
2929
if (index < 0) {
3030
return arr;
3131
}
3232
}
3333

34-
// Don't touch
34+
// don't touch
3535
if (index >= arr.length) {
3636
return arr;
3737
}

src/crypto.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type HashMethod = (method: string, data: HashInput, outputEncoding?: BinaryToTex
77
const nativeHash = 'hash' in crypto ? crypto.hash as HashMethod : null;
88

99
/**
10-
* Hash
10+
* hash
1111
*
1212
* @param {String} method hash method, e.g.: 'md5', 'sha1'
1313
* @param {String|Buffer|ArrayBuffer|TypedArray|DataView|Object} s input value
@@ -25,7 +25,7 @@ export function hash(method: string, s: HashInput, format?: BinaryToTextEncoding
2525
}
2626

2727
if (nativeHash) {
28-
// Try to use crypto.hash first
28+
// try to use crypto.hash first
2929
// https://nodejs.org/en/blog/release/v21.7.0#crypto-implement-cryptohash
3030
return nativeHash(method, s, format);
3131
}
@@ -36,7 +36,7 @@ export function hash(method: string, s: HashInput, format?: BinaryToTextEncoding
3636
}
3737

3838
/**
39-
* Md5 hash
39+
* md5 hash
4040
*
4141
* @param {String|Buffer|Object} s input value
4242
* @param {String} [format] output string format, could be 'hex' or 'base64'. default is 'hex'.
@@ -48,7 +48,7 @@ export function md5(s: HashInput, format?: BinaryToTextEncoding): string {
4848
}
4949

5050
/**
51-
* Sha1 hash
51+
* sha1 hash
5252
*
5353
* @param {String|Buffer|Object} s input value
5454
* @param {String} [format] output string format, could be 'hex' or 'base64'. default is 'hex'.
@@ -60,7 +60,7 @@ export function sha1(s: HashInput, format?: BinaryToTextEncoding): string {
6060
}
6161

6262
/**
63-
* Sha256 hash
63+
* sha256 hash
6464
*
6565
* @param {String|Buffer|Object} s input value
6666
* @param {String} [format] output string format, could be 'hex' or 'base64'. default is 'hex'.
@@ -72,7 +72,7 @@ export function sha256(s: HashInput, format?: BinaryToTextEncoding): string {
7272
}
7373

7474
/**
75-
* Sha512 hash
75+
* sha512 hash
7676
*
7777
* @param {String|Buffer|Object} s input value
7878
* @param {String} [format] output string format, could be 'hex' or 'base64'. default is 'hex'.

src/date.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const MONTHS: Record<string, string> = {
3232
};
3333

3434
/**
35-
* Return `[ YYYY, MM, DD, HH, mm, ss ]` date string array
35+
* return `[ YYYY, MM, DD, HH, mm, ss ]` date string array
3636
*/
3737
export function getDateStringParts(d?: Date, onlyDate?: boolean) {
3838
d = d || new Date();
@@ -80,11 +80,11 @@ export function logDate(d?: Date): string;
8080
export function logDate(d?: Date | null, msSep?: string): string;
8181
export function logDate(d?: Date | string | null, msSep?: string): string {
8282
if (typeof d === 'string') {
83-
// LogDate(msSep)
83+
// logDate(msSep)
8484
msSep = d;
8585
d = new Date();
8686
} else {
87-
// LogDate(d, msSep)
87+
// logDate(d, msSep)
8888
d = d || new Date();
8989
}
9090
const [ year, month, date, hours, minutes, seconds ] = getDateStringParts(d);
@@ -152,7 +152,7 @@ export interface DateStruct {
152152
}
153153

154154
/**
155-
* Return datetime struct.
155+
* return datetime struct.
156156
*
157157
* @return {Object} date
158158
* - {Number} YYYYMMDD, 20130401
@@ -171,8 +171,8 @@ export function datestruct(now?: Date): DateStruct {
171171
*/
172172
export function timestamp(t?: number | string): number | Date {
173173
if (t) {
174-
// Convert timestamp to Date
175-
// Timestamp(timestampValue)
174+
// convert timestamp to Date
175+
// timestamp(timestampValue)
176176
let v: number;
177177
if (typeof t === 'string') {
178178
v = Number(t);
@@ -184,7 +184,7 @@ export function timestamp(t?: number | string): number | Date {
184184
}
185185
return new Date(v);
186186
}
187-
// Get current timestamp
187+
// get current timestamp
188188
return Math.round(Date.now() / 1000);
189189
}
190190

src/function.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import assert from 'node:assert';
55
*/
66
// eslint-disable-next-line @typescript-eslint/no-unused-vars
77
export function noop(..._args: any[]): any {
8-
// Noop
8+
// noop
99
}
1010

1111
/**

src/number.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ export function toSafeNumber(s: string | number): number | string {
4343
* @return {Number} Returns the random number.
4444
*/
4545
export function random(lower?: number, upper?: number): number {
46-
// Random()
46+
// random()
4747
if (lower === undefined) {
4848
return 0;
4949
}
50-
// Random(lower) => random(0, lower)
50+
// random(lower) => random(0, lower)
5151
if (upper === undefined) {
5252
upper = lower;
5353
lower = 0;
5454
}
5555
let temp: number;
56-
// Random(upper, lower)
56+
// random(upper, lower)
5757
if (lower > upper) {
5858
temp = lower;
5959
lower = upper;

src/object.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ export function getOwnEnumerables(obj: any, ignoreNull?: boolean): Array<string>
4747
});
4848
}
4949

50-
// Faster way like `Object.create(null)` to get a 'clean' empty object
50+
// faster way like `Object.create(null)` to get a 'clean' empty object
5151
// https://github.com/nodejs/node/blob/master/lib/events.js#L5
5252
// https://cnodejs.org/topic/571e0c445a26c4a841ecbcf1
5353
function EmptyObject() {}
5454
EmptyObject.prototype = Object.create(null);
5555

5656
/**
57-
* Generate a real map object(clean object), no constructor, no __proto__
57+
* generate a real map object(clean object), no constructor, no __proto__
5858
* @param {Object} [obj] - init object, optional
5959
*/
6060
export function map(obj?: any): Record<string, any> {

src/optimize.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Optimize try catch
2+
* optimize try catch
33
*/
44
export function tryCatch<T = any>(fn: () => T) {
55
const res: {
@@ -29,7 +29,7 @@ export const UNSTABLE_METHOD = {
2929
};
3030

3131
/**
32-
* Avoid if (a && a.b && a.b.c)
32+
* avoid if (a && a.b && a.b.c)
3333
*/
3434
export function dig(obj?: any, ...keys: string[]) {
3535
if (!obj) {
@@ -51,7 +51,7 @@ export function dig(obj?: any, ...keys: string[]) {
5151
}
5252

5353
/**
54-
* Optimize arguments to array
54+
* optimize arguments to array
5555
*/
5656
export function argumentsToArray(args: any[]) {
5757
const res = new Array(args.length);

src/string.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function randomString(length?: number, charSet?: string) {
1010
}
1111

1212
/**
13-
* Split string to array
13+
* split string to array
1414
* @param {String} str input string
1515
* @param {String} [sep] default is ','
1616
*/
@@ -26,7 +26,7 @@ export function split(str?: string, sep?: string) {
2626
}
2727
return needs;
2828
}
29-
// Keep compatibility
29+
// keep compatibility
3030
export const splitAlwaysOptimized = split;
3131

3232
type StringReplacer = (substring: string, ...args: any[]) => string;
@@ -41,7 +41,7 @@ export function replace(str: string, substr: string | RegExp, newSubstr: string
4141
return str.replace(substr, newSubstr);
4242
}
4343

44-
// Original source https://github.com/nodejs/node/blob/v7.5.0/lib/_http_common.js#L300
44+
// original source https://github.com/nodejs/node/blob/v7.5.0/lib/_http_common.js#L300
4545
/**
4646
* True if val contains an invalid field-vchar
4747
* field-value = *( field-content / obs-fold )
@@ -93,7 +93,7 @@ export function replaceInvalidHttpHeaderChar(val: string, replacement?: string |
9393
let chars: string[] | undefined;
9494
for (let i = 0; i < val.length; ++i) {
9595
if (!validHdrChars[val.charCodeAt(i)]) {
96-
// Delay create chars
96+
// delay create chars
9797
chars = chars || val.split('');
9898
if (typeof replacement === 'function') {
9999
chars[i] = replacement(chars[i]);

test/crypto.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ describe('test/crypto.test.ts', () => {
107107
// > 4Vnqz+LV0qMMt/a81E+EURcQMrI=
108108
assert.equal(utility.hmac('sha1', 'I am a key', '中文,你好', 'base64'), '4Vnqz+LV0qMMt/a81E+EURcQMrI=');
109109

110-
// Should work with buffer data
110+
// should work with buffer data
111111
assert.equal(utility.hmac('sha1', 'I am a key', '中文,你好'), utility.hmac('sha1', 'I am a key', Buffer.from('中文,你好')));
112112
});
113113
});
@@ -144,7 +144,7 @@ Encode string s using a URL-safe alphabet, which substitutes - instead of + and
144144
assert.match(utility.base64encode(s), /\+/);
145145
assert.match(utility.base64encode(s), /\//);
146146

147-
// UrlSafe
147+
// urlSafe
148148
assert.equal(utility.base64decode(utility.base64encode(s, true), true), s);
149149
assert.match(utility.base64encode(s, true), /[^+]/);
150150
assert.match(utility.base64encode(s, true), /[^\/]/);

0 commit comments

Comments
 (0)