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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting a failed to load plugin error when running tester locally #382

Closed
sjarva opened this issue Sep 3, 2022 · 4 comments
Closed

Getting a failed to load plugin error when running tester locally #382

sjarva opened this issue Sep 3, 2022 · 4 comments

Comments

@sjarva
Copy link
Contributor

sjarva commented Sep 3, 2022

First of all, thanks for developing this kind of tool, it's really essential in eslint plugin development 馃ぉ 馃檹

I'm trying to run this locally after modifying an existing rule for an existing plugin (eslint-plugin-react), but get the following error:

Configuration validation errors:
- eslintrc: Failed to load plugin 'react' declared in 'CLIOptions': Cannot find module 'eslint-plugin-react'
Require stack:
- /eslint-plugin-react/__placeholder__.js

I have a eslint-remote-tester.config.js with contents copied from React example config, but the rule name changed to the rule I want to test.

Any ideas why I'm getting this error?

@AriPerkkio
Copy link
Owner

Thanks for your interest @sjarva! This tool can indeed be used for local eslint rule development. I used it myself when building new rules to eslint-plugin-react, jsx-eslint/eslint-plugin-react#2750 (comment).

Before debugging this further I just want to ensure you have linked the local project in your package manager - this is something ESLint requires when it is resolving the plugins. In practice this means that you'll have to run npm link && npm link <package>, or similar command depending on your package manager.

Here is how eslint-plugin-react is linking its local copy of the plugin to its own dependencies: https://github.com/jsx-eslint/eslint-plugin-react/blob/91ea5d528b9daf960e8afd1718b590138b5f54f1/.github/workflows/smoke-test.yml#L20-L21

@sjarva
Copy link
Contributor Author

sjarva commented Sep 3, 2022

That did the trick! Thanks for the quick reply @AriPerkkio 馃

@sjarva sjarva closed this as completed Sep 3, 2022
@AriPerkkio
Copy link
Owner

Perfect! Make sure to check the How and when to use section for local development instructions.

Now that I'm looking at these instructions, I think this package linking should be added here.

Follow these steps to test the new rule easily:
1. Include new rule in `rulesUnderTesting`
2. Configure `eslintrc` with the new rule and its options
3. Run `eslint-remote-tester` locally
4. Check generated results at `./eslint-remote-tester-results`

This is a good chance for a documentation PR if you are interested. 馃憤

@sjarva
Copy link
Contributor Author

sjarva commented Sep 3, 2022

Yes, I was just looking at them and came to the same conclusion. I'll make a PR about this tomorrow 馃摑

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants