Update webpack, components for eslint. Adjust effected settings and code.

This commit is contained in:
NI
2021-07-09 17:28:47 +08:00
parent 52b33cc793
commit d66053a0dc
15 changed files with 412 additions and 704 deletions

View File

@@ -173,16 +173,18 @@ export class Address {
throw new Exception("Host name cannot longer than " + MAX_ADDR_LEN);
}
let dataBuf = new Uint8Array(this.addrData.length + 3);
{
let dataBuf = new Uint8Array(this.addrData.length + 3);
dataBuf[0] = (this.addrPort >> 8) & 0xff;
dataBuf[1] = this.addrPort & 0xff;
dataBuf[2] = HOSTNAME << 6;
dataBuf[2] |= this.addrData.length;
dataBuf[0] = (this.addrPort >> 8) & 0xff;
dataBuf[1] = this.addrPort & 0xff;
dataBuf[2] = HOSTNAME << 6;
dataBuf[2] |= this.addrData.length;
dataBuf.set(this.addrData, 3);
dataBuf.set(this.addrData, 3);
return dataBuf;
return dataBuf;
}
default:
throw new Exception("Unknown address type");

View File

@@ -32,9 +32,9 @@ describe("Address", () => {
let addr2 = await address.Address.read(r);
assert.equal(addr2.type(), addr.type());
assert.deepEqual(addr2.address(), addr.address());
assert.equal(addr2.port(), addr.port());
assert.strictEqual(addr2.type(), addr.type());
assert.deepStrictEqual(addr2.address(), addr.address());
assert.strictEqual(addr2.port(), addr.port());
});
it("Address IPv4", async () => {
@@ -53,9 +53,9 @@ describe("Address", () => {
let addr2 = await address.Address.read(r);
assert.equal(addr2.type(), addr.type());
assert.deepEqual(addr2.address(), addr.address());
assert.equal(addr2.port(), addr.port());
assert.strictEqual(addr2.type(), addr.type());
assert.deepStrictEqual(addr2.address(), addr.address());
assert.strictEqual(addr2.port(), addr.port());
});
it("Address IPv6", async () => {
@@ -74,9 +74,9 @@ describe("Address", () => {
let addr2 = await address.Address.read(r);
assert.equal(addr2.type(), addr.type());
assert.deepEqual(addr2.address(), addr.address());
assert.equal(addr2.port(), addr.port());
assert.strictEqual(addr2.type(), addr.type());
assert.deepStrictEqual(addr2.address(), addr.address());
assert.strictEqual(addr2.port(), addr.port());
});
it("Address HostName", async () => {
@@ -95,8 +95,8 @@ describe("Address", () => {
let addr2 = await address.Address.read(r);
assert.equal(addr2.type(), addr.type());
assert.deepEqual(addr2.address(), addr.address());
assert.equal(addr2.port(), addr.port());
assert.strictEqual(addr2.type(), addr.type());
assert.deepStrictEqual(addr2.address(), addr.address());
assert.strictEqual(addr2.port(), addr.port());
});
});

View File

@@ -63,11 +63,11 @@ describe("Common", () => {
ee = e;
}
assert.notEqual(ee, null, "Test " + tests[i].sample);
assert.notStrictEqual(ee, null, "Test " + tests[i].sample);
} else {
let data = common.parseIPv4(tests[i].sample);
assert.deepEqual(data, tests[i].expected);
assert.deepStrictEqual(data, tests[i].expected);
}
}
});
@@ -78,28 +78,14 @@ describe("Common", () => {
sample: "2001:db8:1f70:0:999:de8:7648:6e8",
expectingFailure: false,
expected: new Uint16Array([
0x2001,
0xdb8,
0x1f70,
0x0,
0x999,
0xde8,
0x7648,
0x6e8,
0x2001, 0xdb8, 0x1f70, 0x0, 0x999, 0xde8, 0x7648, 0x6e8,
]),
},
{
sample: "2001:db8:85a3::8a2e:370:7334",
expectingFailure: false,
expected: new Uint16Array([
0x2001,
0xdb8,
0x85a3,
0x0,
0x0,
0x8a2e,
0x370,
0x7334,
0x2001, 0xdb8, 0x85a3, 0x0, 0x0, 0x8a2e, 0x370, 0x7334,
]),
},
{
@@ -116,42 +102,21 @@ describe("Common", () => {
sample: "2001:db8:1f70::999:de8:7648:6e8",
expectingFailure: false,
expected: new Uint16Array([
0x2001,
0xdb8,
0x1f70,
0x0,
0x999,
0xde8,
0x7648,
0x6e8,
0x2001, 0xdb8, 0x1f70, 0x0, 0x999, 0xde8, 0x7648, 0x6e8,
]),
},
{
sample: "2001:0db8:ac10:fe01::",
expectingFailure: false,
expected: new Uint16Array([
0x2001,
0x0db8,
0xac10,
0xfe01,
0x0,
0x0,
0x0,
0x0,
0x2001, 0x0db8, 0xac10, 0xfe01, 0x0, 0x0, 0x0, 0x0,
]),
},
{
sample: "::7f00:1",
expectingFailure: false,
expected: new Uint16Array([
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
0x0000,
0x7f00,
0x0001,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7f00, 0x0001,
]),
},
{
@@ -191,11 +156,11 @@ describe("Common", () => {
ee = e;
}
assert.notEqual(ee, null, "Test " + tests[i].sample);
assert.notStrictEqual(ee, null, "Test " + tests[i].sample);
} else {
let data = common.parseIPv6(tests[i].sample);
assert.deepEqual(data, tests[i].expected);
assert.deepStrictEqual(data, tests[i].expected);
}
}
});
@@ -236,14 +201,7 @@ describe("Common", () => {
expectedType: "IPv6",
expectedAddr: new Uint8Array(
new Uint16Array([
0x2001,
0xdb8,
0x1f70,
0x0,
0x999,
0xde8,
0x7648,
0x6e8,
0x2001, 0xdb8, 0x1f70, 0x0, 0x999, 0xde8, 0x7648, 0x6e8,
]).buffer
),
expectedPort: 22,
@@ -253,14 +211,7 @@ describe("Common", () => {
expectedType: "IPv6",
expectedAddr: new Uint8Array(
new Uint16Array([
0x2001,
0xdb8,
0x1f70,
0x0,
0x999,
0xde8,
0x7648,
0x6e8,
0x2001, 0xdb8, 0x1f70, 0x0, 0x999, 0xde8, 0x7648, 0x6e8,
]).buffer
),
expectedPort: 100,
@@ -270,9 +221,9 @@ describe("Common", () => {
for (let i in tests) {
let hostport = common.splitHostPort(tests[i].sample, 22);
assert.deepEqual(hostport.type, tests[i].expectedType);
assert.deepEqual(hostport.addr, tests[i].expectedAddr);
assert.equal(hostport.port, tests[i].expectedPort);
assert.deepStrictEqual(hostport.type, tests[i].expectedType);
assert.deepStrictEqual(hostport.addr, tests[i].expectedAddr);
assert.strictEqual(hostport.port, tests[i].expectedPort);
}
});
});

View File

@@ -28,7 +28,7 @@ describe("Integer", () => {
return data;
});
assert.equal(marshalled.length, 1);
assert.strictEqual(marshalled.length, 1);
r.feed(marshalled);
@@ -36,7 +36,7 @@ describe("Integer", () => {
await i2.unmarshal(r);
assert.equal(i.value(), i2.value());
assert.strictEqual(i.value(), i2.value());
});
it("Integer MAX", async () => {
@@ -47,7 +47,7 @@ describe("Integer", () => {
return data;
});
assert.equal(marshalled.length, 2);
assert.strictEqual(marshalled.length, 2);
r.feed(marshalled);
@@ -55,6 +55,6 @@ describe("Integer", () => {
await i2.unmarshal(r);
assert.equal(i.value(), i2.value());
assert.strictEqual(i.value(), i2.value());
});
});

View File

@@ -32,7 +32,7 @@ describe("String", () => {
let s2 = await strings.String.read(r);
assert.deepEqual(s2.data(), s.data());
assert.deepStrictEqual(s2.data(), s.data());
});
it("String 2", async () => {
@@ -260,6 +260,6 @@ describe("String", () => {
let s2 = await strings.String.read(r);
assert.deepEqual(s2.data(), s.data());
assert.deepStrictEqual(s2.data(), s.data());
});
});