Commit 1cf0b812 authored by Martin Lowe's avatar Martin Lowe 🇨🇦
Browse files

Update TS files based on feedback, add TS linting

parent d5f88153
......@@ -17,6 +17,21 @@
"parserOptions": {
"requireConfigFile": false
},
"overrides": [
{
"files": ["src/**/*.ts"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/no-non-null-assertion": ["off"]
}
}
],
"rules": {
"max-len": [2, 140, 2],
"eqeqeq": 2,
......
......@@ -33,7 +33,8 @@
"@types/parse-link-header": "^2.0.0",
"@types/simple-oauth2": "^4.1.1",
"@types/uuid": "^8.3.4",
"@typescript-eslint/parser": "^5.23.0",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"chai": "^4.2.0",
"eslint": "^7.5.0",
"eslint-config-strongloop": "^2.1.0",
......@@ -911,6 +912,12 @@
"resolved": "https://registry.npmjs.org/@types/json-buffer/-/json-buffer-3.0.0.tgz",
"integrity": "sha512-3YP80IxxFJB4b5tYC2SUPwkg0XQLiu0nWvhRgEatgjf+29IcWO9X1k8xRv5DGssJ/lCrjYTjQPcobJr2yWIVuQ=="
},
"node_modules/@types/json-schema": {
"version": "7.0.11",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz",
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
"dev": true
},
"node_modules/@types/keyv": {
"version": "3.1.4",
"resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz",
......@@ -974,16 +981,73 @@
"resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz",
"integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA=="
},
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "5.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.27.0.tgz",
"integrity": "sha512-DDrIA7GXtmHXr1VCcx9HivA39eprYBIFxbQEHI6NyraRDxCGpxAFiYQAT/1Y0vh1C+o2vfBiy4IuPoXxtTZCAQ==",
"dev": true,
"dependencies": {
"@typescript-eslint/scope-manager": "5.27.0",
"@typescript-eslint/type-utils": "5.27.0",
"@typescript-eslint/utils": "5.27.0",
"debug": "^4.3.4",
"functional-red-black-tree": "^1.0.1",
"ignore": "^5.2.0",
"regexpp": "^3.2.0",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz",
"integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==",
"dev": true,
"engines": {
"node": ">= 4"
}
},
"node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": {
"version": "7.3.7",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz",
"integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==",
"dev": true,
"dependencies": {
"lru-cache": "^6.0.0"
},
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/@typescript-eslint/parser": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.23.0.tgz",
"integrity": "sha512-V06cYUkqcGqpFjb8ttVgzNF53tgbB/KoQT/iB++DOIExKmzI9vBJKjZKt/6FuV9c+zrDsvJKbJ2DOCYwX91cbw==",
"version": "5.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.27.0.tgz",
"integrity": "sha512-8oGjQF46c52l7fMiPPvX4It3u3V3JipssqDfHQ2hcR0AeR8Zge+OYyKUCm5b70X72N1qXt0qgHenwN6Gc2SXZA==",
"dev": true,
"dependencies": {
"@typescript-eslint/scope-manager": "5.23.0",
"@typescript-eslint/types": "5.23.0",
"@typescript-eslint/typescript-estree": "5.23.0",
"debug": "^4.3.2"
"@typescript-eslint/scope-manager": "5.27.0",
"@typescript-eslint/types": "5.27.0",
"@typescript-eslint/typescript-estree": "5.27.0",
"debug": "^4.3.4"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
......@@ -1002,13 +1066,31 @@
}
},
"node_modules/@typescript-eslint/scope-manager": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.23.0.tgz",
"integrity": "sha512-EhjaFELQHCRb5wTwlGsNMvzK9b8Oco4aYNleeDlNuL6qXWDF47ch4EhVNPh8Rdhf9tmqbN4sWDk/8g+Z/J8JVw==",
"version": "5.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.27.0.tgz",
"integrity": "sha512-VnykheBQ/sHd1Vt0LJ1JLrMH1GzHO+SzX6VTXuStISIsvRiurue/eRkTqSrG0CexHQgKG8shyJfR4o5VYioB9g==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.27.0",
"@typescript-eslint/visitor-keys": "5.27.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/type-utils": {
"version": "5.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.27.0.tgz",
"integrity": "sha512-vpTvRRchaf628Hb/Xzfek+85o//zEUotr1SmexKvTfs7czXfYjXVT/a5yDbpzLBX1rhbqxjDdr1Gyo0x1Fc64g==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.23.0",
"@typescript-eslint/visitor-keys": "5.23.0"
"@typescript-eslint/utils": "5.27.0",
"debug": "^4.3.4",
"tsutils": "^3.21.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
......@@ -1016,12 +1098,20 @@
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "*"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/@typescript-eslint/types": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.23.0.tgz",
"integrity": "sha512-NfBsV/h4dir/8mJwdZz7JFibaKC3E/QdeMEDJhiAE3/eMkoniZ7MjbEMCGXw6MZnZDMN3G9S0mH/6WUIj91dmw==",
"version": "5.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.27.0.tgz",
"integrity": "sha512-lY6C7oGm9a/GWhmUDOs3xAVRz4ty/XKlQ2fOLr8GAIryGn0+UBOoJDWyHer3UgrHkenorwvBnphhP+zPmzmw0A==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
......@@ -1032,17 +1122,17 @@
}
},
"node_modules/@typescript-eslint/typescript-estree": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.23.0.tgz",
"integrity": "sha512-xE9e0lrHhI647SlGMl+m+3E3CKPF1wzvvOEWnuE3CCjjT7UiRnDGJxmAcVKJIlFgK6DY9RB98eLr1OPigPEOGg==",
"version": "5.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.27.0.tgz",
"integrity": "sha512-QywPMFvgZ+MHSLRofLI7BDL+UczFFHyj0vF5ibeChDAJgdTV8k4xgEwF0geFhVlPc1p8r70eYewzpo6ps+9LJQ==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.23.0",
"@typescript-eslint/visitor-keys": "5.23.0",
"debug": "^4.3.2",
"globby": "^11.0.4",
"@typescript-eslint/types": "5.27.0",
"@typescript-eslint/visitor-keys": "5.27.0",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
"semver": "^7.3.5",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
},
"engines": {
......@@ -1073,14 +1163,56 @@
"node": ">=10"
}
},
"node_modules/@typescript-eslint/utils": {
"version": "5.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.27.0.tgz",
"integrity": "sha512-nZvCrkIJppym7cIbP3pOwIkAefXOmfGPnCM0LQfzNaKxJHI6VjI8NC662uoiPlaf5f6ymkTy9C3NQXev2mdXmA==",
"dev": true,
"dependencies": {
"@types/json-schema": "^7.0.9",
"@typescript-eslint/scope-manager": "5.27.0",
"@typescript-eslint/types": "5.27.0",
"@typescript-eslint/typescript-estree": "5.27.0",
"eslint-scope": "^5.1.1",
"eslint-utils": "^3.0.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
}
},
"node_modules/@typescript-eslint/utils/node_modules/eslint-utils": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz",
"integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==",
"dev": true,
"dependencies": {
"eslint-visitor-keys": "^2.0.0"
},
"engines": {
"node": "^10.0.0 || ^12.0.0 || >= 14.0.0"
},
"funding": {
"url": "https://github.com/sponsors/mysticatea"
},
"peerDependencies": {
"eslint": ">=5"
}
},
"node_modules/@typescript-eslint/visitor-keys": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.23.0.tgz",
"integrity": "sha512-Vd4mFNchU62sJB8pX19ZSPog05B0Y0CE2UxAZPT5k4iqhRYjPnqyY3woMxCd0++t9OTqkgjST+1ydLBi7e2Fvg==",
"version": "5.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.27.0.tgz",
"integrity": "sha512-46cYrteA2MrIAjv9ai44OQDUoCZyHeGIc4lsjCUX2WT6r4C+kidz1bNiR4017wHOPUythYeH+Sc7/cFP97KEAA==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.23.0",
"eslint-visitor-keys": "^3.0.0"
"@typescript-eslint/types": "5.27.0",
"eslint-visitor-keys": "^3.3.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
......@@ -5984,6 +6116,12 @@
"resolved": "https://registry.npmjs.org/@types/json-buffer/-/json-buffer-3.0.0.tgz",
"integrity": "sha512-3YP80IxxFJB4b5tYC2SUPwkg0XQLiu0nWvhRgEatgjf+29IcWO9X1k8xRv5DGssJ/lCrjYTjQPcobJr2yWIVuQ=="
},
"@types/json-schema": {
"version": "7.0.11",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz",
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
"dev": true
},
"@types/keyv": {
"version": "3.1.4",
"resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz",
......@@ -6047,46 +6185,91 @@
"resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz",
"integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA=="
},
"@typescript-eslint/eslint-plugin": {
"version": "5.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.27.0.tgz",
"integrity": "sha512-DDrIA7GXtmHXr1VCcx9HivA39eprYBIFxbQEHI6NyraRDxCGpxAFiYQAT/1Y0vh1C+o2vfBiy4IuPoXxtTZCAQ==",
"dev": true,
"requires": {
"@typescript-eslint/scope-manager": "5.27.0",
"@typescript-eslint/type-utils": "5.27.0",
"@typescript-eslint/utils": "5.27.0",
"debug": "^4.3.4",
"functional-red-black-tree": "^1.0.1",
"ignore": "^5.2.0",
"regexpp": "^3.2.0",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
},
"dependencies": {
"ignore": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz",
"integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==",
"dev": true
},
"semver": {
"version": "7.3.7",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz",
"integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==",
"dev": true,
"requires": {
"lru-cache": "^6.0.0"
}
}
}
},
"@typescript-eslint/parser": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.23.0.tgz",
"integrity": "sha512-V06cYUkqcGqpFjb8ttVgzNF53tgbB/KoQT/iB++DOIExKmzI9vBJKjZKt/6FuV9c+zrDsvJKbJ2DOCYwX91cbw==",
"version": "5.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.27.0.tgz",
"integrity": "sha512-8oGjQF46c52l7fMiPPvX4It3u3V3JipssqDfHQ2hcR0AeR8Zge+OYyKUCm5b70X72N1qXt0qgHenwN6Gc2SXZA==",
"dev": true,
"requires": {
"@typescript-eslint/scope-manager": "5.23.0",
"@typescript-eslint/types": "5.23.0",
"@typescript-eslint/typescript-estree": "5.23.0",
"debug": "^4.3.2"
"@typescript-eslint/scope-manager": "5.27.0",
"@typescript-eslint/types": "5.27.0",
"@typescript-eslint/typescript-estree": "5.27.0",
"debug": "^4.3.4"
}
},
"@typescript-eslint/scope-manager": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.23.0.tgz",
"integrity": "sha512-EhjaFELQHCRb5wTwlGsNMvzK9b8Oco4aYNleeDlNuL6qXWDF47ch4EhVNPh8Rdhf9tmqbN4sWDk/8g+Z/J8JVw==",
"version": "5.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.27.0.tgz",
"integrity": "sha512-VnykheBQ/sHd1Vt0LJ1JLrMH1GzHO+SzX6VTXuStISIsvRiurue/eRkTqSrG0CexHQgKG8shyJfR4o5VYioB9g==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.23.0",
"@typescript-eslint/visitor-keys": "5.23.0"
"@typescript-eslint/types": "5.27.0",
"@typescript-eslint/visitor-keys": "5.27.0"
}
},
"@typescript-eslint/type-utils": {
"version": "5.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.27.0.tgz",
"integrity": "sha512-vpTvRRchaf628Hb/Xzfek+85o//zEUotr1SmexKvTfs7czXfYjXVT/a5yDbpzLBX1rhbqxjDdr1Gyo0x1Fc64g==",
"dev": true,
"requires": {
"@typescript-eslint/utils": "5.27.0",
"debug": "^4.3.4",
"tsutils": "^3.21.0"
}
},
"@typescript-eslint/types": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.23.0.tgz",
"integrity": "sha512-NfBsV/h4dir/8mJwdZz7JFibaKC3E/QdeMEDJhiAE3/eMkoniZ7MjbEMCGXw6MZnZDMN3G9S0mH/6WUIj91dmw==",
"version": "5.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.27.0.tgz",
"integrity": "sha512-lY6C7oGm9a/GWhmUDOs3xAVRz4ty/XKlQ2fOLr8GAIryGn0+UBOoJDWyHer3UgrHkenorwvBnphhP+zPmzmw0A==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.23.0.tgz",
"integrity": "sha512-xE9e0lrHhI647SlGMl+m+3E3CKPF1wzvvOEWnuE3CCjjT7UiRnDGJxmAcVKJIlFgK6DY9RB98eLr1OPigPEOGg==",
"version": "5.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.27.0.tgz",
"integrity": "sha512-QywPMFvgZ+MHSLRofLI7BDL+UczFFHyj0vF5ibeChDAJgdTV8k4xgEwF0geFhVlPc1p8r70eYewzpo6ps+9LJQ==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.23.0",
"@typescript-eslint/visitor-keys": "5.23.0",
"debug": "^4.3.2",
"globby": "^11.0.4",
"@typescript-eslint/types": "5.27.0",
"@typescript-eslint/visitor-keys": "5.27.0",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
"semver": "^7.3.5",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
},
"dependencies": {
......@@ -6101,14 +6284,39 @@
}
}
},
"@typescript-eslint/utils": {
"version": "5.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.27.0.tgz",
"integrity": "sha512-nZvCrkIJppym7cIbP3pOwIkAefXOmfGPnCM0LQfzNaKxJHI6VjI8NC662uoiPlaf5f6ymkTy9C3NQXev2mdXmA==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.9",
"@typescript-eslint/scope-manager": "5.27.0",
"@typescript-eslint/types": "5.27.0",
"@typescript-eslint/typescript-estree": "5.27.0",
"eslint-scope": "^5.1.1",
"eslint-utils": "^3.0.0"
},
"dependencies": {
"eslint-utils": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz",
"integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==",
"dev": true,
"requires": {
"eslint-visitor-keys": "^2.0.0"
}
}
}
},
"@typescript-eslint/visitor-keys": {
"version": "5.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.23.0.tgz",
"integrity": "sha512-Vd4mFNchU62sJB8pX19ZSPog05B0Y0CE2UxAZPT5k4iqhRYjPnqyY3woMxCd0++t9OTqkgjST+1ydLBi7e2Fvg==",
"version": "5.27.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.27.0.tgz",
"integrity": "sha512-46cYrteA2MrIAjv9ai44OQDUoCZyHeGIc4lsjCUX2WT6r4C+kidz1bNiR4017wHOPUythYeH+Sc7/cFP97KEAA==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.23.0",
"eslint-visitor-keys": "^3.0.0"
"@typescript-eslint/types": "5.27.0",
"eslint-visitor-keys": "^3.3.0"
},
"dependencies": {
"eslint-visitor-keys": {
......
......@@ -81,7 +81,7 @@ export class EclipseAPI {
let result = [];
let data = [];
// add timestamp to url to avoid browser caching
var url = 'https://projects.eclipse.org/api/projects' + queryStringParams;
let url = 'https://projects.eclipse.org/api/projects' + queryStringParams;
// loop through all available users, and add them to a list to be returned
do {
this.logger.silly('Loading next page...');
......@@ -90,7 +90,7 @@ export class EclipseAPI {
.get(url)
.then(r => {
// return the data to the user
let links = parse(r.headers.link);
const links = parse(r.headers.link);
// check if we should continue processing
if (links === null || links!.self.url === links!.last.url) {
hasMore = false;
......@@ -104,10 +104,8 @@ export class EclipseAPI {
});
// collect the results
if (result != null && result.length > 0) {
for (var i = 0; i < result.length; i++) {
data.push(result[i]);
}
if (result !== null && result.length > 0) {
data = [...data, ...result];
}
} while (hasMore && paginate);
return data;
......@@ -117,7 +115,8 @@ export class EclipseAPI {
* Retrieves an eclipse foundation user using the given username, returning null if the user cannot be found.
*
* @param username the username to retrieve data for
* @returns the Eclipse Foundation user account data, enhanced with sensitive information if oauth is configured. Returns null if user cannot be found.
* @returns the Eclipse Foundation user account data, enhanced with sensitive information if oauth is configured. Returns
* null if user cannot be found.
*/
async eclipseUser(username: string): Promise<EclipseUser | null> {
if (this.config.verbose) {
......@@ -137,7 +136,7 @@ export class EclipseAPI {
if (this.config.verbose) {
this.logger.debug('EclipseAPI:eclipseBots()');
}
var botsRaw = await axios
const botsRaw = await axios
.get('https://api.eclipse.org/bots')
.then(result => result.data)
.catch(err => this.logger.error(`${err}`));
......@@ -155,35 +154,29 @@ export class EclipseAPI {
* @param site the site targeted for bots to limit results
* @returns a mapping of project to configured bot usernames.
*/
processBots(botsRaw: BotDefinition[], site: string = 'github.com'): Record<string, string[]> {
processBots(botsRaw: BotDefinition[], site = 'github.com'): Record<string, string[]> {
if (this.config.verbose) {
this.logger.debug(`EclipseAPI:processBots(botsRaw = ${JSON.stringify(botsRaw)}, site = ${site})`);
}
let rgx = new RegExp(`^${site}.*`);
var botMap: Record<string, string[]> = {};
for (var botIdx in botsRaw) {
let bot = botsRaw[botIdx];
const rgx = new RegExp(`^${site}.*`);
const botMap: Record<string, string[]> = {};
botsRaw.forEach(bot => {
// get the list of bots for project if already created
var projBots = botMap[bot.projectId];
let projBots = botMap[bot.projectId];
if (projBots === undefined) {
projBots = [];
}
// get usernames for site + sub resource bots
let botKeys = Object.keys(bot);
for (let idx in botKeys) {
let key = botKeys[idx];
// if there is a match (either direct or sub resource match) push the bot name to the list
let match = key.match(rgx);
if (match) {
Object.keys(bot).forEach(key => {
if (key.match(rgx)) {
projBots.push(bot[key].username);
}
}
});
// dont add empty arrays to output
if (projBots.length === 0) {
continue;
if (projBots.length !== 0) {
botMap[bot.projectId] = projBots;
}
botMap[bot.projectId] = projBots;
}
});
return botMap;
}
......@@ -194,7 +187,7 @@ export class EclipseAPI {
* @returns request configs including authentication headers if auth is configured, or empty config otherwise.
*/
async getAuthenticationHeaders(): Promise<AxiosRequestConfig> {
let token = await this._getAccessToken();
const token = await this._getAccessToken();
if (token === null) {
this.logger.info('Authentication token cannot be retrieved, information returned mey be limited');
return {};
......@@ -234,7 +227,7 @@ export class EclipseAPI {
return null;
}
generateDefaultConfigs(useStaging: boolean = false): EclipseApiConfig {
generateDefaultConfigs(useStaging = false): EclipseApiConfig {
if (useStaging) {
return {
webroots: {
......@@ -244,16 +237,15 @@ export class EclipseAPI {
testMode: false,
verbose: false,
};
} else {
return {
webroots: {
projects: 'https://projects.eclipse.org',
api: 'https://api.eclipse.org',
},
testMode: false,
verbose: false,
};
}
return {
webroots: {
projects: 'https://projects.eclipse.org',
api: 'https://api.eclipse.org',
},
testMode: false,
verbose: false,
};
}
}
......
......@@ -15,8 +15,8 @@ import { getLogger, isNodeErr } from './logger';
import fs from 'fs';
import { Logger } from 'winston';
export const DEFAULT_FILE_ENCODING: string = 'utf-8';
export const DEFAULT_SECRET_LOCATION: string = '/run/secrets/';
export const DEFAULT_FILE_ENCODING = 'utf-8';
export const DEFAULT_SECRET_LOCATION = '/run/secrets/';
export interface SecretReaderConfig {
root?: string;
...