chore: add eslint, remove dead variables, pin line endings (P0-4)
This commit is contained in:
10
.gitattributes
vendored
Normal file
10
.gitattributes
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
* text=auto
|
||||||
|
*.sh text eol=lf
|
||||||
|
*.ps1 text eol=crlf
|
||||||
|
*.png binary
|
||||||
|
*.jpg binary
|
||||||
|
*.ogg binary
|
||||||
|
*.wav binary
|
||||||
|
*.mp3 binary
|
||||||
|
*.ttf binary
|
||||||
|
*.sqlite binary
|
||||||
33
eslint.config.js
Normal file
33
eslint.config.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
// ESLint (flat config). `npm run lint`. Catches real bugs (undefined names, unused code, typos) - no style rules.
|
||||||
|
'use strict';
|
||||||
|
const js = require('@eslint/js');
|
||||||
|
const globals = require('globals');
|
||||||
|
|
||||||
|
// shared across the classic <script> files of the game (no modules, see CLAUDE.md)
|
||||||
|
const gameGlobals = { RC: 'writable', Kit: 'writable', THREE: 'readonly', KIT_ASSETS: 'readonly', module: 'readonly', require: 'readonly' };
|
||||||
|
|
||||||
|
module.exports = [
|
||||||
|
{
|
||||||
|
ignores: ['node_modules/**', 'server/node_modules/**', 'release/**', 'game/vendor/**', 'game/kit/**',
|
||||||
|
'launcher/**', 'sprite-generator/**', 'tools/shots/**', 'admin/**'],
|
||||||
|
},
|
||||||
|
js.configs.recommended,
|
||||||
|
{
|
||||||
|
rules: {
|
||||||
|
'no-unused-vars': ['warn', { args: 'none', caughtErrors: 'none' }],
|
||||||
|
'no-empty': ['error', { allowEmptyCatch: true }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['game/**/*.js', 'tools/**/*.js'],
|
||||||
|
languageOptions: { sourceType: 'script', globals: { ...globals.browser, ...gameGlobals } },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['server/**/*.js', 'tests/**/*.js', 'eslint.config.js'],
|
||||||
|
languageOptions: { sourceType: 'commonjs', globals: { ...globals.node } },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['**/*.mjs'],
|
||||||
|
languageOptions: { sourceType: 'module', globals: { ...globals.node } },
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -33,7 +33,6 @@
|
|||||||
}
|
}
|
||||||
const saw = (x, z, phase) => ({ x, z, r: 0.95, period: 6, on: 2.2, phase });
|
const saw = (x, z, phase) => ({ x, z, r: 0.95, period: 6, on: 2.2, phase });
|
||||||
const flame = (x, z, phase) => ({ x, z, hw: 0.9, hd: 0.9, period: 7, on: 1.8, phase });
|
const flame = (x, z, phase) => ({ x, z, hw: 0.9, hd: 0.9, period: 7, on: 1.8, phase });
|
||||||
const saw2 = saw, flame2 = flame;
|
|
||||||
const block = (kind, x, z, hw, hd, h2) => ({ kind, x, z, hw, hd, h: h2 || 0.8 });
|
const block = (kind, x, z, hw, hd, h2) => ({ kind, x, z, hw, hd, h: h2 || 0.8 });
|
||||||
const belt = (x, z, hw, hd, ax, az, force) => ({ x, z, hw, hd, ax, az, force });
|
const belt = (x, z, hw, hd, ax, az, force) => ({ x, z, hw, hd, ax, az, force });
|
||||||
const ram = (x, z, hw, hd, nx, nz, phase) => ({ x, z, hw, hd, nx, nz, period: 5, on: 1.3, phase });
|
const ram = (x, z, hw, hd, nx, nz, phase) => ({ x, z, hw, hd, nx, nz, period: 5, on: 1.3, phase });
|
||||||
|
|||||||
@@ -661,7 +661,6 @@
|
|||||||
|
|
||||||
// per-frame robot animation from the combat state
|
// per-frame robot animation from the combat state
|
||||||
function poseRobot(R, r, dt) {
|
function poseRobot(R, r, dt) {
|
||||||
const w = R.st.weapon;
|
|
||||||
R.root.position.set(r.x, r.y, r.z);
|
R.root.position.set(r.x, r.y, r.z);
|
||||||
R.root.rotation.y = -r.a;
|
R.root.rotation.y = -r.a;
|
||||||
// upside down when flipped
|
// upside down when flipped
|
||||||
@@ -759,7 +758,7 @@
|
|||||||
const scene_add = o => group.add(o);
|
const scene_add = o => group.add(o);
|
||||||
scene.background = new T.Color(th.bg);
|
scene.background = new T.Color(th.bg);
|
||||||
scene.fog = new T.Fog(th.fog, half * 3, half * 5.5);
|
scene.fog = new T.Fog(th.fog, half * 3, half * 5.5);
|
||||||
const { key, rimA, rimB, flashLight } = out.lights;
|
const { key, rimA, rimB } = out.lights;
|
||||||
const sc = Math.max(11, half + 3);
|
const sc = Math.max(11, half + 3);
|
||||||
Object.assign(key.shadow.camera, { left: -sc, right: sc, top: sc, bottom: -sc }); key.shadow.camera.updateProjectionMatrix();
|
Object.assign(key.shadow.camera, { left: -sc, right: sc, top: sc, bottom: -sc }); key.shadow.camera.updateProjectionMatrix();
|
||||||
rimA.color.setHex(th.rimA); rimA.position.set(-half - 1, 5, half + 1); rimA.distance = half * 2.6;
|
rimA.color.setHex(th.rimA); rimA.position.set(-half - 1, 5, half + 1); rimA.distance = half * 2.6;
|
||||||
@@ -1343,7 +1342,6 @@
|
|||||||
|
|
||||||
// ---- intro: dark arena -> floodlights flicker on -> camera sweeps up -> two robots are lowered in
|
// ---- intro: dark arena -> floodlights flicker on -> camera sweeps up -> two robots are lowered in
|
||||||
const INTRO_END = RC.INTRO_END = 5.2;
|
const INTRO_END = RC.INTRO_END = 5.2;
|
||||||
const ease = u => (u < 0.5 ? 2 * u * u : 1 - Math.pow(-2 * u + 2, 2) / 2);
|
|
||||||
function lightsOn(k) {
|
function lightsOn(k) {
|
||||||
const L = arena.lights;
|
const L = arena.lights;
|
||||||
L.key.intensity = 1.25 * k; L.rimA.intensity = 1.1 * k; L.rimB.intensity = 0.9 * k;
|
L.key.intensity = 1.25 * k; L.rimA.intensity = 1.1 * k; L.rimB.intensity = 0.9 * k;
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
// ready-made [body, accent] combinations
|
// ready-made [body, accent] combinations
|
||||||
RC.SCHEMES = [[0xff7a1a, 0x15171b], [0x15171b, 0xff7a1a], [0x2a6fd8, 0xe6e6e6], [0xd8452b, 0xf2c230],
|
RC.SCHEMES = [[0xff7a1a, 0x15171b], [0x15171b, 0xff7a1a], [0x2a6fd8, 0xe6e6e6], [0xd8452b, 0xf2c230],
|
||||||
[0x5fae3b, 0x15171b], [0x6a3fb0, 0xf2c230], [0xe6e6e6, 0xd8452b], [0x3a3d44, 0x2e9c8f]];
|
[0x5fae3b, 0x15171b], [0x6a3fb0, 0xf2c230], [0xe6e6e6, 0xd8452b], [0x3a3d44, 0x2e9c8f]];
|
||||||
const hex = n => '#' + (n >>> 0).toString(16).padStart(6, '0');
|
|
||||||
const SELL = 0.5;
|
const SELL = 0.5;
|
||||||
const HOTKEY = { weapon: 'hk_weapon', tower: 'hk_tower', gadget: 'hk_gadget' };
|
const HOTKEY = { weapon: 'hk_weapon', tower: 'hk_tower', gadget: 'hk_gadget' };
|
||||||
const GLYPH = { chassis: '🧱', motor: '⚙️', wheels: '🛞', battery: '🔋', armour: '🛡️', weapon: '🪓', tower: '🔥', gadget: '🧰' };
|
const GLYPH = { chassis: '🧱', motor: '⚙️', wheels: '🛞', battery: '🔋', armour: '🛡️', weapon: '🪓', tower: '🔥', gadget: '🧰' };
|
||||||
|
|||||||
1087
package-lock.json
generated
1087
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,9 @@
|
|||||||
"build:web": "node build-web.mjs"
|
"build:web": "node build-web.mjs"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@eslint/js": "^9.39.5",
|
||||||
|
"eslint": "^9.39.5",
|
||||||
|
"globals": "^16.5.0",
|
||||||
"terser": "^5.46.1"
|
"terser": "^5.46.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ function getTree(p) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const setNode = db.prepare('INSERT INTO nodes (path, data, ts) VALUES (?, ?, ?) ON CONFLICT(path) DO UPDATE SET data = excluded.data, ts = excluded.ts');
|
const setNode = db.prepare('INSERT INTO nodes (path, data, ts) VALUES (?, ?, ?) ON CONFLICT(path) DO UPDATE SET data = excluded.data, ts = excluded.ts');
|
||||||
const delExact = db.prepare('DELETE FROM nodes WHERE path = ?');
|
|
||||||
const delTree = db.prepare('DELETE FROM nodes WHERE path = ? OR path LIKE ?');
|
const delTree = db.prepare('DELETE FROM nodes WHERE path = ? OR path LIKE ?');
|
||||||
|
|
||||||
function putTree(p, value) { // replace the whole subtree at p
|
function putTree(p, value) { // replace the whole subtree at p
|
||||||
|
|||||||
Reference in New Issue
Block a user