eslint config

This commit is contained in:
Rudis Muiznieks 2021-09-05 11:12:18 -05:00
parent 7fed5c7d08
commit da6aac7003
9 changed files with 117 additions and 13 deletions

View File

@ -1,2 +0,0 @@
node_modules
public

View File

@ -1,8 +1,99 @@
{ {
"extends": [ "extends": [
"eslint:recommended", "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", "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"
}
} }

View File

@ -1,5 +1,15 @@
# irreligio.us # 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
```

View File

@ -1,4 +1,8 @@
{ {
"scripts": {
"build": "eslint src/ && tsc",
"lint": "eslint src/"
},
"devDependencies": { "devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/eslint-plugin": "^4.30.0",
"@typescript-eslint/parser": "^4.30.0", "@typescript-eslint/parser": "^4.30.0",

View File

@ -7,10 +7,10 @@ class GameState {
private _timeSinceSave = 0; private _timeSinceSave = 0;
private readonly _timeBetweenSaves: number = 10000; private readonly _timeBetweenSaves: number = 10000;
private _resources: Record<string, IResource> = { }; private _resources: {[key: string]: IResource} = { };
private _resourceKeys: string[] = []; private _resourceKeys: string[] = [];
public onResourceClick: (() => void)[] = []; public onResourceClick: Array<() => void> = [];
public logger: ILogger = null; public logger: ILogger = null;
public numberFormatDigits = 1; public numberFormatDigits = 1;
@ -129,7 +129,7 @@ class GameState {
} }
public save (): void { public save (): void {
const saveObj: { [key: string]: any } = { }; const saveObj: any = { };
saveObj.version = { saveObj.version = {
maj: this._versionMaj, maj: this._versionMaj,
min: this._versionMin min: this._versionMin

View File

@ -1,5 +1,5 @@
class ConsoleLogger implements ILogger { class ConsoleLogger implements ILogger {
public msg (text: string): void { public msg (text: string): void {
console.log(text); // tslint:disable-line console.log(text);
} }
} }

View File

@ -1,6 +1,6 @@
/// <reference path="../model/logging/DebugLogger.ts" /> /// <reference path="../model/logging/DebugLogger.ts" />
class DebugRenderer implements IRenderer { class DebugRenderer implements IRenderer { // eslint-disable-line @typescript-eslint/no-unused-vars
private _initialized = false; private _initialized = false;
private _handleClick = true; private _handleClick = true;
@ -32,7 +32,7 @@ class DebugRenderer implements IRenderer {
for (const item in ResourceType) { for (const item in ResourceType) {
if (isNaN(Number(item))) { if (isNaN(Number(item))) {
const el: HTMLElement = document.createElement('div'); const el: HTMLElement = document.createElement('div');
el.id = `resource-container-${ResourceType[item]}`; el.id = `resource-container-${<string>ResourceType[item]}`;
el.className = 'resource-type-container'; el.className = 'resource-type-container';
resDiv.appendChild(el); resDiv.appendChild(el);
} }

View File

@ -1,3 +1,3 @@
interface IRenderer { interface IRenderer { // eslint-disable-line @typescript-eslint/no-unused-vars
render (state: GameState): void; render (state: GameState): void;
} }

View File

@ -6,6 +6,7 @@
"removeComments": true, "removeComments": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"strictNullChecks": true,
"target": "ES5", "target": "ES5",
"module": "none", "module": "none",
"plugins": [{"name": "typescript-eslint-language-service"}] "plugins": [{"name": "typescript-eslint-language-service"}]