Skip to content

Enhancement: Publish browser-compatible TS ESLint package? #10808

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

Closed
4 tasks done
jasonkuhrt opened this issue Feb 6, 2025 · 7 comments
Closed
4 tasks done

Enhancement: Publish browser-compatible TS ESLint package? #10808

jasonkuhrt opened this issue Feb 6, 2025 · 7 comments
Labels
enhancement New feature or request locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. wontfix This will not be worked on

Comments

@jasonkuhrt
Copy link

Before You File a Proposal Please Confirm You Have Done The Following...

Relevant Package

website

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Description

I recently inquired about the Website Playground in #10798. Since then, after more review of the codebase, I believe there is too much application code for us to try and recreate for our own product. While we clearly don't need the whole playground itself, we do need a way to easily execute ESLint+TS ESLint validation over editor contents. This core functionality seems not available in the ecosystem right now, but is achieved on your website. How feasible would it be to have that core distributed on npm for others to consume? I appreciate the fact that I am asking about something which partially implicates an unrelated projects which is ESLint itself, and perhaps its that project which should ideally lead with a browser compatible package. I'm not sure what makes most sense for TS ESLint, but given you already solved this, maybe its not a stretch to publish that solution/tweaked solution for others.

Thanks for any consideration :)
(and great projects thanks all :))

Additional Info

No response

@jasonkuhrt jasonkuhrt added enhancement New feature or request triage Waiting for team members to take a look labels Feb 6, 2025
@jasonkuhrt jasonkuhrt changed the title Enhancement: Publish browser-compatible ESLint package? Enhancement: Publish browser-compatible TS ESLint package? Feb 6, 2025
@bradzacher
Copy link
Member

Caveat -- we've "solved this" specifically in a way that works in our playground. This isn't a good way to solve this or even a scalable way to solve it -- much of the "solving" involves us purely mocking out any of our internals that touch NodeJS APIs.

One of the reasons we hack around like this is because we have all the tabs on our playground to allow us to inspect our internals and TS's internals.

What we've done is by far NOT what should be done by others. Instead one should be looking to more holistically mock out the NodeJS APIs themselves so that all of the ESLint ecosystem can "just work". For example this is what you will see "VSCode Web" or "Code Sandbox" or other such browser IDEs do.

In an ideal world -- yeah, this is something we could consider to make it easy for people to embed our tooling without any effort. But in our current state I just don't we don't have the bandwidth to consider taking on such a workload.

Thoughts @typescript-eslint/triage-team

@jasonkuhrt
Copy link
Author

jasonkuhrt commented Feb 10, 2025

@bradzacher Thanks for the feedback, its clear and I respect completely your bandwidth. Your giving a sense of magnitude of doing this "properly" is also useful!

For example this is what you will see "VSCode Web" or "Code Sandbox" or other such browser IDEs do.

Good point, they've apparently also crossed this bridge.

Overall, I did and continue to wonder why ESLint went down a path of being coupled to Node APIs, like TS has done which is even more complex of a tool.

@JoshuaKGoldberg
Copy link
Member

why ESLint went down a path of being coupled to Node APIs

Well, they have two areas of APIs:

  • ESLint: relies on Node.js APIs; tailored to the file system use case
  • Linter: doesn't rely on any Node.js APIs or filesystem operations; tailored to the browser use case

like TS has done which

TypeScript also abstracts away system APIs. It runs well on Node.js by default but can be made to run fully virtually: https://www.typescriptlang.org/dev/typescript-vfs.

We've been interested in moving to that VFS for tests for a while: #1891

@bradzacher
Copy link
Member

The problem with decoupling from nodejs APIs is that often means that you can't use 3rd party dependencies for things and instead have to write your own code or fork something.

For example we rely on a 3rd party dependency to do globbing - which requires the node FS API to iterate the disk.

This sort of behaviour falls over when you move to the browser - what does it mean to "glob the file system" if there is no file system? Browser IDEs usually have a VFS which allows them to create and maintain the folder structure - and in using a VFS they also usually reimplement the node FS API.

Ultimately though it depends on usecases and cost/value trade-offs. If 99.99% of usecases are in a NodeJS-like environment - then spending time making the code nodejs agnostic isn't hugely valuable.

@Josh-Cena
Copy link
Member

Is there a proposal to ESLint to make them web-compatible, to the extent of having a reusable ESLint playground that you can attach plugins to? I think we shouldn't concern us about infra more than a typical ESLint plugin should do.

@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented Feb 19, 2025

Indeed, this isn't something we're in a good place to support. If you're interested in taking this on then I think the right next steps would be #1891 to prove out running typed linting in a VFS.

But, regardless of how that goes, we definitely don't have the bandwidth to set up an ESLint VFS + browser solution ourselves (as much as we would love to!). That task would just be something we could give advice to if you want to ask us in our Discord / ping us on an ESLint RFC.

Thanks for asking! Closing out as out-of-scope for typescript-eslint itself.

@JoshuaKGoldberg JoshuaKGoldberg closed this as not planned Won't fix, can't repro, duplicate, stale Feb 19, 2025
@JoshuaKGoldberg JoshuaKGoldberg added wontfix This will not be worked on and removed triage Waiting for team members to take a look labels Feb 19, 2025
@jasonkuhrt
Copy link
Author

Thanks for the thoughtful responses all!

@github-actions github-actions bot added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label Feb 28, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants