vercel / style-guide

Vercel's engineering style guide
Mozilla Public License 2.0
1.25k stars 33 forks source link

Installing plugins not needed? #86

Closed magnusriga closed 7 months ago

magnusriga commented 8 months ago

According to ESLint's docs, plugins are resolved relative to the end-user's application. So, if you create an eslint config in a separate package in a monorepo (like for instance turborepo suggests), and use @vercel/style-guide there, then all the plugins should, according to the ESLint docs, be installed in the end-user package.

@vercel/style-guide/eslint/react.js (as an example), has plugin:react/recommended in its extends field. For some reason, I was not required to install this plugin in the end-user app.

How come @vercel/style-guide/react.js does not need the plugin installed in the end-user app, unlike plugin:@next/next/recommended which does have that requirement? Both plugins are used in @vercel/style-guide so they should be needed.

My ESLint extends chain is as follows:

apps/foo/.eslintrc.js --> package/eslint-config/next.js --> @vercel/style-guide/eslint/react (resolves via local node_modules) --> plugin:@next/next/recommended

mrmckeb commented 7 months ago

Hi @magnusriga, this is because we list them as dependencies here: https://github.com/vercel/style-guide/blob/d6ccd35125379a173de32b31d6b4cf66cbdeac0f/package.json#L39-L59

We use a community created solution to allow us to ship plugins as a dependency, which isn't normally supported in ESLint: https://github.com/vercel/style-guide/blob/d6ccd35125379a173de32b31d6b4cf66cbdeac0f/eslint/_base.js#L4

We do this as we feel it creates the best user experience, and let's us better manage versions, etc.

Let me know if you have any other questions!

magnusriga commented 7 months ago

Ahhhh, I missed the @rushstack/eslint-patch/modern-module-resolution. Thank you so much.

I recommend putting a note in the docs about the fact that you use that patch. I spent several days scratching my head and debugging, before eventually giving up :)

Quick question: If I use @rushstack/eslint-patch/modern-module-resolution in my own eslint-config folder, I might not have to hoist the eslint plugins up to the node_mudules at the root of the monorepo? What about prettier plugins, do they have the same issue?

Thanks again!