Static Analysis

December 18, 2025 ยท View on GitHub

All static analysis tools configured in this app and how to use them.

Quick Reference

ToolPurposeCommandIn check:all
TypeScriptType checkingnpm run typecheckYes
ESLintSyntax, style, TS rulesnpm run lintYes
PrettierCode formattingnpm run format:checkYes
ast-grepArchitecture patternsnpm run ast:lintYes
React CompilerAutomatic memoizationBuild-timeYes
cargo fmtRust formattingnpm run rust:fmt:checkYes
clippyRust lintingnpm run rust:clippyYes
VitestFrontend testsnpm run test:runYes
cargo testRust testsnpm run rust:testYes
knipUnused code detectionnpm run knipNo
jscpdDuplicate code detectionnpm run jscpdNo

Running All Checks

npm run check:all    # Must pass before commits
npm run fix:all      # Auto-fix what can be fixed

Tool Details

ESLint

Handles syntax, style, and TypeScript-specific rules.

npm run lint        # Check for issues
npm run lint:fix    # Auto-fix issues

Configuration in eslint.config.js.

Prettier

Consistent code formatting.

npm run format:check   # Check formatting
npm run format         # Fix formatting

Configuration in prettier.config.js.

ast-grep

Enforces architectural patterns ESLint can't detect. Catches violations like Zustand destructuring and hooks in wrong directories.

npm run ast:lint    # Scan for violations
npm run ast:fix     # Auto-fix where possible

Key rules:

  • No Zustand destructuring (causes render cascades)
  • Hooks must be in hooks/ directory
  • No store subscriptions in lib/

See writing-ast-grep-rules.md for creating new rules.

React Compiler

Handles memoization automatically at build time. You do not need to manually add:

  • useMemo for computed values
  • useCallback for function references
  • React.memo for components

The compiler analyzes code and adds memoization where beneficial.

Note: The getState() pattern is still critical - it avoids store subscriptions, not memoization. See state-management.md.

Rust Tooling

npm run rust:fmt:check   # Check formatting
npm run rust:fmt         # Fix formatting
npm run rust:clippy      # Lint with clippy
npm run rust:clippy:fix  # Auto-fix clippy warnings
npm run rust:test        # Run Rust tests

knip (Periodic Cleanup)

Detects unused exports, dependencies, and files. Not in check:all - use periodically.

npm run knip

jscpd (Periodic Cleanup)

Detects duplicated code blocks. Not in check:all - use periodically.

npm run jscpd

Use the /cleanup command for guided analysis and cleanup of both knip and jscpd findings.

CI Integration

check:all runs in CI. Ensure it passes locally before pushing:

npm run check:all

Adding New Rules

ESLint: Add rules to eslint.config.js

ast-grep: Create YAML files in .ast-grep/rules/. See writing-ast-grep-rules.md.

Prettier: Modify prettier.config.js