Bring back eslint.

This commit is contained in:
Daniel Scalzi 2020-05-24 19:11:34 -04:00
parent dc7386f19d
commit 7ef375db7a
No known key found for this signature in database
GPG Key ID: D18EA3FB4B142A57
26 changed files with 508 additions and 200 deletions

View File

@ -1,66 +1,49 @@
{
"env": {
"es2017": true,
"node": true
},
"extends": "eslint:recommended",
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended"
],
"parserOptions": {
"ecmaVersion": 2019,
"sourceType": "module"
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"indent": [
"error",
4,
{
"SwitchCase": 1
}
],
"linebreak-style": [
"error",
"windows"
],
"quotes": [
"error",
"single"
],
"semi": [
"semi": "off",
"@typescript-eslint/semi": [
"error",
"never"
],
"no-var": [
"error"
"quotes": "off",
"@typescript-eslint/quotes": [
"error",
"single"
],
"no-console": [
0
"indent": "off",
"@typescript-eslint/indent": [
"error",
4
],
"no-control-regex": [
0
],
"no-unused-vars": [
"@typescript-eslint/member-delimiter-style": [
"error",
{
"vars": "all",
"args": "none",
"ignoreRestSiblings": false,
"argsIgnorePattern": "reject"
"multiline": {
"delimiter": "none",
"requireLast": false
},
"singleline": {
"delimiter": "comma",
"requireLast": false
}
}
],
"no-async-promise-executor": [
0
]
},
"overrides": [
{
"files": [ "src/scripts/*.js" ],
"rules": {
"no-unused-vars": [
0
],
"no-undef": [
0
]
}
}
]
"@typescript-eslint/no-non-null-assertion": "off"
}
}

66
.eslintrc.json.old Normal file
View File

@ -0,0 +1,66 @@
{
"env": {
"es2017": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2019,
"sourceType": "module"
},
"rules": {
"indent": [
"error",
4,
{
"SwitchCase": 1
}
],
"linebreak-style": [
"error",
"windows"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"never"
],
"no-var": [
"error"
],
"no-console": [
0
],
"no-control-regex": [
0
],
"no-unused-vars": [
"error",
{
"vars": "all",
"args": "none",
"ignoreRestSiblings": false,
"argsIgnorePattern": "reject"
}
],
"no-async-promise-executor": [
0
]
},
"overrides": [
{
"files": [ "src/scripts/*.js" ],
"rules": {
"no-unused-vars": [
0
],
"no-undef": [
0
]
}
}
]
}

1
.gitignore vendored
View File

@ -5,3 +5,4 @@
/logs/
/dist/
/out/
/old/

254
package-lock.json generated
View File

@ -1251,6 +1251,24 @@
"regenerator-runtime": "^0.13.2"
}
},
"@babel/runtime-corejs3": {
"version": "7.9.6",
"resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.9.6.tgz",
"integrity": "sha512-6toWAfaALQjt3KMZQc6fABqZwUDDuWzz+cAfPhqyEnzxvdWOAkjwPNxgF8xlmo7OWLsSjaKjsskpKHRLaMArOA==",
"dev": true,
"requires": {
"core-js-pure": "^3.0.0",
"regenerator-runtime": "^0.13.4"
},
"dependencies": {
"regenerator-runtime": {
"version": "0.13.5",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz",
"integrity": "sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA==",
"dev": true
}
}
},
"@babel/template": {
"version": "7.8.6",
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.8.6.tgz",
@ -1592,6 +1610,12 @@
"integrity": "sha512-Ee0vt82qcg05OeJrQZ/YN+NQwaBCnAul1rVLYaMLPkwR5f44WC3BpBQNvn5Z3Axu9szaVOHqXEDBI+uAXAiyrg==",
"dev": true
},
"@types/eslint-visitor-keys": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz",
"integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==",
"dev": true
},
"@types/events": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz",
@ -1648,6 +1672,12 @@
"@types/sizzle": "*"
}
},
"@types/json-schema": {
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.4.tgz",
"integrity": "sha512-8+KAKzEvSUdeo+kmqnKrqgeE+LcA0tjYWFY7RPProVYwnqDjukzO+3b6dLD56rYX5TdWejnEOLJYOIeh4CXKuA==",
"dev": true
},
"@types/keyv": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.1.tgz",
@ -1861,6 +1891,58 @@
"integrity": "sha512-FA/BWv8t8ZWJ+gEOnLLd8ygxH/2UFbAvgEonyfN6yWGLKc7zVjbpl2Y4CTjid9h2RfgPP6SEt6uHwEOply00yw==",
"dev": true
},
"@typescript-eslint/eslint-plugin": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.0.0.tgz",
"integrity": "sha512-lcZ0M6jD4cqGccYOERKdMtg+VWpoq3NSnWVxpc/AwAy0zhkUYVioOUZmfNqiNH8/eBNGhCn6HXd6mKIGRgNc1Q==",
"dev": true,
"requires": {
"@typescript-eslint/experimental-utils": "3.0.0",
"functional-red-black-tree": "^1.0.1",
"regexpp": "^3.0.0",
"semver": "^7.3.2",
"tsutils": "^3.17.1"
}
},
"@typescript-eslint/experimental-utils": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.0.0.tgz",
"integrity": "sha512-BN0vmr9N79M9s2ctITtChRuP1+Dls0x/wlg0RXW1yQ7WJKPurg6X3Xirv61J2sjPif4F8SLsFMs5Nzte0WYoTQ==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
"@typescript-eslint/typescript-estree": "3.0.0",
"eslint-scope": "^5.0.0",
"eslint-utils": "^2.0.0"
}
},
"@typescript-eslint/parser": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.0.0.tgz",
"integrity": "sha512-8RRCA9KLxoFNO0mQlrLZA0reGPd/MsobxZS/yPFj+0/XgMdS8+mO8mF3BDj2ZYQj03rkayhSJtF1HAohQ3iylw==",
"dev": true,
"requires": {
"@types/eslint-visitor-keys": "^1.0.0",
"@typescript-eslint/experimental-utils": "3.0.0",
"@typescript-eslint/typescript-estree": "3.0.0",
"eslint-visitor-keys": "^1.1.0"
}
},
"@typescript-eslint/typescript-estree": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.0.0.tgz",
"integrity": "sha512-nevQvHyNghsfLrrByzVIH4ZG3NROgJ8LZlfh3ddwPPH4CH7W4GAiSx5qu+xHuX5pWsq6q/eqMc1io840ZhAnUg==",
"dev": true,
"requires": {
"debug": "^4.1.1",
"eslint-visitor-keys": "^1.1.0",
"glob": "^7.1.6",
"is-glob": "^4.0.1",
"lodash": "^4.17.15",
"semver": "^7.3.2",
"tsutils": "^3.17.1"
}
},
"@webassemblyjs/ast": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.9.0.tgz",
@ -2298,6 +2380,17 @@
"integrity": "sha512-hNfzcOV8W4NdualtqBFPyVO+54DSJuZGY9qT4pRroB6S9e3iiido2ISIC5h9R2sPJ8H3FHCIiEnsv1lPXO3KtQ==",
"dev": true
},
"array-includes": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.1.tgz",
"integrity": "sha512-c2VXaCHl7zPsvpkFsw4nxvFie4fh1ur9bpcgsVkIjqn0H/Xwdg+7fv3n2r/isyS8EBj5b06M9kHyZuIr4El6WQ==",
"dev": true,
"requires": {
"define-properties": "^1.1.3",
"es-abstract": "^1.17.0",
"is-string": "^1.0.5"
}
},
"array-union": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz",
@ -3806,6 +3899,12 @@
}
}
},
"core-js-pure": {
"version": "3.6.5",
"resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.6.5.tgz",
"integrity": "sha512-lacdXOimsiD0QyNf9BC/mxivNJ/ybBGJXQFKzRekp1WTHoVUWsUHEn+2T8GJAzzIhyOuXA+gOxCVN3l+5PLPUA==",
"dev": true
},
"core-util-is": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
@ -5459,6 +5558,36 @@
}
}
},
"eslint-plugin-react": {
"version": "7.20.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.20.0.tgz",
"integrity": "sha512-rqe1abd0vxMjmbPngo4NaYxTcR3Y4Hrmc/jg4T+sYz63yqlmJRknpEQfmWY+eDWPuMmix6iUIK+mv0zExjeLgA==",
"dev": true,
"requires": {
"array-includes": "^3.1.1",
"doctrine": "^2.1.0",
"has": "^1.0.3",
"jsx-ast-utils": "^2.2.3",
"object.entries": "^1.1.1",
"object.fromentries": "^2.0.2",
"object.values": "^1.1.1",
"prop-types": "^15.7.2",
"resolve": "^1.15.1",
"string.prototype.matchall": "^4.0.2",
"xregexp": "^4.3.0"
},
"dependencies": {
"doctrine": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz",
"integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==",
"dev": true,
"requires": {
"esutils": "^2.0.2"
}
}
}
},
"eslint-scope": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz",
@ -7815,6 +7944,17 @@
"ipaddr.js": "^1.9.0"
}
},
"internal-slot": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.2.tgz",
"integrity": "sha512-2cQNfwhAfJIkU4KZPkDI+Gj5yNNnbqi40W9Gge6dfnk4TocEVm00B3bdiL+JINrbGJil2TeHvM4rETGzk/f/0g==",
"dev": true,
"requires": {
"es-abstract": "^1.17.0-next.1",
"has": "^1.0.3",
"side-channel": "^1.0.2"
}
},
"interpret": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/interpret/-/interpret-1.2.0.tgz",
@ -8096,6 +8236,12 @@
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz",
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ="
},
"is-string": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz",
"integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==",
"dev": true
},
"is-symbol": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz",
@ -8309,6 +8455,16 @@
"verror": "1.10.0"
}
},
"jsx-ast-utils": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.2.3.tgz",
"integrity": "sha512-EdIHFMm+1BPynpKOpdPqiOsvnIrInRGJD7bzPZdPkjitQEqpdpUuFpq4T0npZFKTiB3RhWFdGN+oqOJIdhDhQA==",
"dev": true,
"requires": {
"array-includes": "^3.0.3",
"object.assign": "^4.1.0"
}
},
"keyv": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.1.tgz",
@ -9530,6 +9686,50 @@
"object-keys": "^1.0.11"
}
},
"object.entries": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.2.tgz",
"integrity": "sha512-BQdB9qKmb/HyNdMNWVr7O3+z5MUIx3aiegEIJqjMBbBf0YT9RRxTJSim4mzFqtyr7PDAHigq0N9dO0m0tRakQA==",
"dev": true,
"requires": {
"define-properties": "^1.1.3",
"es-abstract": "^1.17.5",
"has": "^1.0.3"
},
"dependencies": {
"es-abstract": {
"version": "1.17.5",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.5.tgz",
"integrity": "sha512-BR9auzDbySxOcfog0tLECW8l28eRGpDpU3Dm3Hp4q/N+VtLTmyj4EUN088XZWQDW/hzj6sYRDXeOFsaAODKvpg==",
"dev": true,
"requires": {
"es-to-primitive": "^1.2.1",
"function-bind": "^1.1.1",
"has": "^1.0.3",
"has-symbols": "^1.0.1",
"is-callable": "^1.1.5",
"is-regex": "^1.0.5",
"object-inspect": "^1.7.0",
"object-keys": "^1.1.1",
"object.assign": "^4.1.0",
"string.prototype.trimleft": "^2.1.1",
"string.prototype.trimright": "^2.1.1"
}
}
}
},
"object.fromentries": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.2.tgz",
"integrity": "sha512-r3ZiBH7MQppDJVLx6fhD618GKNG40CZYH9wgwdhKxBDDbQgjeWGGd4AtkZad84d291YxvWe7bJGuE65Anh0dxQ==",
"dev": true,
"requires": {
"define-properties": "^1.1.3",
"es-abstract": "^1.17.0-next.1",
"function-bind": "^1.1.1",
"has": "^1.0.3"
}
},
"object.getownpropertydescriptors": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.0.tgz",
@ -9549,6 +9749,18 @@
"isobject": "^3.0.1"
}
},
"object.values": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.1.tgz",
"integrity": "sha512-WTa54g2K8iu0kmS/us18jEmdv1a4Wi//BZ/DTVYEcH0XhLM5NYdpDHja3gt57VrZLcNAO2WGA+KpWsDBaHt6eA==",
"dev": true,
"requires": {
"define-properties": "^1.1.3",
"es-abstract": "^1.17.0-next.1",
"function-bind": "^1.1.1",
"has": "^1.0.3"
}
},
"obuf": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/obuf/-/obuf-1.1.2.tgz",
@ -11354,6 +11566,16 @@
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=",
"dev": true
},
"side-channel": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.2.tgz",
"integrity": "sha512-7rL9YlPHg7Ancea1S96Pa8/QWb4BtXL/TZvS6B8XFetGBeuhAsfmUspK6DokBeZ64+Kj9TCNRD/30pVz1BvQNA==",
"dev": true,
"requires": {
"es-abstract": "^1.17.0-next.1",
"object-inspect": "^1.7.0"
}
},
"signal-exit": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
@ -11861,6 +12083,20 @@
}
}
},
"string.prototype.matchall": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.2.tgz",
"integrity": "sha512-N/jp6O5fMf9os0JU3E72Qhf590RSRZU/ungsL/qJUYVTNv7hTG0P/dbPjxINVN9jpscu3nzYwKESU3P3RY5tOg==",
"dev": true,
"requires": {
"define-properties": "^1.1.3",
"es-abstract": "^1.17.0",
"has-symbols": "^1.0.1",
"internal-slot": "^1.0.2",
"regexp.prototype.flags": "^1.3.0",
"side-channel": "^1.0.2"
}
},
"string.prototype.trimleft": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz",
@ -12375,6 +12611,15 @@
"integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==",
"dev": true
},
"tsutils": {
"version": "3.17.1",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz",
"integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==",
"dev": true,
"requires": {
"tslib": "^1.8.1"
}
},
"tty-browserify": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz",
@ -13694,6 +13939,15 @@
"integrity": "sha1-jdi/Rfw/f1Xw4FS4ePQ6YmFNr98=",
"dev": true
},
"xregexp": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/xregexp/-/xregexp-4.3.0.tgz",
"integrity": "sha512-7jXDIFXh5yJ/orPn4SXjuVrWWoi4Cr8jfV1eHv9CixKSbU+jY4mxfrBwAuDvupPNKpMUY+FeIqsVw/JLT9+B8g==",
"dev": true,
"requires": {
"@babel/runtime-corejs3": "^7.8.3"
}
},
"xtend": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",

View File

@ -62,6 +62,8 @@
"@types/tar-fs": "^2.0.0",
"@types/triple-beam": "^1.3.1",
"@types/winreg": "^1.2.30",
"@typescript-eslint/eslint-plugin": "^3.0.0",
"@typescript-eslint/parser": "^3.0.0",
"chai": "^4.2.0",
"cross-env": "^7.0.2",
"electron": "^8.3.0",
@ -69,6 +71,7 @@
"electron-webpack": "^2.8.2",
"electron-webpack-ts": "^4.0.1",
"eslint": "^7.1.0",
"eslint-plugin-react": "^7.20.0",
"helios-distribution-types": "1.0.0-pre.1",
"mocha": "^7.2.0",
"nock": "^12.0.3",

View File

@ -2,9 +2,9 @@ export class AssetGuardError extends Error {
code?: string
stack!: string
error?: Partial<Error & {code?: string;}>
error?: Partial<Error & {code?: string}>
constructor(message: string, error?: Partial<Error & {code?: string;}>) {
constructor(message: string, error?: Partial<Error & {code?: string}>) {
super(message)
Error.captureStackTrace(this, this.constructor)
@ -16,16 +16,16 @@ export class AssetGuardError extends Error {
this.code = error?.code
if (error.stack != null) {
const indexOfMessage = this.stack.indexOf(this.message) + this.message.length;
const thisStackTrace = this.stack.slice(indexOfMessage).split('\n').reverse();
const errorStackTrace = error.stack.slice(error.stack.indexOf(error.message!) + error.message!.length).split('\n').reverse();
const indexOfMessage = this.stack.indexOf(this.message) + this.message.length
const thisStackTrace = this.stack.slice(indexOfMessage).split('\n').reverse()
const errorStackTrace = error.stack.slice(error.stack.indexOf(error.message!) + error.message!.length).split('\n').reverse()
// Remove duplicated traces
while (errorStackTrace.length !== 0 && errorStackTrace[0] === thisStackTrace[0]) {
thisStackTrace.shift();
thisStackTrace.shift()
}
this.stack = `${this.stack.slice(0, indexOfMessage)}${thisStackTrace.reverse().join('\n')}${errorStackTrace.reverse().join('\n')}`;
this.stack = `${this.stack.slice(0, indexOfMessage)}${thisStackTrace.reverse().join('\n')}${errorStackTrace.reverse().join('\n')}`
}
}

View File

@ -77,7 +77,7 @@ export class MojangIndexProcessor extends IndexProcessor {
* complete init when 3 files are validated and loaded.
*
*/
public async init() {
public async init(): Promise<void> {
const versionManifest = await this.loadVersionManifest()
this.versionJson = await this.loadVersionJson(this.version, versionManifest)
@ -103,7 +103,7 @@ export class MojangIndexProcessor extends IndexProcessor {
}
const hash = this.getVersionJsonHash(versionJsonUrl)
if(hash == null) {
throw new AssetGuardError(`Format of Mojang's version manifest has changed. Unable to proceed.`)
throw new AssetGuardError('Format of Mojang\'s version manifest has changed. Unable to proceed.')
}
const versionJson = await this.loadContentWithRemoteFallback<VersionJson>(versionJsonUrl, versionJsonPath, { algo: 'sha1', value: hash })
if(versionJson == null) {
@ -186,7 +186,8 @@ export class MojangIndexProcessor extends IndexProcessor {
}
// TODO progress tracker
public async validate() {
// TODO type return object
public async validate(): Promise<any> {
const assets = await this.validateAssets(this.assetIndex)
const libraries = await this.validateLibraries(this.versionJson)
@ -239,8 +240,10 @@ export class MojangIndexProcessor extends IndexProcessor {
if(libEntry.natives == null) {
artifact = libEntry.downloads.artifact
} else {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const classifier = libEntry.natives[getMojangOS()].replace('${arch}', process.arch.replace('x', ''))
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
artifact = libEntry.downloads.classifiers[classifier]
}

View File

@ -23,7 +23,7 @@ export class ConfigManager {
*
* @returns {string} The absolute path of the launcher directory.
*/
public static getLauncherDirectory(){
public static getLauncherDirectory(): string {
return ConfigManager.launcherDir
}
@ -33,7 +33,7 @@ export class ConfigManager {
*
* @returns {string} The absolute path of the launcher's data directory.
*/
public static getDataDirectory(def = false){
public static getDataDirectory(def = false): string {
return !def ? ConfigManager.config.settings.launcher.dataDirectory : ConfigManager.DEFAULT_CONFIG.settings.launcher.dataDirectory
}
@ -42,7 +42,7 @@ export class ConfigManager {
*
* @param {string} dataDirectory The new data directory.
*/
public static setDataDirectory(dataDirectory: string){
public static setDataDirectory(dataDirectory: string): void {
ConfigManager.config.settings.launcher.dataDirectory = dataDirectory
}
@ -94,12 +94,12 @@ export class ConfigManager {
private static config: LauncherConfig = null as unknown as LauncherConfig
public static getAbsoluteMinRAM(){
public static getAbsoluteMinRAM(): number {
const mem = totalmem()
return mem >= 6000000000 ? 3 : 2
}
public static getAbsoluteMaxRAM(){
public static getAbsoluteMaxRAM(): number {
const mem = totalmem()
const gT16 = mem-16000000000
return Math.floor((mem-1000000000-(gT16 > 0 ? (Number.parseInt(gT16/8 as unknown as string) + 16000000000/4) : mem/4))/1000000000)
@ -119,7 +119,7 @@ export class ConfigManager {
/**
* Save the current configuration to a file.
*/
public static save(){
public static save(): void {
writeFileSync(ConfigManager.configPath, JSON.stringify(ConfigManager.config, null, 4), 'UTF-8')
}
@ -129,7 +129,7 @@ export class ConfigManager {
* be generated. Note that "resolved" values default to null and will
* need to be externally assigned.
*/
public static load(){
public static load(): void {
let doLoad = true
if(!pathExistsSync(ConfigManager.configPath)){
@ -228,7 +228,7 @@ export class ConfigManager {
*
* @param {Object} newsCache The new news cache object.
*/
public static setNewsCache(newsCache: any): void {
public static setNewsCache(newsCache: NewsCache): void {
ConfigManager.config.newsCache = newsCache
}
@ -391,8 +391,8 @@ export class ConfigManager {
*/
public static getSelectedAccount(): SavedAccount | null {
return ConfigManager.config.selectedAccount == null ?
null :
ConfigManager.config.authenticationDatabase[ConfigManager.config.selectedAccount]
null :
ConfigManager.config.authenticationDatabase[ConfigManager.config.selectedAccount]
}
/**

View File

@ -1,6 +1,6 @@
import { SavedAccount } from './SavedAccount';
import { NewsCache } from './NewsCache';
import { ModConfig } from './ModConfig';
import { SavedAccount } from './SavedAccount'
import { NewsCache } from './NewsCache'
import { ModConfig } from './ModConfig'
export interface LauncherConfig {
@ -27,7 +27,7 @@ export interface LauncherConfig {
clientToken: string | null
selectedServer: string | null
selectedAccount: string | null
authenticationDatabase: {[uuid: string]: SavedAccount},
authenticationDatabase: {[uuid: string]: SavedAccount}
modConfigurations: ModConfig[]
}

View File

@ -1,11 +1,11 @@
import { createLogger, format, transports } from 'winston'
import { createLogger, format, transports, Logger } from 'winston'
import { SPLAT } from 'triple-beam'
import moment from 'moment'
import { inspect } from 'util'
export class LoggerUtil {
public static getLogger(label: string) {
public static getLogger(label: string): Logger {
return createLogger({
format: format.combine(
format.label(),
@ -19,6 +19,7 @@ export class LoggerUtil {
info.message = info.message.substring(0, info.message.length-err.message.length)
}
} else if(info[SPLAT].length > 0) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
info.message += ' ' + info[SPLAT].map((it: any) => {
if(typeof it === 'object' && it != null) {
return inspect(it, false, null, true)

View File

@ -1,4 +1,4 @@
import { RequestError } from "got/dist/source"
import { RequestError } from 'got'
/**
* @see https://wiki.vg/Authentication#Errors
@ -74,18 +74,12 @@ export function deciperResponseCode(body: MojangErrorBody): MojangResponseCode {
// These indicate problems with the code and not the data.
export function isInternalError(responseCode: MojangResponseCode): boolean {
switch(responseCode) {
// We've sent the wrong method to an endpoint. (ex. GET to POST)
case MojangResponseCode.ERROR_METHOD_NOT_ALLOWED:
// Indicates endpoint has changed. (404)
case MojangResponseCode.ERROR_NOT_FOUND:
// Selecting profiles isn't implemented yet. (Shouldnt happen)
case MojangResponseCode.ERROR_ACCESS_TOKEN_HAS_PROFILE:
// Username/password was not submitted. (UI should forbid this)
case MojangResponseCode.ERROR_CREDENTIALS_ARE_NULL:
// ??? (Shouldnt happen)
case MojangResponseCode.ERROR_INVALID_SALT_VERSION:
// Data was not submitted as application/json
case MojangResponseCode.ERROR_UNSUPPORTED_MEDIA_TYPE:
case MojangResponseCode.ERROR_METHOD_NOT_ALLOWED: // We've sent the wrong method to an endpoint. (ex. GET to POST)
case MojangResponseCode.ERROR_NOT_FOUND: // Indicates endpoint has changed. (404)
case MojangResponseCode.ERROR_ACCESS_TOKEN_HAS_PROFILE: // Selecting profiles isn't implemented yet. (Shouldnt happen)
case MojangResponseCode.ERROR_CREDENTIALS_ARE_NULL: // Username/password was not submitted. (UI should forbid this)
case MojangResponseCode.ERROR_INVALID_SALT_VERSION: // ??? (Shouldnt happen)
case MojangResponseCode.ERROR_UNSUPPORTED_MEDIA_TYPE: // Data was not submitted as application/json
return true
default:
return false

View File

@ -75,7 +75,7 @@ export class Mojang {
* are 'green', 'yellow', 'red', and 'grey'. Grey is a custom status
* to our project which represents an unknown status.
*/
public static statusToHex(status: string){
public static statusToHex(status: string): string {
switch(status.toLowerCase()){
case StatusColor.GREEN:
return '#a5c325'
@ -181,7 +181,7 @@ export class Mojang {
username: string,
password: string,
clientToken: string | null,
requestUser: boolean = true,
requestUser = true,
agent: Agent = Mojang.MINECRAFT_AGENT
): Promise<MojangResponse<Session | null>> {
@ -291,7 +291,7 @@ export class Mojang {
*
* @see http://wiki.vg/Authentication#Refresh
*/
public static async refresh(accessToken: string, clientToken: string, requestUser: boolean = true): Promise<MojangResponse<Session | null>> {
public static async refresh(accessToken: string, clientToken: string, requestUser = true): Promise<MojangResponse<Session | null>> {
try {

View File

@ -2,7 +2,7 @@ import { createHash } from 'crypto'
import { join } from 'path'
import { pathExists, readFile } from 'fs-extra'
export function calculateHash(buf: Buffer, algo: string) {
export function calculateHash(buf: Buffer, algo: string): string {
return createHash(algo).update(buf).digest('hex')
}
@ -21,14 +21,14 @@ function getVersionExtPath(commonDir: string, version: string, ext: string) {
return join(commonDir, 'versions', version, `${version}.${ext}`)
}
export function getVersionJsonPath(commonDir: string, version: string) {
export function getVersionJsonPath(commonDir: string, version: string): string {
return getVersionExtPath(commonDir, version, 'json')
}
export function getVersionJarPath(commonDir: string, version: string) {
export function getVersionJarPath(commonDir: string, version: string): string {
return getVersionExtPath(commonDir, version, 'jar')
}
export function getLibraryDir(commonDir: string) {
export function getLibraryDir(commonDir: string): string {
return join(commonDir, 'libraries')
}

View File

@ -1,4 +1,4 @@
import { Rule, Natives } from "../asset/model/mojang/VersionJson"
import { Rule, Natives } from '../asset/model/mojang/VersionJson'
export function getMojangOS(): string {
const opSys = process.platform
@ -47,7 +47,7 @@ export function isLibraryCompatible(rules?: Rule[], natives?: Natives): boolean
* @param {string} desired The desired version.
* @param {string} actual The actual version.
*/
export function mcVersionAtLeast(desired: string, actual: string){
export function mcVersionAtLeast(desired: string, actual: string): boolean {
const des = desired.split('.')
const act = actual.split('.')

View File

@ -1,20 +1,20 @@
import { ipcMain, app, BrowserWindow, Menu, MenuItem } from "electron"
import { prerelease } from "semver"
import { join } from "path"
import { readdirSync } from "fs-extra"
import { format } from "url"
import { ipcMain, app, BrowserWindow, Menu, MenuItem } from 'electron'
import { prerelease } from 'semver'
import { join } from 'path'
import { readdirSync } from 'fs-extra'
import { format } from 'url'
import { autoUpdater } from 'electron-updater'
import isdev from "../common/util/isdev"
import isdev from '../common/util/isdev'
const installExtensions = async () => {
const installer = require('electron-devtools-installer');
const forceDownload = !!process.env.UPGRADE_EXTENSIONS;
const extensions = ['REACT_DEVELOPER_TOOLS', 'REDUX_DEVTOOLS'];
const installer = require('electron-devtools-installer')
const forceDownload = !!process.env.UPGRADE_EXTENSIONS
const extensions = ['REACT_DEVELOPER_TOOLS', 'REDUX_DEVTOOLS']
return Promise.all(
extensions.map(name => installer.default(installer[name], forceDownload))
).catch(console.log); // eslint-disable-line no-console
};
).catch(console.log) // eslint-disable-line no-console
}
// Setup auto updater.
function initAutoUpdater(event: any, data: any) {
@ -100,7 +100,7 @@ let win: BrowserWindow | null
async function createWindow() {
if (process.env.NODE_ENV !== 'production') {
await installExtensions();
await installExtensions()
}
win = new BrowserWindow({
@ -147,8 +147,8 @@ async function createWindow() {
if (process.env.NODE_ENV !== 'production') {
// Open DevTools, see https://github.com/electron/electron/issues/12438 for why we wait for dom-ready
win.webContents.once('dom-ready', () => {
win!.webContents.openDevTools();
});
win!.webContents.openDevTools()
})
}
win.on('closed', () => {
@ -161,7 +161,7 @@ function createMenu() {
if(process.platform === 'darwin') {
// Extend default included application menu to continue support for quit keyboard shortcut
let applicationSubMenu = new MenuItem({
const applicationSubMenu = new MenuItem({
label: 'Application',
submenu: [{
label: 'About Application',
@ -179,7 +179,7 @@ function createMenu() {
})
// New edit menu adds support for text-editing keyboard shortcuts
let editSubMenu = new MenuItem({
const editSubMenu = new MenuItem({
label: 'Edit',
submenu: [
{
@ -219,8 +219,8 @@ function createMenu() {
})
// Bundle submenus into a single template and build a menu object with it
let menuTemplate: MenuItem[] = [applicationSubMenu, editSubMenu]
let menuObject = Menu.buildFromTemplate(menuTemplate)
const menuTemplate: MenuItem[] = [applicationSubMenu, editSubMenu]
const menuObject = Menu.buildFromTemplate(menuTemplate)
// Assign it to the application
Menu.setApplicationMenu(menuObject)

View File

@ -1,12 +1,12 @@
import { hot } from 'react-hot-loader/root';
import * as React from 'react';
import Frame from './frame/Frame';
import Welcome from './welcome/Welcome';
import { connect } from 'react-redux';
import { View } from '../meta/Views';
import Landing from './landing/Landing';
import Login from './login/Login';
import Settings from './settings/Settings';
import { hot } from 'react-hot-loader/root'
import * as React from 'react'
import Frame from './frame/Frame'
import Welcome from './welcome/Welcome'
import { connect } from 'react-redux'
import { View } from '../meta/Views'
import Landing from './landing/Landing'
import Login from './login/Login'
import Settings from './settings/Settings'
import './Application.css'
@ -55,4 +55,4 @@ const connected = connect((state: any) => ({
currentView: state.currentView
}), undefined)(Application)
export default hot(connected);
export default hot(connected)

View File

@ -1,10 +1,10 @@
import * as React from 'react';
import { remote } from 'electron';
import './Frame.css';
import * as React from 'react'
import { remote } from 'electron'
import './Frame.css'
function closeHandler() {
const window = remote.getCurrentWindow();
window.close();
const window = remote.getCurrentWindow()
window.close()
}
function restoreDownHandler() {
@ -23,40 +23,40 @@ function minimizeHandler() {
(document.activeElement as HTMLElement).blur()
}
const Frame = () => (
const Frame = (): JSX.Element => (
<div id="frameBar">
<div id="frameResizableTop" className="frameDragPadder"></div>
<div id="frameMain">
<div className="frameResizableVert frameDragPadder"></div>
{ process.platform === 'darwin' ?
<div id="frameContentDarwin">
<div id="frameButtonDockDarwin">
<button className="frameButtonDarwin" onClick={closeHandler} id="frameButtonDarwin_close" tabIndex={-1}></button>
<button className="frameButtonDarwin" onClick={minimizeHandler} id="frameButtonDarwin_minimize" tabIndex={-1}></button>
<button className="frameButtonDarwin" onClick={restoreDownHandler} id="frameButtonDarwin_restoredown" tabIndex={-1}></button>
<div id="frameResizableTop" className="frameDragPadder"></div>
<div id="frameMain">
<div className="frameResizableVert frameDragPadder"></div>
{ process.platform === 'darwin' ?
<div id="frameContentDarwin">
<div id="frameButtonDockDarwin">
<button className="frameButtonDarwin" onClick={closeHandler} id="frameButtonDarwin_close" tabIndex={-1}></button>
<button className="frameButtonDarwin" onClick={minimizeHandler} id="frameButtonDarwin_minimize" tabIndex={-1}></button>
<button className="frameButtonDarwin" onClick={restoreDownHandler} id="frameButtonDarwin_restoredown" tabIndex={-1}></button>
</div>
</div>
</div>
:
<div id="frameContentWin">
<div id="frameTitleDock">
<span id="frameTitleText">Helios Launcher</span>
:
<div id="frameContentWin">
<div id="frameTitleDock">
<span id="frameTitleText">Helios Launcher</span>
</div>
<div id="frameButtonDockWin">
<button className="frameButton" onClick={minimizeHandler} id="frameButton_minimize" tabIndex={-1}>
<svg name="TitleBarMinimize" width="10" height="10" viewBox="0 0 12 12"><rect stroke="#ffffff" fill="#ffffff" width="10" height="1" x="1" y="6"></rect></svg>
</button>
<button className="frameButton" onClick={restoreDownHandler} id="frameButton_restoredown" tabIndex={-1}>
<svg name="TitleBarMaximize" width="10" height="10" viewBox="0 0 12 12"><rect width="9" height="9" x="1.5" y="1.5" fill="none" stroke="#ffffff" strokeWidth="1.4px"></rect></svg>
</button>
<button className="frameButton" onClick={closeHandler} id="frameButton_close" tabIndex={-1}>
<svg name="TitleBarClose" width="10" height="10" viewBox="0 0 12 12"><polygon stroke="#ffffff" fill="#ffffff" fillRule="evenodd" points="11 1.576 6.583 6 11 10.424 10.424 11 6 6.583 1.576 11 1 10.424 5.417 6 1 1.576 1.576 1 6 5.417 10.424 1"></polygon></svg>
</button>
</div>
</div>
<div id="frameButtonDockWin">
<button className="frameButton" onClick={minimizeHandler} id="frameButton_minimize" tabIndex={-1}>
<svg name="TitleBarMinimize" width="10" height="10" viewBox="0 0 12 12"><rect stroke="#ffffff" fill="#ffffff" width="10" height="1" x="1" y="6"></rect></svg>
</button>
<button className="frameButton" onClick={restoreDownHandler} id="frameButton_restoredown" tabIndex={-1}>
<svg name="TitleBarMaximize" width="10" height="10" viewBox="0 0 12 12"><rect width="9" height="9" x="1.5" y="1.5" fill="none" stroke="#ffffff" strokeWidth="1.4px"></rect></svg>
</button>
<button className="frameButton" onClick={closeHandler} id="frameButton_close" tabIndex={-1}>
<svg name="TitleBarClose" width="10" height="10" viewBox="0 0 12 12"><polygon stroke="#ffffff" fill="#ffffff" fillRule="evenodd" points="11 1.576 6.583 6 11 10.424 10.424 11 6 6.583 1.576 11 1 10.424 5.417 6 1 1.576 1.576 1 6 5.417 10.424 1"></polygon></svg>
</button>
</div>
</div>
}
<div className="frameResizableVert frameDragPadder"></div>
}
<div className="frameResizableVert frameDragPadder"></div>
</div>
</div>
</div>
);
)
export default Frame;
export default Frame

View File

@ -2,7 +2,7 @@ import * as React from 'react'
export default class Landing extends React.Component {
render() {
render(): JSX.Element {
return <>
LANDING TBD
</>

View File

@ -15,9 +15,9 @@ type LoginProperties = {
}
type LoginState = {
rememberMe: boolean,
userValid: boolean,
passValid: boolean,
rememberMe: boolean
userValid: boolean
passValid: boolean
status: LoginStatus
}
@ -113,7 +113,7 @@ export default class Login extends React.Component<LoginProperties, LoginState>
})
}
render() {
render(): JSX.Element {
return (
<>
<div id="loginContainer">
@ -154,7 +154,7 @@ export default class Login extends React.Component<LoginProperties, LoginState>
id="loginButton"
disabled={!this.canSave()}
onClick={this.handleLoginButtonClick}
{...(this.isLoading() ? {loading: "true"} : {})}>
{...(this.isLoading() ? {loading: 'true'} : {})}>
<div id="loginButtonContent">
{this.getButtonText()}
<svg id="loginSVG" viewBox="0 0 24.87 13.97">

View File

@ -8,15 +8,15 @@ enum FieldError {
}
type LoginFieldProps = {
password: boolean,
disabled: boolean,
password: boolean
disabled: boolean
onValidityChange: (valid: boolean) => void
}
type LoginFieldState = {
errorText: FieldError,
hasError: boolean,
shake: boolean,
errorText: FieldError
hasError: boolean
shake: boolean
value: string
}
@ -42,9 +42,10 @@ export default class LoginField extends React.Component<LoginFieldProps, LoginFi
this.errorSpanRef = React.createRef()
}
componentDidUpdate() {
componentDidUpdate(): void {
if(this.internalTrigger) {
if(this.state.hasError) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore Opacity is a number, not a string..
this.errorSpanRef.current!.style.opacity = 1
if(this.state.shake) {
@ -53,6 +54,7 @@ export default class LoginField extends React.Component<LoginFieldProps, LoginFi
this.errorSpanRef.current!.classList.add(this.SHAKE_CLASS)
}
} else {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore Opacity is a number, not a string..
this.errorSpanRef.current!.style.opacity = 0
}
@ -158,7 +160,7 @@ export default class LoginField extends React.Component<LoginFieldProps, LoginFi
this.getValidateFunction()((event.target as HTMLInputElement).value, false)
}
render() {
render(): JSX.Element {
return (
<>
<div className="loginFieldContainer">

View File

@ -2,7 +2,7 @@ import * as React from 'react'
export default class Settings extends React.Component {
render() {
render(): JSX.Element {
return <>
SETTINGS TBD
</>

View File

@ -1,12 +1,12 @@
import * as React from 'react';
import './Welcome.css';
import * as React from 'react'
import './Welcome.css'
const Welcome = () => (
const Welcome = (): JSX.Element => (
<div id="welcomeContainer">
<div id="welcomeContent">
<img id="welcomeImageSeal" src="../images/SealCircle.png"/>
<span id="welcomeHeader">WELCOME TO HELIOS LAUNCHER</span>
<span id="welcomeDescription">Our mission is to provide modded servers with a simple and reliable client. When a server needs more than vanilla minecraft offers, they turn to modding platforms to fill in the gaps. Managing and deploying client updates can be difficult and time consuming. Helios Launcher provides a platform to handle all of this for you through a customized, simple, and elegant client. It shouldn't be hard to play modded minecraft. It's shouldn't be hard to set up Java. With Helios, it isn't. Let's get going.</span>
<span id="welcomeDescription">Our mission is to provide modded servers with a simple and reliable client. When a server needs more than vanilla minecraft offers, they turn to modding platforms to fill in the gaps. Managing and deploying client updates can be difficult and time consuming. Helios Launcher provides a platform to handle all of this for you through a customized, simple, and elegant client. It shouldn&apos;t be hard to play modded minecraft. It&apos;s shouldn&apos;t be hard to set up Java. With Helios, it isn&apos;t. Let&apos;s get going.</span>
<br />
<span id="welcomeDescCTA">You are just a few clicks away from the game.</span>
<button id="welcomeButton">
@ -19,6 +19,6 @@ const Welcome = () => (
</button>
</div>
</div>
);
)
export default Welcome;
export default Welcome

View File

@ -1,15 +1,15 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { AppContainer } from 'react-hot-loader';
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import { AppContainer } from 'react-hot-loader'
import store from './redux/store'
import './index.css';
import './index.css'
import Application from './components/Application';
import { Provider } from 'react-redux';
import Application from './components/Application'
import { Provider } from 'react-redux'
// Create main element
const mainElement = document.createElement('div');
document.body.appendChild(mainElement);
const mainElement = document.createElement('div')
document.body.appendChild(mainElement)
// Render components
ReactDOM.render(
@ -19,7 +19,7 @@ ReactDOM.render(
</Provider>
</AppContainer>,
mainElement
);
)
// setTimeout(() => {
// console.log('firing')

View File

@ -1,5 +1,5 @@
import { View } from "../../meta/Views";
import { Action } from "redux";
import { View } from '../../meta/Views'
import { Action } from 'redux'
export enum ViewActionType {
ChangeView = 'CHANGE_VIEW'

View File

@ -1,5 +1,5 @@
import { combineReducers } from "redux";
import ViewReducer from "./viewReducer";
import { combineReducers } from 'redux'
import ViewReducer from './viewReducer'
export default combineReducers({
currentView: ViewReducer

View File

@ -1,3 +1,4 @@
/* eslint-disable */
import { combineReducers, createStore, Reducer, Action, AnyAction } from 'redux'
const userReducer: Reducer<any, AnyAction> = (state = {name: 'Name1', age: 0}, action) => {