feat: add type-checking with jsdoc TypeScript types and publish types#571
feat: add type-checking with jsdoc TypeScript types and publish types#571bmish merged 15 commits intoqunitjs:mainfrom
Conversation
| eqeqeq: "error", | ||
| "func-style": ["error", "declaration"], | ||
| "guard-for-in": "error", | ||
| "lines-around-comment": [ |
There was a problem hiding this comment.
There's a number of old rules I had to remove because they conflict with prettier.
eslint.config.js
Outdated
| "spaced-comment": ["error", "always", { exceptions: ["-"] }], | ||
| strict: ["error", "global"], | ||
| "use-isnan": "error", | ||
| "valid-jsdoc": [ |
There was a problem hiding this comment.
This rule is deprecated and didn't appear to be compatible with the jsdoc TypeScript comments I added. We can replace with https://github.com/gajus/eslint-plugin-jsdoc later.
| "statements": 92, | ||
| "functions": 100, | ||
| "branches": 100, | ||
| "branches": 90, |
There was a problem hiding this comment.
Unfortunately, I had to reduce test coverage requirements because of the 100+ type guards I added. Some type guards could be tested, while most would necessitate /* istanbul ignore */ comments. We can add tests or ignore comments later as it would be very time-consuming to do so.
* main: upgrade: Bump @eslint/js from 8.56.0 to 9.24.0 (qunitjs#568) upgrade: Bump eslint-plugin-markdown from 3.0.1 to 5.1.0 (qunitjs#542) chore: fix violations of eslint-plugin-eslint-plugin v6 (qunitjs#572) upgrade: Bump cross-spawn (qunitjs#551) upgrade: Bump braces from 3.0.2 to 3.0.3 (qunitjs#521) upgrade: Bump ws from 7.5.9 to 7.5.10 (qunitjs#524) upgrade: Bump eslint-plugin-eslint-plugin from 5.5.1 to 6.4.0 (qunitjs#537) upgrade: Bump serialize-javascript and mocha (qunitjs#550) upgrade: Bump @eslint/eslintrc from 2.1.4 to 3.3.1 (qunitjs#563) upgrade: Bump typescript from 5.3.3 to 5.8.3 (qunitjs#569) upgrade: Bump eslint-doc-generator from 1.6.2 to 2.1.2 (qunitjs#562)
Pull Request Test Coverage Report for Build 15933563230Details
💛 - Coveralls |
|
I'm going to merge this now for a forthcoming minor release. I'm open to receiving and addressing feedback after the merge. |
| recommended: { | ||
| plugins: ["qunit"], | ||
| rules: { | ||
| rules: /** @type {import('eslint').Linter.RulesRecord} */ ({ |
There was a problem hiding this comment.
This was necessary so that consumers who use our flat config in their eslint.config.ts has the right RuleEntry type instead of just generic string.
|
This is awesome, thank you @bmish! |
Fixes #241.
This PR enables the
checkJsTypeScript option for this plugin's codebase which requires us to add jsdoc type annotations anywhere types are missing. It also exports types for anyone who uses TypeScript in their eslint.config.js/ts.The majority of the changes in this PR involve adding type annotations as well as adding type guards (checking node types).
Challenges:
import('eslint').Rule.Nodewhen the node parent was provided by ESLint but others neededimport('estree').Nodewhen ESLint did not add the parentIt's likely this fixes a bunch of unknown bugs from not correctly checking node types or not checking for null/undefined variables.
This should significantly improve the developer experience from having autocomplete and type information available.
Follow-up PRs to consider:
This took 10+ hours to do by hand. Cursor was helpful for autocomplete.
Related examples:
eslint-plugin-nextvercel/next.js#78109Follow-up fixes I needed to get this to work:
literal-compare-orderrule #601