diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 670e2d3..cb0b211 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -27,8 +27,3 @@ jobs: - name: Lint run: npm run lint:test - - # this has been covered in the prepare script - - # - name: Dtslint test - # run: npm run test diff --git a/.npmignore b/.npmignore index 5783c78..55846da 100644 --- a/.npmignore +++ b/.npmignore @@ -6,7 +6,7 @@ node_modules/ .editorconfig .gitattributes tsconfig.json -tslint.json +eslint.config.* src/ dist/screeps.ts diff --git a/build/header.txt b/build/header.txt index 71d91df..cc39ff5 100644 --- a/build/header.txt +++ b/build/header.txt @@ -8,6 +8,6 @@ // Kieran Carnegie // Mofeng // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 4.6 +// TypeScript Version: 5.5 // Please contribute types to https://github.com/screepers/typed-screeps diff --git a/dist/.eslintrc.json b/dist/.eslintrc.json new file mode 100644 index 0000000..b4f451d --- /dev/null +++ b/dist/.eslintrc.json @@ -0,0 +1,8 @@ +{ + "rules": { + "@definitelytyped/no-any-union": "off", + "@definitelytyped/no-unnecessary-generics": "off", + "@typescript-eslint/no-empty-interface": "off", + "@typescript-eslint/no-misused-new": "off" + } +} diff --git a/dist/index.d.ts b/dist/index.d.ts index 0a97ca0..99a8eb7 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1919,7 +1919,6 @@ interface FindPathOpts { * @param costMatrix The current CostMatrix * @returns The new CostMatrix to use */ - // tslint:disable-next-line: invalid-void costCallback?: (roomName: string, costMatrix: CostMatrix) => void | CostMatrix; /** diff --git a/dist/screeps-tests.ts b/dist/screeps-tests.ts index ce58283..bb72ec0 100644 --- a/dist/screeps-tests.ts +++ b/dist/screeps-tests.ts @@ -237,7 +237,6 @@ function resources(o: GenericStore): ResourceConstant[] { { const exits = Game.map.describeExits("W8N3"); if (exits) { - // tslint:disable-next-line:newline-per-chained-call keys(exits).map((exitKey) => { const nextRoom = exits[exitKey]; const exitDir = +exitKey as ExitConstant; @@ -451,7 +450,6 @@ function resources(o: GenericStore): ResourceConstant[] { { const pfCreep = Game.creeps.John; - // tslint:disable-next-line:newline-per-chained-call const goals = pfCreep.room.find(FIND_SOURCES).map((source) => { // We can't actually walk on sources-- set `range` to 1 // so we path next to it. @@ -474,7 +472,6 @@ function resources(o: GenericStore): ResourceConstant[] { } const costs = new PathFinder.CostMatrix(); - // tslint:disable-next-line:newline-per-chained-call curRoom.find(FIND_STRUCTURES).forEach((struct) => { if (struct.structureType === STRUCTURE_ROAD) { // Favor roads over plain tiles @@ -489,7 +486,6 @@ function resources(o: GenericStore): ResourceConstant[] { }); // Avoid creeps in the room - // tslint:disable-next-line:newline-per-chained-call curRoom.find(FIND_CREEPS).forEach((thisCreep) => { costs.set(thisCreep.pos.x, thisCreep.pos.y, 0xff); }); @@ -539,7 +535,7 @@ function resources(o: GenericStore): ResourceConstant[] { const interShardData = JSON.parse(RawMemory.interShardSegment); if (interShardData.creeps[creep.name]) { creep.memory = interShardData[creep.name]; - delete interShardData.creeps[creep.name]; // tslint:disable-line no-dynamic-delete + delete interShardData.creeps[creep.name]; } RawMemory.interShardSegment = JSON.stringify(interShardData); diff --git a/dist/tslint.json b/dist/tslint.json deleted file mode 100644 index f7cbc1d..0000000 --- a/dist/tslint.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "@definitelytyped/dtslint/dtslint.json", - "rules": { - "file-name-casing": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "dt-header": false, - "no-empty-interface": false, - "no-unnecessary-generics": false, - "no-misused-new": false, - "no-any-union": false, - "no-redundant-undefined": false - } -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..a241d5f --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,25 @@ +// @ts-check +import tseslint, { parser } from 'typescript-eslint'; +import expectType from "eslint-plugin-expect-type/configs/recommended"; + +export const sharedOpts = tseslint.config( + tseslint.configs.base, + expectType, + // global ignore + { ignores: ["build/*", "eslint.config.*"], }, +); + +export default tseslint.config( + ...sharedOpts, + { files: ['src/**/*.ts', 'dist/screeps-tests.ts'], }, + { + languageOptions: { + ecmaVersion: 2022, + sourceType: "module", + parserOptions: { + parser: parser, + project: ["./tsconfig.json", './dist/tsconfig.json'], + }, + }, + }, +) diff --git a/eslint.config.test.mjs b/eslint.config.test.mjs new file mode 100644 index 0000000..96cfb45 --- /dev/null +++ b/eslint.config.test.mjs @@ -0,0 +1,19 @@ +// @ts-check +// only used for 'dist/screeps-tests.ts' +import tseslint, { parser } from 'typescript-eslint'; +import { sharedOpts } from "./eslint.config.mjs"; + +export default tseslint.config( + ...sharedOpts, + { files: ['dist/screeps-tests.ts'], }, + { + languageOptions: { + ecmaVersion: 2022, + sourceType: "module", + parserOptions: { + parser: parser, + project: ['./dist/tsconfig.json'], + }, + }, + }, +) diff --git a/package.json b/package.json index 7972b40..2ae7b62 100644 --- a/package.json +++ b/package.json @@ -8,17 +8,14 @@ "dist/index.d.ts" ], "scripts": { - "compile:dtslint": "node ./build/concat.js && node ./build/prependHeader.js", - "compile": "npm run compile:dtslint && node ./build/prependDescription.js", - "dtslint": "npm run compile:dtslint && dtslint dist", + "compile": "node ./build/concat.js && node ./build/prependHeader.js && node ./build/prependDescription.js", "format": "npm run format:build && npm run format:src", "format:build": "prettier --write 'build/**/*.js'", "format:src": "prettier --write 'src/**/*.ts'", - "lint": "tslint -p tsconfig.json 'src/**/*.ts'", - "lint:test": "tslint -p dist/tsconfig.json dist/screeps-tests.ts", + "lint": "eslint -c eslint.config.mjs", + "lint:test": "eslint -c eslint.config.test.mjs dist/screeps-tests.ts", "pre-commit": "npm run compile && git add dist/index.d.ts", - "prepare": "husky install && npm test", - "test": "npm run dtslint" + "prepare": "husky install && npm test" }, "keywords": [ "Screeps", @@ -29,15 +26,13 @@ "author": "Marko Sulamagi ", "license": "MIT", "devDependencies": { - "@definitelytyped/dtslint": "^0.0.111", + "eslint": "^9.7.0", "husky": "^7.0.4", "lint-staged": "^12.3.8", "prepend": "^1.0.2", "prettier": "^2.6.2", - "tslint": "^6.1.3", - "tslint-config-prettier": "^1.18.0", - "tslint-plugin-prettier": "^2.3.0", - "typescript": "^5.5.0" + "typescript": "^5.5.0", + "typescript-eslint": "^7.16.1" }, "lint-staged": { "*.{ts,tsx}": [ diff --git a/src/helpers.ts b/src/helpers.ts index 62519b7..4dfc9c5 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -320,7 +320,6 @@ interface FindPathOpts { * @param costMatrix The current CostMatrix * @returns The new CostMatrix to use */ - // tslint:disable-next-line: invalid-void costCallback?: (roomName: string, costMatrix: CostMatrix) => void | CostMatrix; /** diff --git a/src/literals.ts b/src/literals.ts index 53ac152..c0b36a5 100644 --- a/src/literals.ts +++ b/src/literals.ts @@ -662,8 +662,6 @@ type PowerConstant = | PWR_OPERATE_EXTENSION | PWR_OPERATE_OBSERVER | PWR_OPERATE_TERMINAL - | PWR_OPERATE_SPAWN - | PWR_OPERATE_TOWER | PWR_DISRUPT_SPAWN | PWR_DISRUPT_TOWER | PWR_DISRUPT_SOURCE diff --git a/tsconfig.json b/tsconfig.json index 40d90f5..fad0509 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,11 @@ "newLine": "LF", "removeComments": false }, - "include": ["./src/**/*.ts"], - "exclude": ["node_modules", "dist"] + "include": [ + "./src/**/*.ts" + ], + "exclude": [ + "node_modules", + "dist", + ], } diff --git a/tslint.json b/tslint.json deleted file mode 100644 index defbe48..0000000 --- a/tslint.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "rulesDirectory": ["tslint-plugin-prettier"], - "extends": ["@definitelytyped/dtslint/dtslint.json", "tslint-config-prettier"], - "rules": { - "prettier": true, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "dt-header": false, - "no-empty-interface": false, - "no-unnecessary-generics": false, - "no-misused-new": false, - "no-any-union": false, - "no-redundant-undefined": false - } -}