eslint-config-lwc icon indicating copy to clipboard operation
eslint-config-lwc copied to clipboard

Add support for ESLint v9

Open DougMidgley opened this issue 1 year ago • 5 comments

The current plugin does not seem to work with eslint 9 which by default uses the flat config format https://eslint.org/blog/2023/11/whats-coming-in-eslint-9.0.0/ We get the following error [Error - 11:23:02 PM] ConfigError: Config (unnamed): Key "extends": This appears to be in eslintrc format rather than flat config format.

DougMidgley avatar Apr 21 '24 21:04 DougMidgley

Hi, ESLint v9 support is not implemented yet, apologies for that.

nolanlawson avatar May 06 '24 20:05 nolanlawson

Are there any plans yet to update this? Thanks.

smithmd avatar Aug 02 '24 19:08 smithmd

It is on our roadmap, but we are very concerned about shipping breaking changes to our customers, so we are doing this carefully. 🙂

nolanlawson avatar Aug 05 '24 18:08 nolanlawson

Hey Team, do we have any updates in regards to the issue?

szymon-halik avatar Sep 11 '24 07:09 szymon-halik

Sorry no, there is no update at this time.

nolanlawson avatar Sep 11 '24 20:09 nolanlawson

Given ESLINT v8.x is no longer supported, it is coming up on client security scans. Any timelines on when we can expect this?

DougMidgley avatar Oct 30 '24 21:10 DougMidgley

This continues to be an issue. Whom can we tag to get this looked at? I'm faced with either using unsupported eslint or unsupported eslint-config-lwc.

dschach avatar Dec 18 '24 19:12 dschach

This is still on our roadmap. We have heard from multiple sources that ESLint v9 support is much needed.

nolanlawson avatar Dec 19 '24 18:12 nolanlawson

One more source here saying that the lack of support for ESLint v9 is causing us friction, and it will be great when this is released!

aidan-harding avatar Jan 02 '25 09:01 aidan-harding

Folks on this thread and @DougMidgley, we just published a new beta version with support for ESLint v9. Please give @salesforce/[email protected] a trial and post on this thread if you face any issues.

Note: For peer dependencies, please use the following:

{
    "@lwc/eslint-plugin-lwc": "3.0.0-beta1",
    "@salesforce/eslint-plugin-lightning": "2.0.0-beta.1"
}

ravijayaramappa avatar Jan 08 '25 00:01 ravijayaramappa

@salesforce/[email protected] requires an update of peer depoendancies @lwc/eslint-plugin-lwc@^2.0.0 and eslint@^9

but @lwc/eslint-plugin-lwc has eslint@"^7 || ^8" (i.e. doesn't support eslint v9)

YodaDaCoda avatar Jan 08 '25 02:01 YodaDaCoda

@YodaDaCoda Thanks for catching that, I update my post with the peer dependencies to use for your testing. I will fix the. peer dependency specification in a follow up PR.

ravijayaramappa avatar Jan 08 '25 03:01 ravijayaramappa

I ran npm i --save @salesforce/[email protected] @lwc/[email protected] eslint@9 but I get ERESOLVE unable to resolve dependency tree (the presence or absence of @salesforce/[email protected] had no impact on this)

╰─ npm i --save @salesforce/[email protected] @lwc/[email protected] eslint@9
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: [email protected]
npm error Found: @lwc/[email protected]
npm error node_modules/@lwc/eslint-plugin-lwc
npm error   @lwc/eslint-plugin-lwc@"3.0.0-beta.1" from the root project
npm error
npm error Could not resolve dependency:
npm error peer @lwc/eslint-plugin-lwc@"^3.0.0" from @salesforce/[email protected]
npm error node_modules/@salesforce/eslint-config-lwc
npm error   @salesforce/eslint-config-lwc@"4.0.0-beta.2" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /home/will/.npm/_logs/2025-01-08T22_46_21_072Z-eresolve-report.txt
npm error A complete log of this run can be found in: /home/will/.npm/_logs/2025-01-08T22_46_21_072Z-debug-0.log

It's not clear to me why it's complaining about that version; as far as I understand 3.0.0-beta.1 satisfies the ^3.0.0 version spec.

YodaDaCoda avatar Jan 08 '25 22:01 YodaDaCoda

@YodaDaCoda Thank you for testing it out. So apparently the semver ^3.0.0 does not accept 3.0.0-beta.1 as a qualifying range. https://github.com/semver/semver/issues/871 https://github.com/vitest-dev/vitest/issues/1960#issuecomment-1236126263

I will release a new beta version of @salesforce/eslint-config-lwc to adjust the peer-dependencies specification to accept prerelease versions. In the meantime you can use these changes if you want to continue testing: Screenshot 2025-01-09 at 4 09 16 PM

ravijayaramappa avatar Jan 10 '25 00:01 ravijayaramappa

Trying this out now. The way this is implemented is really all or nothing. Previously we had different rules for LWC and Aura setup, but because the extend key is no longer in the flat file we have issues. https://github.com/eslint/rfcs/pull/126/files looks like we are not alone in this. Effectively, applying config for all files is fine, but when you run a filter (ie. files: ["**/lwc/**/*.js"] ), it doesn't work as one may expect. Given that recommended returns an array of configs this can only be applied at the whole config level OR you need to parse each of them into the filtered arrays. Not sure if others have looked at this?

DougMidgley avatar Feb 05 '25 10:02 DougMidgley

@nolanlawson Any updates here? Just broke our CICD pipe as I applied the dependabot recommended updates. Reverted the change and now it works. But this is not a good experience for sfdx

james-ef avatar Feb 14 '25 17:02 james-ef

What version did you try to upgrade to? ESLint v9 support will only be available beginning with v4 of eslint-config-lwc. That is currently available under the beta dist tag on npm; the latest release is 4.0.0-beta.5.

If you're using the beta release of this config, and you've migrated your eslint config to the new flat format, please provide details about what went wrong, so that we can help address the issue.

wjhsf avatar Feb 14 '25 19:02 wjhsf

Hi! Any updates on this? A simple sf generate project --name newsfproject && cd newsfproject && npm install crashes as mentioned in https://github.com/forcedotcom/salesforcedx-templates/issues/619.

Details `❯ sf --version && sf generate project --name newsfproject && cd newsfproject && npm install @salesforce/cli/2.83.7 darwin-arm64 node-v22.14.0 target dir = /Users/lrz/coding/sfdx create newsfproject/config/project-scratch-def.json create newsfproject/README.md create newsfproject/sfdx-project.json create newsfproject/.husky/pre-commit create newsfproject/.vscode/extensions.json create newsfproject/.vscode/launch.json create newsfproject/.vscode/settings.json create newsfproject/force-app/main/default/lwc/.eslintrc.json create newsfproject/force-app/main/default/aura/.eslintrc.json create newsfproject/scripts/soql/account.soql create newsfproject/scripts/apex/hello.apex create newsfproject/.forceignore create newsfproject/.gitignore create newsfproject/.prettierignore create newsfproject/.prettierrc create newsfproject/jest.config.js create newsfproject/package.json

npm error code ERESOLVE npm error ERESOLVE unable to resolve dependency tree npm error npm error While resolving: [email protected] npm error Found: @lwc/[email protected] npm error node_modules/@lwc/eslint-plugin-lwc npm error dev @lwc/eslint-plugin-lwc@"^1.1.2" from the root project npm error npm error Could not resolve dependency: npm error peer @lwc/eslint-plugin-lwc@"^2.0.0" from @salesforce/[email protected] npm error node_modules/@salesforce/eslint-config-lwc npm error dev @salesforce/eslint-config-lwc@"^3.2.3" from the root project npm error npm error Fix the upstream dependency conflict, or retry npm error this command with --force or --legacy-peer-deps npm error to accept an incorrect (and potentially broken) dependency resolution. npm error npm error npm error For a full report see: npm error /Users/lrz/.npm/_logs/2025-04-12T09_58_05_012Z-eresolve-report.txt npm error A complete log of this run can be found in: /Users/lrz/.npm/_logs/2025-04-12T09_58_05_012Z-debug-0.log`

benjaminloerincz avatar Apr 12 '25 09:04 benjaminloerincz

Looks like this issue can now be closed as v4 is out with ESLint v9 support. The project template still needs to be updated thought but that's another repo/issue.

pozil avatar Apr 16 '25 10:04 pozil