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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: nested plugins cannot be found when nested in a shared config (6.0.0) #11884

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extends:
- awesome

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 19 additions & 1 deletion tests/lib/cli-engine/cascading-config-array-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ describe("CascadingConfigArrayFactory", () => {

// copy into clean area so as not to get "infected" by this project's .eslintrc files
before(() => {
fixtureDir = `${os.tmpdir()}/eslint/fixtures`;
fixtureDir = `${fs.realpathSync(os.tmpdir())}/eslint/fixtures`;
sh.mkdir("-p", fixtureDir);
sh.cp("-r", "./tests/fixtures/config-hierarchy", fixtureDir);
sh.cp("-r", "./tests/fixtures/rules", fixtureDir);
Expand Down Expand Up @@ -575,6 +575,24 @@ describe("CascadingConfigArrayFactory", () => {
});


it("should resolve plugins/parsers nested within a shared package", () => {
const factory = new CascadingConfigArrayFactory({
cwd: getFixturePath("nested-plugins-parser")
});
const file = getFixturePath("nested-plugins-parser", "foo.js");
const expected = {
parser: getFixturePath("nested-plugins-parser", "node_modules", "eslint-config-awesome", "node_modules", "awesome-parser", "index.js"),
plugins: ["awesome"],
rules: {
"awesome/is-awesome": [2]
}
};
const actual = getConfig(factory, file);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This throws with:

     Error: Failed to load plugin 'awesome' declared in '.eslintrc.yml » eslint-config-awesome': Cannot find module 'eslint-plugin-awesome'
Require stack:
- /private/var/folders/j6/0rhhpj0x0db7yqhhby7x27_r0000gn/T/eslint/fixtures/config-hierarchy/nested-plugins-parser/__placeholder__.js
      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
      at Function.resolve (internal/modules/cjs/helpers.js:32:19)
      at Object.resolve (lib/shared/relative-module-resolver.js:44:50)
      at ConfigArrayFactory._loadPlugin (lib/cli-engine/config-array-factory.js:840:39)
      at names.reduce (lib/cli-engine/config-array-factory.js:729:33)
      at Array.reduce (<anonymous>)
      at ConfigArrayFactory._loadPlugins (lib/cli-engine/config-array-factory.js:725:22)
      at ConfigArrayFactory._normalizeObjectConfigDataBody (lib/cli-engine/config-array-factory.js:551:32)
      at _normalizeObjectConfigDataBody.next (<anonymous>)
      at ConfigArrayFactory._normalizeObjectConfigData (lib/cli-engine/config-array-factory.js:490:20)
      at _normalizeObjectConfigData.next (<anonymous>)
      at ConfigArrayFactory._normalizeObjectConfigDataBody (lib/cli-engine/config-array-factory.js:544:25)
      at _normalizeObjectConfigDataBody.next (<anonymous>)
      at ConfigArrayFactory._normalizeObjectConfigData (lib/cli-engine/config-array-factory.js:490:20)
      at _normalizeObjectConfigData.next (<anonymous>)
      at createConfigArray (lib/cli-engine/config-array-factory.js:306:25)
      at ConfigArrayFactory.loadInDirectory (lib/cli-engine/config-array-factory.js:399:16)
      at CascadingConfigArrayFactory._loadConfigInAncestors (lib/cli-engine/cascading-config-array-factory.js:293:46)
      at CascadingConfigArrayFactory.getConfigArrayForFile (lib/cli-engine/cascading-config-array-factory.js:238:18)
      at getConfig (tests/lib/cli-engine/cascading-config-array-factory.js:144:22)
      at Context.it (tests/lib/cli-engine/cascading-config-array-factory.js:590:32)

Copy link
Contributor Author

@nevir nevir Jun 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug output leading up to the failure:

  eslint:config-array-factory Loading YAML config file: /private/var/folders/j6/0rhhpj0x0db7yqhhby7x27_r0000gn/T/eslint/fixtures/config-hierarchy/nested-plugins-parser/.eslintrc.yml +0ms
  eslint:config-array-factory Config file found: /private/var/folders/j6/0rhhpj0x0db7yqhhby7x27_r0000gn/T/eslint/fixtures/config-hierarchy/nested-plugins-parser/.eslintrc.yml +5ms
  eslint:config-array-factory Loading {extends:"awesome"} relative to /private/var/folders/j6/0rhhpj0x0db7yqhhby7x27_r0000gn/T/eslint/fixtures/config-hierarchy/nested-plugins-parser/.eslintrc.yml +15ms
  eslint:config-array-factory Loaded: eslint-config-awesome@1.0.0 (/private/var/folders/j6/0rhhpj0x0db7yqhhby7x27_r0000gn/T/eslint/fixtures/config-hierarchy/nested-plugins-parser/node_modules/eslint-config-awesome/index.js) +1ms
  eslint:config-array-factory Loading JS config file: /private/var/folders/j6/0rhhpj0x0db7yqhhby7x27_r0000gn/T/eslint/fixtures/config-hierarchy/nested-plugins-parser/node_modules/eslint-config-awesome/index.js +0ms
  eslint:config-array-factory Loading parser "awesome-parser" from /private/var/folders/j6/0rhhpj0x0db7yqhhby7x27_r0000gn/T/eslint/fixtures/config-hierarchy/nested-plugins-parser/node_modules/eslint-config-awesome/index.js +1ms
  eslint:config-array-factory Loaded: awesome-parser@1.0.0 (/private/var/folders/j6/0rhhpj0x0db7yqhhby7x27_r0000gn/T/eslint/fixtures/config-hierarchy/nested-plugins-parser/node_modules/eslint-config-awesome/node_modules/awesome-parser/index.js) +2ms
  eslint:config-array-factory Loading plugin "awesome" from /private/var/folders/j6/0rhhpj0x0db7yqhhby7x27_r0000gn/T/eslint/fixtures/config-hierarchy/nested-plugins-parser/node_modules/eslint-config-awesome/index.js +1ms
  eslint:config-array-factory Failed to load plugin 'awesome' declared in '.eslintrc.yml » eslint-config-awesome'. +1ms

Copy link
Contributor Author

@nevir nevir Jun 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the ConfigArrayFactory is trying to resolve plugin 'awesome' relative to the root package, not eslint-config-awesome (but the require stack thinks otherwise)

relativeTo points to:
eslint/fixtures/config-hierarchy/nested-plugins-parser/__placeholder__.js


assertConfigsEqual(actual, expected);
});


it("should merge multiple different config file formats", () => {
const factory = new CascadingConfigArrayFactory();
const file = getFixturePath("fileexts/subdir/subsubdir/foo.js");
Expand Down