diff --git a/package.json b/package.json index 7b851815..2c872325 100644 --- a/package.json +++ b/package.json @@ -154,6 +154,13 @@ "type": "string", "default": "", "order": 5 + }, + "cwdIndicatorFile": { + "title": "Current working directory indicator file", + "description": "Attempt to find this file and use it's location as eslint's current working directory (requires restart).", + "type": "string", + "default": "", + "order": 6 } } } diff --git a/src/worker-helpers.js b/src/worker-helpers.js index d1a392b8..0c76a339 100644 --- a/src/worker-helpers.js +++ b/src/worker-helpers.js @@ -139,6 +139,17 @@ export function getConfigPath(fileDir) { } export function getRelativePath(fileDir, filePath, config, projectPath) { + // If a current working directory indicator file is specified, try to find it to determine cwd + if (config.advanced.cwdIndicatorFile) { + const indicatorFile = findCached(fileDir, config.advanced.cwdIndicatorFile) + + if (indicatorFile) { + const indicatorDir = Path.dirname(indicatorFile) + process.chdir(indicatorDir) + return Path.relative(indicatorDir, filePath) + } + } + const ignoreFile = config.advanced.disableEslintIgnore ? null : findCached(fileDir, '.eslintignore') // If we can find an .eslintignore file, we can set cwd there