Skip to content

Commit aa8119f

Browse files
committed
bring back rudimentary linting of @pkmn/sim
1 parent c45c095 commit aa8119f

12 files changed

+47
-14
lines changed

import

+3
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ const FRAGILE = new Set([
442442
// because they only exist in the generated package
443443
const OVERRIDDEN = new Set([
444444
...Array.from(FRAGILE).slice(5), // most sim/dex-*.ts have *not* been overridden
445+
'.eslintcache',
445446
'.tsbuildinfo',
446447
'config/formats.ts',
447448
'data/index.ts',
@@ -464,6 +465,7 @@ const OVERRIDDEN = new Set([
464465
'data/mods/gen2/legality.ts',
465466
'data/mods/gen6/legality.ts',
466467
'data/mods/gen8/legality.ts',
468+
'eslint.config.mjs',
467469
'lib/index.ts',
468470
'lib/streams.ts',
469471
'package-lock.json', // double sigh...
@@ -690,6 +692,7 @@ const changes = async (where, last, now, repo) => ({
690692
let rewritten = REWRITES[file]
691693
? rewrite(original, line => line in REWRITES[file] ? REWRITES[file][line] : line)
692694
: original;
695+
rewritten = rewritten.replaceAll(/\n[^\n]*@typescript-eslint\/ban-types[^\n]*/g, '');
693696
if (file.startsWith('sim/dex-')) {
694697
rewritten = rewritten.replaceAll(/Object.freeze\((.*)\)/g, (_, $1) => $1);
695698
}

sim/eslint.config.mjs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import pkmn from "@pkmn/eslint-config";
2+
3+
export default [...pkmn, {
4+
ignores: ["eslint.config.mjs", "build"],
5+
}, {
6+
rules: {
7+
"@stylistic/array-bracket-spacing": "off",
8+
"@stylistic/comma-dangle": "off",
9+
"@stylistic/indent": "off",
10+
"@stylistic/key-spacing": "off",
11+
"@stylistic/member-delimiter-style": "off",
12+
"@stylistic/no-mixed-spaces-and-tabs": "off",
13+
"@stylistic/no-multi-spaces": "off",
14+
"@stylistic/no-multiple-empty-lines": "off",
15+
"@stylistic/object-curly-spacing": "off",
16+
"@stylistic/operator-linebreak": "off",
17+
"@stylistic/quotes": "off",
18+
"@stylistic/spaced-comment": "off",
19+
"@typescript-eslint/no-base-to-string": "off",
20+
"@typescript-eslint/no-floating-promises": "off",
21+
"@typescript-eslint/no-redundant-type-constituents": "off",
22+
"@typescript-eslint/no-this-alias": "off",
23+
"@typescript-eslint/no-unnecessary-type-assertion": "off",
24+
"@typescript-eslint/no-unsafe-function-type": "off",
25+
"@typescript-eslint/no-unused-vars": "off",
26+
"@typescript-eslint/prefer-optional-chain": "off",
27+
"@typescript-eslint/restrict-template-expressions": "off",
28+
"@typescript-eslint/return-await": "off",
29+
"@typescript-eslint/unbound-method": "off",
30+
"import/order": "off",
31+
"max-len": "off",
32+
"no-case-declarations": "off",
33+
"no-constant-binary-expression": "off",
34+
"no-shadow": "off",
35+
"no-undef": "off",
36+
"no-unused-vars": "off",
37+
"no-var": "off",
38+
"sort-imports": "off",
39+
}
40+
}];

sim/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
"compile": "tsc -p .",
4343
"build": "node ../build",
4444
"test": "mocha test/main.js test/sim/*.js test/sim/**/*.js -R dot -u bdd --exit",
45+
"lint": "eslint --quiet --cache",
4546
"prepare": "npm run build",
46-
"pretest": "node ../build --cjs"
47+
"pretest": "node ../build --cjs",
48+
"posttest": "npm run lint"
4749
}
4850
}

sim/sim/battle.ts

-4
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,8 @@ interface EventListenerWithoutPriority {
9999
effect: Effect;
100100
target?: Pokemon;
101101
index?: number;
102-
// eslint-disable-next-line @typescript-eslint/ban-types
103102
callback?: Function;
104103
state: EffectState | null;
105-
// eslint-disable-next-line @typescript-eslint/ban-types
106104
end: Function | null;
107105
endCallArgs?: any[];
108106
effectHolder: Pokemon | Side | Field | Battle;
@@ -2965,13 +2963,11 @@ export class Battle {
29652963
this.addSplit(side!, secret, shared);
29662964
}
29672965

2968-
// eslint-disable-next-line @typescript-eslint/ban-types
29692966
addMove(...args: (string | number | Function | AnyObject)[]) {
29702967
this.lastMoveLine = this.log.length;
29712968
this.log.push(`|${args.join('|')}`);
29722969
}
29732970

2974-
// eslint-disable-next-line @typescript-eslint/ban-types
29752971
attrLastMove(...args: (string | number | Function | AnyObject)[]) {
29762972
if (this.lastMoveLine < 0) return;
29772973
if (this.log[this.lastMoveLine].startsWith('|-anim|')) {

sim/sim/dex-formats.ts

-1
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,6 @@ export class Format extends BasicEffect implements Readonly<BasicEffect> {
501501

502502
constructor(data: AnyObject) {
503503
super(data);
504-
// eslint-disable-next-line @typescript-eslint/no-this-alias
505504
data = this;
506505

507506
this.mod = Utils.getString(data.mod) || DEFAULT_MOD;

sim/sim/dex-species.ts

-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ export class Species extends BasicEffect implements Readonly<BasicEffect & Speci
301301

302302
constructor(data: AnyObject) {
303303
super(data);
304-
// eslint-disable-next-line @typescript-eslint/no-this-alias
305304
data = this;
306305

307306
this.fullname = `pokemon: ${data.name}`;

sim/sim/dex.ts

-2
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,13 @@ const TEXT = {
129129
Default: DefaultText as DexTable<AnyObject>,
130130
};
131131

132-
/* eslint-disable @typescript-eslint/array-type */
133132
type DeepPartial<T> = {
134133
[P in keyof T]?: T[P] extends Array<infer U>
135134
? Array<DeepPartial<U>>
136135
: T[P] extends ReadonlyArray<infer V>
137136
? ReadonlyArray<DeepPartial<V>>
138137
: DeepPartial<T[P]>
139138
};
140-
/* eslint-enable @typescript-eslint/array-type */
141139

142140
export type ModData = DeepPartial<ModdedDex['data']>;
143141

sim/sim/side.ts

-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ export class Side {
392392
return true;
393393
}
394394

395-
// eslint-disable-next-line @typescript-eslint/ban-types
396395
send(...parts: (string | number | Function | AnyObject)[]) {
397396
const sideUpdate = '|' + parts.map(part => {
398397
if (typeof part !== 'function') return part;

sim/sim/state.ts

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ export const State = new class {
6666
// due to circular module dependencies on Battle and Field instead
6767
// of simply initializing it as a const. See isReferable for where this
6868
// gets lazily created on demand.
69-
// eslint-disable-next-line @typescript-eslint/ban-types
7069
REFERABLE?: Set<Function>;
7170

7271
serializeBattle(battle: Battle): /* Battle */ AnyObject {

sim/sim/teams.ts

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ interface TeamGeneratorFactory {
1414
getTeamGenerator(format: Format | string, seed?: PRNG | PRNGSeed | null): TeamGenerator;
1515
}
1616

17-
// eslint-disable-next-line no-var
1817
var teamGeneratorFactory: TeamGeneratorFactory | undefined;
1918

2019
export const Teams = new class Teams {

sim/sim/tools/exhaustive-runner.ts

-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ export class ExhaustiveRunner {
109109
const log = console.log;
110110
const error = console.error;
111111
try {
112-
// eslint-disable-next-line @typescript-eslint/no-this-alias
113112
const self = this;
114113
console.log = (...s) => {
115114
self.maybeClear();

sim/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
"noImplicitReturns": false,
1414
"tsBuildInfoFile": ".tsbuildinfo"
1515
},
16-
"exclude": ["test", "build"]
16+
"exclude": ["eslint.config.mjs", "test", "build"]
1717
}

0 commit comments

Comments
 (0)