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] eslint not working with eslint-plugin-import in an monorepo #1057

Closed
1 task done
ChiefORZ opened this issue Mar 11, 2020 · 9 comments
Closed
1 task done

[Bug] eslint not working with eslint-plugin-import in an monorepo #1057

ChiefORZ opened this issue Mar 11, 2020 · 9 comments
Labels
bug Something isn't working reproducible This issue can be successfully reproduced

Comments

@ChiefORZ
Copy link

ChiefORZ commented Mar 11, 2020

  • I'd be willing to implement a fix

Describe the bug

When using eslint & eslint-plugin-import in an monorepo, where we have dependencies on each other workspace - eslint is accessing the symlinked (from the workspace) folder and checking the eslint errors from that file. which results in following error:

[Info  - 10:33:24 AM] ESLint library loaded from: /Users/sschaffernak/dev/_yarnv2/application-engine/.vscode/pnpify/eslint/lib/api.js
[Info  - 10:33:27 AM] Something that got detected as your top-level application (because it doesn't seem to belong to any package) tried to access a package that is not declared in your dependencies  Required package: resolve (via "resolve") Required by: /Users/sschaffernak/dev/_yarnv2/application-engine/.yarn/$$virtual/@company-application-engine-common-virtual-f54925b670/0/cache/eslint-import-resolver-node-npm-0.3.3-9648418358-2.zip/node_modules/eslint-import-resolver-node/  Require stack: - /Users/sschaffernak/dev/_yarnv2/application-engine/.yarn/$$virtual/@company-application-engine-common-virtual-f54925b670/0/cache/eslint-import-resolver-node-npm-0.3.3-9648418358-2.zip/node_modules/eslint-import-resolver-node/index.js - /Users/sschaffernak/dev/_yarnv2/application-engine/.yarn/cache/eslint-module-utils-npm-2.5.2-5962609579-2.zip/node_modules/eslint-module-utils/resolve.js - /Users/sschaffernak/dev/_yarnv2/application-engine/.yarn/$$virtual/eslint-plugin-import-virtual-43a57153b3/0/cache/eslint-plugin-import-npm-2.20.1-ad5426c673-2.zip/node_modules/eslint-plugin-import/lib/rules/no-unresolved.js - /Users/sschaffernak/dev/_yarnv2/application-engine/.yarn/$$virtual/eslint-plugin-import-virtual-43a57153b3/0/cache/eslint-plugin-import-npm-2.20.1-ad5426c673-2.zip/node_modules/eslint-plugin-import/lib/index.js - /Users/sschaffernak/dev/_yarnv2/application-engine/.yarn/cache/eslint-npm-6.8.0-d27045f313-2.zip/node_modules/eslint/lib/cli-engine/config-array-factory.js - /Users/sschaffernak/dev/_yarnv2/application-engine/.yarn/cache/eslint-npm-6.8.0-d27045f313-2.zip/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js - /Users/sschaffernak/dev/_yarnv2/application-engine/.yarn/cache/eslint-npm-6.8.0-d27045f313-2.zip/node_modules/eslint/lib/cli-engine/cli-engine.js - /Users/sschaffernak/dev/_yarnv2/application-engine/.yarn/cache/eslint-npm-6.8.0-d27045f313-2.zip/node_modules/eslint/lib/cli-engine/index.js - /Users/sschaffernak/dev/_yarnv2/application-engine/.yarn/cache/eslint-npm-6.8.0-d27045f313-2.zip/node_modules/eslint/lib/api.js - /Users/sschaffernak/dev/_yarnv2/application-engine/.pnp.js Occurred while linting /Users/sschaffernak/dev/_yarnv2/application-engine/frontend/protected/src/App.js:7

next i tried to re-produce this issue on an minimalistic setup - where everything worked fine. i even made the sherlock script to re-produce the error, but its not an issue on those setups. so i investigated and looked into differences in both.

const path = require(`path`);
const {promises: {mkdir, readFile, writeFile, writeJson}} = require(`fs`);

await packageJsonAndInstall({
  "name": "root",
  "private": true,
  "devDependencies": {
    "@yarnpkg/pnpify": "^2.0.0-rc.18",
    "eslint": "^6.8.0"
  },
  "workspaces": [
    "frontend/*"
  ]
});

/* create shared module*/

await mkdir('frontend/common/src', { recursive: true });

await writeFile("frontend/common/.eslintrc", `{
  "extends": ["airbnb-base"],
}`);

await writeFile("frontend/common/index.js", `
module.exports = 'Hello from @company/common!';
`);

await writeFile("frontend/common/package.json", `{
  "devDependencies": {
    "eslint": "latest",
    "eslint-config-airbnb-base": "latest",
    "eslint-import-resolver-node": "latest",
    "eslint-plugin-import": "latest"
  },
  "main": "index.js",
  "name": "@company/common",
  "scripts": {
    "lint": "eslint index.js"
  },
  "version": "0.0.1"
}`);

/* create an app module*/

await mkdir('frontend/app', { recursive: true });

await writeFile("frontend/app/index.js", `
import React from 'react';
import common from '@company/common';

console.log(common);
const App = () => <div>{common}</div>;

export default App;
`);

await writeFile("frontend/app/.eslintrc", `{
  "extends": ["airbnb"],
  "rules": {
    "react/jsx-filename-extension": 0
  }
}`);


await writeFile("frontend/app/package.json", `{
  "dependencies": {
    "@company/common": "workspace:*",
    "react": "latest",
    "react-dom": "latest"
  },
  "devDependencies": {
    "eslint": "latest",
    "eslint-config-airbnb": "latest",
    "eslint-import-resolver-node": "latest",
    "eslint-plugin-import": "latest",
    "eslint-plugin-jsx-a11y": "latest",
    "eslint-plugin-react": "latest",
    "eslint-plugin-react-hooks": "latest"
  },
  "main": "index.js",
  "name": "@company/app",
  "scripts": {
    "lint": "eslint index.js"
  },
  "version": "0.0.1"
}`);

const version = await yarn('--version');
console.log('version', version);

await yarn(`install`);

await expect(yarn(`workspaces`, `foreach`, `run`, `lint`, `--fix`)).rejects.not.toThrow(`Command failed`);

as i looked into the .pnp.js of both - i saw that the common package gets linked a bit differently:

// working package

["@company/common", [
  ["workspace:frontend/common", {
    "packageLocation": "./frontend/common/",
    "packageDependencies": [
      ["@company/common", "workspace:frontend/common"],
      ["eslint", "npm:6.8.0"],
      ["eslint-config-airbnb-base", "virtual:5b272d5e7c4ae0f775b65f25600bbe13c46a8f95a0cd3c9f30e63424a5d8b4df83bd6de9624dacfb82717730ebb610754fa2ebd2ccea9ef901a87851ba366fc3#npm:14.0.0"],
      ["eslint-import-resolver-node", "npm:0.3.3"],
      ["eslint-plugin-import", "virtual:5b272d5e7c4ae0f775b65f25600bbe13c46a8f95a0cd3c9f30e63424a5d8b4df83bd6de9624dacfb82717730ebb610754fa2ebd2ccea9ef901a87851ba366fc3#npm:2.20.1"]
    ],
    "linkType": "SOFT",
  }]
]],
// failing package

["@company/application-engine-common", [
   ["virtual:3363278033f03d7b5830777922dd557240be196eed2db347fc0b8d722a456d4b58d0791e438fe86e45567e6c54c29ff03abbff1a62eddda5965d9da0ea71cb90#workspace:frontend/common", {
      "packageLocation": "./.yarn/$$virtual/@company-application-engine-common-virtual-f54925b670/1/frontend/common/",
      "packageDependencies": [
        ["@company/application-engine-common", "virtual:3363278033f03d7b5830777922dd557240be196eed2db347fc0b8d722a456d4b58d0791e438fe86e45567e6c54c29ff03abbff1a62eddda5965d9da0ea71cb90#workspace:frontend/common"],
        ["@apollo/react-hooks", "virtual:3363278033f03d7b5830777922dd557240be196eed2db347fc0b8d722a456d4b58d0791e438fe86e45567e6c54c29ff03abbff1a62eddda5965d9da0ea71cb90#npm:3.1.3"],
        ["@babel/cli", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:7.8.4"],
        ["@babel/core", "npm:7.8.7"],
        ["@babel/plugin-proposal-class-properties", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:7.8.3"],
        ["@babel/plugin-proposal-optional-chaining", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:7.8.3"],
        ["@babel/plugin-transform-runtime", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:7.8.3"],
        ["@babel/preset-env", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:7.8.7"],
        ["@babel/preset-react", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:7.8.3"],
        ["@company/eslint-config-react", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:0.10.0"],
        ["@company/prettier-config", "npm:0.10.0"],
        ["@company/react-components", "virtual:3363278033f03d7b5830777922dd557240be196eed2db347fc0b8d722a456d4b58d0791e438fe86e45567e6c54c29ff03abbff1a62eddda5965d9da0ea71cb90#npm:2.10.4"],
        ["@company/react-hooks", "virtual:3363278033f03d7b5830777922dd557240be196eed2db347fc0b8d722a456d4b58d0791e438fe86e45567e6c54c29ff03abbff1a62eddda5965d9da0ea71cb90#npm:0.4.30"],
        ["@lingui/cli", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:2.9.1"],
        ["@lingui/react", "virtual:3363278033f03d7b5830777922dd557240be196eed2db347fc0b8d722a456d4b58d0791e438fe86e45567e6c54c29ff03abbff1a62eddda5965d9da0ea71cb90#npm:2.9.1"],
        ["apollo-cache-inmemory", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:1.6.5"],
        ["apollo-client", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:2.6.8"],
        ["apollo-link-http", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:1.5.16"],
        ["babel-core", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:7.0.0-bridge.0"],
        ["babel-eslint", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:10.1.0"],
        ["babel-loader", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:8.0.6"],
        ["babel-plugin-inline-react-svg", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:1.1.1"],
        ["babel-plugin-macros", "npm:2.8.0"],
        ["babel-plugin-styled-components", "virtual:f54925b670d342b2a26b9cfbdd22173564c51308da4cfa53be313e974776ae215815d0d7a72c1836358eebc172071d6ea3b43fe38681d577af9699ae5685ea9b#npm:1.10.7"],
        ["babel-plugin-transform-react-remove-prop-types", "npm:0.4.24"],
        ["concurrently", "npm:5.1.0"],
        ["cross-env", "npm:7.0.2"],
        ["eslint", "npm:6.8.0"],
        ["eslint-config-airbnb", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:18.0.1"],
        ["eslint-config-prettier", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:6.10.0"],
        ["eslint-plugin-import", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:2.20.1"],
        ["eslint-plugin-jsx-a11y", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:6.2.3"],
        ["eslint-plugin-prettier", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:3.1.2"],
        ["eslint-plugin-react", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:7.19.0"],
        ["eslint-plugin-react-hooks", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:2.5.0"],
        ["graphql", "npm:14.6.0"],
        ["graphql-tag", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:2.10.3"],
        ["lint-staged", "npm:10.0.8"],
        ["polished", "npm:3.4.4"],
        ["prettier", "npm:1.19.1"],
        ["prop-types", "npm:15.7.2"],
        ["react", "npm:16.13.0"],
        ["react-dom", "virtual:3363278033f03d7b5830777922dd557240be196eed2db347fc0b8d722a456d4b58d0791e438fe86e45567e6c54c29ff03abbff1a62eddda5965d9da0ea71cb90#npm:16.13.0"],
        ["react-test-renderer", "virtual:3363278033f03d7b5830777922dd557240be196eed2db347fc0b8d722a456d4b58d0791e438fe86e45567e6c54c29ff03abbff1a62eddda5965d9da0ea71cb90#npm:16.13.0"],
        ["rimraf", "npm:3.0.2"],
        ["styled-components", "virtual:3363278033f03d7b5830777922dd557240be196eed2db347fc0b8d722a456d4b58d0791e438fe86e45567e6c54c29ff03abbff1a62eddda5965d9da0ea71cb90#npm:4.4.1"],
        ["stylelint", "npm:13.2.1"],
        ["typescript", "patch:typescript@npm%3A3.8.3#builtin<compat/typescript>::version=3.8.3&hash=273569"],
        ["why-did-you-update", "virtual:f54925b670d342b2a26b9cfbdd22173564c51308da4cfa53be313e974776ae215815d0d7a72c1836358eebc172071d6ea3b43fe38681d577af9699ae5685ea9b#npm:1.0.8"]
      ],
      "packagePeers": [
        "apollo-cache-inmemory",
        "apollo-client",
        "apollo-link-http",
        "graphql",
        "graphql-tag",
        "prop-types",
        "@lingui/react",
        "react",
        "@company/react-components",
        "react-dom",
        "@apollo/react-hooks",
        "@company/react-hooks",
        "styled-components"
      ],
      "linkType": "SOFT",
    }],
    ["workspace:frontend/common", {
      "packageLocation": "./frontend/common/",
      "packageDependencies": [
        ["@company/application-engine-common", "workspace:frontend/common"],
        ["@apollo/react-hooks", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:3.1.3"],
        ["@babel/cli", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:7.8.4"],
        ["@babel/core", "npm:7.8.7"],
        ["@babel/plugin-proposal-class-properties", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:7.8.3"],
        ["@babel/plugin-proposal-optional-chaining", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:7.8.3"],
        ["@babel/plugin-transform-runtime", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:7.8.3"],
        ["@babel/preset-env", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:7.8.7"],
        ["@babel/preset-react", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:7.8.3"],
        ["@company/eslint-config-react", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:0.10.0"],
        ["@company/prettier-config", "npm:0.10.0"],
        ["@company/react-components", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:2.10.4"],
        ["@company/react-hooks", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:0.4.30"],
        ["@lingui/cli", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:2.9.1"],
        ["@lingui/react", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:2.9.1"],
        ["apollo-cache-inmemory", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:1.6.5"],
        ["apollo-client", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:2.6.8"],
        ["apollo-link-http", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:1.5.16"],
        ["babel-core", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:7.0.0-bridge.0"],
        ["babel-eslint", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:10.1.0"],
        ["babel-loader", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:8.0.6"],
        ["babel-plugin-inline-react-svg", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:1.1.1"],
        ["babel-plugin-macros", "npm:2.8.0"],
        ["babel-plugin-styled-components", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:1.10.7"],
        ["babel-plugin-transform-react-remove-prop-types", "npm:0.4.24"],
        ["concurrently", "npm:5.1.0"],
        ["cross-env", "npm:7.0.2"],
        ["eslint", "npm:6.8.0"],
        ["eslint-config-airbnb", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:18.0.1"],
        ["eslint-config-prettier", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:6.10.0"],
        ["eslint-plugin-import", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:2.20.1"],
        ["eslint-plugin-jsx-a11y", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:6.2.3"],
        ["eslint-plugin-prettier", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:3.1.2"],
        ["eslint-plugin-react", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:7.19.0"],
        ["eslint-plugin-react-hooks", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:2.5.0"],
        ["graphql", "npm:14.6.0"],
        ["graphql-tag", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:2.10.3"],
        ["lint-staged", "npm:10.0.8"],
        ["polished", "npm:3.4.4"],
        ["prettier", "npm:1.19.1"],
        ["prop-types", "npm:15.7.2"],
        ["react", "npm:16.13.0"],
        ["react-dom", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:16.13.0"],
        ["react-test-renderer", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:16.13.0"],
        ["rimraf", "npm:3.0.2"],
        ["styled-components", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:5.0.1"],
        ["stylelint", "npm:13.2.1"],
        ["typescript", "patch:typescript@npm%3A3.8.3#builtin<compat/typescript>::version=3.8.3&hash=273569"],
        ["why-did-you-update", "virtual:9667ad72a35e2ac32dfd324586b946df87333c5d774f6122c4b77c99ccd40f7be13e4d1dc27db7649345a8f4337a87d23742f9b4c5d58b1e0e97f2583b009e5a#npm:1.0.8"]
      ],
      "packagePeers": [
        "apollo-cache-inmemory",
        "apollo-client",
        "apollo-link-http",
        "graphql",
        "graphql-tag",
        "polished",
        "prop-types",
        "@lingui/react",
        "react",
        "@company/react-components",
        "react-dom",
        "@apollo/react-hooks",
        "@company/react-hooks",
        "styled-components"
      ],
      "linkType": "SOFT",
    }]
  ]],

and in the original error its even mentioning the virtual package /Users/sschaffernak/dev/_yarnv2/application-engine/.yarn/$$virtual/@company-application-engine-common-virtual-f54925b670 so i think it has something to do with it.

can somebody explain why there are two versions created by yarn in my pnp file?

Environment if relevant (please complete the following information):

Environment Info:

  System:
    OS: macOS 10.15.3
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  Binaries:
    Node: 10.16.3 - /usr/local/bin/node
    Yarn: 2.0.0-rc.29 - /usr/local/bin/yarn
    npm: 6.9.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 80.0.3987.132
    Firefox: 72.0.2
    Safari: 13.0.5
@ChiefORZ ChiefORZ added the bug Something isn't working label Mar 11, 2020
@yarnbot

This comment has been minimized.

@yarnbot yarnbot added the reproducible This issue can be successfully reproduced label Mar 11, 2020
@yarnbot

This comment has been minimized.

@bertho-zero
Copy link

bertho-zero commented Mar 21, 2020

I have the same problem with babel plugins that cannot be found, it is because some packages from workspace have several virtuals in .pnp.js rather than pointing to workspace:./path/to/package.

I manage to temporarily fix the problem by manually modifying .pnp.js

Note: If I remove the peerDependencies field from my package then it works, no virtual superfluous.

@bertho-zero
Copy link

@arcanis I have not found a way to force the resolution of my packages to use the workspace directly, without going through virtuals, do you have a solution or a plan for that?

@bertho-zero
Copy link

pnpMode: "loose"
pnpFallbackMode: "all"

This help me, waiting for eslint/rfcs#47 and eslint/eslint#12922

@merceyz merceyz removed the reproducible This issue can be successfully reproduced label Feb 5, 2021
@merceyz
Copy link
Member

merceyz commented Feb 5, 2021

I have not found a way to force the resolution of my packages to use the workspace directly, without going through virtuals, do you have a solution or a plan for that?

We can't do that as it would prevent access to peer dependencies, virtual: means it has peer dependencies and points to which ones it can access

@yarnbot yarnbot added the reproducible This issue can be successfully reproduced label Feb 5, 2021
@yarnbot

This comment has been minimized.

@yarnbot
Copy link
Collaborator

yarnbot commented Feb 5, 2021

This issue reproduces on master:

Error: expect(received).rejects.not.toThrow()

Received promise resolved instead of rejected
Resolved to value: "➤ YN0000: 
➤ YN0000: /tmp/tmp-229pl5QHA5kxKE/frontend/app/index.js
➤ YN0000:   4:1  warning  Unexpected console statement  no-console
➤ YN0000: 
➤ YN0000: ✖ 1 problem (0 errors, 1 warning)
➤ YN0000: 
➤ YN0000: Done in 4s 692ms
"
    at expect (/github/workspace/.yarn/cache/expect-npm-24.8.0-8c7640c562-0ac41999f0.zip/node_modules/expect/build/index.js:138:15)
    at module.exports (evalmachine.<anonymous>:95:7)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async /github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.38-d4f5e2dbf3-63f998598d.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:56:13
    at async executeInTempDirectory (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.38-d4f5e2dbf3-63f998598d.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:17:16)
    at async Object.executeRepro (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.38-d4f5e2dbf3-63f998598d.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:24:12)
    at async ExecCommand.execute (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.38-d4f5e2dbf3-63f998598d.zip/node_modules/@arcanis/sherlock/lib/commands/exec.js:25:38)
    at async ExecCommand.validateAndExecute (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-a57989414f.zip/node_modules/clipanion/lib/advanced/Command.js:161:26)
    at async Cli.run (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-a57989414f.zip/node_modules/clipanion/lib/advanced/Cli.js:74:24)
    at async Cli.runExit (/github/workspace/.yarn/cache/clipanion-npm-2.0.0-rc.16-b9444aaf89-a57989414f.zip/node_modules/clipanion/lib/advanced/Cli.js:83:28)

@merceyz
Copy link
Member

merceyz commented Feb 5, 2021

This seems to have been fixed in #695

@merceyz merceyz closed this as completed Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working reproducible This issue can be successfully reproduced
Projects
None yet
Development

No branches or pull requests

4 participants