Skip to content

Commit

Permalink
Refactor: re-enable airbnb-base ESLint (#768)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm authored Oct 17, 2023
1 parent 54e6bd6 commit 71c0fb3
Show file tree
Hide file tree
Showing 10 changed files with 181 additions and 110 deletions.
7 changes: 7 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"airbnb-base",
"airbnb-typescript/base",
"plugin:jsdoc/recommended-typescript-error",
"plugin:jest/recommended"
],
Expand Down Expand Up @@ -139,6 +141,11 @@
// There are a few places where this needs to be allowed, but only a few, so warn on them
"@typescript-eslint/no-unused-expressions": "warn",

// ***** airbnb-base, airbnb-typescript/base *****
"no-await-in-loop": "off",
"no-bitwise": "off",
"no-restricted-syntax": "off",

// ***** plugin:jest/recommended *****
// A lot of test files define their own expect functions
"jest/expect-expect": "off"
Expand Down
250 changes: 157 additions & 93 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,13 @@
"@types/which": "3.0.0",
"@types/xml2js": "0.4.12",
"@types/yargs": "17.0.25",
"@typescript-eslint/eslint-plugin": "6.7.3",
"@typescript-eslint/parser": "6.7.3",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"auto-changelog": "2.4.0",
"caxa": "3.0.1",
"eslint": "8.50.0",
"eslint-plugin-import": "2.28.1",
"eslint": "^8.51.0",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jest": "27.4.0",
"eslint-plugin-jsdoc": "46.8.2",
"eslint-plugin-simple-import-sort": "10.0.0",
Expand Down
2 changes: 0 additions & 2 deletions src/modules/candidateGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export default class CandidateGenerator extends Module {
// For every release (ensuring at least one), find all release candidates
const releases = game.getReleases().length > 0 ? game.getReleases() : [undefined];
for (const release of releases) {

const releaseCandidate = await this.buildReleaseCandidateForRelease(
dat,
game,
Expand Down Expand Up @@ -338,7 +337,6 @@ export default class CandidateGenerator extends Module {

let hasConflict = false;
for (const duplicateOutput of duplicateOutputPaths) {

// For an output path that has multiple input paths, filter to only the unique input paths,
// and if there are still multiple input file paths then we won't be able to resolve this
// at write time
Expand Down
5 changes: 4 additions & 1 deletion src/modules/datScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,10 @@ export default class DATScanner extends Scanner {
.validate((row: SmdbRow) => row.name
&& row.crc
&& row.crc.length === 8
&& (row.size === undefined || row.size.length === 0 || Number.isInteger(Number.parseInt(row.size, 10))))
&& (row.size === undefined
|| row.size.length === 0
|| Number.isInteger(Number.parseInt(row.size, 10))
))
.on('error', reject)
.on('data', (row) => {
rows.push(row);
Expand Down
4 changes: 2 additions & 2 deletions src/types/patches/vcdiffPatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,9 @@ class VcdiffCache {

constructor(sNear = 4, sSame = 3) {
this.sNear = sNear;
this.near = Array.from({length: sNear});
this.near = Array.from({ length: sNear });
this.sSame = sSame;
this.same = Array.from({length: sSame * 256});
this.same = Array.from({ length: sSame * 256 });
}

reset(): void {
Expand Down
2 changes: 0 additions & 2 deletions test/modules/candidatePreferer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ async function buildReleaseCandidatesWithRegionLanguage(
const games: Game[] = [];
const releaseCandidates: ReleaseCandidate[] = [];
for (const [idx, romName] of namesArr.entries()) {

for (const language of languagesArr) {

// Every region is a different Release+ReleaseCandidate
const releases: Release[] = [];
for (const region of regionsArr) {
Expand Down
2 changes: 0 additions & 2 deletions test/modules/datFilter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ function buildGameWithRegionLanguage(
// Every different name+language combo is a different ROM+Game
const games: Game[] = [];
for (const [idx, romName] of namesArr.entries()) {

for (const language of languagesArr) {

// Every region is a different Release+ReleaseCandidate
const releases: Release[] = [];
for (const region of regionsArr) {
Expand Down
4 changes: 3 additions & 1 deletion test/modules/datGameInferrer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ test.each([
const dats = new DATGameInferrer(new ProgressBarFake()).infer(romFiles);

// Then
const datNameToGameCount = Object.fromEntries(dats.map(( dat) => [dat.getName(), dat.getGames().length]));
const datNameToGameCount = Object.fromEntries(
dats.map((dat) => [dat.getName(), dat.getGames().length]),
);
expect(datNameToGameCount).toEqual(expected);
});
6 changes: 3 additions & 3 deletions test/modules/endOfLifeChecker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import LogLevel from '../../src/console/logLevel.js';
import EndOfLifeChecker from '../../src/modules/endOfLifeChecker.js';

function range(start: number, end: number): number[] {
return [...Array.from({length:end - start + 1}).keys()].map((val) => val + start);
return [...Array.from({ length: end - start + 1 }).keys()].map((val) => val + start);
}
const versions = range(4, 20 + 5)
.map((major) => `v${major}.${major}.0`);

const logger = new Logger(LogLevel.ALWAYS, new PassThrough());

describe('should not throw', () => {
test.each(versions)('with an old date: v%d', (version) => {
test.each(versions)('with an old date: %s', (version) => {
expect.assertions(1);
const date = new Date(1999, 9, 9);
expect(() => new EndOfLifeChecker(logger).check(version, date)).not.toThrow();
});

test.each(versions)('with a far future date: v%d', (version) => {
test.each(versions)('with a far future date: %s', (version) => {
expect.assertions(1);
const date = new Date(2100, 1, 1);
expect(() => new EndOfLifeChecker(logger).check(version, date)).not.toThrow();
Expand Down

0 comments on commit 71c0fb3

Please sign in to comment.