Update doctestts, add lint config

This commit is contained in:
pietervdvn 2022-04-08 17:59:14 +02:00
parent 55dd4c58ee
commit 2f2e58faff
5 changed files with 108 additions and 21 deletions

View file

@ -33,24 +33,27 @@ import ExtraLinkButton from "./BigComponents/ExtraLinkButton";
* Adds a welcome pane, contorl buttons, ... etc to index.html * Adds a welcome pane, contorl buttons, ... etc to index.html
*/ */
export default class DefaultGUI { export default class DefaultGUI {
private readonly _guiState: DefaultGuiState; private readonly guiState: DefaultGuiState;
private readonly state: FeaturePipelineState; private readonly state: FeaturePipelineState;
constructor(state: FeaturePipelineState, guiState: DefaultGuiState) { constructor(state: FeaturePipelineState, guiState: DefaultGuiState) {
this.state = state; this.state = state;
this._guiState = guiState; this.guiState = guiState;
if (state.layoutToUse.customCss !== undefined) { }
Utils.LoadCustomCss(state.layoutToUse.customCss);
public setup(){
if (this.state.layoutToUse.customCss !== undefined) {
Utils.LoadCustomCss(this.state.layoutToUse.customCss);
} }
this.SetupUIElements(); this.SetupUIElements();
this.SetupMap() this.SetupMap()
if (state.layoutToUse.customCss !== undefined && window.location.pathname.indexOf("index") >= 0) { if (this.state.layoutToUse.customCss !== undefined && window.location.pathname.indexOf("index") >= 0) {
Utils.LoadCustomCss(state.layoutToUse.customCss) Utils.LoadCustomCss(this.state.layoutToUse.customCss)
} }
} }
@ -125,7 +128,7 @@ export default class DefaultGUI {
private SetupMap() { private SetupMap() {
const state = this.state; const state = this.state;
const guiState = this._guiState; const guiState = this.guiState;
// Attach the map // Attach the map
state.mainMapObject.SetClass("w-full h-full") state.mainMapObject.SetClass("w-full h-full")
@ -155,7 +158,7 @@ export default class DefaultGUI {
private SetupUIElements() { private SetupUIElements() {
const state = this.state; const state = this.state;
const guiState = this._guiState; const guiState = this.guiState;
const self = this const self = this
new Combine([ new Combine([
@ -210,8 +213,8 @@ export default class DefaultGUI {
} }
private InitWelcomeMessage(): BaseUIElement { private InitWelcomeMessage(): BaseUIElement {
const isOpened = this._guiState.welcomeMessageIsOpened const isOpened = this.guiState.welcomeMessageIsOpened
const fullOptions = new FullWelcomePaneWithTabs(isOpened, this._guiState.welcomeMessageOpenedTab, this.state); const fullOptions = new FullWelcomePaneWithTabs(isOpened, this.guiState.welcomeMessageOpenedTab, this.state);
// ?-Button on Desktop, opens panel with close-X. // ?-Button on Desktop, opens panel with close-X.
const help = new MapControlButton(Svg.help_svg()); const help = new MapControlButton(Svg.help_svg());

View file

@ -36,7 +36,7 @@ class Init {
// This 'leaks' the global state via the window object, useful for debugging // This 'leaks' the global state via the window object, useful for debugging
// @ts-ignore // @ts-ignore
window.mapcomplete_state = State.state; window.mapcomplete_state = State.state;
new DefaultGUI(State.state, guiState) new DefaultGUI(State.state, guiState).setup()
} }
} }

26
package-lock.json generated
View file

@ -26,7 +26,7 @@
"@types/wikidata-sdk": "^6.1.0", "@types/wikidata-sdk": "^6.1.0",
"@types/xml2js": "^0.4.9", "@types/xml2js": "^0.4.9",
"country-language": "^0.1.7", "country-language": "^0.1.7",
"doctest-ts-improved": "^0.8.5", "doctest-ts-improved": "^0.8.6",
"email-validator": "^2.0.4", "email-validator": "^2.0.4",
"escape-html": "^1.0.3", "escape-html": "^1.0.3",
"geojson2svg": "^1.3.1", "geojson2svg": "^1.3.1",
@ -6024,14 +6024,15 @@
"integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==" "integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA=="
}, },
"node_modules/doctest-ts-improved": { "node_modules/doctest-ts-improved": {
"version": "0.8.5", "version": "0.8.6",
"resolved": "https://registry.npmjs.org/doctest-ts-improved/-/doctest-ts-improved-0.8.5.tgz", "resolved": "https://registry.npmjs.org/doctest-ts-improved/-/doctest-ts-improved-0.8.6.tgz",
"integrity": "sha512-4zU8fQV263CU3jAi+K7xohhT9b2ZDGw20M4O7AgzW1IoKklmNkSlHMoKZX6gqN1DAouo08R+MD5aSgACG5ILRw==", "integrity": "sha512-J7fXMJ29ve6DUsUHKEO5bOwGmYjhNZd88L7NMVDKIiLIiUCJ9zkR2k7IZOGjMC0RXw/q788REawcMUgIj+7Muw==",
"dependencies": { "dependencies": {
"@types/chai": "^4.3.0", "@types/chai": "^4.3.0",
"chai": "^4.3.6", "chai": "^4.3.6",
"global": "^4.3.2", "global": "^4.3.2",
"mocha": "^9.2.2", "mocha": "^9.2.2",
"process-yargs-parser": "^2.1.0",
"typescript": "^4.6.2" "typescript": "^4.6.2"
}, },
"bin": { "bin": {
@ -12326,6 +12327,11 @@
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
}, },
"node_modules/process-yargs-parser": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/process-yargs-parser/-/process-yargs-parser-2.1.0.tgz",
"integrity": "sha512-tzMsZn3lKksICtEhICR/k+Qv1UmQNVtzm0FaL10OiGJtw0ixgw0woNefcREDc6ZjqXOKBSruRagyULuwZ4FK4Q=="
},
"node_modules/prompt-sync": { "node_modules/prompt-sync": {
"version": "4.2.0", "version": "4.2.0",
"resolved": "https://registry.npmjs.org/prompt-sync/-/prompt-sync-4.2.0.tgz", "resolved": "https://registry.npmjs.org/prompt-sync/-/prompt-sync-4.2.0.tgz",
@ -21413,14 +21419,15 @@
"integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==" "integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA=="
}, },
"doctest-ts-improved": { "doctest-ts-improved": {
"version": "0.8.5", "version": "0.8.6",
"resolved": "https://registry.npmjs.org/doctest-ts-improved/-/doctest-ts-improved-0.8.5.tgz", "resolved": "https://registry.npmjs.org/doctest-ts-improved/-/doctest-ts-improved-0.8.6.tgz",
"integrity": "sha512-4zU8fQV263CU3jAi+K7xohhT9b2ZDGw20M4O7AgzW1IoKklmNkSlHMoKZX6gqN1DAouo08R+MD5aSgACG5ILRw==", "integrity": "sha512-J7fXMJ29ve6DUsUHKEO5bOwGmYjhNZd88L7NMVDKIiLIiUCJ9zkR2k7IZOGjMC0RXw/q788REawcMUgIj+7Muw==",
"requires": { "requires": {
"@types/chai": "^4.3.0", "@types/chai": "^4.3.0",
"chai": "^4.3.6", "chai": "^4.3.6",
"global": "^4.3.2", "global": "^4.3.2",
"mocha": "^9.2.2", "mocha": "^9.2.2",
"process-yargs-parser": "^2.1.0",
"typescript": "^4.6.2" "typescript": "^4.6.2"
}, },
"dependencies": { "dependencies": {
@ -26306,6 +26313,11 @@
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
}, },
"process-yargs-parser": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/process-yargs-parser/-/process-yargs-parser-2.1.0.tgz",
"integrity": "sha512-tzMsZn3lKksICtEhICR/k+Qv1UmQNVtzm0FaL10OiGJtw0ixgw0woNefcREDc6ZjqXOKBSruRagyULuwZ4FK4Q=="
},
"prompt-sync": { "prompt-sync": {
"version": "4.2.0", "version": "4.2.0",
"resolved": "https://registry.npmjs.org/prompt-sync/-/prompt-sync-4.2.0.tgz", "resolved": "https://registry.npmjs.org/prompt-sync/-/prompt-sync-4.2.0.tgz",

View file

@ -12,7 +12,7 @@
"strttest": "export NODE_OPTIONS=--max_old_space_size=8364 && parcel serve test.html", "strttest": "export NODE_OPTIONS=--max_old_space_size=8364 && parcel serve test.html",
"watch:css": "tailwindcss -i index.css -o css/index-tailwind-output.css --watch", "watch:css": "tailwindcss -i index.css -o css/index-tailwind-output.css --watch",
"generate:css": "tailwindcss -i index.css -o css/index-tailwind-output.css", "generate:css": "tailwindcss -i index.css -o css/index-tailwind-output.css",
"generate:doctests": "doctest-ts-improved .", "generate:doctests": "doctest-ts-improved . --ignore .*.spec.ts --ignore .*ConfigJson.ts",
"test:run-only": "mocha --require ts-node/register --require test/testhooks.ts \"./**/*.doctest.ts\" \"test/*\" \"test/**/*.ts\"", "test:run-only": "mocha --require ts-node/register --require test/testhooks.ts \"./**/*.doctest.ts\" \"test/*\" \"test/**/*.ts\"",
"test": "(npm run generate:doctests 2>&1 | grep -v \"No doctests found in\") && npm run test:run-only && npm run clean:tests", "test": "(npm run generate:doctests 2>&1 | grep -v \"No doctests found in\") && npm run test:run-only && npm run clean:tests",
"init": "npm ci && npm run generate && npm run generate:editor-layer-index && npm run generate:layouts && npm run clean", "init": "npm ci && npm run generate && npm run generate:editor-layer-index && npm run generate:layouts && npm run clean",
@ -72,7 +72,7 @@
"@types/wikidata-sdk": "^6.1.0", "@types/wikidata-sdk": "^6.1.0",
"@types/xml2js": "^0.4.9", "@types/xml2js": "^0.4.9",
"country-language": "^0.1.7", "country-language": "^0.1.7",
"doctest-ts-improved": "^0.8.5", "doctest-ts-improved": "^0.8.6",
"email-validator": "^2.0.4", "email-validator": "^2.0.4",
"escape-html": "^1.0.3", "escape-html": "^1.0.3",
"geojson2svg": "^1.3.1", "geojson2svg": "^1.3.1",

72
tslint.json Normal file
View file

@ -0,0 +1,72 @@
{
"rules": {
"class-name": false,
"comment-format": [
true
],
"curly": false,
"eofline": false,
"forin": false,
"indent": [
true,
"spaces"
],
"label-position": true,
"max-line-length": false,
"member-access": false,
"member-ordering": [
true,
"static-after-instance",
"variables-before-functions"
],
"no-arg": true,
"no-bitwise": false,
"no-console": false,
"no-construct": true,
"no-debugger": true,
"no-duplicate-variable": true,
"no-empty": false,
"no-eval": true,
"no-inferrable-types": true,
"no-shadowed-variable": true,
"no-string-literal": false,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unused-expression": true,
"no-use-before-declare": false,
"no-var-keyword": true,
"object-literal-sort-keys": false,
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"quotemark": false,
"radix": true,
"semicolon": [
"always"
],
"triple-equals": [],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"variable-name": false,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
}
}