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

fix: use path.relative to determine if resource path is relative to cwd #336

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Linter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import process from 'process';
import { isAbsolute, join } from 'path';
import { isAbsolute, join, relative } from 'path';

import { writeFileSync, ensureFileSync } from 'fs-extra';
import { interpolateName } from 'loader-utils';
Expand All @@ -25,8 +25,9 @@ export default class Linter {
// 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));
const relativePath = relative(cwd, resourcePath);
if (relativePath.indexOf('..') === -1) {
resourcePath = relativePath;
}

return resourcePath;
Expand Down