-
-
Notifications
You must be signed in to change notification settings - Fork 196
chore: migrate @typedef
jsdoc to @import
#729
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
|
""" WalkthroughThis set of changes focuses on updating type annotations and JSDoc typedef imports across several files. Type imports are migrated from multiple Changes
Assessment against linked issues
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Important
Looks good to me! 👍
Reviewed everything up to 18973d6 in 44 seconds. Click for details.
- Reviewed
72
lines of code in3
files - Skipped
0
files when reviewing. - Skipped posting
8
draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. eslint-plugin-prettier.js:9
- Draft comment:
Ensure './types' path is correct relative to this file. Migration looks good. - Reason this comment was not posted:
Confidence changes required:0%
<= threshold50%
None
2. types.d.ts:21
- Draft comment:
Add a trailing newline at the end of file for consistency with best practices. - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
3. worker.js:3
- Draft comment:
Typedef migrations referencing './types' are consistent. Verify type definitions match expectations. - Reason this comment was not posted:
Confidence changes required:0%
<= threshold50%
None
4. eslint-plugin-prettier.js:9
- Draft comment:
Good refactor: centralizing typedefs by importing from './types' improves maintainability. - Reason this comment was not posted:
Confidence changes required:0%
<= threshold50%
None
5. worker.js:3
- Draft comment:
Typedef migration in worker.js to use './types' is clear and consistent. - Reason this comment was not posted:
Confidence changes required:0%
<= threshold50%
None
6. types.d.ts:21
- Draft comment:
Consider adding a trailing newline at the end of the file for consistency. - Reason this comment was not posted:
Confidence changes required:33%
<= threshold50%
None
7. types.d.ts:21
- Draft comment:
The file currently doesn't end with a newline. Adding a newline at the end can help maintain consistency with standard formatting practices. - Reason this comment was not posted:
Comment did not seem useful. Confidence is useful =20%
<= threshold50%
This comment is purely informative and does not provide a specific code suggestion or highlight a potential issue. It suggests adding a newline for consistency, which is a minor formatting preference and not a critical issue.
8. worker.js:106
- Draft comment:
It appears that the string literal on line 106 uses a mismatched closing character: it starts with a single quote but ends with a backtick (). Please verify if this is intentional or if it should be corrected (e.g., to 'ESLintPluginGraphQLFile' or
ESLintPluginGraphQLFile`) to ensure consistency. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
Workflow ID: wflow_BoFrPaHtPlg5RM5M
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
@typedef
jsdoc to @import
@yashtech00 Thanks for your efforts first! But that's not what I was proposing, I meant something like the following: /**
* @import { AST, ESLint } from 'eslint'
*/ |
/**
* @import { AST, ESLint } from 'eslint'
*/ so migrate |
Nope, it's just jsdoc. https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#import |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
eslint-plugin-prettier.js (1)
138-141
: Consider using optional chaining for cleaner code.The static analysis tool suggests using optional chaining here, which would make the code more concise.
-const fileInfoOptions = (options && options.fileInfoOptions) || {}; +const fileInfoOptions = options?.fileInfoOptions || {};🧰 Tools
🪛 Biome (1.9.4)
[error] 141-141: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (5)
.prettierrc
(1 hunks)eslint-plugin-prettier.js
(9 hunks)package.json
(1 hunks)test/prettier.mjs
(3 hunks)worker.js
(2 hunks)
✅ Files skipped from review due to trivial changes (2)
- package.json
- .prettierrc
🚧 Files skipped from review as they are similar to previous changes (1)
- worker.js
🧰 Additional context used
🪛 Biome (1.9.4)
eslint-plugin-prettier.js
[error] 141-141: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
🔇 Additional comments (9)
test/prettier.mjs (1)
294-294
: Added helpful reference link.The added JSDoc comment provides a useful reference to the Svelte package.json file that defines Node.js version requirements, which helps explain the conditional logic in the next line that checks for Node.js version compatibility.
eslint-plugin-prettier.js (8)
9-12
: Good migration to JSDoc@import
syntax.The migration from multiple
@typedef
declarations to consolidated@import
statements improves code organization and follows TypeScript's recommended JSDoc approach. This aligns perfectly with the PR objective.
14-22
: Well-structured type definition with proper references.The
Options
type is now well-structured with explicit property types that reference the imported types. This improves code readability and type safety.
59-61
: Good parameter type annotations.Proper type annotations for function parameters improve type safety and documentation.
65-66
: Helpful type annotation for range variable.Adding explicit type annotation for the
range
variable enhances type safety and code clarity.
146-148
: Good explicit type casting for sourceCode.This explicit type casting handles the ESLint API compatibility layer properly while ensuring type safety.
175-180
: Appropriate type annotations for better safety.These type annotations improve code quality by making types explicit and providing better IDE support.
217-222
: Improved error type definition.The detailed error type definition with properties like
codeFrame
andloc
improves error handling and type safety.
249-252
: Explicit casting ensures type safety.Explicit type casting for
context
ensures proper type checking when callingreportDifference
.
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
eslint-plugin-prettier.js (1)
138-141
: Consider using optional chainingThe code can be improved with optional chaining for better readability.
- const fileInfoOptions = (options && options.fileInfoOptions) || {}; + const fileInfoOptions = options?.fileInfoOptions || {};🧰 Tools
🪛 Biome (1.9.4)
[error] 141-141: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (5)
.prettierrc
(1 hunks)eslint-plugin-prettier.js
(9 hunks)package.json
(1 hunks)test/prettier.mjs
(4 hunks)worker.js
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
- package.json
- .prettierrc
- test/prettier.mjs
- worker.js
🧰 Additional context used
🪛 Biome (1.9.4)
eslint-plugin-prettier.js
[error] 141-141: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
🔇 Additional comments (6)
eslint-plugin-prettier.js (6)
9-12
: Great job migrating to@import
syntax!The migration from multiple
@typedef
declarations to consolidated@import
statements from 'eslint', 'prettier', and 'prettier-linter-helpers' improves code organization and aligns with the PR objectives.
14-22
: Good type definition improvementNice restructuring of the
Options
typedef to extendPrettierOptions
with explicit property types. This multiline JSDoc format improves readability and provides better type clarity.
146-148
: Good type assertion for sourceCodeThe explicit type casting for
sourceCode
improves type safety while maintaining backward compatibility with different ESLint versions.
178-180
: Good type assertion for parserThe explicit type casting for the parser with proper type definition improves type safety when accessing the parser properties.
217-222
: Improved error type definitionGood enhancement of the error type definition with specific properties like
codeFrame
andloc
. This provides better type safety when accessing these properties later in the code.
249-252
: Good explicit type castingThe explicit type casting for the
context
parameter in thereportDifference
function call ensures type safety.
6ca913e
to
becc77b
Compare
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.
Pull Request Overview
This PR migrates JSDoc @typedef declarations to the new @import syntax, centralizing type definitions in types.d.ts and addressing formatting issues.
- Migrated type declarations in worker.js and eslint-plugin-prettier.js using @import.
- Updated documentation comments in test/prettier.mjs for formatting consistency.
Reviewed Changes
Copilot reviewed 3 out of 6 changed files in this pull request and generated no comments.
File | Description |
---|---|
worker.js | Replaced JSDoc @typedef with @import lines and updated inline type usage. |
test/prettier.mjs | Reformatted JSDoc comments and adjusted inline annotations. |
eslint-plugin-prettier.js | Migrated type definitions to @import syntax and refined type casts. |
Files not reviewed (3)
- .prettierrc: Language not supported
- package.json: Language not supported
- pnpm-lock.yaml: Language not supported
@coderabbitai full review |
✅ Actions performedFull review triggered. |
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
worker.js (2)
4-11
: Ensure correct JSDoc import order for typedef.The
@typedef
block referencesPrettierOptions
andESLint
types before the corresponding@import
tags. TypeScript JSDoc parsers usually expect@import
declarations to appear prior to their use in@typedef
. Consider moving the two@import
lines above the@typedef
definition or to a separate import-only JSDoc block at the top of this file. This will improve clarity and reduce the risk of unresolved types under// @ts-check
.
17-19
: Reorder JSDoc@import
before@type
.In the second JSDoc block the
@type {typeof Prettier}
tag precedes the@import * as Prettier
tag. For consistency and correct resolution by the TS checker, swap these lines so that the import appears first:- * @type {typeof Prettier} - * @import * as Prettier from 'prettier' + * @import * as Prettier from 'prettier' + * @type {typeof Prettier}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (5)
.prettierrc
(1 hunks)eslint-plugin-prettier.js
(9 hunks)package.json
(1 hunks)test/prettier.mjs
(4 hunks)worker.js
(2 hunks)
🔇 Additional comments (19)
package.json (1)
95-95
: Great addition of the JSDoc plugin for consistent formatting.Adding the
prettier-plugin-jsdoc
dependency aligns with the PR's objective to improve JSDoc comment formatting in the codebase. This package will help ensure consistent formatting of JSDoc blocks..prettierrc (1)
6-6
: Good configuration to enable the JSDoc plugin.Adding
prettier-plugin-jsdoc
to the plugins array properly enables the plugin in the Prettier configuration, which is consistent with the new development dependency added in package.json.test/prettier.mjs (5)
294-294
: Properly formatted JSDoc comment.The multi-line
@see
comment has been condensed into a single line, improving readability while maintaining the reference link.
387-392
: Well-formatted JSDoc block.The JSDoc comment for
loadInvalidFixture
function has been reformatted to be more concise and readable, without changing the meaning or content.
422-424
: Improved JSDoc formatting.The JSDoc comment for
getPrettierRcJsFilename
function has been reformatted to be more concise and readable.
435-438
: Good type annotation with @import syntax.The addition of proper type annotation for the
eslint
variable using both@type
and@import
syntax from ESLint correctly implements the JSDoc import pattern requested in the PR.
441-447
: Correctly implemented JSDoc import for function parameter.The type annotation for the
runFixture
function's parameter now uses the proper@import
syntax to reference the Linter type from ESLint, which aligns with the PR's goal.eslint-plugin-prettier.js (11)
9-12
: Excellent migration from @typedef to @import syntax.The code properly consolidates multiple individual
@typedef
imports into grouped@import
statements importing types from 'eslint', 'prettier', and 'prettier-linter-helpers'. This implementation exactly follows the requested pattern of using JSDoc@import
syntax rather than converting to TypeScript files.
14-28
: Well-structured Options typedef with explicit property types.The
Options
typedef has been reformatted into a clean multiline JSDoc with explicit property types referencing the imported ESLint types. ThePrettierFormat
typedef is also reformatted to multiline style for better readability.
53-54
: Proper type annotation for prettierFormat variable.Added a JSDoc type annotation for the lazily-loaded Prettier format function, improving type safety.
67-71
: Improved type safety with explicit AST.Range type.The
range
variable's type annotation was changed from an inline cast to a proper JSDoc type declaration, improving code readability and type safety.
93-94
: Good type annotation for the plugin object.Added a JSDoc type annotation for the eslintPluginPrettier object, improving type safety.
142-146
: Enhanced type safety for options extraction.The option extraction in the
create
method was refactored to assigncontext.options[1]
to a typedoptions
variable, improving clarity and type safety. ThefileInfoOptions
variable is also properly typed.
150-152
: Updated to use modern ESLint API with fallback.The code now properly uses the newer
context.sourceCode
property with fallback to the deprecatedcontext.getSourceCode()
method, and includes an explicit type assertion for better type safety.
179-185
: Improved type annotations for Prettier options and parser.Added proper type annotations for
eslintPrettierOptions
andparser
variables, increasing type safety while maintaining the same functionality.
194-195
: Added missing type annotation.Added a type annotation for the
prettierSource
variable that was previously missing, improving code clarity and type safety.
221-227
: Enhanced error type definition for better error handling.The error object now has a more precise type definition that includes
codeFrame
andloc
properties, improving type safety and making the error handling more robust.
253-257
: Added proper type casting for context parameter.The
reportDifference
function call now explicitly castscontext
toRule.RuleContext
, ensuring type safety and preventing potential type errors.worker.js (1)
185-185
: TypedprettierOptions
is consistent with imported alias.The usage of
/** @type {PrettierOptions} */
for theprettierOptions
constant aligns correctly with theOptions as PrettierOptions
alias imported fromprettier
. This ensures proper type checking under// @ts-check
. Looks good!
Summary
This PR migrates the JSDoc
@typedef
declarations to@import
syntax in:worker.js
eslint-plugin-prettier.js
close #728
Important
Migrates JSDoc
@typedef
to@import
syntax inworker.js
andeslint-plugin-prettier.js
, centralizing types intypes.d.ts
and fixing formatting issues.@typedef
to@import
syntax inworker.js
andeslint-plugin-prettier.js
.types.d.ts
.worker.js
andeslint-plugin-prettier.js
.This description was created by
for 18973d6. You can customize this summary. It will automatically update as commits are pushed.
Summary by CodeRabbit