-
-
Notifications
You must be signed in to change notification settings - Fork 74
feat: migrate playground to ESLint v10 #853
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for new-eslint ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for ja-eslint ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for hi-eslint ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for zh-hans-eslint ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for pt-br-eslint ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for fr-eslint ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for de-eslint ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for es-eslint ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| '/* eslint quotes: ["error", "double"] */\nconst a = \'b\';'; | ||
|
|
||
| const linter = new Linter({ configType: "flat" }); | ||
| const legacyLinter = new Linter({ configType: "eslintrc" }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, this wouldn't work with ESLint v10 so we have to figure out another way to get rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This problem was discussed in eslint/eslint#18103, and a proposed solution that could do the work is to fetch rules_meta.json from the eslint/eslint repo's latest branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify: does the proposed solution involve fetching rules_meta.json from the eslint repo at runtime, or is the idea to fetch it ahead of time (e.g., during build)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not at runtime (i.e., not from browser) but ahead of time (e.g., during the build). Here's an example of how we are fetching versions data while building docs sites:
https://github.com/eslint/eslint/blob/main/docs/src/_data/eslintVersions.js
though I'm not sure if this example is applicable for web-packing the playground.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative to fetching is to copy this file during the eslint release process (it already creates and commits the blog post to this repo). @fasttime what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think fetching rules metadata during docs build or at eslint release time are both viable solutions. Another option is using a postinstall script in src/playground/package.json (or similar) to fetch rules metadata from the installed eslint dependency, either from builtinRules or directly from the resolved lib/rules directory location in node_modules, for example:
// postinstall.js
const { writeFileSync } = require("node:fs");
const { builtinRules } = require("eslint/use-at-your-own-risk");
const rulesMeta = Object.fromEntries(builtinRules.entries().map(([key, { meta }]) => [key, meta]));
writeFileSync("rules_meta.json", JSON.stringify(rulesMeta));This would also ensure that the rules metadata are set correctly when the Playground is built locally with an unpublished eslint version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option is using a
postinstallscript insrc/playground/package.json(or similar) to fetch rules metadata from the installedeslintdependency, either frombuiltinRulesor directly from the resolvedlib/rulesdirectory location innode_modules, for example:// postinstall.js const { writeFileSync } = require("node:fs"); const { builtinRules } = require("eslint/use-at-your-own-risk"); const rulesMeta = Object.fromEntries(builtinRules.entries().map(([key, { meta }]) => [key, meta])); writeFileSync("rules_meta.json", JSON.stringify(rulesMeta));
This look like the simplest solution at the moment so let's go with it 👍
If and when we remove the builtinRules export in the future, we can then figure out a different way to get rules_meta.json in this repo.
Prerequisites checklist
What is the purpose of this pull request?
What changes did you make? (Give an overview)
Related Issues
Is there anything you'd like reviewers to focus on?