Add ESLint and Prettier
Prettier owns formatting: .prettierrc.json, format and format:check scripts, and a one-off pass over the repo so the check is green from the start. Embedded language formatting is off deliberately - the renderers build HTML in html tagged templates and letting Prettier reflow those would change the markup customers receive. docs/ is excluded because it is hand-wrapped prose, and shell scripts have no Prettier parser. ESLint covers the JavaScript: the two browser scripts, the build and check scripts, and its own config. no-var is scoped out for the browser scripts on purpose; they are plain ES5-shaped IIFEs and a hoisting difference would only show up in a browser. ESLint cannot lint the TypeScript here: typescript@7 is the native port with no JavaScript compiler API, and typescript-eslint requires a 4.8-6.1 peer, so it refuses to install and forcing it through would leave a parser that cannot read the compiler. tsc --noEmit stays the TypeScript gate; README records the two ways to change that. lint and format:check now run in deploy.sh, and VS Code formats on save with Prettier and surfaces ESLint findings.
This commit is contained in:
1 parent
ce8079355b
commit
e64f65642f
40 files changed
+1469
-172
No files matched your search
+14
-11
@@ -27,10 +27,7 @@ describe('creating a Menu Set', () => {
|
||||
assert.equal(set.state, 'draft');
|
||||
assert.equal(set.manifest.publishedAt, null);
|
||||
assert.deepEqual(set.manifest.pages, []);
|
||||
assert.equal(
|
||||
set.dir,
|
||||
path.join(sitePaths(dataDir).drafts, 'bar', set.manifest.id),
|
||||
);
|
||||
assert.equal(set.dir, path.join(sitePaths(dataDir).drafts, 'bar', set.manifest.id));
|
||||
assert.deepEqual(await filesIn(set.dir), ['manifest.json']);
|
||||
|
||||
const listed = await store.list();
|
||||
@@ -138,10 +135,7 @@ describe('publishing', () => {
|
||||
|
||||
const published = await store.publish(set.id);
|
||||
assert.equal(published.slug, '2026-06-26');
|
||||
assert.equal(
|
||||
published.dir,
|
||||
path.join(sitePaths(dataDir).published, 'bar', '2026-06-26'),
|
||||
);
|
||||
assert.equal(published.dir, path.join(sitePaths(dataDir).published, 'bar', '2026-06-26'));
|
||||
assert.equal(published.manifest.publishedAt, '2026-01-05T04:00:00.000Z');
|
||||
assert.deepEqual(await filesIn(sitePaths(dataDir).drafts), ['bar']);
|
||||
|
||||
@@ -169,7 +163,10 @@ describe('publishing', () => {
|
||||
await store.publish(first.id);
|
||||
|
||||
clock.advance(60_000);
|
||||
const second = await store.create('bar', { label: 'Bar Menu, revised', validUntil: '2026-06-26' });
|
||||
const second = await store.create('bar', {
|
||||
label: 'Bar Menu, revised',
|
||||
validUntil: '2026-06-26',
|
||||
});
|
||||
await store.addPage(second.id, { data: pngBytes('two'), originalName: 'b.jpg' });
|
||||
const published = await store.publish(second.id);
|
||||
|
||||
@@ -200,7 +197,10 @@ describe('publishing', () => {
|
||||
const page = await store.addPage(set.id, { data: pngBytes('one'), originalName: 'a.jpg' });
|
||||
await store.publish(set.id);
|
||||
|
||||
await assert.rejects(() => store.addPage(set.id, { data: pngBytes('two'), originalName: 'b.jpg' }), StoreError);
|
||||
await assert.rejects(
|
||||
() => store.addPage(set.id, { data: pngBytes('two'), originalName: 'b.jpg' }),
|
||||
StoreError,
|
||||
);
|
||||
await assert.rejects(() => store.update(set.id, { label: 'New' }), StoreError);
|
||||
await assert.rejects(() => store.removePage(set.id, page.id), StoreError);
|
||||
});
|
||||
@@ -296,7 +296,10 @@ describe('page index', () => {
|
||||
const { store } = makeStore(dataDir);
|
||||
const draft = await store.create('bar', { label: 'Bar Menu' });
|
||||
const published = await store.create('food', { label: 'Food Menu' });
|
||||
const draftPage = await store.addPage(draft.id, { data: pngBytes('one'), originalName: 'a.jpg' });
|
||||
const draftPage = await store.addPage(draft.id, {
|
||||
data: pngBytes('one'),
|
||||
originalName: 'a.jpg',
|
||||
});
|
||||
const publishedPage = await store.addPage(published.id, {
|
||||
data: pngBytes('two'),
|
||||
originalName: 'b.jpg',
|
||||
|
||||
Reference in new issue
Block a user