Skip to content

Commit eed07fe

Browse files
chore: Linting
Upgrade ESLint to `v9`
1 parent 7324b40 commit eed07fe

23 files changed

+776
-2247
lines changed

.eslintrc

Lines changed: 0 additions & 34 deletions
This file was deleted.

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v20
1+
v22

2015/day/1/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
type Parenthesis = '(' | ')';
22
const OPEN_PARENTHESIS = '(' as const;
3+
type OpenParenthesis = typeof OPEN_PARENTHESIS;
34

4-
function isOpenParenthesis(parenthesis: string): boolean {
5+
function isOpenParenthesis(parenthesis: string): parenthesis is OpenParenthesis {
56
return parenthesis === OPEN_PARENTHESIS;
67
}
78

2015/day/12/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
2-
31
function add(a: number, b: number): number {
42
return a + b;
53
}

2015/day/14/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
2-
31
const TIME = 2503;
42

53
function getDistance(speed: number, time: number, rest: number): number {

2015/day/15/index.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
import { readFile } from 'node:fs/promises';
21
import { describe, expect, it } from 'vitest';
32
import { part1 } from '.';
43

5-
const input = (await readFile(`${__dirname}/input`, 'utf-8')).split('\n');
6-
74
describe('Day 15', () => {
85
describe('Part 1', () => {
96
it('should', () => {
107
expect.assertions(1);
118

12-
expect(part1(input)).toStrictEqual(0);
9+
expect(part1()).toStrictEqual(0);
1310
});
1411
});
1512
});

2015/day/15/index.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
2-
31
const a = {
42
capacity: 3,
53
durability: 0,
@@ -16,22 +14,6 @@ const b = {
1614
calories: 9,
1715
};
1816

19-
const c = {
20-
capacity: -1,
21-
durability: 0,
22-
flavor: 4,
23-
texture: 0,
24-
calories: 1,
25-
};
26-
27-
const d = {
28-
capacity: 0,
29-
durability: 0,
30-
flavor: -2,
31-
texture: 2,
32-
calories: 8,
33-
};
34-
3517
function calculate(a, b, ai, bi) {
3618
const capacity = Math.max(0, ai * a.capacity + bi * b.capacity);
3719
const durability = Math.max(0, ai * a.durability + bi * b.durability);
@@ -41,8 +23,8 @@ function calculate(a, b, ai, bi) {
4123
return capacity * durability * flavor * texture;
4224
}
4325

44-
function part1(input: string[]) {
45-
const results = [];
26+
function part1() {
27+
const results: number[] = [];
4628

4729
for (let i = 0; i < 100; i += 1) {
4830
results.push(calculate(a, b, i, 100 - i));

2015/day/16/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
2-
31
interface Signature {
42
[key: string]: number;
53
}

2015/day/8/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable import/prefer-default-export, no-eval */
2-
31
import { sum } from '../../../utils/math';
42

53
function mapString(str: string): number {

2015/day/9/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable import/prefer-default-export, no-eval */
2-
31
import { RADIX } from '../../../utils/math';
42

53
function permutater<T>(arr: T[]) {

2016/day/1/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
2-
31
function manhattanDistance(x1: number, x2: number, y1: number, y2: number): number {
42
return Math.abs(x1 - x2) + Math.abs(y1 - y2);
53
}
@@ -26,7 +24,6 @@ function part1(instructions: string[]): number {
2624
currentDirection += 1;
2725
}
2826

29-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
3027
const direction = directions.at(currentDirection % directions.length)!;
3128
const newX = direction[0] * blocks;
3229
const newY = direction[1] * blocks;

2017/day/1/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
2-
31
function part1(digits: number[]): number {
42
return digits.reduce((accumulator, currentValue, index) => {
53
const nextValue = digits.length - 1 === index ? digits[0] : digits[index + 1];

2017/day/2/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
2-
31
function part1(rows: number[][]): number {
42
return rows.reduce((accumulator, currentValue) => {
53
const min = Math.min(...currentValue);

2017/day/4/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
2-
31
function part1(passphrases: string[]): number {
42
return passphrases.filter((passphrase) => {
53
const words = passphrase.split(' ');

2018/day/2/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
2-
31
function part1(boxes: string[]): number {
42
let twoLetters = 0;
53
let threeLetters = 0;

2018/day/3/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
2-
31
interface Claim {
42
id: string;
53
x: number;

2018/day/5/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
2-
31
function peek<T>(stack: T[]): T {
42
return stack[stack.length - 1];
53
}

2019/day/4/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function countLetters(input: string): Map<string, number> {
3939
}
4040

4141
function find(map: Map<string, number>): boolean {
42-
return !![...map].find(([_key, value]) => {
42+
return !![...map].find(([, value]) => {
4343
return value === 2;
4444
});
4545
}

2020/day/25/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable import/prefer-default-export */
2-
31
function part1(input: number[]): number {
42
const [cardPublicKey, doorPublicKey] = input;
53

eslint.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import js from '@eslint/js';
2+
import globals from 'globals';
3+
import tseslint from 'typescript-eslint';
4+
5+
export default tseslint.config(
6+
{ ignores: ['dist'] },
7+
{
8+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
9+
files: ['**/*.{ts,tsx}'],
10+
languageOptions: {
11+
ecmaVersion: 2020,
12+
globals: globals.browser,
13+
},
14+
},
15+
);

0 commit comments

Comments
 (0)