Skip to content

Add ESLint rule: types must live in types.ts files#1068

Open
craigmarker wants to merge 6 commits intomainfrom
craig/eslint-types-in-types-file
Open

Add ESLint rule: types must live in types.ts files#1068
craigmarker wants to merge 6 commits intomainfrom
craig/eslint-types-in-types-file

Conversation

@craigmarker
Copy link
Copy Markdown
Contributor

Enforces that type/interface declarations belong in types.ts (or *-types.ts, or files in a types/ directory). Only *Props interfaces used as component function parameters or forwardRef generics are exempt.

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

What changed?

Why?

How did you test it?

Potential risks

Release notes

Documentation Changes

Enforces that type/interface declarations belong in types.ts (or
*-types.ts, or files in a types/ directory). Only *Props interfaces
used as component function parameters or forwardRef generics are
exempt.

Fixes 3 existing violations by moving types to their proper files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

JavaScript Coverage Report

Total Coverage: 88.67%

Coverage Policy:

  • Baseline (existing code): ≥78.74% (current coverage)
  • New/changed code: ≥90% ✅ STRICTLY ENFORCED
Coverage Details
$(cat coverage/coverage-summary.json 2>/dev/null | node -p "const c=require('fs').readFileSync(0,'utf8'); JSON.stringify(JSON.parse(c).total, null, 2)" || echo "Coverage summary not available")

View detailed HTML report in artifacts

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

📊 Combined Coverage Report

Component Coverage Baseline New Code Status
🐍 Python N/A% (no coverage data) ≥70% ≥90% ✅ ⏭️
🐹 Go N/A% (no coverage data) ≥60% ≥90% ✅ ⏭️
📜 JavaScript N/A% (no coverage data) ≥78.74% ≥90% ✅ ⏭️

Coverage Policy

Baseline (Existing Code):

  • Python: ≥70% (current coverage)
  • Go: ≥60% (current coverage)
  • JavaScript: ≥78.74% (current coverage)

New/Changed Code: ≥90% STRICTLY ENFORCED

Long-term Goal: Maintain and improve coverage baselines


📝 Coverage Guidelines
  • All new code must include tests
  • Coverage should not decrease from the base branch
  • Use # pragma: no cover sparingly for truly untestable code
  • Aim for meaningful tests, not just coverage numbers
🔗 Quick Links

craigmarker and others added 5 commits April 9, 2026 10:15
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Small single-use types (≤2 members, referenced once) now get an inline
suggestion rather than always being told to move to types.ts. A named
type that annotates exactly one call site adds indirection without aiding
discoverability.

Also adds types-in-types-file.md as the first example of the co-located
companion doc convention for eslint-local-rules.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The .md file is the canonical reference — the JSDoc header was
duplicating it. Restructured the markdown to match the no-module-scope
pattern (one-liner opener, why, exceptions, how-to-fix) and softened
the inline guidance to acknowledge that named types with semantic
value are worth keeping.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
RuntimeConfig (1 field) and UseDateFormattersReturn (2 fields) were
each used in a single file — inlining them is clearer than the
indirection of a types.ts import. Also updated the inlineType lint
message to present both inline and move-to-types options.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant