@noctcore/eslint-plugin-three
A bad fit for code that never touches three.js, and it matches by syntax: a mesh handed to your own disposal helper is trusted to be disposed there.
three.js and React Three Fiber performance and leaks: capped pixel ratios, disposed GPU resources, camera projections that update, and frame loops that neither allocate nor re-render.
What it solves
Section titled “What it solves”A 3D scene fails slowly. An uncapped pixel ratio, a geometry that is never disposed, a new Vector3() in the frame loop or a React state update on every frame all pass review and every test, then show up as dropped frames, a hot phone and GPU memory that climbs each time a component remounts. Neither TypeScript nor a generic linter knows what a frame loop or a GPU resource is; these rules do, without type information. They run only in files that import three, a three/* subpath, three-stdlib or an @react-three/* package (or a module you name in extraModules), so another engine’s camera.fov is left alone.
What it will yell at you about
Section titled “What it will yell at you about”It will yell at you about setPixelRatio(window.devicePixelRatio) and a <Canvas dpr> above 2, geometries, materials and textures an effect creates and never disposes, the same resources built in a component body, new Vector3() and friends inside useFrame, state setters called on every frame, camera.fov changed without updateProjectionMatrix() and setMatrixAt() without instanceMatrix.needsUpdate. Four opt-in rules cover WebGL support checks that pass on software renderers, shadow maps above a size budget, and PCFSoftShadowMap and new Clock() on a three.js release that has deprecated them (the version is read from your package.json). It is a bad fit for code that never touches three.js, and it matches by syntax: a mesh handed to your own disposal helper is trusted to be disposed there.
Install and configure
Section titled “Install and configure”npm install --save-dev @noctcore/eslint-plugin-three @typescript-eslint/parser# or: bun add -D / pnpm add -D @noctcore/eslint-plugin-three @typescript-eslint/parserThe recommended preset enables 7 of 11 rules. The rules board below builds the flat config: start from a preset, switch single rules between error and off, and copy the result.
Each rule links to its page, with the options it takes and Incorrect and Correct examples. A good first
read is require-dispose.
--fixsuggestionsneeds optionstype infoEach switch sets a rule to error or off.
failIfMajorPerformanceCaveat: true on a WebGL getContext() call whose result is only tested, so a support check says no on software renderers.PCFSoftShadowMap, named directly or selected through R3F <Canvas shadows>, from the three.js release that deprecated it (r182, or r186 for the WebGPU build).instanceMatrix.needsUpdate (or instanceColor.needsUpdate) to be set in the function that calls setMatrixAt() (or setColorAt()) on an InstancedMesh.useFrame, setAnimationLoop, a self-scheduling requestAnimationFrame function).Clock on three.js r183 or later, where Timer replaces it.useFrame, setAnimationLoop, a self-scheduling requestAnimationFrame function).devicePixelRatio or set above a cap, in setPixelRatio() and R3F <Canvas dpr>.dispose() for three.js geometries, materials, textures and render targets that a React effect creates and puts in the scene.shadow.mapSize above a cap, set in code or through R3F shadow-mapSize props.camera.updateProjectionMatrix() after assigning a projection field (fov, aspect, near, far, zoom, orthographic bounds) in the same function.