-
-
Notifications
You must be signed in to change notification settings - Fork 8
Add option to include the jsdoc of the rule options #18
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
Open
JoseGalRe
wants to merge
3
commits into
antfu:main
Choose a base branch
from
JoseGalRe:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { ESLint, Rule } from 'eslint' | ||
|
||
export const ruleWithDescriptionInJsdoc: ESLint.Plugin = { | ||
rules: { | ||
'rule-with-description-in-properties-schema': { | ||
create: () => null as unknown as Rule.RuleListener, | ||
meta: { | ||
schema: { | ||
id: 'schemaId', | ||
type: 'object', | ||
additionalProperties: false, | ||
properties: { | ||
a: { | ||
id: 'aId', | ||
type: 'boolean', | ||
default: false, | ||
description: 'This is a boolean property', | ||
}, | ||
b: { | ||
id: 'bId', | ||
type: 'string', | ||
default: 'default', | ||
description: 'This is a string property', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* eslint-disable */ | ||
/* prettier-ignore */ | ||
import type { Linter } from 'eslint' | ||
|
||
declare module 'eslint' { | ||
namespace Linter { | ||
interface RulesRecord extends RuleOptions {} | ||
} | ||
} | ||
|
||
export interface RuleOptions { | ||
'plugin/rule-with-description-in-properties-schema'?: Linter.RuleEntry<_PluginRuleWithDescriptionInPropertiesSchemaSchemaId> | ||
} | ||
|
||
/* ======= Declarations ======= */ | ||
// ----- plugin/rule-with-description-in-properties-schema ----- | ||
/** | ||
* This is a boolean property | ||
*/ | ||
type _PluginRuleWithDescriptionInPropertiesSchemaAId = boolean | ||
/** | ||
* This is a string property | ||
*/ | ||
type _PluginRuleWithDescriptionInPropertiesSchemaBId = string | ||
interface _PluginRuleWithDescriptionInPropertiesSchemaSchemaId { | ||
a?: _PluginRuleWithDescriptionInPropertiesSchemaAId | ||
b?: _PluginRuleWithDescriptionInPropertiesSchemaBId | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 the jsdocs should be here to make it effective on the userland, no?
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.
Yep, I think that too, but the snapshot in the tests places it there, and all tests will pass, it's strange but works xD
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 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.
Well, snapshot only tests changes, but not correctness. If snapshot shows that, it means the implementation should be updated
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.
It's a good point, I'll try out how to fix this.
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.
currently, the
json-schema-to-typescript-lite
packagein the generateInterface and generateStandaloneType functions
the jsdocs is conditioned by
ast.standaloneName
if hasstandaloneName
the jsdoc is placed in the top level type definition.It can be fixed by adding an option to prefer the jsdoc of the options inside the interface instead of the top level type, (I can send a pr for this), or it can be left as is, and used in this way, because the original package also has this behavior (bcherny/json-schema-to-typescript), generateInterface and generateStandaloneType functions