The Expensive Way to Find Out You Were Wrong
Finding out late costs a browser, a test setup, and time spent deciding what to test. Coralite tries to tell you at build time instead.
This is a post about Coralite and compile-time errors in the front end.
One of the things I did with Coralite is make it compile and tell me what's wrong. I've been using it long enough that I now expect a line number and a suggested fix when something breaks. I expect to find out I was wrong in about the time it takes to save a file.
Which means I've stopped noticing that it's unusual. This post is an attempt to describe what the loop used to be like, and what changed.
Finding out late
In the front end, the usual lifecycle is an end-to-end test. Something like Playwright. You write the test, run it, wait for a browser, read the error, and work out whether the failure is in the code or in the test.
That's pretty expensive. It needs a browser or a headless browser, and a setup you keep paying for as the app grows.
It takes time to set up, and more time to figure out what you want to test.
The second one is the part nobody budgets for. You have to hold the intended behaviour in your head, turn it into an assertion, and hope the assertion is about the thing that's actually broken rather than the thing that's easy to assert.
Runtime errors in React are the same story. You need the app in a state where the component renders, and a browser to look at it. You can automate that, but the automation has its own cost.
With an AI in the loop it gets worse. The model proposes a change, the browser runs, the test fails, the model reads the failure, and the model proposes another change. Every round trip costs a browser launch and a few thousand tokens. It works. It's just slow enough that you start avoiding it.
What Coralite catches
A lot of this can be caught earlier. You don't need a browser for it.
If you've created an anti-pattern, if a ref isn't declared, if you're reading an element the wrong way, or if there's a type error, Coralite tells you at build time. You get the file, the line, and a suggested fix. Sometimes it can apply the fix itself.
This doesn't replace end-to-end tests. Race conditions between components, layouts that break at one viewport, a password manager filling a form: none of that shows up in static analysis. The point is that a lot of errors were being sent to the expensive place when a cheaper one was available.
A real run against a component with an inline handler and a module-scope import in client(), trimmed to one finding:
$ coralite check
src/components/ui-counter.html
┌─ [CORALITE-E301] Top-level import 'log' referenced inside client() block.
│ File: src/components/ui-counter.html:15:5
├─ Code Context ────────────────────────────────────────────────────────────────
14 | export async function client ({ state, refs, signal }) {
> 15 | log('mounted')
| ^
16 | refs('button').addEventListener('click', () => {
├─ Why this failed ─────────────────────────────────────────────────────────────
│ Top-level imports cannot be referenced inside client() block as client code
│ is executed in browser context.
├─ Suggested 1-Shot Fix ────────────────────────────────────────────────────────
│ Convert top-level import 'log' to dynamic import inside client()
│ const { log } = await import('../utils/log.js')
└───────────────────────────────────────────────────────────────────────────────
The transformation coralite fix applies:
<template id="ui-counter">
- <button ref="button" type="button" onclick="increment()">
+ <button ref="button" type="button">
Count is {{ count }}
</button>
</template>
<script type="module">
- import { log } from '../utils/log.js'
export function server () {
return { count: 0 }
}
export async function client ({ state, refs, signal }) {
+ const { log } = await import('../utils/log.js')
log('mounted')
refs('button').addEventListener('click', () => {
state.count++
}, { signal })
}
</script>
That's why --dry-run exists. You preview the change, read the diff, then apply it.
The check script
All of the checks are one command, coralite check. You can filter to the codes you're working on with --code, and --format json gives you a report that CI or an agent can read.
The catalogue behind it is a page and a CLI command. coralite diagnostics lists every code with its severity and whether coralite fix can repair it. Today it holds:
| Domain | Codes | Count | What it audits |
|---|---|---|---|
| Component | E1xx–E4xx, W2xx–W6xx |
24 | Template syntax, attribute schemas, script boundaries, reactivity, dead code. |
| Plugin | P1xx–P4xx |
17 | Plugin contracts, lifecycle hooks, config schemas, serialization boundaries. |
| Page | PAGE-101–201 |
4 | Custom element registration, required attributes, encapsulation. |
| Accessibility | A101–A105 |
4 | Alt text, accessible names, ARIA support, nested interactives. |
| Configuration | CFG-001–003 |
3 | CSP mode and directive configuration. |
A few examples. E201 rejects a template expression like {{ count + 1 }} and lifts it into a getter. E202 catches refs('increment') when nothing in the template declares that ref. E301 catches a module-scope import used inside client() and rewrites it to await import().
The rest of the catalogue covers the same kinds of problems: page scripts reaching into component internals, missing alt text, state mutated inside observe(), and CSP configuration mistakes. Component diagnostics can be silenced with a pragma. Configuration and route errors stop the build and can't be ignored.
coralite diagnostics
coralite diagnostics --family plugin --fixable
coralite diagnostics --search template --format json
Why it can do this at build time
None of it needs a browser because the rules are strict. Templates only hold tokens, so every token has to resolve to a declared symbol. Logic lives in named exports, so client and server are known top-level functions. Attributes are declared objects, so the wrong type is visible at the declaration.
That doesn't mean it catches everything. It means the list is finite and the gaps are known.
All just regular HTML and CSS
The part I keep coming back to is that none of it needed a new syntax. The component is an HTML file, the template is HTML, the styles are CSS with :host and ::slotted, and the logic is JavaScript in a <script type="module"> block. The check runs on the same file.
So the loop is fast, and the thing that makes it fast is the thing that makes it readable: there's nothing in the source that isn't HTML, CSS, or JavaScript. When the tool tells you what's wrong, it's telling you about code you can read, in vocabulary the platform already owns.
The full catalogue is at /reference/diagnostics/, grouped by domain, with every fix named. If you're evaluating Coralite and want to know what it catches before you commit, that page tells you exactly.