Files
pipdock/eslint.config.js
T
poli0981andClaude Opus 5 8f6b7ed24b feat: scaffold the Tauri shell, React UI and CI
Completes the Phase 0 scaffold. The app builds, links and renders; no
screens yet.

Frontend (ARCHITECTURE section 9, UI-SPEC section 2):
- React 19 + Vite 8 + Tailwind 4 with the UI-SPEC dark terminal-tech
  tokens, plus a contrast test asserting WCAG AA over every
  text/surface pair, which UI-SPEC section 8 requires be verified.
- EN and VI catalogs with a test that vi has every en key and no
  orphans, standing in for the CI parity script I18N section 1 asks for.
- A local eslint rule enforcing the no-hardcoded-JSX-strings policy.
  eslint-plugin-react was the obvious choice but caps at ESLint 9, which
  drags in six high-severity advisories that would fail npm audit in CI;
  a local rule also implements the documented allowlist (product name,
  package names, versions, catalog codes, glyphs) precisely, which
  react/jsx-no-literals cannot express. Verified it fires on real copy
  and stays quiet on all five allowed shapes.
- no-restricted-imports keeps invoke() out of components, so the
  "no component calls invoke directly" rule is enforced, not just stated.

Tauri (ARCHITECTURE section 7): commands and events only, identifier
com.skullmute.pipdock, NSIS and MSI targets, minimal capability set,
placeholder icon pending the Phase 3 branding pass.

CI (docs/RELEASE-CI.md section 1 as corrected):
- ci-rust.yml and release.yml are project-local, on Windows runners,
  because no reusable Rust or Tauri workflow exists in the ops repo.
  Windows matters here: env discovery reads the PEP 514 registry and the
  py launcher, so a Linux run would skip the code most likely to break.
- ci-node.yml calls the ops web-react reusable and adds the npm audit
  job that reusable lacks.
- codeql.yml is JS/TS only; CodeQL has no Rust analyzer.
- Discord notifiers replace the six-platform notify.yml that never
  existed. Every caller carries an explicit permissions block.
- Action versions checked against the registry rather than assumed:
  checkout v7, cache v6, gh-release v3, setup-node v6.

Two toolchain holds, both forced and both recorded:
- TypeScript 6.0.3, not 7: typescript-eslint peers on <6.1.0.
- ESLint 10 with eslint-plugin-react dropped, as above.

Verified: cargo fmt/clippy -D warnings/28 tests green, tsc clean,
18 vitest tests green, eslint clean, npm audit reports 0
vulnerabilities, vite build and both binaries link.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 17:44:39 +07:00

107 lines
3.5 KiB
JavaScript

import js from '@eslint/js'
import tseslint from 'typescript-eslint'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
/**
* `docs/I18N.md` §1 — the no-hardcoded-strings rule.
*
* Every user-visible string must come from an i18next catalog, so untranslated copy can never
* ship. The documented allowlist is `PipDock`, package names, versions and catalog codes, which is
* pattern-shaped rather than a fixed word list — so this is a local rule instead of
* `react/jsx-no-literals` (which also caps out at ESLint 9 and pulls a vulnerable minimatch).
*/
const noJsxLiterals = {
meta: {
type: 'problem',
docs: { description: 'JSX text must come from an i18next catalog (docs/I18N.md §1)' },
schema: [],
messages: {
literal:
'Hardcoded JSX text {{text}} — use t() with a key from ui/src/locales (docs/I18N.md §1).',
},
},
create(context) {
// Allowed without translation: the product name, PEP 503 package names, PEP 440 versions,
// catalog codes, and pure punctuation/symbols (the terminal glyphs in UI-SPEC §7).
const allowed = [
/^PipDock$/,
/^[a-z0-9][a-z0-9._-]*$/, // package name
/^v?\d+(\.\d+)*([a-z].*)?$/i, // version
/^PD-[A-Z]{3}-\d{3}$/, // catalog code
/^[^\p{L}\p{N}]+$/u, // punctuation and glyphs only
]
const check = (node, raw) => {
const text = raw.trim()
if (!text) return
if (allowed.some((re) => re.test(text))) return
context.report({ node, messageId: 'literal', data: { text: JSON.stringify(text) } })
}
return {
JSXText: (node) => check(node, node.value),
JSXExpressionContainer(node) {
if (node.expression.type === 'Literal' && typeof node.expression.value === 'string') {
check(node, node.expression.value)
}
},
}
},
}
export default tseslint.config(
{ ignores: ['dist/**', 'target/**', 'src-tauri/target/**', 'node_modules/**'] },
js.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
{
files: ['ui/src/**/*.{ts,tsx}'],
languageOptions: {
parserOptions: { projectService: true, tsconfigRootDir: import.meta.dirname },
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
pipdock: { rules: { 'no-jsx-literals': noJsxLiterals } },
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
'pipdock/no-jsx-literals': 'error',
// ARCHITECTURE §9: no component calls `invoke` directly — everything goes through the typed
// wrappers in ui/src/ipc, which are the only place Rust types cross into TS.
'no-restricted-imports': [
'error',
{
paths: [
{
name: '@tauri-apps/api/core',
importNames: ['invoke'],
message: 'Import a typed wrapper from @/ipc instead (ARCHITECTURE §9).',
},
],
},
],
},
},
// The IPC layer is the one place allowed to call invoke().
{
files: ['ui/src/ipc/**/*.ts'],
rules: { 'no-restricted-imports': 'off' },
},
// Tests assert on real copy, so literals are expected there.
{
files: ['ui/src/**/*.test.{ts,tsx}', 'ui/src/test/**/*.{ts,tsx}'],
rules: { 'pipdock/no-jsx-literals': 'off' },
},
// Config files are plain Node modules, outside the type-aware program.
{
files: ['*.js', '*.ts'],
...tseslint.configs.disableTypeChecked,
},
)