Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

relative path is wrong when use eslint-loader in monorepo #335

Closed
@githoniel

Description

parseResourcePath() {
const cwd = process.cwd();
let { resourcePath } = this.loaderContext;
// remove cwd from resource path in case webpack has been started from project
// root, to allow having relative paths in .eslintignore
// istanbul ignore next
if (resourcePath.indexOf(cwd) === 0) {
resourcePath = resourcePath.substr(cwd.length + (cwd === '/' ? 0 : 1));
}
return resourcePath;
}

My project is using Lerna and fold structure is like below

- packages
  - @gem-mine
     - glaucus
     - glaucus-plugin-align
     - glaucus-plugin-hr

I will run webpack in @gem-mine/glaucus, so the process.cwd would be ${workspaceFolder}/packages/@gem-mine/glaucus.When I'm using file from 'glaucus-plugin-align' folder, eg glaucus-plugin-align/src/index.js, the resourcePath would be ${workspaceFolder}/packages/@gem-mine/glaucus-plugin-align/src/index/js.

The above code would think they are relative and then set resoucePath to plugin-align/src/index/js.

I'm using @typescript-eslint that it will restore fullPath to ${workspaceFolder}/packages/@gem-mine/glaucus/plugin-align/src/index/js and consider the file is missing....

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions