-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
ESLint cannot find already installed plugins when linting exercises in local environment #1386
Comments
Hello. Thanks for opening an issue on Exercism. We are currently in a phase of our journey where we have paused community contributions to allow us to take a breather and redesign our community model. You can learn more in this blog post. As such, all issues and PRs in this repository are being automatically closed. Note: If this issue has been pre-approved, please link back to this issue on the forum thread and a maintainer or staff member will reopen it. |
@SleeplessByte Can you reopen? I can confirm that this problem happens. But I had to start a fresh exercise to be able to reproduce, I'm not sure yet why it didn't happen on an exercise I already started before, which has an identical |
I just downloaded You can see in https://github.com/exercism/typescript/blob/main/exercises/practice/resistor-color-trio/package.json#L19-L25 that Could it be that you @angelikatyborska or you @konradkozubek have not yet updated your exercise? If yes, can you tell me where it's happening? Additionally, after running
|
@SleeplessByte It happens to me on completely fresh exercises. Earlier today I tried on Normally I use yarn I tested this with my IDE closed so that any IDE Eslint plugins do not interfere. Normally I use Webstorm. I never rely on Eslint run via the IDE, I always run it myself in the terminal.
|
Thank you. This helps. I'll try to make it work for your use case. |
@angelikatyborska can you try adding the following line to the exercise nodeLinker: node-modules It doesn't matter if it's above or below the If this works, we unfortunately will have to revert PnP because of some shitty decisions eslint have taken in the past. I have read all the threads. I neither agree with the original resolution (and completely agree with Sindre's assesment and commentary) and I don't think the "flat structure" will work as well as we want it to. It also has been experimental for over a year so I am not keen to introduce that here. Futhermore, adding the dependencies directly to the exercise is exactly what we do not want, nor do we want peerDepedencies. The students should be able to just install the exercise and not worry about these things at all, nor should the exercise be invalidated when a plugin updates. A decent workaround may be https://www.npmjs.com/package/@rushstack/eslint-patch, but I need to explore that. It is also listed as workaround for the Plug'n'Play issue you both are experiencing as listed here: https://yarnpkg.com/features/pnp#native-support |
It did, and now |
@konradkozubek you can use the method above to make it work in the meantime. I will work on implementing eslint-patch. |
Sorry, I've been quite busy these last few days, so I'm responding now. Yes, adding
As I mentioned in the initial comment, I considered adding plugin packages to exercise projects as only a quick workaround not requiring changing of ESLint configuration, and I thought that using the new config system would solve the problem the right way - but I understand, that you don't want to use it in favor of
Of course I meant that in this quick workaround - making plugin packages peer dependencies of |
I'll let both of you know when you can upgrade to test out the new way of doing it! |
Hi there. This issue was linked in a thread for a separate issue related to Yarn 3 and Jest testing locally on the typescript track. https://forum.exercism.org/t/issue-with-local-jest-type-definitions-yarn-3-and-jest/6867/7 I'm just posting to raise the possibility that Yarn PnP related issues may be more widespread than this in the track, and possibly there are more things out there going wrong that haven't been reported yet due to people not having had the opportunity to thoroughly test the track. I have been unable to solve a missing type dependency for jest without somehow involving I don't really know if these are for sure related, but since this issue was linked on the provided post, I thought I'd poke my nose in and say hey :) |
@WigglyDon I replied in your thread https://forum.exercism.org/t/issue-with-local-jest-type-definitions-yarn-3-and-jest/6867/7. When using Yarn PnP, I fixed problems with VS Code not recognizing the type definitions for Jest by following the official Yarn guide on how to integrate VS Code with Yarn PnP: Editor SDKs | Yarn. However, if you follow @SleeplessByte's advice of adding |
Issue
Hello, I hope that it is the right place to mention this issue.
I recently started TypeScript track and found out that there seems to be a problem with linting configuration when working locally, both in Two Fer and Resistor Color Duo exercises (so probably in all exercises in the track).
ESLint cannot find two plugins, which are installed as dependencies of
@exercism/eslint-config-typescript
package, which is present inpackage.json
file.TL;DR
It seems to be a long known issue in ESLint, that seems to be resolved with introduction of the new config system (see the last comment in mentioned issue). The new config system will be used by default in v9, but it also can be used now in v8 after some configuration (I haven't tried that).
However, there is a simple workaround to fix this issue. ESLint can find those plugins, if they are explicitly present in the
package.json
file.@exercism/eslint-config-typescript
package declareseslint-plugin-import@npm:^2.27.5
and@typescript-eslint/eslint-plugin@npm:^5.59.9
as dependencies, so adding"eslint-plugin-import": "npm:^2.27.5",
and"@typescript-eslint/eslint-plugin": "npm:^5.59.9",
to the object in"devDependencies"
inpackage.json
solves the issue.Following sections explain the details.
Steps to reproduce error
I am working on macOS Monterey, using Node v18.17.0 installed by
nvm
.After running
exercism download --exercise=two-fer --track=typescript
, entering exercise directory and installing dependencies withyarn install
, runyarn lint:ci
.Expected behavior
ESLint working normally.
Encountered behavior
ESLint cannot find two plugins, even though they are installed as dependencies of
@exercism/eslint-config-typescript
. Runninggives following error:
Running:
confirms, that the package is installed, because it is a dependency of
@exercism/eslint-config-typescript
. However, runningfixes this problem - ESLint is now able to find
eslint-plugin-import
package, but cannot find another one. (Version range is the same as specified by@exercism/eslint-config-typescript
package.) Runningnow gives another error:
Again, running
confirms, that the package is installed, because it is a dependency of
@exercism/eslint-config-typescript
. Similarly, runningfixes this problem - ESLint is now able to find
@typescript-eslint/eslint-plugin
package, too. (Version range is the same as specified by@exercism/eslint-config-typescript
package.) Runningnow shows, that ESLint is working correctly.
Solution
As I said in TL;DR section, the issue can be quickly fixed by adding
eslint-plugin-import@npm:^2.27.5
and@typescript-eslint/eslint-plugin@npm:^5.59.9
as development dependencies topackage.json
of the exercise project. It is important to use the version ranges specified by@exercism/eslint-config-typescript
package, because runningyarn add -D @typescript-eslint/eslint-plugin
and installing the latest version of this package leads to another ESLint error:Definition for rule '@typescript-eslint/no-parameter-properties' was not found
, as this rule was deleted meanwhile (typescript-eslint.io blog post announcing typescript-eslint v6 informs about removal of this deprecated rule).It seems that with currently used ESLint configuration that is the way to go by quickly solving the issue, however maybe using the new config system of ESLint is worth trying - maybe then plugins provided as
@exercism/eslint-config-typescript
package dependencies would be visible to ESLint.The text was updated successfully, but these errors were encountered: