xojs / SublimeLinter-contrib-xo

SublimeLinter plugin for XO
https://github.com/xojs/xo
MIT License
55 stars 7 forks source link

Wrong defaults in Lerna repo #14

Open alistair-hmh opened 5 years ago

alistair-hmh commented 5 years ago

I am using a Lerna repo which puts a package.json in the root of the repo, as well as all the subprojects for the repo in packages/.

Example:

. tree lerna-mono-repo/
├── package.json
├── node_modules/
│   └── xo/...
└── packages/
    ├── sub-repo-a
    │   └── package.json
    └── sub-repo-b.svg
        └── package.json

Each of my sub-packages in the Lerna repo has different XO rules.

When I edit the code in Sublime for a sub-package, it shows me default XO rules, when I would expect to see the rules working from the package I'm editing.

Is there a way to make the closest package.json to the file being edited - as the package.json the rules are picked from?

alistair-hmh commented 5 years ago

Apologies, I just saw this: https://github.com/xojs/xo#monorepo - trying this now...

alistair-hmh commented 5 years ago

The suggestion in the XO documentation only seems to work if the root package.json contains the XO config. In the mono-repo I'm working with, I have to have different settings for each package, for example, one package is a React app, another is a standard Node module.

Is XO just the wrong tool for the job here?

sindresorhus commented 5 years ago

Is there a way to make the closest package.json to the file being edited - as the package.json the rules are picked from?

That's how it should work. Otherwise it's a bug. It uses the closest package.json as long as it doesn't contains {"xo": false}.

sindresorhus commented 5 years ago

This might be related to https://github.com/xojs/xo/pull/279.

alistair-hmh commented 5 years ago

Thanks. Yes, that looks like the exact same thing I'm experiencing.

For now, I'm forced to drop Sublime for VSCode for this mono-repo project. Not a huge deal, but I'll look forward to switching back.

(In case it's useful to know, I am using the {xo: false} in the root package, and not in the sub-packages. Also, I open the Sublime project from the Lerna mono-repo root. I can open Sublime from each subpackage and the linting works fine, but then my desktop gets littered with windows.)