Open jbadavis opened 11 months ago
I'm seeing the same behavior / having the same problem. Running xo
in a sub-package does not seem to "search upwards" and find the parent package.json config.
- package.json # Includes XO config
- packages/
- packageName/
- package.json # Does not include XO config
I believe there are some magic filenames that might work - I'll try those out and report back. I'll watch this issue with interest though, as I'd rather not have yet another root config file.
I've found the discrepancy!
From lines 103 and 104 of lib/options-manager.js
:
options.cwd = path.resolve(options.cwd || process.cwd());
const configExplorer = cosmiconfig(MODULE_NAME, {searchPlaces: CONFIG_FILES, loaders: {noExt: defaultLoaders['.json']}, stopDir: options.cwd});
Note that stopDir
is set to options.cwd
, which defaults to process.cwd()
.
From the comsiconfig readme:
- If none of those searches reveal a configuration object, move up one directory level and try again. So the search continues in ./, ../, ../../, ../../../, etc., checking the same places in each directory.
- Continue searching until arriving at your home directory (or some other directory defined by the cosmiconfig option stopDir).
In short, xo does not search upwards - the search is stopped in the current working directory.
--cwd
flag to start xo from your monorepo root (overriding options.cwd){
"scripts": {
"lint": "xo --cwd=../.. $(pwd)"
}
}
There's probably a better way to identify the monorepo root than just hard-coding ../..
, but that's all I've got for now.
Hello,
I have a very simple XO configuration I'd like to share between all the packages and apps in my Turborepo monorepo:
The project README states that I should just need one version of this in the root package.json file:
However, I'm seeing linting errors in each of my packages if I don't have this XO config in every package.json. Have I configured something incorrectly?