Skip to content

Commit a23884f

Browse files
dx: Enable eslint-plugin-typegpu in repo (#2193)
1 parent 4a98e0f commit a23884f

17 files changed

Lines changed: 262 additions & 138 deletions

File tree

.oxlintrc.json

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

apps/typegpu-docs/src/examples/algorithms/concurrent-chart/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ async function runBenchmarks() {
7272
drawCharts();
7373
}
7474

75-
runBenchmarks();
75+
void runBenchmarks();
7676

7777
// #region Example controls & Cleanup
7878

apps/typegpu-docs/src/examples/common/setup-first-person-camera.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export function setupFirstPersonCamera(
106106

107107
// mouse events
108108
canvas.addEventListener('mousedown', () => {
109-
canvas.requestPointerLock();
109+
void canvas.requestPointerLock();
110110
});
111111

112112
canvas.addEventListener('mousemove', (event: MouseEvent) => {

apps/typegpu-docs/src/examples/tests/prefix-scan/functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function applyOp(
3737
a: number | undefined,
3838
b: number | undefined,
3939
): number {
40-
return op.operation(a as number & d.F32, b as number & d.F32) as number;
40+
return op.operation(a as number & d.F32, b as number & d.F32);
4141
}
4242

4343
export function prefixScanJS(arr: number[], op: BinaryOp) {

apps/typegpu-docs/src/examples/tests/prefix-scan/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ const table = document.querySelector<HTMLDivElement>('.result');
263263
if (!table) {
264264
throw new Error('Nowhere to display the results');
265265
}
266-
runTests().then((result) => {
266+
void runTests().then((result) => {
267267
table.innerText = `Tests ${result ? 'succeeded' : 'failed'}.`;
268268
});
269269

apps/typegpu-docs/src/examples/threejs/varyings/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ dirLight.position.set(-7, 10, 0);
8282
scene.add(dirLight);
8383
scene.add(new THREE.AmbientLight(0x444444));
8484

85-
renderer.setAnimationLoop(() => {
85+
void renderer.setAnimationLoop(() => {
8686
renderer.render(scene, camera);
8787
});
8888

oxlint.config.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { defineConfig } from 'oxlint';
2+
import typegpu from 'eslint-plugin-typegpu';
3+
4+
const typegpuPreset = typegpu.configs?.recommended;
5+
const typegpuRules = typegpuPreset && 'rules' in typegpuPreset
6+
? typegpuPreset.rules
7+
: {};
8+
9+
export default defineConfig({
10+
plugins: ['eslint', 'typescript', 'import', 'unicorn', 'oxc'],
11+
jsPlugins: ['eslint-plugin-typegpu'],
12+
categories: {
13+
correctness: 'warn',
14+
suspicious: 'warn',
15+
},
16+
rules: {
17+
...typegpuRules,
18+
'typescript/no-unsafe-enum-comparison': 'off',
19+
'typescript/restrict-template-expressions': 'off',
20+
'typescript/no-unsafe-type-assertion': 'off',
21+
'typescript/no-explicit-any': 'error',
22+
'typescript/no-non-null-assertion': 'error',
23+
'eslint/no-shadow': 'off',
24+
'eslint-plugin-unicorn/prefer-add-event-listener': 'off',
25+
'eslint-plugin-import/no-named-as-default': 'off',
26+
'eslint-plugin-import/no-named-as-default-member': 'off',
27+
'eslint-plugin-import/extensions': [
28+
'error',
29+
'always',
30+
{ ignorePackages: true },
31+
],
32+
},
33+
ignorePatterns: ['**/*.astro', '**/*.mjs'],
34+
overrides: [
35+
{
36+
files: ['**/*.test.ts', '**/tests/**'],
37+
rules: {
38+
'typescript/unbound-method': 'off',
39+
'typescript/no-non-null-assertion': 'off',
40+
'eslint/no-unused-vars': 'off',
41+
'eslint/no-unused-expressions': 'off',
42+
'eslint-plugin-unicorn/consistent-function-scoping': 'off',
43+
'eslint/no-unsafe-optional-chaining': 'off',
44+
'eslint/no-constant-condition': 'off',
45+
},
46+
},
47+
],
48+
env: {
49+
builtin: true,
50+
},
51+
});

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"test": "pnpm run test:types && pnpm run test:style && pnpm run test:unit-and-attest && pnpm run test:circular-deps",
1212
"test:circular-deps": "pnpm dpdm -T --exit-code circular:1 packages/**/index.ts",
1313
"test:types": "pnpm run -r --parallel test:types",
14-
"test:style": "oxlint --type-aware && deno fmt --check",
14+
"test:style": "oxlint --max-warnings=0 --type-aware && deno fmt --check",
1515
"test:unit-and-attest": "vitest run --project=!browser",
1616
"test:unit": "ATTEST_skipTypes=1 vitest run --project=!browser",
1717
"test:unit:watch": "ATTEST_skipTypes=1 vitest --project=!browser",
@@ -43,8 +43,9 @@
4343
"@vitest/coverage-v8": "3.1.2",
4444
"@webgpu/types": "catalog:types",
4545
"dpdm": "^3.14.0",
46+
"eslint-plugin-typegpu": "workspace:*",
4647
"jiti": "catalog:build",
47-
"oxlint": "^1.43.0",
48+
"oxlint": "^1.49.0",
4849
"oxlint-tsgolint": "^0.12.1",
4950
"pkg-pr-new": "^0.0.62",
5051
"typescript": "catalog:types",

packages/eslint-plugin/package.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@
55
"type": "module",
66
"exports": {
77
".": {
8-
"types": "./dist/index.d.ts",
9-
"import": "./dist/index.js"
8+
"types": "./src/index.ts",
9+
"import": "./src/index.ts"
10+
}
11+
},
12+
"publishConfig": {
13+
"exports": {
14+
".": {
15+
"types": "./dist/index.d.mts",
16+
"import": "./dist/index.mjs"
17+
}
1018
}
1119
},
1220
"scripts": {
13-
"build": "tsup",
21+
"build": "tsdown",
1422
"test:types": "pnpm tsc --p ./tsconfig.json --noEmit",
1523
"test": "vitest"
1624
},
@@ -27,6 +35,7 @@
2735
"@types/node": "^25.0.10",
2836
"@typescript-eslint/rule-tester": "^8.53.1",
2937
"eslint": "^9.39.2",
38+
"tsdown": "^0.20.3",
3039
"typescript": "^5.9.3",
3140
"vitest": "^4.0.17"
3241
}

packages/eslint-plugin/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pkg from '../package.json';
1+
import pkg from '../package.json' with { type: 'json' };
22
import type { TSESLint } from '@typescript-eslint/utils';
33
import { allRules, recommendedRules, rules } from './configs.ts';
44

0 commit comments

Comments
 (0)