From da6aac7003d7ac00726ba5bc80bb43cdcfa9567e Mon Sep 17 00:00:00 2001 From: Rudis Muiznieks Date: Sun, 5 Sep 2021 11:12:18 -0500 Subject: [PATCH] eslint config --- .eslintignore | 2 - .eslintrc.json | 95 +++++++++++++++++++++++++++++- README.md | 14 ++++- package.json | 4 ++ src/model/GameState.ts | 6 +- src/model/logging/ConsoleLogger.ts | 2 +- src/render/DebugRenderer.ts | 4 +- src/render/IRenderer.ts | 2 +- tsconfig.json | 1 + 9 files changed, 117 insertions(+), 13 deletions(-) delete mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 36170a7..0000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -public diff --git a/.eslintrc.json b/.eslintrc.json index 6e1ea5c..3c548b9 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,8 +1,99 @@ { "extends": [ "eslint:recommended", - "plugin:@typescript-eslint/recommended" + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking" ], "parser": "@typescript-eslint/parser", - "plugins": ["@typescript-eslint"] + "parserOptions": {"project": "tsconfig.json"}, + "plugins": ["@typescript-eslint"], + "rules": { + "@typescript-eslint/triple-slash-reference": "off", + "@typescript-eslint/no-unused-vars": "off", + "@typescript-eslint/array-type": ["warn", {"default": "array-simple"}], + "@typescript-eslint/consistent-indexed-object-style": ["warn", "index-signature"], + "@typescript-eslint/consistent-type-assertions": ["warn", { + "assertionStyle": "angle-bracket", + "objectLiteralTypeAssertions": "never"}], + "@typescript-eslint/explicit-function-return-type": "warn", + "@typescript-eslint/explicit-member-accessibility": ["error", { + "accessibility": "explicit", + "overrides": {"constructors": "no-public"}}], + "@typescript-eslint/member-delimiter-style": ["warn", { + "multiline": {"delimiter": "semi", "requireLast": true}, + "singleline": {"delimiter": "comma", "requireLast": false}}], + "@typescript-eslint/member-ordering": "warn", + "@typescript-eslint/method-signature-style": ["warn", "property"], + "@typescript-eslint/naming-convention": "warn", + "@typescript-eslint/no-base-to-string": "error", + "@typescript-eslint/no-confusing-non-null-assertion": "error", + "@typescript-eslint/no-confusing-void-expression": "error", + "@typescript-eslint/no-dynamic-delete": "warn", + "@typescript-eslint/no-extraneous-class": "error", + "@typescript-eslint/no-implicit-any-catch": "error", + "@typescript-eslint/no-invalid-void-type": "error", + "@typescript-eslint/no-parameter-properties": ["error", { + "allows": ["public", "readonly", "public readonly"]}], + "@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn", + "@typescript-eslint/no-unnecessary-condition": "warn", + "@typescript-eslint/no-unnecessary-qualifier": "warn", + "@typescript-eslint/no-unnecessary-type-arguments": "warn", + "@typescript-eslint/no-unnecessary-type-constraint": "warn", + "@typescript-eslint/no-unsafe-argument": "error", + "@typescript-eslint/non-nullable-type-assertion-style": "warn", + "@typescript-eslint/prefer-enum-initializers": "warn", + "@typescript-eslint/prefer-function-type": "warn", + "@typescript-eslint/prefer-includes": "warn", + "@typescript-eslint/prefer-literal-enum-member": "error", + "@typescript-eslint/prefer-nullish-coalescing": "warn", + "@typescript-eslint/prefer-optional-chain": "warn", + "@typescript-eslint/prefer-readonly": "warn", + "@typescript-eslint/prefer-reduce-type-parameter": "warn", + "@typescript-eslint/prefer-return-this-type": "warn", + "@typescript-eslint/prefer-string-starts-ends-with": "warn", + "@typescript-eslint/prefer-ts-expect-error": "error", + "@typescript-eslint/promise-function-async": "warn", + "@typescript-eslint/require-array-sort-compare": "warn", + "@typescript-eslint/strict-boolean-expressions": ["error", { + "allowString": false, + "allowNumber": false, + "allowNullableObject": false}], + "@typescript-eslint/switch-exhaustiveness-check": "warn", + "@typescript-eslint/type-annotation-spacing": "warn", + "@typescript-eslint/typedef": ["error", { + "arrowParameter": true, + "memberVariableDeclaration": true, + "parameter": true, + "propertyDeclaration": true, + "variableDeclaration": true}], + "@typescript-eslint/unified-signatures": "warn", + "@typescript-eslint/brace-style": "warn", + "@typescript-eslint/comma-dangle": ["warn", "always-multiline"], + "@typescript-eslint/comma-spacing": "warn", + "@typescript-eslint/default-param-last": "error", + "@typescript-eslint/dot-notation": "error", + "@typescript-eslint/func-call-spacing": ["warn", "never"], + "@typescript-eslint/indent": ["warn", 2], + "@typescript-eslint/keyword-spacing": "error", + "@typescript-eslint/lines-between-class-members": ["warn", "always", { + "exceptAfterSingleLine": true}], + "@typescript-eslint/no-dupe-class-members": "error", + "@typescript-eslint/no-extra-parens": "warn", + "@typescript-eslint/no-invalid-this": "error", + "@typescript-eslint/no-loop-func": "error", + "@typescript-eslint/no-loss-of-precision": "warn", + "@typescript-eslint/no-redeclare": "error", + "@typescript-eslint/no-shadow": "error", + "@typescript-eslint/no-unused-expressions": "error", + "@typescript-eslint/no-use-before-define": "error", + "@typescript-eslint/no-useless-constructor": "warn", + "@typescript-eslint/object-curly-spacing": ["warn", "always", { + "arraysInObjects": true, + "objectsInObjects": false}], + "@typescript-eslint/quotes": ["warn", "single", {"avoidEscape": true}], + "@typescript-eslint/semi": ["error", "always"], + "@typescript-eslint/space-before-function-paren": ["warn", "always"], + "@typescript-eslint/space-infix-ops": "warn" + } } diff --git a/README.md b/README.md index 00902fc..c4e9fff 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,15 @@ # irreligio.us -An incremental game. +An incremental game in which you start a cult and must grow it into the dominant world religion. -Nothing here works or is very interesting yet. +## Current State + +It can be run and played through a not-very-pretty debugging interface. To make testing easier, default configuration is massively sped up from what the final game will use, and the relationships between resources have not been play-tested or balanced in any meaningful way. + +## Build and Run + +``` +npm install +npm run build +firefox public/index.html +``` diff --git a/package.json b/package.json index 675e8c6..831f42e 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,8 @@ { + "scripts": { + "build": "eslint src/ && tsc", + "lint": "eslint src/" + }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", diff --git a/src/model/GameState.ts b/src/model/GameState.ts index c586048..ea76436 100644 --- a/src/model/GameState.ts +++ b/src/model/GameState.ts @@ -7,10 +7,10 @@ class GameState { private _timeSinceSave = 0; private readonly _timeBetweenSaves: number = 10000; - private _resources: Record = { }; + private _resources: {[key: string]: IResource} = { }; private _resourceKeys: string[] = []; - public onResourceClick: (() => void)[] = []; + public onResourceClick: Array<() => void> = []; public logger: ILogger = null; public numberFormatDigits = 1; @@ -129,7 +129,7 @@ class GameState { } public save (): void { - const saveObj: { [key: string]: any } = { }; + const saveObj: any = { }; saveObj.version = { maj: this._versionMaj, min: this._versionMin diff --git a/src/model/logging/ConsoleLogger.ts b/src/model/logging/ConsoleLogger.ts index 656aea8..0c63c61 100644 --- a/src/model/logging/ConsoleLogger.ts +++ b/src/model/logging/ConsoleLogger.ts @@ -1,5 +1,5 @@ class ConsoleLogger implements ILogger { public msg (text: string): void { - console.log(text); // tslint:disable-line + console.log(text); } } diff --git a/src/render/DebugRenderer.ts b/src/render/DebugRenderer.ts index c832a6b..aa71b26 100644 --- a/src/render/DebugRenderer.ts +++ b/src/render/DebugRenderer.ts @@ -1,6 +1,6 @@ /// -class DebugRenderer implements IRenderer { +class DebugRenderer implements IRenderer { // eslint-disable-line @typescript-eslint/no-unused-vars private _initialized = false; private _handleClick = true; @@ -32,7 +32,7 @@ class DebugRenderer implements IRenderer { for (const item in ResourceType) { if (isNaN(Number(item))) { const el: HTMLElement = document.createElement('div'); - el.id = `resource-container-${ResourceType[item]}`; + el.id = `resource-container-${ResourceType[item]}`; el.className = 'resource-type-container'; resDiv.appendChild(el); } diff --git a/src/render/IRenderer.ts b/src/render/IRenderer.ts index b42f549..37f5ce2 100644 --- a/src/render/IRenderer.ts +++ b/src/render/IRenderer.ts @@ -1,3 +1,3 @@ -interface IRenderer { +interface IRenderer { // eslint-disable-line @typescript-eslint/no-unused-vars render (state: GameState): void; } diff --git a/tsconfig.json b/tsconfig.json index 3acf527..f37b2c3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ "removeComments": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, + "strictNullChecks": true, "target": "ES5", "module": "none", "plugins": [{"name": "typescript-eslint-language-service"}]