Enhance TypeScript Typings in `prefer-theme-color-classnames` Rule
Opened this issue · 0 comments
Description
The prefer-theme-color-classnames
rule within the @metamask/eslint-plugin-design-tokens
package currently utilizes TypeScript's any
type in certain instances. This usage of any
undermines the benefits of TypeScript's strong typing system, potentially leading to less maintainable and error-prone code. To address this, we propose an overhaul of the typing framework used in this rule (and potentially across other rules in the package) by adopting the @typescript-eslint/utils
package, as utilized by the eslint-plugin-testing-library
. This change aims to improve type safety, enhance code quality, and align with best practices in TypeScript development.
Technical Details
- Objective: Refactor the TypeScript typings in the
prefer-theme-color-classnames
rule to eliminate the use ofany
and improve type safety. - Implementation Steps:
- Evaluate the current usage of
any
within theprefer-theme-color-classnames
rule and identify areas for improvement. - Explore the adoption of the
@typescript-eslint/utils
package, reviewing its documentation and how it's applied in theeslint-plugin-testing-library
. - Refactor the typing framework used in the rule, replacing
any
with more specific and appropriate TypeScript types. - Conduct thorough testing to ensure that the refactored rule maintains its intended functionality without introducing regressions.
- Consider extending this typing improvement effort to other rules within the
@metamask/eslint-plugin-design-tokens
package.
- Evaluate the current usage of
- Dependencies: Familiarity with TypeScript, ESLint rule development, and the
@typescript-eslint/utils
package is required.
Acceptance Criteria
- All instances of
any
within theprefer-theme-color-classnames
rule are replaced with specific TypeScript types, enhancing type safety. - The rule successfully leverages the
@typescript-eslint/utils
package (or similar utilities) to improve its typing framework. - The refactored rule is thoroughly tested, with no loss of functionality or introduction of regressions.
- Documentation (e.g., README or inline comments) is updated to reflect the changes made to the rule's typing framework.
- The improvements in typing potentially serve as a model for enhancing other rules within the package.
Additional Notes
This initiative represents a commitment to leveraging TypeScript's capabilities to their fullest, ensuring that our development practices are both robust and aligned with the latest standards. By enhancing the typings in our ESLint rules, we not only improve our own codebase's quality but also set a higher standard for TypeScript usage in linting rules.