oxsecurity / megalinter

🦙 MegaLinter analyzes 50 languages, 22 formats, 21 tooling formats, excessive copy-pastes, spelling mistakes and security issues in your repository sources with a GitHub Action, other CI tools or locally.
https://megalinter.io
GNU Affero General Public License v3.0
1.82k stars 214 forks source link

Configuring additional eslint plugins #3081

Open YElyousfi opened 8 months ago

YElyousfi commented 8 months ago

Hello,

New to using megalinter (great tool) and wanted to know if additional plugins for eslint could be installed during runtime. I couldn't find and documentation, examples, or issues on this. I was thinking this could be accomplished via the precommands but figured I'd also ask here as well.

echoix commented 8 months ago

Does this help? There is an example specifically for an eslint plugin

https://megalinter.io/latest/config-precommands/

YElyousfi commented 8 months ago

Is it possible to run the project's npm ci command using the dependencies from the package.json file instead of specifying each plugin?

The error below is what ultimately led to me posting this issue. I have cwd set to root and it fails when running my project's npm prepare after install.

Screenshot 2023-11-05 at 4 28 59 PM
echoix commented 8 months ago

In these kind of problems, I like to temporarily add something like pwd and ls -la to see where I am. Remember that Megalinter runs in a Docker container, and thus the folder with the repo is mounted. So things done outside the Docker container and things done inside the container aren't exactly the same.

Yes, of course outside the repo the path on a GitHub runner would be /github/workspace, but I expect something else inside the container.

So I see how it fails to install your other dependencies, as is-ci and husky aren't recognized.

YElyousfi commented 8 months ago

I see, thanks for clarifying, it's very much appreciated!

I tried debugging with ls -l with cwd: root and everything seems to be fine in the screenshot below with all the files. I see the mounted files as 127 including the repo's package.json file. However, node_modules is root and its contents are not what the repo's package.json defines.

What is the recommended approach to properly run an npm clean-install as PRE_COMMAND for the relevant linters? Do we need to copy or give root access to the package.json of the repository?

Screenshot 2023-11-05 at 10 37 19 PM
github-actions[bot] commented 7 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.