Closed onlywei closed 1 month ago
Latest commit: b6a1cb48d1ba718f246a6f4f0f6d2d4c4b4f8913
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
@ota-meshi Whenever you get a chance, could you please take a look at this PR? Thank you!
Hmm. I'm not sure if this PR change will work in anyone's environment. Can you please explain that it's not just your environment that works?
Hmm. I'm not sure if this PR change will work in anyone's environment. Can you please explain that it's not just your environment that works?
@ota-meshi My thinking is this: two scenarios:
Scenario One: with --resolve-plugins-relative-to
In this scenario, the folder structure is as follows:
some/other/path/
node_modules/
eslint-plugin-prettier/
eslint-plugin-jsonc/
dist/
utils/
get-auto-jsonc-rules-config/
index.ts
.eslintrc.cjs
Eslint is executed on the CLI using:
eslint --resolve-plugins-relative-to=some/other/path/ .
We want to resolve the eslint-plugin-prettier
that is a sibling of eslint-plugin-jsonc
. From dist/utils/get-auto-jsonc-rules-config/
, we need to navigate up five directories in order to be at another-path/
. Once we are there, require('eslint-plugin-prettier')
should work and find the correct path.
Scenario One: WITHOUT --resolve-plugins-relative-to
In this scenario, which is how most people use eslint, the folder structure is as follows:
node_modules/
eslint-plugin-prettier/
eslint-plugin-jsonc/
dist/
utils/
get-auto-jsonc-rules-config/
index.ts
.eslintrc.cjs
Eslint is executed on the CLI using:
eslint .
From dist/utils/get-auto-jsonc-rules-config/
, if we navigate up five directories, we will be at the root of this folder structure. The behavior here should be the exact same as if I had not submitted this PR at all.
Therefore, I believe this PR should work in both scenarios.
Thank you for the explanation! I think that explanation makes sense!
Why do I want this? I have a monorepo with the current file structure:
I want to install eslint and all of its configs and plugins into the repotools/central-linter/node_modules. I do not want to install a separate copy of eslint and its plugins in each app/package. Also note that there is no package.json file at the root of the repo because I have lots of issues with npm workspaces.
I also want to keep the .eslintrc.json and .eslintignore files at the root of the monorepo for better IDE integration.
I am able to accomplish all of this except for this
eslint-plugin-jsonc
since this plugin keeps trying to load plugins relative to the root of the monorepo, rather than theresolvePluginsRelativeTo
that I passed to my central linter.This PR should modify the behavior of
eslint-plugin-jsonc
to always resolve plugins relative to itself.P.S. I cannot upgrade to ESLint v9 yet because
nx
andeslint-plugin-react
does not support ESLint v9 yet.