-
Notifications
You must be signed in to change notification settings - Fork 168
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
feat: add eslint 9 config support #762
Conversation
✅ Deploy Preview for creative-fairy-df92c4 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Thanks for the PR, will review this today! |
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.
Edit: See #762 (comment) first before worrying about tests
Couple of changes requested. I'll implement a E2E test for this, can you update it so it passes?
# To run tests:
pnpm test
I see we're just re-exporting the JSON file in a JS file. Edit: ESLint doesn't like the // eslint.config.js
- import autoImports from './.wxt/eslintrc-auto-import.js';
+ import autoImports from './.wxt/eslintrc-auto-import.json' with { type: 'json' };
export default [
{
languageOptions: {
globals: {
...autoImports.globals,
},
sourceType: 'module',
},
},
]; What about fully adopting the new file config format and do something like this? import autoImports from './.wxt/eslint-auto-import-config.js';
export default [
autoImports,
{
// User config here...
},
]; // ./.wxt/eslint-auto-import-config.js
import { globals } from './eslintrc-auto-import.json' with { type: 'json' };
export default {
languageOptions: {
globals,
sourceType: 'module',
},
} |
Doing some more testing, and it appears |
OK, got a basic example of using the new flat file format Screen.Recording.2024-06-23.at.11.39.04.AM.movI think we should use this format instead. |
Also, I just merged #767, which will effect this PR. I knew it would cause conflicts with this PR when I merged it, but I needed it merged for some other work. So don't worry about fixing the merge conflicts yourself, I can do it since I broke it. |
import('eslint') is not compatible `"type": "module"`
The idea I had was keeping it BC, since jumping to ESLint 9+ might be bigger hurdle for some. There was a package, ESLint import plugin I had that's not ESLint 9 compatible and hasn't been updated in 6 months, and I wasn't sure when it was going to be updated so I opted not to move to ESLint 9 for now. What about splitting it so that it generates >=9+ config and <9 config depending on the ESLint version. Edit: extended though was that eventually the ESLint 9 config would be the default and deprecate the ESLint <9 config |
... That's an interesting opinion.
I think this is what we should do. Checking out your latest code now. |
Cool, if I have some time today I'll work on splitting it into separate dedicated configs based on the ESLint version, otherwise probably next weekend. I already liked what the WXT framework has to offer. Working on this small part, and digging into the the internals of how it works has made me appreciate even more all the effort that has gone into it. It's non-trivial effort, so well done |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #762 +/- ##
==========================================
+ Coverage 87.08% 87.15% +0.07%
==========================================
Files 116 117 +1
Lines 9939 10007 +68
Branches 973 976 +3
==========================================
+ Hits 8655 8722 +67
- Misses 1271 1272 +1
Partials 13 13 ☔ View full report in Codecov by Sentry. |
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.
OK, this is looking good. Fixed the merge conflicts, so the code has moved.
I need to test if this actually creates a valid config file, and I'll add an E2E test for that later today maybe...
switch (rawEslintEnabled) { | ||
case undefined: | ||
case 'auto': | ||
eslintEnabled = await isModuleInstalled('eslint'); |
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.
Seems like "auto"
was not working. Using your code though, it's working now!
eslintEnabled === 9 | ||
? 'eslint-auto-imports.mjs' | ||
: 'eslintrc-auto-import.json', |
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.
Needed to change the default file path for this file based on the version, so I moved the version detection code into the config resolution.
Add ESLint 9 support: #710
With ESLint 9, the config has changed, this generates a ESLint JS file to work with the ESLint 9 config changes.
This also adds ESLint to the wxt-demo package.
There is just one issue to address.
IDE has an ESLint error
SyntaxError: The requested module './.wxt/eslintrc-auto-import.js' does not provide an export named 'default'
I think this is because it's not an
index.js
file and is doing amodule.exports
but in the demo package I'm using animport
statement. If it's safe to now just use anexport
statement in the JS file I can update it to do that instead, or what would be the preferred approach to this?I think everything else is correct, the Vitest was a bit of a learning curve, luckily there's plenty of other tests to learn from :)