diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..7cf9063 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,155 @@ +module.exports = { + "env": { + "browser": true, + "es6": true, + "node": true + }, + "extends": [ + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", + "prettier/@typescript-eslint", + "plugin:prettier/recommended", + "plugin:import/errors", + "plugin:import/warnings", + "plugin:import/typescript" + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": "tsconfig.json", + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint", + ], + "rules": { + "@typescript-eslint/adjacent-overload-signatures": "error", + "@typescript-eslint/array-type": "error", + "@typescript-eslint/ban-types": "error", + "@typescript-eslint/class-name-casing": "error", + "@typescript-eslint/consistent-type-assertions": "error", + "@typescript-eslint/consistent-type-definitions": "error", + "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/explicit-member-accessibility": [ + "error", + { + "accessibility": "explicit" + } + ], + "@typescript-eslint/indent": "off", + "@typescript-eslint/interface-name-prefix": "error", + "@typescript-eslint/member-delimiter-style": [ + "off", + { + "multiline": { + "delimiter": "none", + "requireLast": true + }, + "singleline": { + "delimiter": "semi", + "requireLast": false + } + } + ], + "@typescript-eslint/member-ordering": "off", + "@typescript-eslint/no-empty-function": "error", + "@typescript-eslint/no-empty-interface": "error", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-misused-new": "error", + "@typescript-eslint/no-namespace": "error", + "@typescript-eslint/no-parameter-properties": "off", + "@typescript-eslint/no-use-before-define": "off", + "@typescript-eslint/no-var-requires": "error", + "@typescript-eslint/prefer-for-of": "error", + "@typescript-eslint/prefer-function-type": "error", + "@typescript-eslint/prefer-namespace-keyword": "error", + "@typescript-eslint/quotes": "off", + "@typescript-eslint/semi": [ + "off", + null + ], + "@typescript-eslint/space-within-parens": [ + "off", + "never" + ], + "@typescript-eslint/triple-slash-reference": "error", + "@typescript-eslint/type-annotation-spacing": "off", + "@typescript-eslint/unified-signatures": "error", + "arrow-body-style": "error", + "arrow-parens": [ + "off", + "as-needed" + ], + "camelcase": "error", + "comma-dangle": "off", + "complexity": "off", + "constructor-super": "error", + "curly": "error", + "dot-notation": "error", + "eol-last": "off", + "eqeqeq": [ + "error", + "smart" + ], + "guard-for-in": "off", + "id-blacklist": [ + "error", + "any", + "Number", + "number", + "String", + "string", + "Boolean", + "boolean", + "Undefined" + ], + "id-match": "error", + "linebreak-style": "off", + "max-classes-per-file": [ + "error", + 1 + ], + "max-len": "off", + "new-parens": "off", + "newline-per-chained-call": "off", + "no-bitwise": "error", + "no-caller": "error", + "no-cond-assign": "error", + "no-console": "off", + "no-debugger": "error", + "no-empty": "error", + "no-eval": "error", + "no-extra-semi": "off", + "no-fallthrough": "off", + "no-invalid-this": "off", + "no-irregular-whitespace": "off", + "no-multiple-empty-lines": "off", + "no-new-wrappers": "error", + "no-shadow": [ + "error", + { + "hoist": "all" + } + ], + "no-throw-literal": "error", + "no-trailing-spaces": "off", + "no-undef-init": "error", + "no-underscore-dangle": "warn", + "no-unsafe-finally": "error", + "no-unused-expressions": "error", + "no-unused-labels": "error", + "no-var": "error", + "object-shorthand": "error", + "one-var": [ + "error", + "never" + ], + "prefer-const": "error", + "quote-props": "off", + "radix": "error", + "sort-imports": "warn", + "space-before-function-paren": "off", + "spaced-comment": "error", + "use-isnan": "error", + "valid-typeof": "off", + } +}; diff --git a/.vscode/settings.json b/.vscode/settings.json index 0b1a7d9..c122d94 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,23 +1,28 @@ { - "editor.renderWhitespace": "boundary", - "files.encoding": "utf8", - "files.trimTrailingWhitespace": true, - "files.insertFinalNewline": true, - "search.exclude": { - "_book/**": true, - ".rpt2_cache/**": true, - "dist/**": true, - "node_modules/**": true, - "typings/**": true - }, - "typescript.tsdk": "./node_modules/typescript/lib", - "[json]": { - "editor.formatOnSave": true - }, - "[javascript]": { - "editor.formatOnSave": true - }, - "[typescript]": { - "editor.formatOnSave": true - } + "[javascript]": { + "editor.formatOnSave": false + }, + "[json]": { + "editor.formatOnSave": true + }, + "[typescript]": { + "editor.formatOnSave": false + }, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + }, + "editor.formatOnSave": true, + "editor.renderWhitespace": "boundary", + "files.encoding": "utf8", + "files.insertFinalNewline": true, + "files.trimTrailingWhitespace": true, + "search.exclude": { + "_book/**": true, + ".rpt2_cache/**": true, + "dist/**": true, + "node_modules/**": true, + "typings/**": true + }, + "typescript.tsdk": "./node_modules/typescript/lib", + "eslint.enable": true } diff --git a/package.json b/package.json index 9f61cab..ef04529 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "//": "If you add or change the names of destinations in screeps.json, make sure you update these scripts to reflect the changes", "scripts": { - "lint": "tslint -p tsconfig.json \"src/**/*.ts\"", + "lint": "eslint \"src/**/*.ts\"", "build": "rollup -c", "push-main": "rollup -c --environment DEST:main", "push-pserver": "rollup -c --environment DEST:pserver", @@ -35,10 +35,17 @@ "@types/screeps": "^3.0.0", "@types/sinon": "^5.0.5", "@types/sinon-chai": "^3.2.0", + "@typescript-eslint/eslint-plugin": "^2.6.1", + "@typescript-eslint/parser": "^2.6.1", + "@typescript-eslint/typescript-estree": "^2.6.1", "chai": "^4.2.0", + "eslint": "^6.6.0", + "eslint-config-prettier": "^6.5.0", + "eslint-plugin-import": "^2.20.0", + "eslint-plugin-prettier": "^3.1.1", "lodash": "^3.10.1", "mocha": "^5.2.0", - "prettier": "^1.14.0", + "prettier": "^1.19.1", "rollup": "^0.63.4", "rollup-plugin-buble": "^0.19.4", "rollup-plugin-clear": "^2.0.7", @@ -51,10 +58,7 @@ "sinon": "^6.3.5", "sinon-chai": "^3.2.0", "ts-node": "^7.0.1", - "tslint": "^5.9.1", - "tslint-config-prettier": "^1.14.0", - "tslint-plugin-prettier": "^1.3.0", - "typescript": "^2.9.2" + "typescript": "^3.7.5" }, "dependencies": { "source-map": "~0.6.1" diff --git a/src/main.ts b/src/main.ts index bd762c4..4e1144a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,4 @@ -import { ErrorMapper } from "utils/ErrorMapper"; +import { ErrorMapper } from "./utils/ErrorMapper"; // When compiling TS to JS and bundling with rollup, the line numbers and file names in error messages change // This utility uses source maps to get the line numbers and file names of the original, TS source code diff --git a/tsconfig.test-integration.json b/tsconfig.test-integration.json deleted file mode 100644 index 875a94b..0000000 --- a/tsconfig.test-integration.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "module": "esnext", - "lib": ["esnext"], - "target": "es5", - "moduleResolution": "Node", - "outDir": "dist", - "baseUrl": "src/", - "sourceMap": true, - "strict": true, - "experimentalDecorators": true, - "noImplicitReturns": true, - "noImplicitAny": false, - "allowSyntheticDefaultImports": true, - "allowUnreachableCode": false - }, - "exclude": [ - "node_modules" - ] -} diff --git a/tslint.json b/tslint.json deleted file mode 100644 index adbf116..0000000 --- a/tslint.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "rulesDirectory": "tslint-plugin-prettier", - "extends" : [ - "tslint:recommended", - "tslint-config-prettier" - ], - "rules": { - "forin": false, - "interface-name": [true, "never-prefix"], - "member-ordering": [false], - "no-console": [false], - "no-namespace": [true, "allow-declarations"], - "variable-name": [ - true, - "ban-keywords", - "check-format", - "allow-pascal-case", - "allow-leading-underscore" - ] - } -}