Skip to content

Commit 328c774

Browse files
chore: ESLint
Upgrade ESLint to `v9`
1 parent 7fd9016 commit 328c774

File tree

49 files changed

+660
-722
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+660
-722
lines changed

eslint.config.js

+15
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'],
10+
languageOptions: {
11+
ecmaVersion: 2020,
12+
globals: globals.browser,
13+
},
14+
},
15+
);

kata/5 kyu/perimeter-of-squares-in-a-rectangle/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-param-reassign */
2-
31
function fibonacci(n: number, cache: number[] = []): number {
42
if (cache[n]) {
53
return cache[n];

kata/6 kyu/array-dot-diff/index.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable camelcase */
2-
31
import assert from 'node:assert/strict';
42
import { describe, it } from 'node:test';
53
import array_diff from './index.ts';

kata/6 kyu/array-dot-diff/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable camelcase */
2-
31
function array_diff(a: number[], b: number[]): number[] {
42
return a.filter((val) => !b.includes(val));
53
}

kata/6 kyu/can-you-keep-a-secret/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
function createSecretHolder(secret: number) {
2-
// eslint-disable-next-line no-underscore-dangle
32
let _secret = secret;
43

54
return {

kata/6 kyu/pokemon-damage-calculator/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import type { Any } from '../../@types/types.ts';
2+
13
type Type = 'electric' | 'fire' | 'grass' | 'water';
24

3-
type EffectivenessTable = Record<Type, any>;
5+
type EffectivenessTable = Record<Type, Any>;
46

57
const effectivenessTable: EffectivenessTable = {
68
electric: {

kata/6 kyu/prefill-an-array/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
function prefill<T>(n: any, v: T): T[] {
1+
import type { Any } from '../../@types/types.ts';
2+
3+
function prefill<T>(n: Any, v: T): T[] {
24
const parsed = parseInt(n, 10);
35

46
if (parsed !== Math.abs(n)) {

kata/6 kyu/rectangle-into-squares/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-shadow */
2-
31
function sqInRect(lng: number, wdth: number): number[] | null {
42
if (lng === wdth) {
53
return null;

kata/6 kyu/roman-numerals-encoder/index.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/* eslint-disable */
2-
3-
const symbols = {
1+
const letters = {
42
M: 1000,
53
CM: 900,
64
D: 500,
@@ -16,16 +14,16 @@ const symbols = {
1614
I: 1,
1715
};
1816

19-
type Symbol = keyof typeof symbols;
17+
type Letter = keyof typeof letters;
2018

2119
function solution(num: number): string {
2220
let roman = '';
23-
let i: Symbol;
21+
let i: Letter;
2422

25-
for (i in symbols) {
26-
while (num >= symbols[i]) {
23+
for (i in letters) {
24+
while (num >= letters[i]) {
2725
roman += i;
28-
num -= symbols[i];
26+
num -= letters[i];
2927
}
3028
}
3129

kata/6 kyu/sum-of-digits-slash-digital-root/index.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable camelcase */
2-
31
import assert from 'node:assert/strict';
42
import { describe, it } from 'node:test';
53
import digital_root from './index.ts';

kata/6 kyu/sum-of-digits-slash-digital-root/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable camelcase */
2-
31
function digital_root(n: number): number {
42
return ((n - 1) % 9) + 1;
53
}

kata/6 kyu/valid-braces/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { Any } from '../../@types/types.ts';
2+
13
interface Matches {
24
[key: string]: string;
35
}
@@ -17,7 +19,7 @@ function validBraces(braces: string): boolean {
1719
if (matches[currentBrace]) {
1820
stack.push(currentBrace);
1921
} else {
20-
const lastBrace: any = stack.pop();
22+
const lastBrace: Any = stack.pop();
2123

2224
if (currentBrace !== matches[lastBrace]) {
2325
return false;

kata/7 kyu/area-of-a-circle/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
function isNumber(n: any): n is number {
1+
function isNumber(n: unknown): n is number {
22
return typeof n === 'number';
33
}
44

5-
function circleArea(radius: any): number | false {
5+
function circleArea(radius: unknown): number | false {
66
if (!isNumber(radius) || radius <= 0) {
77
return false;
88
}

kata/7 kyu/deodorant-evaporator/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable camelcase */
2-
31
function evaporator(_content: number, evap_per_day: number, threshold: number): number {
42
return Math.ceil(Math.log(threshold / 100) / Math.log(1 - evap_per_day / 100));
53
}

kata/7 kyu/fixme-get-full-name/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-useless-constructor */
2-
31
class Dinglemouse {
42
private firstName: string;
53
private lastName: string;

kata/7 kyu/flatten-1/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
function flatten(arr: any[]): any[] {
1+
import type { Any } from '../../@types/types.ts';
2+
3+
function flatten(arr: Any[]): Any[] {
24
return [].concat(...arr);
35
}
46

kata/7 kyu/fun-with-es6-classes-number-2-animals-and-inheritance/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable max-classes-per-file */
2-
31
class Animal {
42
public name: string;
53
public age: number;

kata/7 kyu/gauss-needs-help-sums-of-a-lot-of-numbers/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
function f(n?: any): number | boolean {
1+
import type { Any } from '../../@types/types.ts';
2+
3+
function f(n?: Any): number | boolean {
24
if (!Number.isInteger(n) || n < 1) {
35
return false;
46
}

kata/7 kyu/last/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import type { Any } from '../../@types/types.ts';
2+
13
function last<T>(...list: T[] | T[][]): T {
2-
const lastElement: any = list[list.length - 1];
4+
const lastElement: Any = list[list.length - 1];
35

46
return lastElement[lastElement.length - 1] || lastElement;
57
}

kata/7 kyu/list-filtering/index.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable camelcase */
2-
31
import assert from 'node:assert/strict';
42
import { describe, it } from 'node:test';
53
import filter_list from './index.ts';

kata/7 kyu/list-filtering/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/* eslint-disable camelcase */
1+
import type { Any } from '../../@types/types.ts';
22

3-
function filter_list(l: any[]): number[] {
3+
function filter_list(l: Any[]): number[] {
44
return l.filter(Number.isInteger);
55
}
66

kata/7 kyu/santaclausable-interface/index.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-console */
2-
31
import assert from 'node:assert/strict';
42
import { describe, it } from 'node:test';
53
import isSantaClausable from './index.ts';

kata/7 kyu/shorter-concat-reverse-longer/index.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable camelcase */
2-
31
import assert from 'node:assert/strict';
42
import { describe, it } from 'node:test';
53
import shorter_reverse_longer from './index.ts';

kata/7 kyu/shorter-concat-reverse-longer/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable camelcase */
2-
31
function shorter_reverse_longer(a: string, b: string): string {
42
const shorter = a.length < b.length ? a : b;
53
const longer = a.length >= b.length ? a : b;

kata/7 kyu/sum-of-odd-cubed-numbers/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
function cubeOdd(arr: any[]): number | undefined {
1+
import type { Any } from '../../@types/types.ts';
2+
3+
function cubeOdd(arr: Any[]): number | undefined {
24
let sum = 0;
35

46
for (let i = 0; i < arr.length; i += 1) {

kata/8 kyu/a-needle-in-the-haystack/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
function findNeedle(haystack: any[]): string {
1+
import type { Any } from '../../@types/types.ts';
2+
3+
function findNeedle(haystack: Any[]): string {
24
const position = haystack.indexOf('needle');
35

46
return `found the needle at position ${position}`;

kata/8 kyu/basic-subclasses-adam-and-eve/index.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable max-classes-per-file */
2-
31
class Human {}
42

53
class Man extends Human {}
@@ -14,4 +12,4 @@ class God {
1412

1513
export default God;
1614

17-
export { Man, Woman, Human };
15+
export { Human, Man, Woman };

kata/8 kyu/calculate-average/index.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable camelcase */
2-
31
import assert from 'node:assert/strict';
42
import { describe, it } from 'node:test';
53
import find_average from './index.ts';

kata/8 kyu/calculate-average/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable camelcase */
2-
31
function find_average(array: number[]): number {
42
return array.reduce((accumulator, currentValue) => accumulator + currentValue, 0) / array.length;
53
}

kata/8 kyu/classic-hello-world/index.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-console */
2-
31
import assert from 'node:assert/strict';
42
import { describe, it, mock } from 'node:test';
53
import Solution from './index.ts';

kata/8 kyu/classic-hello-world/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-console */
2-
31
class Solution {
42
static main(): void {
53
console.log('Hello World!');

kata/8 kyu/even-or-odd/index.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable camelcase */
2-
31
import assert from 'node:assert/strict';
42
import { describe, it } from 'node:test';
53
import even_or_odd from './index.ts';

kata/8 kyu/even-or-odd/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable camelcase */
2-
31
function even_or_odd(number: number): string {
42
return number % 2 ? 'Odd' : 'Even';
53
}

kata/8 kyu/find-the-smallest-integer-in-the-array/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable class-methods-use-this */
2-
31
class SmallestIntegerFinder {
42
findSmallestInt(args: number[]): number {
53
return Math.min(...args);

kata/8 kyu/lexical-this/index.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-underscore-dangle */
2-
31
import assert from 'node:assert/strict';
42
import { describe, it } from 'node:test';
53
import Person from './index.ts';

kata/8 kyu/lexical-this/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-underscore-dangle */
2-
31
interface Person {
42
_name: string;
53
_friends: string[];

kata/8 kyu/pillars/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable camelcase */
2-
31
function pillars(num_pill: number, dist: number, width: number): number {
42
if (num_pill < 2) {
53
return 0;

kata/8 kyu/printing-array-elements-with-comma-delimiters/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function printArray(array: any[]): string {
1+
function printArray<T>(array: T[]): string {
22
return array.join(',');
33
}
44

kata/8 kyu/repeatit/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
function repeatIt(str: any, n: number): string | 'Not a string' {
1+
import type { Any } from '../../@types/types.ts';
2+
3+
function repeatIt(str: Any, n: number): string | 'Not a string' {
24
if (typeof str !== 'string') {
35
return 'Not a string';
46
}

kata/8 kyu/the-if-function/index.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-console */
2-
31
import assert from 'node:assert/strict';
42
import { describe, it, mock } from 'node:test';
53
import _if from './index.ts';

kata/8 kyu/the-if-function/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-underscore-dangle */
2-
31
function _if(bool: boolean, func1: () => void, func2: () => void): void {
42
return bool ? func1() : func2();
53
}

kata/8 kyu/training-js-number-1-create-your-first-js-function-and-print-helloworld/index.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-console */
2-
31
import assert from 'node:assert/strict';
42
import { describe, it, mock } from 'node:test';
53
import helloWorld from './index.ts';

kata/8 kyu/training-js-number-1-create-your-first-js-function-and-print-helloworld/index.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
/* eslint-disable no-console */
2-
/* eslint-disable no-var */
3-
41
function helloWorld(): void {
5-
var str = 'Hello World!';
2+
const str = 'Hello World!';
63

74
console.log(str);
85
}

kata/8 kyu/training-js-number-6-basic-data-types-boolean-and-conditional-statements-if-dot-else/index.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/* eslint-disable @typescript-eslint/ban-ts-comment */
2-
/* eslint-disable no-bitwise */
3-
42
// @ts-nocheck
53

64
import assert from 'node:assert/strict';

kata/@types/types.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2+
type Any = any;
3+
4+
export type { Any };

0 commit comments

Comments
 (0)