Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Conversation

JoshuaKGoldberg
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg commented Jun 12, 2024

PR Checklist

Overview

Removes dependencies from rules.d.ts that don't exist, so it'll correctly type check for all consumers - even if they don't skipLibCheck.

💖

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @JoshuaKGoldberg!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

@JoshuaKGoldberg JoshuaKGoldberg added this to the 8.0.0 milestone Jun 12, 2024
Copy link

netlify bot commented Jun 12, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit b3d2b25
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/668009fd38fb8800084ea8cf
😎 Deploy Preview https://deploy-preview-9339--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

nx-cloud bot commented Jun 12, 2024

Copy link
Member Author

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 under dist/ for this package and don't publish src/.

My preference would be to start publishing .d.ts files to move towards a future where folks can strongly type individual rule options in their eslint.config.ts / // @ts-check'd eslint.config.js. But that seems like a bigger change, with potential for serious package size increases, out of scope for this PR.

Copy link
Member

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 and ESLintPluginRuleModule from packages/eslint-plugin/src/util/createRule.ts and import them from packages/eslint-plugin/rules.d.ts instead? I don't see any reason why this could end badly 🙂

 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 { ESLintPluginDocs } from '../../rules';

 export const createRule = ESLintUtils.RuleCreator<ESLintPluginDocs>(
   name => `https://typescript-eslint.io/rules/${name}`,
 );

-export type ESLintPluginRuleModule = RuleModuleWithMetaDocs<
-  string,
-  readonly unknown[],
-  ESLintPluginDocs
->;

Copy link
Member Author

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. 😄

@JoshuaKGoldberg JoshuaKGoldberg changed the title fix(eslint-plugin): use ./dist/util path in rules.d.ts fix(eslint-plugin): correct rules.d.ts types to not rely on non-existent imports Jun 25, 2024
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review June 25, 2024 18:54
@JoshuaKGoldberg JoshuaKGoldberg requested a review from a team June 25, 2024 18:54
@JoshuaKGoldberg JoshuaKGoldberg requested a review from auvred June 29, 2024 13:20
Copy link
Member

@auvred auvred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@auvred auvred merged commit 7812072 into typescript-eslint:v8 Jun 29, 2024
62 of 63 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the eslint-plugin-rules-util-path branch June 29, 2024 13:52
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants