Skip to content

feat: add TypeScript parser support to playground #714

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
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

Tanujkanti4441
Copy link
Contributor

Prerequisites checklist

What is the purpose of this pull request?

What changes did you make? (Give an overview)

Added an option called Parser under the section Versioning and Configuration to enable @typescript-eslint/parser in playground.

Related Issues

#709

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

Copy link

netlify bot commented Mar 31, 2025

Deploy Preview for hi-eslint ready!

Name Link
🔨 Latest commit 580bccc
🔍 Latest deploy log https://app.netlify.com/projects/hi-eslint/deploys/683ad52fb01da20008251485
😎 Deploy Preview https://deploy-preview-714--hi-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 project configuration.

Copy link

netlify bot commented Mar 31, 2025

Deploy Preview for new-eslint ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 580bccc
🔍 Latest deploy log https://app.netlify.com/projects/new-eslint/deploys/683ad52fed5ec60008f3514c
😎 Deploy Preview https://deploy-preview-714--new-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 project configuration.

Copy link

netlify bot commented Mar 31, 2025

Deploy Preview for ja-eslint ready!

Name Link
🔨 Latest commit 580bccc
🔍 Latest deploy log https://app.netlify.com/projects/ja-eslint/deploys/683ad52f4f73860008601e0e
😎 Deploy Preview https://deploy-preview-714--ja-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 project configuration.

Copy link

netlify bot commented Mar 31, 2025

Deploy Preview for zh-hans-eslint ready!

Name Link
🔨 Latest commit 580bccc
🔍 Latest deploy log https://app.netlify.com/projects/zh-hans-eslint/deploys/683ad52f2e56240008475012
😎 Deploy Preview https://deploy-preview-714--zh-hans-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 project configuration.

Copy link

netlify bot commented Mar 31, 2025

Deploy Preview for es-eslint ready!

Name Link
🔨 Latest commit 580bccc
🔍 Latest deploy log https://app.netlify.com/projects/es-eslint/deploys/683ad52f4f73860008601e0c
😎 Deploy Preview https://deploy-preview-714--es-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 project configuration.

Copy link

netlify bot commented Mar 31, 2025

Deploy Preview for fr-eslint ready!

Name Link
🔨 Latest commit 580bccc
🔍 Latest deploy log https://app.netlify.com/projects/fr-eslint/deploys/683ad52f81056100088a1f06
😎 Deploy Preview https://deploy-preview-714--fr-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 project configuration.

Copy link

netlify bot commented Mar 31, 2025

Deploy Preview for pt-br-eslint ready!

Name Link
🔨 Latest commit 580bccc
🔍 Latest deploy log https://app.netlify.com/projects/pt-br-eslint/deploys/683ad52f341c1b0008f624f3
😎 Deploy Preview https://deploy-preview-714--pt-br-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 project configuration.

Copy link

netlify bot commented Mar 31, 2025

Deploy Preview for de-eslint ready!

Name Link
🔨 Latest commit 580bccc
🔍 Latest deploy log https://app.netlify.com/projects/de-eslint/deploys/683ad52fa2783a000841292c
😎 Deploy Preview https://deploy-preview-714--de-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 project configuration.

@Tanujkanti4441 Tanujkanti4441 marked this pull request as ready for review April 4, 2025 14:49
@snitin315 snitin315 moved this from Needs Triage to Implementing in Triage Apr 8, 2025
@nzakas
Copy link
Member

nzakas commented Apr 10, 2025

This is looking good! Can we make the default parser option say "Espree (default)"?

@snitin315 this is waiting for your re-review.

Comment on lines 173 to 175
...(options?.languageOptions.parser && {
parser: typeScriptESLintParser,
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to make sure to pass the languageOptions.sourceType correctly to parserOptions.sourceType in case of typeScriptESLintParser, More information here eslint/eslint#19563 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Copy link
Contributor

@snitin315 snitin315 left a comment

Choose a reason for hiding this comment

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

I think we can also remove impliedStrict from ecma features in case of typescriptEslintParser. As per the docs, only jsx & globalReturn seems to be valid.

Screenshot 2025-04-30 at 6 16 50 AM

@snitin315
Copy link
Contributor

@Tanujkanti4441 It seems there are few merge conflicts now, can you please resolve them?

snitin315
snitin315 previously approved these changes May 11, 2025
Copy link
Contributor

@snitin315 snitin315 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!

Would like @nzakas to verify as well.

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.

When @typescript-eslint/parser is selected, downloaded config file looks like this:

export default [
    {
        "languageOptions": {
            "parser": true
        }
    }
];

Which is an invalid config file. Perhaps the config file should import the parser and use it?

@mdjermanovic
Copy link
Member

The value of "parser" serialized in the URL is also true. Perhaps we could use a string value ("@typescript-eslint/parser") to allow for adding more parsers in the future?

@lumirlumir lumirlumir linked an issue May 15, 2025 that may be closed by this pull request
1 task
@Tanujkanti4441
Copy link
Contributor Author

The value of "parser" serialized in the URL is also true. Perhaps we could use a string value ("@typescript-eslint/parser") to allow for adding more parsers in the future?

i didn't get It may be, you mean parser: "@typescript-eslint/parser" in downloaded config file?

@nzakas
Copy link
Member

nzakas commented May 28, 2025

Ping @mdjermanovic

@mdjermanovic
Copy link
Member

The value of "parser" serialized in the URL is also true. Perhaps we could use a string value ("@typescript-eslint/parser") to allow for adding more parsers in the future?

i didn't get It may be, you mean parser: "@typescript-eslint/parser" in downloaded config file?

Sorry for the delay. I was referring to encoded config in the URL.

For example:

https://deploy-preview-714--new-eslint.netlify.app/play/#eyJ0ZXh0IjoiIiwib3B0aW9ucyI6eyJydWxlcyI6e30sImxhbmd1YWdlT3B0aW9ucyI6eyJwYXJzZXJPcHRpb25zIjp7ImVjbWFGZWF0dXJlcyI6eyJqc3giOnRydWV9LCJzb3VyY2VUeXBlIjoibW9kdWxlIn0sInBhcnNlciI6dHJ1ZX19fQ==

The part after # is Base64-encoded text and config:

{
  "text": "",
  "options": {
    "rules": {},
    "languageOptions": {
      "parserOptions": {
        "ecmaFeatures": { "jsx": true },
        "sourceType": "module"
      },
      "parser": true
    }
  }
}

"parser": true means that the "@typescript-eslint/parser" should be used. But that limits the Playground URLs to only one custom parser, and if we add more in the future, we'd need to support true for backcompat. I think it would be better to encode parser: "@typescript-eslint/parser" from the start.

@Tanujkanti4441
Copy link
Contributor Author

"parser": true means that the "@typescript-eslint/parser" should be used. But that limits the Playground URLs to only one custom parser, and if we add more in the future, we'd need to support true for backcompat. I think it would be better to encode parser: "@typescript-eslint/parser" from the start.

@mdjermanovic, i tried to fix this in 229a2e1 can you check this please and tell if it still needs an update?

@mdjermanovic
Copy link
Member

"parser": true means that the "@typescript-eslint/parser" should be used. But that limits the Playground URLs to only one custom parser, and if we add more in the future, we'd need to support true for backcompat. I think it would be better to encode parser: "@typescript-eslint/parser" from the start.

@mdjermanovic, i tried to fix this in 229a2e1 can you check this please and tell if it still needs an update?

I was testing today with the deploy preview (which I believe should represent the latest version), and URLs the Playground generates still have "parser":true encoded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Implementing
Development

Successfully merging this pull request may close these issues.

Suggestion: Support TypeScript syntax in playground
5 participants