[repo] Workspace: Scaffold Phase 0 with schema, engine, content, ui and the PWA shell
pnpm + turbo workspace with the commands from CLAUDE.md §3. The contracts from §6 as JSON Schemas with generated types; localDay as the one place a day is computed; the forbidden-word list shared by lint:copy and the library validator, with 13 negative fixtures; a Svelte 5 PWA shell built under /Rosea/ with a meta CSP. E2E and offline suites run against the built bundle; the offline one closes the server rather than emulating. Analysis: .agents/features/phase0-workspace.md
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* The linter earns its place on the rules a compiler will not give: the ones
|
||||
* about intent. Types belong to `tsc --strict` and `svelte-check`; formatting
|
||||
* belongs to nobody.
|
||||
*
|
||||
* Two house rules live here:
|
||||
* - CLAUDE.md §7 "never swallow an error": `no-empty` with no empty catch.
|
||||
* - CLAUDE.md §7 "the engine is pure — enforced by a lint rule": the block
|
||||
* scoped to packages/engine/src below. `packages/engine/test/purity-lint.test.ts`
|
||||
* proves each ban fires, because a guard only ever seen not firing is untested.
|
||||
*/
|
||||
import js from '@eslint/js';
|
||||
import ts from 'typescript-eslint';
|
||||
import svelte from 'eslint-plugin-svelte';
|
||||
import svelteParser from 'svelte-eslint-parser';
|
||||
import globals from 'globals';
|
||||
|
||||
const CLOCK = 'Time is a parameter (`now: number`). A clock in the engine makes replaying the event log non-deterministic.';
|
||||
const DICE = 'Randomness is a parameter (`rng: () => number`) so a replay gives byte-identical derived state.';
|
||||
const IO = 'The engine performs no I/O. It returns values; packages/storage, packages/sync and the app do the rest.';
|
||||
const ZONE = 'The time zone is a parameter. The app reads the device zone; the engine never does.';
|
||||
const UTC_DAY = 'That is the UTC day. Days come from engine/src/time/localDay.ts and nowhere else (CLAUDE.md §7).';
|
||||
|
||||
export default [
|
||||
{
|
||||
ignores: [
|
||||
'**/dist/**',
|
||||
'**/node_modules/**',
|
||||
'**/.turbo/**',
|
||||
'**/generated/**',
|
||||
'**/playwright-report/**',
|
||||
'**/test-results/**'
|
||||
]
|
||||
},
|
||||
|
||||
js.configs.recommended,
|
||||
...ts.configs.recommended,
|
||||
...svelte.configs['flat/recommended'],
|
||||
|
||||
{
|
||||
languageOptions: {
|
||||
ecmaVersion: 2023,
|
||||
sourceType: 'module',
|
||||
globals: { ...globals.browser, ...globals.node }
|
||||
},
|
||||
rules: {
|
||||
'no-empty': ['error', { allowEmptyCatch: false }],
|
||||
eqeqeq: ['error', 'always', { null: 'ignore' }],
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'error',
|
||||
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrors: 'none' }
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
|
||||
languageOptions: {
|
||||
parser: svelteParser,
|
||||
parserOptions: { parser: ts.parser }
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
// THE ENGINE IS PURE. Scoped to src/: tests may read clocks to build fixtures.
|
||||
files: ['packages/engine/src/**/*.ts'],
|
||||
rules: {
|
||||
'no-restricted-globals': [
|
||||
'error',
|
||||
{ name: 'fetch', message: IO },
|
||||
{ name: 'XMLHttpRequest', message: IO },
|
||||
{ name: 'WebSocket', message: IO },
|
||||
{ name: 'localStorage', message: IO },
|
||||
{ name: 'sessionStorage', message: IO },
|
||||
{ name: 'indexedDB', message: IO },
|
||||
{ name: 'document', message: IO },
|
||||
{ name: 'window', message: IO },
|
||||
{ name: 'globalThis', message: IO },
|
||||
{ name: 'navigator', message: IO },
|
||||
{ name: 'crypto', message: DICE },
|
||||
{ name: 'performance', message: CLOCK },
|
||||
{ name: 'setTimeout', message: CLOCK },
|
||||
{ name: 'setInterval', message: CLOCK },
|
||||
{ name: 'requestAnimationFrame', message: CLOCK },
|
||||
{ name: 'process', message: IO }
|
||||
],
|
||||
'no-restricted-properties': [
|
||||
'error',
|
||||
{ object: 'Date', property: 'now', message: CLOCK },
|
||||
{ object: 'Math', property: 'random', message: DICE },
|
||||
{ property: 'resolvedOptions', message: ZONE }
|
||||
],
|
||||
'no-restricted-syntax': [
|
||||
'error',
|
||||
{ selector: "NewExpression[callee.name='Date'][arguments.length=0]", message: CLOCK },
|
||||
{ selector: "CallExpression[callee.name='Date']", message: CLOCK },
|
||||
{
|
||||
selector: "CallExpression[callee.property.name='slice'][callee.object.callee.property.name='toISOString']",
|
||||
message: UTC_DAY
|
||||
},
|
||||
{ selector: 'ImportDeclaration[source.value=/^node:/]', message: IO },
|
||||
{ selector: 'ImportExpression', message: IO }
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
files: ['**/test/**', '**/*.test.ts', '**/*.spec.ts', 'scripts/**', 'e2e/**'],
|
||||
rules: {
|
||||
'@typescript-eslint/no-unused-expressions': 'off'
|
||||
}
|
||||
}
|
||||
];
|
||||
Reference in New Issue
Block a user