-
-
Notifications
You must be signed in to change notification settings - Fork 14
feat!: Update package types for better reuse #91
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
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 pull request simplifies and extends the package’s type definitions by consolidating imports and updating JSDoc comments for improved clarity and reuse. Key changes include:
- Switching to using @import in JSDoc comments to allow importing generic types.
- Consolidating and updating type definitions and import statements in both types and rule files.
- Updating rule definitions (and their JSDoc typedefs) to work with the new consolidated types.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/types.ts | Consolidated import statements and updated JSONRuleDefinition types. |
src/rules/top-level-interop.js | Updated JSDoc typedefs to use the new JSONRuleDefinition pattern. |
src/rules/sort-keys.js | Revised JSDoc typedefs with additional options and clear import usage. |
src/rules/no-unsafe-values.js | Updated JSDoc typedefs to reflect consolidated type definitions. |
src/rules/no-unnormalized-keys.js | Adjusted JSDoc typedefs to include a new options type. |
src/rules/no-empty-keys.js | Updated JSDoc typedefs to the new JSONRuleDefinition style. |
src/rules/no-duplicate-keys.js | Revised JSDoc typedefs and consolidated imports for clarity. |
src/languages/json-source-code.js | Consolidated JSDoc import statements and updated type annotations. |
src/languages/json-language.js | Updated JSDoc typedefs and type annotations for JSON parsing. |
Comments suppressed due to low confidence (2)
src/languages/json-source-code.js:29
- The import for JSONSyntaxElement uses a .js extension while other similar imports reference .ts. Ensure the file extension is consistent with the actual file to avoid import resolution issues.
* @import { JSONSyntaxElement } from "../types.js";
src/languages/json-language.js:35
- The type annotation references JSONSourceCode but there is no corresponding import. Consider adding an import for JSONSourceCode from './json-source-code.js' to ensure type correctness.
* @implements {Language<{ LangOptions: JSONLanguageOptions; Code: JSONSourceCode; RootNode: DocumentNode; Node: AnyNode }>}
Okay, this is harder than I thought. 😦 Needing to convert into CommonJS is causing a big mess here. |
Thanks for the continued improvements here, @nzakas! |
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.
I think this is already looking good. Would like another review before merging.
Co-authored-by: Francesco Trotta <github@fasttime.org>
export { JSONLanguage, JSONSourceCode }; | ||
export { JSONSourceCode }; | ||
export * from "./languages/json-language.js"; |
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.
Why this change? I don't see any diff in dist/
this change is causing.
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.
Because JSONLanguageOptions
type is defined in json-language.js
, it can only be exported from a JS file using *
. (If this were a .ts
file we could export it directly.)
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.
LGTM, thanks!
Prerequisites checklist
What is the purpose of this pull request?
To simplify and extend the existing types in the package.
What changes did you make? (Give an overview)
Primarily:
@import
in JSDoc comments, which allows importing generic types. That allowed a bunch of optimizations.IJSONLanguage
andIJSONSourceCode
, swapping them out for the actual classes, both of which now have an@implements
directly on their declarations.JSONRuleDefinition
based on discussion with @fasttime.dedupe-types.js
to take into account@import
statements.Specifics:
src/languages/json-language.js
: Consolidated type definitions and import statements for@humanwhocodes/momoa
and@eslint/core
, and updated theJSONLanguage
class to use the new consolidated types. [1] [2] [3]src/languages/json-source-code.js
: Consolidated type definitions and import statements, and updated theJSONSourceCode
class to use the new consolidated types. [1] [2] [3] [4] [5] [6] [7] [8]src/rules/no-duplicate-keys.js
: Consolidated type definitions and import statements for@humanwhocodes/momoa
and../types.ts
, and updated the rule definition to use the new consolidated types.src/rules/no-empty-keys.js
: Consolidated type definitions and import statements for../types.ts
, and updated the rule definition to use the new consolidated types.src/rules/no-unnormalized-keys.js
: Consolidated type definitions and import statements for../types.ts
, and updated the rule definition to use the new consolidated types.src/rules/no-unsafe-values.js
: Consolidated type definitions and import statements for../types.ts
, and updated the rule definition to use the new consolidated types.src/rules/sort-keys.js
: Consolidated type definitions and import statements for@humanwhocodes/momoa
and../types.ts
, and updated the rule definition to use the new consolidated types.src/rules/top-level-interop.js
: Consolidated type definitions and import statements for../types.ts
, and updated the rule definition to use the new consolidated types.src/types.ts
: Removed redundant type definitions and consolidated imports, and updated theJSONRuleDefinition
type to use a more flexible and consolidated structure. [1] [2] [3] [4]Related Issues
refs eslint/eslint#19521
Is there anything you'd like reviewers to focus on?