Skip to content
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

fix: default to parse all JSDoc and provide options to configure it #7999

Merged

Conversation

bradzacher
Copy link
Member

@bradzacher bradzacher commented Nov 28, 2023

Overview

In hindsight #7997 was sadly a breaking change.
There's a number of usecases that do rely on accessing JSDoc on the TS AST (eg eslint-plugin-deprecation).

This PR amends this change so that:

  • we accept the setting via parser options so it's user-configurable.
  • we default JSDoc parsing to all (which was the pre-5.3 behaviour) for type-aware linting.
  • we default JSDoc parsing to none for non-type-aware-linting.
    • Setting this to none by default for this case should provide all non-type-aware-linting users with a free perf boost.
    • This is technically a breaking change - but the scope should be zero.
    • The only usecase this impacts is "accessing JSDoc from the TS AST when not using type-aware linting".
    • This usecase is possible - but I don't think it's something anyone would ever do as this would only give you JSDoc for the current file. Most single-file rules assume there's no TS AST.
    • If we do encounter a breakage we can revert this back to all - but I don't think we'll see it.

In a future we can consider switching the type-aware default to 'type-info' and force users to pass the config if and only if they use a rule that requires 'all'.

FYI @jakebailey / @fisker

@bradzacher bradzacher added the bug Something isn't working label Nov 28, 2023
@typescript-eslint
Copy link
Contributor

Thanks for the PR, @bradzacher!

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.

Copy link

netlify bot commented Nov 28, 2023

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 70ecbb6
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/65653b753f2a6c0008ff31c0
😎 Deploy Preview https://deploy-preview-7999--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: 99 (🟢 up 1 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 98 (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.

@@ -9,7 +9,9 @@ const createStubFileWatcher = (): ts.FileWatcher => ({

export type TypeScriptProjectService = ts.server.ProjectService;

export function createProjectService(): TypeScriptProjectService {
export function createProjectService(
jsDocParsingMode?: ts.JSDocParsingMode,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Preemptive check; IIRC this is public. Should this be some sort of options bag rather than a parameter?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nah this isn't public - we don't export it from either index.ts or use-at-your-own-risk.ts.

@fisker
Copy link
Contributor

fisker commented Nov 28, 2023

Thanks for mentioning, no problem for us.

@bradzacher bradzacher merged commit 779e13e into main Nov 28, 2023
55 of 57 checks passed
@bradzacher bradzacher deleted the jsdoc-parse-style-proper-fix-thats-not-a-breaking-change branch November 28, 2023 09:25
@bradzacher
Copy link
Member Author

This has been released in an out-of-band patch release https://github.com/typescript-eslint/typescript-eslint/releases/tag/v6.13.1

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants