Skip to content

feat: add strict TypeScript rules (53 new rules)#2

Open
titouanmathis wants to merge 1 commit intomainfrom
feat/strict-typescript-rules
Open

feat: add strict TypeScript rules (53 new rules)#2
titouanmathis wants to merge 1 commit intomainfrom
feat/strict-typescript-rules

Conversation

@titouanmathis
Copy link
Copy Markdown
Contributor

Summary

Enable the typescript plugin with 53 new rules to enforce TypeScript best practices and catch common mistakes.

Tier 1 — Safety (17 rules)

Catch real bugs and prevent any from spreading:

  • Ban any spread: no-explicit-any, no-unsafe-argument/assignment/call/member-access/return (warn)
  • Promise safety: no-misused-promises (error)
  • Error handling: only-throw-error, prefer-promise-reject-errors (error)
  • Type safety: restrict-plus-operands, no-mixed-enums, switch-exhaustiveness-check
  • Suppress discipline: ban-ts-comment (warn), prefer-ts-expect-error (error)
  • Misc: no-non-null-assertion, no-deprecated, no-confusing-void-expression

Tier 2 — Best Practices (19 rules)

Modern TypeScript patterns and unnecessary code removal:

  • Imports: consistent-type-imports/exports, no-import-type-side-effects, no-require-imports
  • Modern operators: prefer-optional-chain, prefer-nullish-coalescing
  • Unnecessary code: 8 no-unnecessary-* rules (type assertions, conditions, conversions, etc.)
  • Async: require-await, return-await

Tier 3 — Style (17 rules)

Consistency and readability:

  • consistent-type-definitions, array-type, consistent-generic-constructors
  • no-inferrable-types, no-empty-object-type, no-empty-interface
  • prefer-for-of, prefer-find, prefer-readonly, dot-notation

Deliberately omitted

  • explicit-function-return-type / explicit-module-boundary-types — too noisy, TS inference handles this
  • strict-boolean-expressions — too strict for most codebases
  • no-unsafe-type-assertion — bans all as casts
  • See full analysis in the commit message

Severity philosophy

  • error: Rules that catch definite bugs or enforce critical safety (no-misused-promises, only-throw-error, restrict-plus-operands, etc.)
  • warn: Rules that are best practices but may need occasional escape hatches (no-explicit-any, no-unsafe-*, style rules)

Enable the typescript plugin with 53 rules across 3 tiers:

Safety (17 rules, error/warn):
- Ban `any` spread: no-explicit-any, no-unsafe-* (warn)
- Promise safety: no-misused-promises (error)
- Error handling: only-throw-error, prefer-promise-reject-errors (error)
- Type safety: restrict-plus-operands, no-mixed-enums, switch-exhaustiveness-check
- Suppress discipline: ban-ts-comment (warn), prefer-ts-expect-error (error)

Best practices (19 rules, warn):
- Imports: consistent-type-imports/exports, no-require-imports
- Modern operators: prefer-optional-chain, prefer-nullish-coalescing
- Unnecessary code: 8 no-unnecessary-* rules
- Async: require-await, return-await

Style (17 rules, warn):
- Consistent type syntax: consistent-type-definitions, array-type
- Clean annotations: no-inferrable-types, no-empty-object-type
- Modern patterns: prefer-for-of, prefer-find, prefer-readonly
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