Lint Plugin
eslint-plugin-typegpu is an optional (but highly recommended) tool for projects using TypeGPU. It helps with writing ‘use gpu’ functions by highlighting common pitfalls and unsupported syntax.
Installation
Section titled “Installation”npm add -D eslint-plugin-typegpupnpm add -D eslint-plugin-typegpuyarn add -D eslint-plugin-typegpuAfter installing, the plugin still needs to be added to a config. The way this is done depends on the linter used.
Configuring
Section titled “Configuring”ESLint (eslint.config.js)
Section titled “ESLint (eslint.config.js)”The plugin needs to be imported and included in defineConfig.
import { defineConfig } from 'eslint/config';import typegpu from 'eslint-plugin-typegpu';
export default defineConfig([ { plugins: { typegpu }, rules: { 'typegpu/no-integer-division': 'warn', 'typegpu/no-math': 'warn', // other rules you want to enable } }]);The plugin also exports recommended and all configs, which may be used instead of listing the rules one by one.
import { defineConfig } from 'eslint/config';import typegpu from 'eslint-plugin-typegpu';
export default defineConfig([ typegpu.configs.recommended,]);Oxlint (oxlint.config.ts)
Section titled “Oxlint (oxlint.config.ts)”The plugin needs to be listed in jsPlugins. The rules can either be listed one by one, or a config can be used.
import { defineConfig } from 'oxlint';import typegpu from 'eslint-plugin-typegpu';
export default defineConfig({ jsPlugins: ['eslint-plugin-typegpu'], rules: { ...typegpu.configs.recommended.rules, // (optional) changes from the recommended preset },});Oxlint (.oxlintrc.json)
Section titled “Oxlint (.oxlintrc.json)”The plugin needs to be listed in jsPlugins, and the rules have to be listed one by one.
In this type of config there is no way to enable all rules
{ "$schema": "./node_modules/oxlint/configuration_schema.json", "jsPlugins": ["eslint-plugin-typegpu"], "rules": { "typegpu/no-integer-division": "warn", "typegpu/no-math": "warn", ... }}For the full list of supported rules, as well as their specifics, see the README.md of the plugin.