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

@@ -1,6 +1,6 @@
module.exports = {
parserOptions: {
parser: "babel-eslint",
parser: "@babel/eslint-parser",
},
root: true,
env: {
@@ -14,8 +14,9 @@ module.exports = {
],
rules: {
"vue/component-name-in-template-casing": ["error", "PascalCase"],
"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
"no-unused-vars": process.env.NODE_ENV === "production" ? "warn" : "error",
},
globals: {
$nuxt: true,

730
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -5,11 +5,11 @@
"main": "",
"devDependencies": {
"@babel/core": "^7.14.6",
"@babel/eslint-parser": "^7.14.7",
"@babel/plugin-transform-runtime": "^7.14.5",
"@babel/preset-env": "^7.14.7",
"@babel/register": "^7.14.5",
"@babel/runtime": "^7.14.6",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.2",
"buffer": "^6.0.3",
"clean-webpack-plugin": "^3.0.0",
@@ -18,9 +18,9 @@
"css-minimizer-webpack-plugin": "^3.0.2",
"eslint": "^7.30.0",
"eslint-config-prettier": "^8.3.0",
"eslint-loader": "^4.0.2",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-vue": "^7.13.0",
"eslint-webpack-plugin": "^2.5.4",
"favicons": "^6.2.2",
"favicons-webpack-plugin": "^5.0.2",
"file-loader": "^6.2.0",
@@ -44,7 +44,7 @@
"vue": "^2.6.14",
"vue-loader": "^15.9.7",
"vue-template-compiler": "^2.6.14",
"webpack": "^5.43.0",
"webpack": "^5.44.0",
"webpack-cli": "^4.7.2",
"xterm": "^4.13.0",
"xterm-addon-fit": "^0.5.0",

View File

@@ -173,6 +173,7 @@ export class Address {
throw new Exception("Host name cannot longer than " + MAX_ADDR_LEN);
}
{
let dataBuf = new Uint8Array(this.addrData.length + 3);
dataBuf[0] = (this.addrPort >> 8) & 0xff;
@@ -183,6 +184,7 @@ export class Address {
dataBuf.set(this.addrData, 3);
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());
});
});

View File

@@ -259,6 +259,7 @@ class Parser {
return;
}
{
let dim = this.callbacks.getWindowDim(),
dimData = new DataView(new ArrayBuffer(4));
@@ -275,6 +276,7 @@ class Parser {
this.options.nawsAccpeted = true;
this.sendWillSubNego(cmdWill, dimBytes, optNAWS);
}
return;
case optTerminalType:

View File

@@ -101,7 +101,7 @@ export function build(ctx) {
inbound: 0,
inboundHistory: inboundHistory.get(),
outbound: 0,
outboundHistory: outboundHistory.get()
outboundHistory: outboundHistory.get(),
},
connecting() {
isClosed = false;
@@ -201,6 +201,6 @@ export function build(ctx) {
this.classStyle = "red flash";
this.windowClass = "red";
this.status.description = connectionStatusDisconnected + ". Error: " + e;
}
},
};
}

View File

@@ -22,116 +22,11 @@ describe("Common", () => {
it("separateBuffer", async () => {
let resultArr = [];
const expected = new Uint8Array([
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3,
4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1,
2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5,
6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
]),
sepSeg = common.separateBuffer(expected, 16);
@@ -141,6 +36,6 @@ describe("Common", () => {
const result = new Uint8Array(resultArr);
assert.deepEqual(result, expected);
assert.deepStrictEqual(result, expected);
});
});

View File

@@ -26,10 +26,10 @@ describe("Header", () => {
let n = new header.Header(h.value());
assert.equal(h.type(), n.type());
assert.equal(h.data(), n.data());
assert.equal(n.type(), header.CONTROL);
assert.equal(n.data(), 63);
assert.strictEqual(h.type(), n.type());
assert.strictEqual(h.data(), n.data());
assert.strictEqual(n.type(), header.CONTROL);
assert.strictEqual(n.data(), 63);
});
it("Stream", () => {
@@ -37,11 +37,11 @@ describe("Header", () => {
h.set(header.STREAM_MAX_MARKER, header.STREAM_MAX_LENGTH);
assert.equal(h.marker(), header.STREAM_MAX_MARKER);
assert.equal(h.length(), header.STREAM_MAX_LENGTH);
assert.strictEqual(h.marker(), header.STREAM_MAX_MARKER);
assert.strictEqual(h.length(), header.STREAM_MAX_LENGTH);
assert.equal(h.headerByte1, 0xff);
assert.equal(h.headerByte2, 0xff);
assert.strictEqual(h.headerByte1, 0xff);
assert.strictEqual(h.headerByte2, 0xff);
});
it("InitialStream", () => {
@@ -49,8 +49,8 @@ describe("Header", () => {
h.set(15, 128, true);
assert.equal(h.command(), 15);
assert.equal(h.data(), 128);
assert.equal(h.success(), true);
assert.strictEqual(h.command(), 15);
assert.strictEqual(h.data(), 128);
assert.strictEqual(h.success(), true);
});
});

View File

@@ -27,15 +27,15 @@ describe("Reader", () => {
let ex = buf.export(1);
assert.equal(ex.length, 1);
assert.equal(ex[0], 0);
assert.equal(buf.remains(), 7);
assert.strictEqual(ex.length, 1);
assert.strictEqual(ex[0], 0);
assert.strictEqual(buf.remains(), 7);
ex = await reader.readCompletely(buf);
assert.equal(ex.length, 7);
assert.deepEqual(ex, new Uint8Array([1, 2, 3, 4, 5, 6, 7]));
assert.equal(buf.remains(), 0);
assert.strictEqual(ex.length, 7);
assert.deepStrictEqual(ex, new Uint8Array([1, 2, 3, 4, 5, 6, 7]));
assert.strictEqual(buf.remains(), 0);
});
it("Reader", async () => {
@@ -45,30 +45,7 @@ describe("Reader", () => {
return data;
}),
expected = [
0,
1,
2,
3,
4,
5,
6,
7,
0,
1,
2,
3,
4,
5,
6,
7,
0,
1,
2,
3,
4,
5,
6,
7,
0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
],
feedIntv = setInterval(() => {
r.feed(Uint8Array.from(expected.slice(0, 8)));
@@ -88,7 +65,7 @@ describe("Reader", () => {
result.push((await r.export(1))[0]);
}
assert.deepEqual(result, expected);
assert.deepStrictEqual(result, expected);
});
it("readOne", async () => {
@@ -102,11 +79,11 @@ describe("Reader", () => {
let rr = await reader.readOne(r);
assert.deepEqual(rr, Uint8Array.from([0]));
assert.deepStrictEqual(rr, Uint8Array.from([0]));
rr = await reader.readOne(r);
assert.deepEqual(rr, Uint8Array.from([1]));
assert.deepStrictEqual(rr, Uint8Array.from([1]));
});
it("readN", async () => {
@@ -120,11 +97,11 @@ describe("Reader", () => {
let rr = await reader.readN(r, 3);
assert.deepEqual(rr, Uint8Array.from([0, 1, 2]));
assert.deepStrictEqual(rr, Uint8Array.from([0, 1, 2]));
rr = await reader.readN(r, 3);
assert.deepEqual(rr, Uint8Array.from([3, 4, 5]));
assert.deepStrictEqual(rr, Uint8Array.from([3, 4, 5]));
});
it("Limited", async () => {
@@ -153,8 +130,8 @@ describe("Reader", () => {
result.push((await limited.export(1))[0]);
}
assert.equal(limited.completed(), true);
assert.deepEqual(result, expected);
assert.strictEqual(limited.completed(), true);
assert.deepStrictEqual(result, expected);
});
it("readCompletely", async () => {
@@ -179,8 +156,8 @@ describe("Reader", () => {
let result = await reader.readCompletely(limited);
assert.equal(limited.completed(), true);
assert.deepEqual(result, Uint8Array.from(expected));
assert.strictEqual(limited.completed(), true);
assert.deepStrictEqual(result, Uint8Array.from(expected));
});
it("readUntil", async () => {
@@ -207,14 +184,14 @@ describe("Reader", () => {
let result = await reader.readUntil(limited, 7);
assert.equal(limited.completed(), false);
assert.deepEqual(result.data, expected1);
assert.deepEqual(result.found, true);
assert.strictEqual(limited.completed(), false);
assert.deepStrictEqual(result.data, expected1);
assert.deepStrictEqual(result.found, true);
result = await reader.readUntil(limited, 7);
assert.equal(limited.completed(), true);
assert.deepEqual(result.data, expected2);
assert.deepEqual(result.found, false);
assert.strictEqual(limited.completed(), true);
assert.deepStrictEqual(result.data, expected2);
assert.deepStrictEqual(result.found, false);
});
});

View File

@@ -66,7 +66,7 @@ describe("Sender", () => {
await sendCompleted;
assert.deepEqual(new Uint8Array(result), expected);
assert.deepStrictEqual(new Uint8Array(result), expected);
});
it("Send (Multiple calls)", async () => {
@@ -116,6 +116,6 @@ describe("Sender", () => {
await sendCompleted;
assert.deepEqual(new Uint8Array(result), expected);
assert.deepStrictEqual(new Uint8Array(result), expected);
});
});

View File

@@ -27,7 +27,8 @@ const webpack = require("webpack"),
FaviconsWebpackPlugin = require("favicons-webpack-plugin"),
CopyPlugin = require("copy-webpack-plugin"),
TerserPlugin = require("terser-webpack-plugin"),
{ CleanWebpackPlugin } = require("clean-webpack-plugin");
{ CleanWebpackPlugin } = require("clean-webpack-plugin"),
ESLintPlugin = require("eslint-webpack-plugin");
const inDevMode = process.env.NODE_ENV === "development";
@@ -281,6 +282,7 @@ module.exports = {
handlebarsLoader: {},
},
}),
new ESLintPlugin({}),
new CopyPlugin({
patterns: [
{