Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

feat: add setting to select current working directory indicator file #1368

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/worker-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down