Skip to content

Commit 6da958d

Browse files
authored
chore: update dlint to v0.37.0 for GitHub Actions (denoland#17295)
Updated third_party dlint to v0.37.0 for GitHub Actions. This PR includes following changes: * fix(prefer-primordials): Stop using array pattern assignments * fix(prefer-primordials): Stop using global intrinsics except for `SharedArrayBuffer` * feat(guard-for-in): Apply new guard-for-in rule
1 parent 40134ff commit 6da958d

29 files changed

+128
-103
lines changed

.dlint.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"tags": ["recommended"],
44
"include": [
55
"ban-untagged-todo",
6-
"camelcase"
6+
"camelcase",
7+
"guard-for-in"
78
],
89
"exclude": [
910
"no-invalid-triple-slash-reference"

cli/js/40_testing.js

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
MapPrototypeSet,
2727
MathCeil,
2828
ObjectKeys,
29+
ObjectPrototypeHasOwnProperty,
2930
ObjectPrototypeIsPrototypeOf,
3031
Promise,
3132
SafeArrayIterator,
@@ -167,6 +168,9 @@
167168

168169
const details = [];
169170
for (const key in post.ops) {
171+
if (!ObjectPrototypeHasOwnProperty(post.ops, key)) {
172+
continue;
173+
}
170174
const preOp = pre.ops[key] ??
171175
{ opsDispatchedAsync: 0, opsCompletedAsync: 0 };
172176
const postOp = post.ops[key];

cli/tests/unit/headers_test.ts

+18-18
Original file line numberDiff line numberDiff line change
@@ -34,52 +34,52 @@ const headerDict: Record<string, string> = {
3434
};
3535
// deno-lint-ignore no-explicit-any
3636
const headerSeq: any[] = [];
37-
for (const name in headerDict) {
38-
headerSeq.push([name, headerDict[name]]);
37+
for (const [name, value] of Object.entries(headerDict)) {
38+
headerSeq.push([name, value]);
3939
}
4040

4141
Deno.test(function newHeaderWithSequence() {
4242
const headers = new Headers(headerSeq);
43-
for (const name in headerDict) {
44-
assertEquals(headers.get(name), String(headerDict[name]));
43+
for (const [name, value] of Object.entries(headerDict)) {
44+
assertEquals(headers.get(name), String(value));
4545
}
4646
assertEquals(headers.get("length"), null);
4747
});
4848

4949
Deno.test(function newHeaderWithRecord() {
5050
const headers = new Headers(headerDict);
51-
for (const name in headerDict) {
52-
assertEquals(headers.get(name), String(headerDict[name]));
51+
for (const [name, value] of Object.entries(headerDict)) {
52+
assertEquals(headers.get(name), String(value));
5353
}
5454
});
5555

5656
Deno.test(function newHeaderWithHeadersInstance() {
5757
const headers = new Headers(headerDict);
5858
const headers2 = new Headers(headers);
59-
for (const name in headerDict) {
60-
assertEquals(headers2.get(name), String(headerDict[name]));
59+
for (const [name, value] of Object.entries(headerDict)) {
60+
assertEquals(headers2.get(name), String(value));
6161
}
6262
});
6363

6464
Deno.test(function headerAppendSuccess() {
6565
const headers = new Headers();
66-
for (const name in headerDict) {
67-
headers.append(name, headerDict[name]);
68-
assertEquals(headers.get(name), String(headerDict[name]));
66+
for (const [name, value] of Object.entries(headerDict)) {
67+
headers.append(name, value);
68+
assertEquals(headers.get(name), String(value));
6969
}
7070
});
7171

7272
Deno.test(function headerSetSuccess() {
7373
const headers = new Headers();
74-
for (const name in headerDict) {
75-
headers.set(name, headerDict[name]);
76-
assertEquals(headers.get(name), String(headerDict[name]));
74+
for (const [name, value] of Object.entries(headerDict)) {
75+
headers.set(name, value);
76+
assertEquals(headers.get(name), String(value));
7777
}
7878
});
7979

8080
Deno.test(function headerHasSuccess() {
8181
const headers = new Headers(headerDict);
82-
for (const name in headerDict) {
82+
for (const name of Object.keys(headerDict)) {
8383
assert(headers.has(name), "headers has name " + name);
8484
assert(
8585
!headers.has("nameNotInHeaders"),
@@ -90,7 +90,7 @@ Deno.test(function headerHasSuccess() {
9090

9191
Deno.test(function headerDeleteSuccess() {
9292
const headers = new Headers(headerDict);
93-
for (const name in headerDict) {
93+
for (const name of Object.keys(headerDict)) {
9494
assert(headers.has(name), "headers have a header: " + name);
9595
headers.delete(name);
9696
assert(!headers.has(name), "headers do not have anymore a header: " + name);
@@ -99,8 +99,8 @@ Deno.test(function headerDeleteSuccess() {
9999

100100
Deno.test(function headerGetSuccess() {
101101
const headers = new Headers(headerDict);
102-
for (const name in headerDict) {
103-
assertEquals(headers.get(name), String(headerDict[name]));
102+
for (const [name, value] of Object.entries(headerDict)) {
103+
assertEquals(headers.get(name), String(value));
104104
assertEquals(headers.get("nameNotInHeaders"), null);
105105
}
106106
});

ext/broadcast_channel/01_broadcast_channel.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
break;
3535
}
3636

37-
const [name, data] = message;
37+
const { 0: name, 1: data } = message;
3838
dispatch(null, name, new Uint8Array(data));
3939
}
4040

ext/cache/01_cache.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@
255255
},
256256
);
257257
if (matchResult) {
258-
const [meta, responseBodyRid] = matchResult;
258+
const { 0: meta, 1: responseBodyRid } = matchResult;
259259
let body = null;
260260
if (responseBodyRid !== null) {
261261
body = readableStreamForRid(responseBodyRid);

ext/console/02_console.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@
360360
ObjectKeys(value).length > 0 ||
361361
ObjectGetOwnPropertySymbols(value).length > 0
362362
) {
363-
const [propString, refIndex] = inspectRawObject(
363+
const { 0: propString, 1: refIndex } = inspectRawObject(
364364
value,
365365
inspectOptions,
366366
);
@@ -847,7 +847,7 @@
847847
displayName: "",
848848
delims: ["[", "]"],
849849
entryHandler: (entry, inspectOptions) => {
850-
const [index, val] = entry;
850+
const { 0: index, 1: val } = entry;
851851
let i = index;
852852
lastValidIndex = index;
853853
if (!ObjectPrototypeHasOwnProperty(value, i)) {
@@ -940,7 +940,7 @@
940940
displayName: "Map",
941941
delims: ["{", "}"],
942942
entryHandler: (entry, inspectOptions) => {
943-
const [key, val] = entry;
943+
const { 0: key, 1: val } = entry;
944944
inspectOptions.indentLevel++;
945945
const inspectedValue = `${
946946
inspectValueWithQuotes(key, inspectOptions)
@@ -1100,7 +1100,7 @@
11001100
const cyan = maybeColor(colors.cyan, inspectOptions);
11011101
const red = maybeColor(colors.red, inspectOptions);
11021102

1103-
const [state, result] = core.getPromiseDetails(value);
1103+
const { 0: state, 1: result } = core.getPromiseDetails(value);
11041104

11051105
if (state === PromiseState.Pending) {
11061106
return `Promise { ${cyan("<pending>")} }`;
@@ -1363,7 +1363,7 @@
13631363
);
13641364
} else {
13651365
// Otherwise, default object formatting
1366-
let [insp, refIndex] = inspectRawObject(value, inspectOptions);
1366+
let { 0: insp, 1: refIndex } = inspectRawObject(value, inspectOptions);
13671367
insp = refIndex + insp;
13681368
return insp;
13691369
}
@@ -1568,17 +1568,17 @@
15681568
let g_;
15691569
let b_;
15701570
if (h < 60) {
1571-
[r_, g_, b_] = [c, x, 0];
1571+
({ 0: r_, 1: g_, 2: b_ } = [c, x, 0]);
15721572
} else if (h < 120) {
1573-
[r_, g_, b_] = [x, c, 0];
1573+
({ 0: r_, 1: g_, 2: b_ } = [x, c, 0]);
15741574
} else if (h < 180) {
1575-
[r_, g_, b_] = [0, c, x];
1575+
({ 0: r_, 1: g_, 2: b_ } = [0, c, x]);
15761576
} else if (h < 240) {
1577-
[r_, g_, b_] = [0, x, c];
1577+
({ 0: r_, 1: g_, 2: b_ } = [0, x, c]);
15781578
} else if (h < 300) {
1579-
[r_, g_, b_] = [x, 0, c];
1579+
({ 0: r_, 1: g_, 2: b_ } = [x, 0, c]);
15801580
} else {
1581-
[r_, g_, b_] = [c, 0, x];
1581+
({ 0: r_, 1: g_, 2: b_ } = [c, 0, x]);
15821582
}
15831583
return [
15841584
MathRound((r_ + m) * 255),
@@ -1645,7 +1645,7 @@
16451645
}
16461646

16471647
for (let i = 0; i < rawEntries.length; ++i) {
1648-
const [key, value] = rawEntries[i];
1648+
const { 0: key, 1: value } = rawEntries[i];
16491649
if (key == "background-color") {
16501650
if (value != null) {
16511651
css.backgroundColor = value;
@@ -1736,12 +1736,12 @@
17361736
ansi += `\x1b[47m`;
17371737
} else {
17381738
if (ArrayIsArray(css.backgroundColor)) {
1739-
const [r, g, b] = css.backgroundColor;
1739+
const { 0: r, 1: g, 2: b } = css.backgroundColor;
17401740
ansi += `\x1b[48;2;${r};${g};${b}m`;
17411741
} else {
17421742
const parsed = parseCssColor(css.backgroundColor);
17431743
if (parsed !== null) {
1744-
const [r, g, b] = parsed;
1744+
const { 0: r, 1: g, 2: b } = parsed;
17451745
ansi += `\x1b[48;2;${r};${g};${b}m`;
17461746
} else {
17471747
ansi += "\x1b[49m";
@@ -1770,12 +1770,12 @@
17701770
ansi += `\x1b[37m`;
17711771
} else {
17721772
if (ArrayIsArray(css.color)) {
1773-
const [r, g, b] = css.color;
1773+
const { 0: r, 1: g, 2: b } = css.color;
17741774
ansi += `\x1b[38;2;${r};${g};${b}m`;
17751775
} else {
17761776
const parsed = parseCssColor(css.color);
17771777
if (parsed !== null) {
1778-
const [r, g, b] = parsed;
1778+
const { 0: r, 1: g, 2: b } = parsed;
17791779
ansi += `\x1b[38;2;${r};${g};${b}m`;
17801780
} else {
17811781
ansi += "\x1b[39m";
@@ -1799,7 +1799,7 @@
17991799
}
18001800
if (!colorEquals(css.textDecorationColor, prevCss.textDecorationColor)) {
18011801
if (css.textDecorationColor != null) {
1802-
const [r, g, b] = css.textDecorationColor;
1802+
const { 0: r, 1: g, 2: b } = css.textDecorationColor;
18031803
ansi += `\x1b[58;2;${r};${g};${b}m`;
18041804
} else {
18051805
ansi += "\x1b[59m";
@@ -2045,7 +2045,7 @@
20452045
return;
20462046
}
20472047

2048-
const [first, ...rest] = args;
2048+
const [first, ...rest] = new SafeArrayIterator(args);
20492049

20502050
if (typeof first === "string") {
20512051
this.error(

ext/fetch/21_formdata.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@
305305
const prefix = `--${boundary}\r\nContent-Disposition: form-data; name="`;
306306

307307
// deno-lint-ignore prefer-primordials
308-
for (const [name, value] of formData) {
308+
for (const { 0: name, 1: value } of formData) {
309309
if (typeof value === "string") {
310310
ArrayPrototypePush(
311311
chunks,

ext/fetch/22_body.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
JSONParse,
4343
ObjectDefineProperties,
4444
ObjectPrototypeIsPrototypeOf,
45+
// TODO(lucacasonato): add SharedArrayBuffer to primordials
46+
// SharedArrayBufferPrototype
4547
TypedArrayPrototypeSlice,
4648
TypeError,
4749
Uint8Array,
@@ -185,7 +187,7 @@
185187
* @returns {InnerBody}
186188
*/
187189
clone() {
188-
const [out1, out2] = this.stream.tee();
190+
const { 0: out1, 1: out2 } = this.stream.tee();
189191
this.streamOrStatic = out1;
190192
const second = new InnerBody(out2);
191193
second.source = core.deserialize(core.serialize(this.source));
@@ -447,6 +449,7 @@
447449
if (typeof V === "object") {
448450
if (
449451
ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, V) ||
452+
// deno-lint-ignore prefer-primordials
450453
ObjectPrototypeIsPrototypeOf(SharedArrayBuffer.prototype, V)
451454
) {
452455
return webidl.converters["ArrayBuffer"](V, opts);

ext/ffi/00_ffi.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,10 @@
268268
let size = 0;
269269
let alignment = 1;
270270
for (const field of new SafeArrayIterator(type.struct)) {
271-
const [fieldSize, fieldAlign] = getTypeSizeAndAlignment(field, cache);
271+
const { 0: fieldSize, 1: fieldAlign } = getTypeSizeAndAlignment(
272+
field,
273+
cache,
274+
);
272275
alignment = MathMax(alignment, fieldAlign);
273276
size = MathCeil(size / fieldAlign) * fieldAlign;
274277
size += fieldSize;
@@ -319,7 +322,7 @@
319322
"Invalid UnsafeCallback, cannot be nonblocking",
320323
);
321324
}
322-
const [rid, pointer] = ops.op_ffi_unsafe_callback_create(
325+
const { 0: rid, 1: pointer } = ops.op_ffi_unsafe_callback_create(
323326
definition,
324327
callback,
325328
);
@@ -362,7 +365,7 @@
362365
symbols = {};
363366

364367
constructor(path, symbols) {
365-
[this.#rid, this.symbols] = ops.op_ffi_load({ path, symbols });
368+
({ 0: this.#rid, 1: this.symbols } = ops.op_ffi_load({ path, symbols }));
366369
for (const symbol in symbols) {
367370
if (!ObjectPrototypeHasOwnProperty(symbols, symbol)) {
368371
continue;

ext/flash/01_http.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
// Date header: https://datatracker.ietf.org/doc/html/rfc7231#section-7.1.1.2
141141
let str = `HTTP/1.1 ${status} ${statusCodes[status]}\r\nDate: ${date}\r\n`;
142142
for (let i = 0; i < headerList.length; ++i) {
143-
const [name, value] = headerList[i];
143+
const { 0: name, 1: value } = headerList[i];
144144
// header-field = field-name ":" OWS field-value OWS
145145
str += `${name}: ${value}\r\n`;
146146
}

ext/http/01_http.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
return null;
116116
}
117117

118-
const [streamRid, method, url] = nextRequest;
118+
const { 0: streamRid, 1: method, 2: url } = nextRequest;
119119
SetPrototypeAdd(this.managedResources, streamRid);
120120

121121
/** @type {ReadableStream<Uint8Array> | undefined} */

0 commit comments

Comments
 (0)