Skip to content

Commit 36c5af8

Browse files
committed
Enable more lint rules for skin-database
Enable all root ESLint rules except camelcase (333 violations). Rules now enabled: - eqeqeq (strict equality) - prefer-const - prefer-template - prefer-arrow-callback - no-else-return - no-return-await - no-undef-init - dot-notation - guard-for-in - no-div-regex - new-cap Fixed 51 lint violations across the package.
1 parent 54d5522 commit 36c5af8

35 files changed

+60
-78
lines changed

packages/skin-database/.eslintrc.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,8 @@ module.exports = {
1010
"@typescript-eslint/no-namespace": "off",
1111
// Override the base no-shadow rule since it conflicts with TypeScript
1212
"no-shadow": "off",
13-
// Relax rules for this project's existing style
13+
// camelcase has too many violations (333) to fix now
1414
camelcase: "off",
15-
"dot-notation": "off",
16-
eqeqeq: "off",
17-
"no-undef-init": "off",
18-
"no-return-await": "off",
19-
"prefer-arrow-callback": "off",
20-
"no-div-regex": "off",
21-
"guard-for-in": "off",
22-
"prefer-template": "off",
23-
"no-else-return": "off",
24-
"prefer-const": "off",
25-
"new-cap": "off",
2615
},
2716
ignorePatterns: ["dist/**"],
2817
};

packages/skin-database/api/graphql/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export function getUserContext(ctx: Ctx): UserContext {
1313
return ctx.ctx;
1414
}
1515

16+
// eslint-disable-next-line new-cap -- Express Router uses this pattern
1617
const router = Router();
1718

1819
const yoga = createYoga({

packages/skin-database/api/graphql/resolvers/ClassicSkinResolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default class ClassicSkinResolver implements NodeResolver, ISkin {
2626
async filename(normalize_extension?: boolean): Promise<string> {
2727
const filename = await this._model.getFileName();
2828
if (normalize_extension) {
29-
return path.parse(filename).name + ".wsz";
29+
return `${path.parse(filename).name}.wsz`;
3030
}
3131
return filename;
3232
}

packages/skin-database/api/graphql/resolvers/ModernSkinResolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default class ModernSkinResolver implements NodeResolver, ISkin {
2525
async filename(normalize_extension: boolean): Promise<string> {
2626
const filename = await this._model.getFileName();
2727
if (normalize_extension) {
28-
return path.parse(filename).name + ".wal";
28+
return `${path.parse(filename).name}.wal`;
2929
}
3030
return filename;
3131
}

packages/skin-database/api/graphql/resolvers/SkinResolver.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ export default class SkinResolver {
2121
static fromModel(model: SkinModel): ISkin {
2222
if (model.getSkinType() === "MODERN") {
2323
return new ModernSkinResolver(model);
24-
} else {
25-
return new ClassicSkinResolver(model);
2624
}
25+
return new ClassicSkinResolver(model);
2726
}
2827
}
2928

packages/skin-database/app/(modern)/scroll/getClientSkins.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export async function getClientSkins(sessionId: string): Promise<ClientSkin[]> {
1313

1414
const page = await getScrollPage(sessionId);
1515

16-
return await Promise.all(
16+
return Promise.all(
1717
page.map(async (item) => {
1818
return getSkinForSession(ctx, sessionId, item.md5);
1919
})

packages/skin-database/app/(modern)/scroll/useScrollHint.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ export function useScrollHint({
5252
return n1 * (t -= 1.5 / d1) * t + 0.75;
5353
} else if (t < 2.5 / d1) {
5454
return n1 * (t -= 2.25 / d1) * t + 0.9375;
55-
} else {
56-
return n1 * (t -= 2.625 / d1) * t + 0.984375;
5755
}
56+
return n1 * (t -= 2.625 / d1) * t + 0.984375;
5857
};
5958

6059
// Create a bounce effect: scroll down quickly, then bounce back

packages/skin-database/data/KeyValue.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ export default class KeyValue {
1515
.count({ count: "*" })
1616
.first()) as { count: number };
1717
if (count) {
18-
return await KeyValue.update(key, value);
19-
} else {
20-
return await KeyValue.insert(key, value);
18+
return KeyValue.update(key, value);
2119
}
20+
return KeyValue.insert(key, value);
2221
}
2322

2423
static async update(key: string, value: any): Promise<void> {

packages/skin-database/data/SkinModel.ts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -242,23 +242,22 @@ export default class SkinModel {
242242
this.getMd5() + ext
243243
);
244244
return fs.readFile(skinPath);
245-
} else {
246-
const response = await fetch(this.getSkinUrl());
247-
if (!response.ok) {
248-
const missingModernSkins =
249-
(await KeyValue.get<string[]>("missingModernSkins")) ?? [];
250-
const missingModernSkinsSet = new Set(missingModernSkins);
251-
missingModernSkinsSet.add(this.getMd5());
252-
await KeyValue.set(
253-
"missingModernSkins",
254-
Array.from(missingModernSkinsSet)
255-
);
256-
throw new Error(
257-
`Could not fetch skin at "${this.getSkinUrl()}" (Marked in missingModernSkins in the KeyValue store)`
258-
);
259-
}
260-
return response.buffer();
261245
}
246+
const response = await fetch(this.getSkinUrl());
247+
if (!response.ok) {
248+
const missingModernSkins =
249+
(await KeyValue.get<string[]>("missingModernSkins")) ?? [];
250+
const missingModernSkinsSet = new Set(missingModernSkins);
251+
missingModernSkinsSet.add(this.getMd5());
252+
await KeyValue.set(
253+
"missingModernSkins",
254+
Array.from(missingModernSkinsSet)
255+
);
256+
throw new Error(
257+
`Could not fetch skin at "${this.getSkinUrl()}" (Marked in missingModernSkins in the KeyValue store)`
258+
);
259+
}
260+
return response.buffer();
262261
});
263262

264263
getScreenshotBuffer = mem(async (): Promise<Buffer> => {
@@ -385,10 +384,9 @@ export default class SkinModel {
385384
}
386385

387386
async hasGeneral(): Promise<boolean> {
388-
return (
389-
(await this._hasSpriteSheet("GEN")) &&
390-
(await this._hasSpriteSheet("GENEX"))
391-
);
387+
const hasGen = await this._hasSpriteSheet("GEN");
388+
const hasGenEx = await this._hasSpriteSheet("GENEX");
389+
return hasGen && hasGenEx;
392390
}
393391

394392
async getAlgoliaIndexUpdates(limit?: number): Promise<any[]> {

packages/skin-database/db.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ import Knex from "knex";
22
import * as knexConfigs from "./knexfile";
33
import { NODE_ENV } from "./config";
44

5+
// eslint-disable-next-line new-cap -- Knex uses this pattern
56
export const knex = Knex(knexConfigs[NODE_ENV ?? "test"]);

0 commit comments

Comments
 (0)