printhive/eslint.config.js
dlawler489 ac88a247ae Add ESLint, and run it with the tests in CI
A variable declared inside a try block but read after it shipped and broke
collection checks for a day; tests can't reach that path and node --check
only parses. ESLint flags it as no-undef. Wired into npm run lint / check
and into CI before the image build, so a failure stops the build.

Three findings fixed on the way: an unread argument, and two values
assigned then immediately replaced.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-21 11:40:43 +10:00

45 lines
1.3 KiB
JavaScript

// Lint rules, kept to the mistakes tests can't catch — chiefly a name that
// doesn't exist, which only shows up when that line finally runs.
const js = require('@eslint/js');
const globals = require('globals');
module.exports = [
{ ignores: ['node_modules/**', 'uploads/**', 'thumbnails/**', 'glb/**', 'extracted/**', 'models/**', 'data/**', 'backups/**', 'tools/venv/**'] },
// The server: Node, CommonJS.
{
files: ['**/*.js'],
languageOptions: {
ecmaVersion: 2023,
sourceType: 'commonjs',
globals: { ...globals.node },
},
rules: {
...js.configs.recommended.rules,
'no-unused-vars': ['error', { argsIgnorePattern: '^_|^next$', caughtErrors: 'none' }],
},
},
// The browser: plain scripts sharing globals across files, plus one module.
{
files: ['public/**/*.js'],
languageOptions: {
sourceType: 'script',
globals: {
...globals.browser,
ModelViewer: 'readonly', // viewer.js hangs it on window
PRINTER_MODELS: 'readonly', // printer-art.js does the same
},
},
},
{
files: ['public/viewer.js'],
languageOptions: { sourceType: 'module' },
},
// Tests.
{
files: ['test/**/*.js'],
languageOptions: { globals: { ...globals.node } },
},
];