Skip to content

Commit

Permalink
Update eslint config to use tseslint helper and fix new linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
leeyi45 committed Oct 22, 2024
1 parent 297452b commit 80768e9
Show file tree
Hide file tree
Showing 13 changed files with 788 additions and 798 deletions.
18 changes: 11 additions & 7 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @ts-check

import js from '@eslint/js';
import stylePlugin from '@stylistic/eslint-plugin';
import importPlugin from 'eslint-plugin-import';
import * as importPlugin from 'eslint-plugin-import';
import jestPlugin from 'eslint-plugin-jest';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import globals from 'globals';
Expand All @@ -9,10 +11,7 @@ import tseslint from 'typescript-eslint';
const todoTreeKeywordsWarning = ['TODO', 'TODOS', 'TODO WIP', 'FIXME', 'WIP'];
const todoTreeKeywordsAll = [...todoTreeKeywordsWarning, 'NOTE', 'NOTES', 'LIST'];

/**
* @type {import('eslint').Linter.FlatConfig[]}
*/
export default [
export default tseslint.config(
{
// global ignores
ignores: [
Expand Down Expand Up @@ -115,8 +114,13 @@ export default [
rules: {
'prefer-const': 'warn', // Was 'error'

'@typescript-eslint/no-empty-object-type': ['error', {
allowInterfaces: 'with-single-extends',
allowWithName: '(?:Props)|(?:State)$'
}],
'@typescript-eslint/no-namespace': 'off', // Was 'error'
'@typescript-eslint/no-var-requires': 'warn', // Was 'error'
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/switch-exhaustiveness-check': 'error',
},
},
Expand Down Expand Up @@ -154,7 +158,7 @@ export default [
},
globals: {
...globals.browser,
...globals.node2020
...globals.node
}
},
},
Expand All @@ -176,4 +180,4 @@ export default [
'jest/valid-describe-callback': 'off'
}
}
];
);
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react-hooks": "^4.4.0",
"globals": "^14.0.0",
"globals": "^15.11.0",
"http-server": "^0.12.3",
"husky": "^9.0.11",
"jest": "^29.7.0",
Expand All @@ -85,7 +85,7 @@
"ts-jest": "^29.1.2",
"typedoc": "^0.25.12",
"typescript": "^5.4.3",
"typescript-eslint": "^7.10.0",
"typescript-eslint": "^8.11.0",
"vite": "^5.2.11",
"yarnhook": "^0.5.1"
},
Expand Down
8 changes: 4 additions & 4 deletions src/bundles/ar/ObjectsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function createCubeObject(
height: number,
depth: number,
color: number,
onSelect?: () => {},
onSelect?: () => any
): CubeObject {
return new CubeObject(
uniqid(),
Expand Down Expand Up @@ -82,7 +82,7 @@ export function createSphereObject(
position: Vector3,
radius: number,
color: number,
onSelect?: () => {},
onSelect?: () => any
): SphereObject {
return new SphereObject(
uniqid(),
Expand Down Expand Up @@ -112,7 +112,7 @@ export function createGltfObject(
position: Vector3,
src: string,
scale: number,
onSelect?: () => {},
onSelect?: () => any,
): GltfObject {
return new GltfObject(
uniqid(),
Expand Down Expand Up @@ -140,7 +140,7 @@ export function createGltfObject(
export function createInterfaceObject(
position: Vector3,
rootComponent: UIBasicItem,
onSelect?: () => {},
onSelect?: () => any
): UIObject {
return new UIObject(
uniqid(),
Expand Down
2 changes: 1 addition & 1 deletion src/bundles/copy_gc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ function get_flips(): number[] {
return flips;
}

function get_types(): String[] {
function get_types(): string[] {
return typeTag;
}

Expand Down
8 changes: 4 additions & 4 deletions src/bundles/copy_gc/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ export enum COMMAND {
}

export type CommandHeapObject = {
type: String;
type: string;
to: number;
from: number;
heap: number[];
left: number;
right: number;
sizeLeft: number;
sizeRight: number;
desc: String;
desc: string;
scan: number;
leftDesc: String;
rightDesc: String;
leftDesc: string;
rightDesc: string;
free: number;
};
2 changes: 1 addition & 1 deletion src/bundles/mark_sweep/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ function get_flips(): number[] {
return flips;
}

function get_types(): String[] {
function get_types(): string[] {
return typeTag;
}

Expand Down
8 changes: 4 additions & 4 deletions src/bundles/mark_sweep/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ export enum COMMAND {
}

export type CommandHeapObject = {
type: String;
type: string;
heap: number[];
left: number;
right: number;
sizeLeft: number;
sizeRight: number;
desc: String;
leftDesc: String;
rightDesc: String;
desc: string;
leftDesc: string;
rightDesc: string;
queue: number[];
};
4 changes: 2 additions & 2 deletions src/bundles/physics_2d/PhysicsWorld.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ export class PhysicsWorld {
return this.b2World;
}

public getWorldStatus(): String {
let world_status: String = `
public getWorldStatus(): string {
let world_status: string = `
World time: ${this.timer.toString()}
Objects:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Wheel', () => {
getMass: jest.fn().mockReturnValue(1),
getCollider: jest.fn().mockReturnValue({}),
}),
},
};
mockConfig = {
displacement: { x: 1, y: 0, z: 0 },
pid: {
Expand Down
8 changes: 4 additions & 4 deletions src/tabs/CopyGc/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ type State = {
tags: number[];
heap: number[];
commandHeap: any[];
command: String;
command: string;
flips: number[];
toMemoryMatrix: number[][];
fromMemoryMatrix: number[][];
firstChild: number;
lastChild: number;
description: String;
leftDesc: String;
rightDesc: String;
description: string;
leftDesc: string;
rightDesc: string;
running: boolean;
};

Expand Down
8 changes: 4 additions & 4 deletions src/tabs/MarkSweep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ type State = {
tags: number[];
heap: number[];
commandHeap: any[];
command: String;
command: string;
flips: number[];
memoryMatrix: number[][];
firstChild: number;
lastChild: number;
description: String;
leftDesc: String;
rightDesc: String;
description: string;
leftDesc: string;
rightDesc: string;
unmarked: number;
marked: number;
queue: number[];
Expand Down
3 changes: 1 addition & 2 deletions src/tabs/Nbody/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ type Props = {
/**
* React component state for the viz tab.
*/
type State = {
};
type State = {};

/**
* React component props for the control buttons.
Expand Down
Loading

0 comments on commit 80768e9

Please sign in to comment.