Skip to content

Commit

Permalink
migrate to eslint 9
Browse files Browse the repository at this point in the history
regression: tools/{stats,teams} no longer checked
  • Loading branch information
scheibo committed Oct 18, 2024
1 parent 9985d76 commit 519b0e6
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 66 deletions.
3 changes: 3 additions & 0 deletions anon/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import pkmn from "@pkmn/eslint-config";

export default pkmn;
13 changes: 5 additions & 8 deletions anon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
"access": "public"
},
"dependencies": {
"@pkmn/data": "^0.9.19",
"@pkmn/protocol": "^0.6.26"
"@pkmn/data": "^0.9.21",
"@pkmn/protocol": "^0.6.28"
},
"devDependencies": {
"@pkmn/dex": "^0.9.19"
"@pkmn/dex": "^0.9.21"
},
"scripts": {
"lint": "eslint --cache src --ext ts",
"fix": "eslint --fix src --ext ts",
"lint": "eslint --cache src",
"fix": "eslint --fix src",
"compile": "tsc -p .",
"build": "npm run compile && tsup src/index.ts",
"test": "jest",
Expand All @@ -51,8 +51,5 @@
"@babel/preset-typescript",
["@babel/preset-env", {"targets": {"node": "current"}}]
]
},
"eslintConfig": {
"extends": "@pkmn"
}
}
12 changes: 12 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pkmn from "@pkmn/eslint-config";

export default [...pkmn, {
files: ["workflows/**/*.ts"],
rules: {
"@typescript-eslint/no-floating-promises": ["error", {ignoreVoid: true}],
"@typescript-eslint/require-await": "off"
}
}, {
files: ["workflows/pkmn/*.ts"],
languageOptions: { parserOptions: {project: ["./tsconfig.pkmn.json"]} },
}];
6 changes: 6 additions & 0 deletions logs/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import pkmn from "@pkmn/eslint-config";

export default [...pkmn, {
files: ["src/storage.ts"],
rules: {"@typescript-eslint/require-await": "off"},
}];
13 changes: 2 additions & 11 deletions logs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"bthreads": "^0.5.1"
},
"scripts": {
"lint": "eslint --cache src --ext ts",
"fix": "eslint --fix src --ext ts",
"lint": "eslint --cache src",
"fix": "eslint --fix src",
"compile": "tsc -p .",
"build": "npm run compile && tsup src/index.ts",
"test": "jest",
Expand All @@ -41,14 +41,5 @@
"@babel/preset-typescript",
["@babel/preset-env", {"targets": {"node": "current"}}]
]
},
"eslintConfig": {
"extends": "@pkmn",
"overrides": [{
"files": ["src/storage.ts"],
"rules": {
"@typescript-eslint/require-await": "off"
}
}]
}
}
4 changes: 1 addition & 3 deletions logs/src/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ function isGzipped(buf: Buffer) {

export function unpack(input: string, output: string) {
return new Promise<void>((resolve, reject) => {
zip.unpack(input, output, err => {
err ? reject(err) : resolve();
});
zip.unpack(input, output, err => err ? reject(err) : resolve());
});
}
2 changes: 1 addition & 1 deletion logs/src/random.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('Random', () => {

r = new Random();
a = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K'];
delete a[9];
delete a[9]; // eslint-disable-line @typescript-eslint/no-array-delete
expect(() => {
for (let i = 0; i < 100; i++) {
r.sample(a);
Expand Down
42 changes: 13 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"license": "MIT",
"dependencies": {
"@pkmn/anon": "file:anon",
"@pkmn/data": "^0.9.19",
"@pkmn/dex": "^0.9.19",
"@pkmn/data": "^0.9.21",
"@pkmn/dex": "^0.9.21",
"@pkmn/logs": "file:logs",
"@pkmn/stats": "file:stats",
"json-stringify-pretty-compact": "3.0.0",
Expand All @@ -17,46 +17,30 @@
"@pkmn/sets": "^5.1.2"
},
"devDependencies": {
"@babel/preset-env": "^7.25.4",
"@babel/preset-typescript": "^7.24.7",
"@pkmn/eslint-config": "^8.4.0",
"@babel/preset-env": "^7.25.8",
"@babel/preset-typescript": "^7.25.7",
"@pkmn/eslint-config": "^9.0.0",
"@types/jest": "^29.5.13",
"@types/node": "^22.7.4",
"@typescript-eslint/eslint-plugin": "<=7",
"@typescript-eslint/parser": "<=7",
"eslint": "<=8",
"eslint-plugin-import": "<=2.30.0",
"@types/node": "^22.7.6",
"eslint": "^9.12.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "^28.8.3",
"jest": "^29.7.0",
"subpkg": "^4.1.0",
"tsup": "^8.3.0",
"typescript": "^5.6.2"
"typescript-eslint": "^8.10.0",
"typescript": "^5.6.3"
},
"subPackages": ["anon", "logs", "stats"],
"scripts": {
"lint": "subpkg run lint && eslint --cache workflows tools/{stats,teams} --ext ts",
"fix": "subpkg run fix && eslint --fix workflows tools/{stats,teams} --ext ts",
"lint": "subpkg run lint && eslint --cache workflows",
"fix": "subpkg run fix && eslint --fix workflows",
"compile:smogon": "tsc -p .",
"compile:pkmn": "tsc -p tsconfig.pkmn.json",
"compile": "subpkg run compile && npm run compile:smogon",
"build": "npm run compile && npm run compile:pkmn",
"test": "subpkg run test",
"posttest": "npm run compile:smogon && npm run compile:pkmn && eslint --cache workflows tools/{stats,teams} --ext ts",
"posttest": "npm run compile:smogon && npm run compile:pkmn && eslint --cache workflows",
"postinstall": "subpkg install"
},
"eslintConfig": {
"extends": "@pkmn",
"overrides": [{
"files": ["workflows/**/*.ts"],
"rules": {
"@typescript-eslint/no-floating-promises": ["error", {"ignoreVoid": true}],
"@typescript-eslint/require-await": "off"
}
}, {
"files": ["workflows/pkmn/*.ts"],
"parserOptions": {
"project": ["./tsconfig.pkmn.json"]
}
}]
}
}
3 changes: 3 additions & 0 deletions stats/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import pkmn from "@pkmn/eslint-config";

export default [...pkmn, {rules: {"@typescript-eslint/no-redundant-type-constituents": "off"}}];
14 changes: 4 additions & 10 deletions stats/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
"access": "public"
},
"dependencies": {
"@pkmn/data": "^0.9.19"
"@pkmn/data": "^0.9.21"
},
"devDependencies": {
"@pkmn/dex": "^0.9.19",
"@pkmn/dex": "^0.9.21",
"json-stringify-pretty-compact": "3.0.0"
},
"scripts": {
"lint": "eslint --cache src --ext ts",
"fix": "eslint --fix src --ext ts",
"lint": "eslint --cache src",
"fix": "eslint --fix src",
"compile": "tsc -p .",
"build": "npm run compile && tsup src/index.ts src/test/integration.ts",
"test": "jest",
Expand All @@ -48,11 +48,5 @@
"@babel/preset-typescript",
["@babel/preset-env", {"targets": {"node": "current"}}]
]
},
"eslintConfig": {
"extends": "@pkmn",
"rules": {
"@typescript-eslint/no-redundant-type-constituents": "off"
}
}
}
4 changes: 2 additions & 2 deletions stats/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {Generation, ID, PokemonSet, StatID, toID} from '@pkmn/data';

import {Classifier} from './classifier';
import {Outcome} from './util';
// eslint-disable-next-line no-duplicate-imports
import * as util from './util';

export interface Log {
Expand Down Expand Up @@ -170,7 +169,7 @@ export const Parser = new class {
battle.matchups.push(...turnMatchups);
break;
}
case 'move':
case 'move': {
if (line.length < 4) {
throw new Error(`Could not parse line: '${rawLine}'`);
}
Expand All @@ -182,6 +181,7 @@ export const Parser = new class {
flags.uturn = true;
}
break;
}
case '-enditem':
if (rawLine.lastIndexOf('Red Card') > -1) {
flags.roar = true;
Expand Down
1 change: 0 additions & 1 deletion stats/src/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {Generation, ID, Nature, PokemonSet, StatID, StatsTable} from '@pkmn/data

import {Battle, Player, Pokemon} from './parser';
import {Outcome} from './util';
// eslint-disable-next-line no-duplicate-imports
import * as util from './util';

export interface TaggedStatistics {
Expand Down
2 changes: 1 addition & 1 deletion stats/src/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-loss-of-precision */
/* eslint-disable no-loss-of-precision */
import {Dex, Generation, Generations, ID, PokemonSet, Specie, toID} from '@pkmn/data';

import * as aliases from './aliases.json';
Expand Down

0 comments on commit 519b0e6

Please sign in to comment.