jsx-eslint / eslint-plugin-react

React-specific linting rules for ESLint
MIT License
8.86k stars 2.75k forks source link

Proposal for Stringent Type Checking #3728

Open y-hsgw opened 2 months ago

y-hsgw commented 2 months ago

Would it be feasible to enhance the strictness of type checking?

I suggest modifying the code from:

module.exports = {
  //...
};

to:

/** @type { import("eslint").Rule.RuleModule } */
const config = {
  //...
};

module.exports = config;

This change aims to improve type checking by specifying the type explicitly using JSDoc annotations.

I have checked existing PRs and issues but couldn't find a similar proposal being addressed. If this is already in progress, we apologize for the redundancy.

ljharb commented 2 months ago

I'm not sure what you mean - are you talking about how the plugin code is authored?

It would be great to typescript-jsdoc annotate the entire plugin. The first form, however, can also be annotated and is superior to the second form.

y-hsgw commented 2 months ago

are you talking about how the plugin code is authored?

Yes, I am referring to how the plugin code is authored.

The former doesn't seem to provide type checking, so I proposed the latter.

スクリーンショット 2024-04-08 23 23 15

Similar issue: https://github.com/microsoft/TypeScript/issues/47107

ljharb commented 2 months ago

oof, that's terrible.

i'd want one commit that adds all the annotations, and another that refactors from module.exports = { … } to const config = { … }; module.exports = config;, so i can easily revert that commit in the future when TS fixes themselves.