Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to explicitly tell xo to use a config file #448

Open
itaisteinherz opened this issue Mar 30, 2020 · 5 comments · May be fixed by #664
Open

Add option to explicitly tell xo to use a config file #448

itaisteinherz opened this issue Mar 30, 2020 · 5 comments · May be fixed by #664

Comments

@itaisteinherz
Copy link

In my current project, my xo config file isn't in any of the parent directories of the linted files, but instead in a separate directory. However, I still want to be able to use my custom config, without having to move it to one of the parent directories or publish it to npm.

In my opinion, a decent solution to the issue would be to add a --config option to xo, which (when specified) would tell xo to use the configuration at the given path (e.g. xo --config ../.xo-config.json).

I'd appreciate your feedback, and if you agree this should be a part of xo, let me know and I'll be happy to implement this.

@itaisteinherz
Copy link
Author

(Note that this could resolve #250 as well.)

@pvdlg
Copy link
Contributor

pvdlg commented Apr 1, 2020

Would having a minimal config at the root of your repo that extends you global works?
For example in your the package.json:

{
  "xo": {
    "extends": ["../path/to/global/config"]
  }
}

@itaisteinherz
Copy link
Author

@pvdlg Apologies for the delay in my response, I forgot to reply to you.

That would work, however I'd say that it would be best to allow people to configure this either in package.json or via a flag.

@mrsauravsahu
Copy link

I had made the changes for this. Just need to do the final testing, but I'm short on time.

https://github.com/mrsauravsahu/xo/tree/feat/config-path-option

@chrisspiegl
Copy link

I was able to kind of have a work around for my current project by using a cjs config file:

const config = require('../../.xo-config.cjs')
module.exports = {
  ...config
}

Somehow the "parent folder import" for monorepo setups also did not work for me. Not sure if it's related to me using .cjs config files instead of putting it into the package.json but at least this way I only have to really manage one .xo-config.cjs file and all the others can extend it if necessary and fall back to my defaults for the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants