Repository navigation
v1.63: ESLint in CI and a syntax check of every script - #61
Merged
Merged
Conversation
Adds an ESLint flat config for the code as it is (classic browser scripts on window.Amber, CommonJS unit checks and specs; 4-space indent, single quotes, semicolons), an `npm run lint` script, and a lint step in the Tests workflow. A small local rule, no-extra-arguments, reports calls that pass more arguments than a function in the same file takes. Fixes what it found, with no change in behaviour: the unused amberRates in computePlanTotals and perKwh in precalculateDailySummaries and channelPeriodBreakdown, demandMonthsHtml's ignored second argument, shadowed names (money, th, sum, d), an unused n in simulateBattery, a raw byte-order mark inside two regex literals, and unused helpers in three specs. tests/unit-syntax.js now starts the unit run: it parses every js/*.js and checks that index.html loads each of them once, with app.js last. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016net8VqMzbBJe1deXahjg6
RickUsingGitHub
marked this pull request as ready for review
November 10, 2026 20:43
RickUsingGitHub
added a commit
that referenced
this pull request
Nov 15, 2026
v1.63: ESLint in CI and a syntax check of every script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 1 of 2 of the structural clean-up left over from the v1.62 code review. No change in behaviour. Step 2 (splitting
js/app.js) follows as its own pull request on top of this one.What's added
eslint.config.js(ESLint 10, flat config) suited to the code as it is:js/*.jsare linted as classic browser scripts (no modules), withChart,pdfjsLibandmoduleas the only extra globals.Amberneeds none: each file declares it.tests/unit-*.js,scripts/and the config files are CommonJS; the Playwright specs get Node and browser globals.no-unused-vars,no-shadow,no-var,prefer-const,eqeqeq, and the house style from@stylistic/eslint-plugin: 4-space indent, single quotes, semicolons.eslint-rules/no-extra-arguments.js, a small rule of the project's own. ESLint has nothing built in for a call that passes more arguments than the function takes, which is what thedemandMonthsHtmlleftover was. It checks functions, andAmber.*functions, defined in the same file, and leaves alone anything with...rest,argumentsor a spread call.npm run lint, and a lint step in.github/workflows/test.yml(straight afternpm ci, so it fails before the browsers are installed).tests/unit-syntax.js, now first in the unit run. It parses everyjs/*.js(no other unit script loadshelp.js,app.jsand the other DOM files), and checks thatindex.htmlloads each of them once, withapp.jslast. That second check is there for the split in step 2.What it found, and what was done
amberRatescomputePlanTotals(js/costs.js)perKwhprecalculateDailySummariesand alsochannelPeriodBreakdown(js/costs.js)demandMonthsHtml(…, 'demandDays'), twice (js/app.js)money(four functions had their own, under a file-level one)js/app.jsdisplayResults, so it moved in there. Each function keeps its own formatter, unchangedth,d; an initialnullnever readjs/planner-ui.jsthgave the same output as the outer one, so it went;drenamedsum; unusednplanYear,simulateBattery(js/planner.js)weighted; removedidjs/calendar.jsObject.valuesinstead ofObject.entriesjs/estimate.js,js/import.jsletthat never changes (7)constnem12,planner,uispecs; a shadowed name inunit-planner.jsRules tuned rather than code restyled
assertconditions and tables of cases (indent checks for call arguments and arrays are off undertests/).preserve-caught-erroris off: network errors are replaced on purpose by a plain message.eslint-disable-next-lineinjs/redispatch.js, on a tally that isn't read again but should stay right if a step is added after it.Checks
npm run lint: clean.npm run test:unit: passes (383oklines).mainbefore the change.npm run build:cssleavescss/app.cssunchanged.index.html,js/constants.jsandtests/unit-time.js;README.md,CLAUDE.mdanddocs/updated.Generated by Claude Code