feat: add strict TypeScript rules (53 new rules)#2
Open
titouanmathis wants to merge 1 commit intomainfrom
Open
feat: add strict TypeScript rules (53 new rules)#2titouanmathis wants to merge 1 commit intomainfrom
titouanmathis wants to merge 1 commit intomainfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enable the
typescriptplugin with 53 new rules to enforce TypeScript best practices and catch common mistakes.Tier 1 — Safety (17 rules)
Catch real bugs and prevent
anyfrom spreading:anyspread:no-explicit-any,no-unsafe-argument/assignment/call/member-access/return(warn)no-misused-promises(error)only-throw-error,prefer-promise-reject-errors(error)restrict-plus-operands,no-mixed-enums,switch-exhaustiveness-checkban-ts-comment(warn),prefer-ts-expect-error(error)no-non-null-assertion,no-deprecated,no-confusing-void-expressionTier 2 — Best Practices (19 rules)
Modern TypeScript patterns and unnecessary code removal:
consistent-type-imports/exports,no-import-type-side-effects,no-require-importsprefer-optional-chain,prefer-nullish-coalescingno-unnecessary-*rules (type assertions, conditions, conversions, etc.)require-await,return-awaitTier 3 — Style (17 rules)
Consistency and readability:
consistent-type-definitions,array-type,consistent-generic-constructorsno-inferrable-types,no-empty-object-type,no-empty-interfaceprefer-for-of,prefer-find,prefer-readonly,dot-notationDeliberately omitted
explicit-function-return-type/explicit-module-boundary-types— too noisy, TS inference handles thisstrict-boolean-expressions— too strict for most codebasesno-unsafe-type-assertion— bans allascastsSeverity 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)