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

[WIP] Fix Framework Inference for eslint-config-turbo. #8505

Closed
wants to merge 3 commits into from
Closed

Conversation

anthonyshew
Copy link
Contributor

@anthonyshew anthonyshew commented Jun 15, 2024

Description

A fairly naive implementation of Framework Inference (as it stands at the moment). turbo's Framework Inference support is per-package whereas this one wholesale allowslists all framework environment variables in every package.

I tried my hand at making it per-package but fell flat. Could use some assistance if we don't think this is sufficient. From my perspective, the risk of someone using the wrong vars in the wrong framework is minimal and this is an improvement on our current support (which is none at all).

Testing Instructions

Double-checking the tests I have would be great. I've never written an ESLint plugin before and had...quite a time with this.

@turbo-orchestrator turbo-orchestrator bot added created-by: turborepo pkg: turbo-eslint eslint-config-turbo and eslint-plugin-turbo labels Jun 15, 2024
Copy link

vercel bot commented Jun 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 15, 2024 9:04pm
9 Ignored Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Jun 15, 2024 9:04pm
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview Jun 15, 2024 9:04pm
examples-gatsby-web ⬜️ Ignored (Inspect) Visit Preview Jun 15, 2024 9:04pm
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview Jun 15, 2024 9:04pm
examples-native-web ⬜️ Ignored (Inspect) Visit Preview Jun 15, 2024 9:04pm
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview Jun 15, 2024 9:04pm
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Jun 15, 2024 9:04pm
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview Jun 15, 2024 9:04pm
rust-docs ⬜️ Ignored (Inspect) Visit Preview Jun 15, 2024 9:04pm

Copy link
Contributor

github-actions bot commented Jun 15, 2024

🟢 Turbopack Benchmark CI successful 🟢

Thanks

Copy link
Contributor

github-actions bot commented Jun 15, 2024

🟢 CI successful 🟢

Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing these since the intent is to auto-include these.

Copy link

socket-security bot commented Jun 15, 2024

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/..%2F..@2.0.4 None 0 0 B
npm/vite@5.2.13 environment, eval, filesystem, network, shell, unsafe +41 274 MB vitebot

View full report↗︎

@@ -81,6 +83,10 @@ function create(context: RuleContextWithOptions): Rule.RuleListener {
}
});

frameworkInferencePrefixes.forEach((prefix) => {
regexAllowList.push(new RegExp(`^${prefix}`));
Copy link
Contributor Author

@anthonyshew anthonyshew Jun 15, 2024

Choose a reason for hiding this comment

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

This might be too naive, since it doesn't account for package boundaries. It's going to auto-allow NEXT_PUBLIC in a Vite application, for example.

(In practice, this probably isn't a big problem?)

@anthonyshew anthonyshew changed the title Very naive version. [WIP] Fix Framework Inference for eslint-config-turbo. Jun 15, 2024
Copy link
Contributor

✅ This change can build next-swc

Copy link
Member

@tknickman tknickman left a comment

Choose a reason for hiding this comment

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

Nice! Let's chat about this today. I think we should compare this with what is available in vercel/vercel. Ultimately we have to match turbo's inference here, but I think that was ported from vercel/vercel originally. So instead of porting that back to JS I would prefer that we just use that inference directly.

But if we've diverged we'll need to roll it ourselves so we match directly. We'll also need to think about a good way to ensure this doesn't drift from what's in turbo core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: turbo-eslint eslint-config-turbo and eslint-plugin-turbo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants