Skip to content

Conversation

JoshuaKGoldberg
Copy link
Contributor

@JoshuaKGoldberg JoshuaKGoldberg commented Feb 17, 2025

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[x] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

Starts on #19173.

Updates default-param-last to account for TypeScript syntax features as handled in the @typescript-eslint/default-param-last extension rule:

  • Class parameter properties
  • Type annotations

Includes tests equivalent to what the extension rule currently tests that's exclusive to TypeScript. They're in a separate ruleTesterTypeScript instance that uses @typescript-eslint/parser.

Also updates tools/check-rule-examples.js to allow TypeScript code block. Previously it only allowed JavaScript.

Is there anything you'd like reviewers to focus on?

Should we also update documentation?

@JoshuaKGoldberg JoshuaKGoldberg requested a review from a team as a code owner February 17, 2025 15:18
@eslint-github-bot eslint-github-bot bot added the feature This change adds a new feature to ESLint label Feb 17, 2025
@github-actions github-actions bot added the rule Relates to ESLint's core rules label Feb 17, 2025
Copy link

netlify bot commented Feb 17, 2025

Deploy Preview for docs-eslint ready!

Name Link
🔨 Latest commit edecb67
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/67d82f662505400008e9f2f3
😎 Deploy Preview https://deploy-preview-19431--docs-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

Thanks for getting this started. I left some points of clarification.

With regards to documentation, I think it would be good to add some code examples showing TypeScript.

I'm also wondering if maybe we should add something into meta indicating that this rule is TypeScript-aware?

JoshuaKGoldberg and others added 2 commits February 17, 2025 14:44
Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>
@pubmikeb
Copy link

@JoshuaKGoldberg, I have a question: once this feature will be released, does it mean that ESLint could support the TypeScript linting out-of-box without any extra plugins or projects like typescript-eslint?

@JoshuaKGoldberg
Copy link
Contributor Author

Depends what you mean by "TypeScript linting".

For syntax-only linting with just ESLint core rules, technically yes. See #19173 (comment) -> #19173 (comment) for a list of what will switch from needing a typescript-eslint extension rule to working out-of-the-box in ESLint core.

Typed linting, however, will not be supported in ESLint core. You'll still need typescript-eslint or an equivalent for that. See #19173 -> #19173 (comment).

ESLint core also presently doesn't have any plans that I know of to support TypeScript-specific rules that don't need typed linting. Example: @typescript-eslint/no-empty-object-type.

tl;dr: no, the strong recommendation from typescript-eslint going forward will still be to use typescript-eslint when linting TypeScript code.

@nzakas
Copy link
Member

nzakas commented Feb 20, 2025

We discussed today and we're at least going to start with this:

  • meta.language = "javascript" - to indicate that this rule is meant for JavaScript or a derivative of it
  • meta.dialects = ["javascript", "typescript"] - to indicate that this rule is known to work with both plain JavaScript and TypeScript.

For now, I think this is enough and we don't need to get to deep into the difference between being syntax-aware and type-aware. We're not planning on displaying this info anywhere so in the short-term it will be mostly for our own edification but we are also looking at how we can use this info to, for example, automatically disable JavaScript-specific rules when linting JSON.

Copy link

github-actions bot commented Mar 7, 2025

Hi everyone, it looks like we lost track of this pull request. Please review and see what the next steps are. This pull request will auto-close in 7 days without an update.

@github-actions github-actions bot added the Stale label Mar 7, 2025
@Tanujkanti4441
Copy link
Contributor

Not stale! waiting for a review.

@nzakas
Copy link
Member

nzakas commented Mar 11, 2025

@JoshuaKGoldberg did you intended to include updates to check-rule-examples.js in this PR?

@JoshuaKGoldberg
Copy link
Contributor Author

Ah, yes, and never mentioned this in the OP - editing it in now. Without the changes:

docs/src/rules/default-param-last.md
  56:4   error  Nonstandard language tag 'ts': use one of 'javascript', 'js' or 'jsx'
  59:20  error  Unexpected lint error found: Parsing error: Unexpected token :
  68:4   error  Nonstandard language tag 'ts': use one of 'javascript', 'js' or 'jsx'
  71:20  error  Unexpected lint error found: Parsing error: Unexpected token ?

nzakas
nzakas previously approved these changes Mar 12, 2025
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Would like another review to double check the check-rule-examples changes.

@nzakas nzakas moved this from Implementing to Second Review Needed in Triage Mar 12, 2025
@github-project-automation github-project-automation bot moved this from Second Review Needed to Complete in Triage Mar 17, 2025
@github-project-automation github-project-automation bot moved this from Complete to Evaluating in Triage Mar 17, 2025
@Tanujkanti4441
Copy link
Contributor

Sorry! closed it accidentally.

@JoshuaKGoldberg
Copy link
Contributor Author

Coming over from https://github.com/eslint/eslint/pull/19431/files#r1991932318: this PR is accumulating more and more TypeScript support changes. Would it be preferable to split them out once everything is working into their own PR?

I see #19529 was also sent with some of the same changes.

@nzakas
Copy link
Member

nzakas commented Mar 17, 2025

I think if we hide "Open in Playground" for now, that's enough to merge this. The playground changes may take a bit to get working and we can always iterate on the error location in a separate PR.

@JoshuaKGoldberg JoshuaKGoldberg moved this from Evaluating to Implementing in Triage Mar 17, 2025
@JoshuaKGoldberg JoshuaKGoldberg moved this from Implementing to Evaluating in Triage Mar 17, 2025
@mdjermanovic
Copy link
Member

I think if we hide "Open in Playground" for now, that's enough to merge this. The playground changes may take a bit to get working and we can always iterate on the error location in a separate PR.

Agreed.

@Tanujkanti4441 Tanujkanti4441 added the accepted There is consensus among the team that this change meets the criteria for inclusion label Mar 18, 2025
@Tanujkanti4441 Tanujkanti4441 moved this from Evaluating to Implementing in Triage Mar 18, 2025
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@mdjermanovic mdjermanovic merged commit 8320241 into eslint:main Mar 18, 2025
31 checks passed
@github-project-automation github-project-automation bot moved this from Implementing to Complete in Triage Mar 18, 2025
@JoshuaKGoldberg JoshuaKGoldberg deleted the default-param-last-typescript-syntax branch March 18, 2025 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion feature This change adds a new feature to ESLint rule Relates to ESLint's core rules
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

5 participants