import globals from 'globals' import tseslint from 'typescript-eslint' import pluginReact from 'eslint-plugin-react' import pluginReactHooks from 'eslint-plugin-react-hooks' /** * Census of the call sites of the keys that must go through `coreFailureMessage`: once the * engine stopped, a direct `t('')` would tell the practitioner to retry (owner * decision 2026-10-15). Dictionaries and key strings passed as arguments are not call sites. */ const failureKeySelector = (key) => ({ selector: `CallExpression[callee.name='t'][arguments.0.value='${key}']`, message: `Use coreFailureMessage(t, '${key}') (src/core/failure.ts), not a direct t() call.`, }) const FAILURE_KEYS = [ 'core.action_failed', 'editor.export_failed', 'home.import.error_core_unavailable', ] export default tseslint.config( { ignores: ['dist/**', 'node_modules/**', 'coverage/**'] }, { files: ['**/*.{ts,tsx}'], extends: [ ...tseslint.configs.recommended, ], plugins: { react: pluginReact, 'react-hooks': pluginReactHooks, }, languageOptions: { globals: { ...globals.browser, ...globals.es2022, }, parserOptions: { ecmaFeatures: { jsx: true }, }, }, settings: { react: { version: 'detect' }, }, rules: { ...pluginReact.configs.recommended.rules, ...pluginReactHooks.configs.recommended.rules, 'react/react-in-jsx-scope': 'off', 'react/prop-types': 'off', '@typescript-eslint/no-explicit-any': 'warn', '@typescript-eslint/no-unused-vars': [ 'error', { argsIgnorePattern: '^_' }, ], }, }, { // R2: the application's rules run in the Rust core; its contracts come from // @faunosteo/core-wasm. The TypeScript domain left the application at R4.8 and // the repository at R5.7 with the pipeline package and its xmldom // (RUST_ARCHITECTURE_REVIEW VI.4). The rule keeps the door closed. files: ['src/**/*.{ts,tsx}'], rules: { 'no-restricted-imports': [ 'error', { paths: [ { name: '@faunosteo/domain', message: 'Use @faunosteo/core-wasm (types) and the core operations.', }, { name: '@faunosteo/anatomy', message: 'The SVG layer and composition are the core operations.', }, { name: '@xmldom/xmldom', message: 'Every SVG goes through the core reader (anatomy::svg).', }, ], patterns: ['@faunosteo/domain/*', '@faunosteo/anatomy/*'], }, ], }, }, { files: ['src/**/*.{ts,tsx}'], ignores: [ 'src/core/failure.ts', 'src/components/report/CoreUnavailable.tsx', 'src/components/canvas/AnatomyCanvas.tsx', ], rules: { 'no-restricted-syntax': [ 'error', ...[...FAILURE_KEYS, 'sheet.core_unavailable'].map(failureKeySelector), ], }, }, { // These two own the degraded engine notice, which names `sheet.core_unavailable`. files: [ 'src/components/report/CoreUnavailable.tsx', 'src/components/canvas/AnatomyCanvas.tsx', ], rules: { 'no-restricted-syntax': ['error', ...FAILURE_KEYS.map(failureKeySelector)], }, }, )