-
Notifications
You must be signed in to change notification settings - Fork 24
feat: add type-checking with jsdoc TypeScript types and publish types #571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -43,21 +52,6 @@ module.exports = [ | |||
eqeqeq: "error", | |||
"func-style": ["error", "declaration"], | |||
"guard-for-in": "error", | |||
"lines-around-comment": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a number of old rules I had to remove because they conflict with prettier.
eslint.config.js
Outdated
@@ -137,14 +130,6 @@ module.exports = [ | |||
"spaced-comment": ["error", "always", { exceptions: ["-"] }], | |||
strict: ["error", "global"], | |||
"use-isnan": "error", | |||
"valid-jsdoc": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
"functions": 100, | ||
"branches": 100, | ||
"branches": 90, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
@@ -22,7 +24,7 @@ module.exports = { | |||
configs: { | |||
recommended: { | |||
plugins: ["qunit"], | |||
rules: { | |||
rules: /** @type {import('eslint').Linter.RulesRecord} */ ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
checkJs
TypeScript 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.Node
when the node parent was provided by ESLint but others neededimport('estree').Node
when 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-next
vercel/next.js#78109Follow-up fixes I needed to get this to work:
literal-compare-order
rule #601