AriPerkkio / eslint-remote-tester

CLI tool for testing given ESlint rules against multiple repositories at once.

Home Page:https://www.npmjs.com/package/eslint-remote-tester

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting a `failed to load plugin` error when running tester locally

sjarva opened this issue · comments

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?

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

That did the trick! Thanks for the quick reply @AriPerkkio 🤗

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. 👍

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