Vue-cli: Link package with Lerna generate ESLint error

Created on 23 Oct 2019  路  3Comments  路  Source: vuejs/vue-cli

Version

4.0.5

Reproduction link

https://github.com/diegoleme/vue-cli-with-lerna

Environment info

Environment Info:

  System:
    OS: macOS 10.15
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 12.9.1 - ~/.nvm/versions/node/v12.9.1/bin/node
    Yarn: 1.17.3 - ~/.yarn/bin/yarn
    npm: 6.10.2 - ~/.nvm/versions/node/v12.9.1/bin/npm
  Browsers:
    Chrome: 77.0.3865.120
    Firefox: Not Found
    Safari: 13.0.2
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0
    @vue/babel-plugin-transform-vue-jsx:  1.0.0
    @vue/babel-preset-app:  4.0.5
    @vue/babel-preset-jsx:  1.1.1
    @vue/babel-sugar-functional-vue:  1.0.0
    @vue/babel-sugar-inject-h:  1.0.0
    @vue/babel-sugar-v-model:  1.1.1
    @vue/babel-sugar-v-on:  1.1.0
    @vue/cli-overlay:  4.0.5
    @vue/cli-plugin-babel: ^4.0.0 => 4.0.5
    @vue/cli-plugin-eslint: ^4.0.0 => 4.0.5
    @vue/cli-plugin-router:  4.0.5
    @vue/cli-plugin-vuex:  4.0.5
    @vue/cli-service: ^4.0.0 => 4.0.5
    @vue/cli-shared-utils:  4.0.5
    @vue/component-compiler-utils:  3.0.0
    @vue/preload-webpack-plugin:  1.1.1
    @vue/web-component-wrapper:  1.2.0
    eslint-plugin-vue: ^5.0.0 => 5.2.3
    vue: ^2.6.10 => 2.6.10
    vue-eslint-parser:  5.0.0
    vue-hot-reload-api:  2.3.4
    vue-loader:  15.7.1
    vue-style-loader:  4.1.2
    vue-template-compiler: ^2.6.10 => 2.6.10
    vue-template-es2015-compiler:  1.9.1
  npmGlobalPackages:
    @vue/cli: 4.0.5

Steps to reproduce

$ yarn
$ npx lerna bootstrap
$ cd packages/vue-project/
$ yarn serve

What is expected?

Link modules using lerna without any errors

What is actually happening?

When I link on the simple-project module in vue-project using Lerna, and import it, it generates this error:

Failed to compile.

../simple-project/lib/simple-project.js
Module build failed (from ./node_modules/eslint-loader/index.js):
Error: No ESLint configuration found.
    at Config.getLocalConfigHierarchy (/Users/diegoleme/Code/vue-cli-with-lerna/packages/vue-project/node_modules/eslint/lib/config.js:268:39)
    at Config.getConfigHierarchy (/Users/diegoleme/Code/vue-cli-with-lerna/packages/vue-project/node_modules/eslint/lib/config.js:192:43)
    at Config.getConfigVector (/Users/diegoleme/Code/vue-cli-with-lerna/packages/vue-project/node_modules/eslint/lib/config.js:299:21)
    at Config.getConfig (/Users/diegoleme/Code/vue-cli-with-lerna/packages/vue-project/node_modules/eslint/lib/config.js:342:29)
    at processText (/Users/diegoleme/Code/vue-cli-with-lerna/packages/vue-project/node_modules/eslint/lib/cli-engine.js:181:33)
    at CLIEngine.executeOnText (/Users/diegoleme/Code/vue-cli-with-lerna/packages/vue-project/node_modules/eslint/lib/cli-engine.js:690:40)
    at lint (/Users/diegoleme/Code/vue-cli-with-lerna/packages/vue-project/node_modules/eslint-loader/index.js:278:17)
    at transform (/Users/diegoleme/Code/vue-cli-with-lerna/packages/vue-project/node_modules/eslint-loader/index.js:252:18)
    at /Users/diegoleme/Code/vue-cli-with-lerna/packages/vue-project/node_modules/loader-fs-cache/index.js:127:18
    at ReadFileContext.callback (/Users/diegoleme/Code/vue-cli-with-lerna/packages/vue-project/node_modules/loader-fs-cache/index.js:31:14)
    at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:247:13)

The error happens when I import simple-project: https://github.com/diegoleme/vue-cli-with-lerna/blob/d3fb8dde4e48c556a9b00925e66ff1b49411d9d0/packages/vue-project/src/main.js#L7

Most helpful comment

The issue you linked to does not contain any reference to the "fix" you posted in the next comment so I'm not sure what you are referring to.

Your solution works in this scenario, but would break projects that import files from somewhere else that do have an eslint file / config, and I don't know if such use cases are out there as well.

The core issue of the problem is that the webpack config by default resolves symlinks to their real paths, which means eslint doesn't see the file as nested in node_modules but it sees the path to the original folder, which then doesn't have an elint config hence the error.

Since eslint isn't the only tool that can have problems with that, we recommend deactivating that webpack behaviour instead of working around it within the config of indiviual tools

https://cli.vuejs.org/guide/troubleshooting.html#symbolic-links-in-node-modules

All 3 comments

The solution found here I think could be done somehow as standard for vue-cli

https://github.com/vuejs/vue-cli/issues/2539

Add this file in my vue-project and works...

# .eslintignore file
../*
!/*

What do you think about setting this setting to vue-cli by default?

The issue you linked to does not contain any reference to the "fix" you posted in the next comment so I'm not sure what you are referring to.

Your solution works in this scenario, but would break projects that import files from somewhere else that do have an eslint file / config, and I don't know if such use cases are out there as well.

The core issue of the problem is that the webpack config by default resolves symlinks to their real paths, which means eslint doesn't see the file as nested in node_modules but it sees the path to the original folder, which then doesn't have an elint config hence the error.

Since eslint isn't the only tool that can have problems with that, we recommend deactivating that webpack behaviour instead of working around it within the config of indiviual tools

https://cli.vuejs.org/guide/troubleshooting.html#symbolic-links-in-node-modules

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandon93s picture brandon93s  路  3Comments

CodeApePro picture CodeApePro  路  3Comments

jgribonvald picture jgribonvald  路  3Comments

chasegiunta picture chasegiunta  路  3Comments

BusyHe picture BusyHe  路  3Comments