-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(eslint-plugin): correct rules.d.ts types to not rely on non-existent imports #9339
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
Merged
auvred
merged 6 commits into
typescript-eslint:v8
from
JoshuaKGoldberg:eslint-plugin-rules-util-path
Jun 29, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2e97705
fix(eslint-plugin): use ./dist/util path in rules.d.ts
JoshuaKGoldberg f08e1e4
Merge branch 'v8' into eslint-plugin-rules-util-path
JoshuaKGoldberg ea7cb79
Fix introduced type complaint
JoshuaKGoldberg 8878dd4
test: one more fix for default
JoshuaKGoldberg c76814f
Move to copying the types, as we don't publish .d.ts
JoshuaKGoldberg b3d2b25
import from rules, heck yes
JoshuaKGoldberg 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,7 @@ | ||
import { ESLintUtils } from '@typescript-eslint/utils'; | ||
import type { | ||
RuleModuleWithMetaDocs, | ||
RuleRecommendation, | ||
RuleRecommendationAcrossConfigs, | ||
} from '@typescript-eslint/utils/ts-eslint'; | ||
|
||
export interface ESLintPluginDocs { | ||
/** | ||
* Does the rule extend (or is it based off of) an ESLint code rule? | ||
* Alternately accepts the name of the base rule, in case the rule has been renamed. | ||
* This is only used for documentation purposes. | ||
*/ | ||
extendsBaseRule?: boolean | string; | ||
|
||
/** | ||
* If a string config name, which starting config this rule is enabled in. | ||
* If an object, which settings it has enabled in each of those configs. | ||
*/ | ||
recommended?: RuleRecommendation | RuleRecommendationAcrossConfigs<unknown[]>; | ||
|
||
/** | ||
* Does the rule require us to create a full TypeScript Program in order for it | ||
* to type-check code. This is only used for documentation purposes. | ||
*/ | ||
requiresTypeChecking?: boolean; | ||
} | ||
import type { ESLintPluginDocs } from '../../rules'; | ||
|
||
export const createRule = ESLintUtils.RuleCreator<ESLintPluginDocs>( | ||
name => `https://typescript-eslint.io/rules/${name}`, | ||
); | ||
|
||
export type ESLintPluginRuleModule = RuleModuleWithMetaDocs< | ||
string, | ||
readonly unknown[], | ||
ESLintPluginDocs | ||
>; |
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
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
Oops, something went wrong.
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 don't love this copy & pasting of types between files. But we don't publish
.d.ts
files underdist/
for this package and don't publishsrc/
.My preference would be to start publishing
.d.ts
files to move towards a future where folks can strongly type individual rule options in theireslint.config.ts
/// @ts-check
'deslint.config.js
. But that seems like a bigger change, with potential for serious package size increases, out of scope for this PR.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 wonder what if we remove
ESLintPluginDocs
andESLintPluginRuleModule
frompackages/eslint-plugin/src/util/createRule.ts
and import them frompackages/eslint-plugin/rules.d.ts
instead? I don't see any reason why this could end badly 🙂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 am ... deeply amused at how much better of a solution this is. 😄