Xo: Support an external config file instead of just package.json config

Created on 5 Jun 2018  Â·  10Comments  Â·  Source: xojs/xo


Issuehunt badges

This is somewhat of a similar ask to #250, but with a little different use context:

I'd like to put my XO configuration in a separate file (.xorc.*), just like how ESLint and Prettier do it.

Having all of those config options in a single file really clutters up my package.json, and I'd like to be able to more easily copy/symlink files from a central location, instead of having to copy/paste configurations into my package.json every time.




IssueHunt Summary

pvdlg pvdlg has been rewarded.

Backers (Total: $80.00)

Submitted pull Requests

- #425 Find XO config based on linted file path

Tips

IssueHunt has been backed by the following sponsors. Become a sponsor


Rewarded on Issuehunt enhancement help wanted

Most helpful comment

A reason to adopt cosmiconfig would be https://github.com/xojs/xo/pull/279#issuecomment-356021126

All 10 comments

Using a package like cosmiconfig, to replace pkg-conf altogether, seems like the best option. It will import configurations from a variety of locations, including package.json, .xorc, .xorc.json, .xorc.yaml, .xorc.js, etc.

Additionally, _I think_ it removes the need for defining { "xo" : false } in nested package.jsons — instead of traversing upwards until it finds the first package.json, and skipping it if skipOnFalse is true (like with pkg-conf), it will just keep searching upwards until it finds a defined config. So if you just want to use a single top-level xo config, just define it in the uppermost package.json (or .xorc) and nowhere else.

and I'd like to be able to more easily copy/symlink files from a central location, instead of having to copy/paste configurations into my package.json every time.

Why are you copy-pasting the config each time? That sounds like a maintenance nightmare. Instead, just create a shareable ESLint config file and all you need in your package.json is:

{
    "xo": {
        "extends": "name-of-your-shareable-config"
    }
}

That's beside the point though — XO is so customizable, that it's really frustrating that I _have to_ put my config in the package.json, especially when so many other tools make that optional. While it may work great for a lot of people, I'm personally not a fan of defining my configurations in my package.json — I want nothing in there besides metadata and dependencies.

I issued a pull request yesterday (hopefully) with the fix.

A reason to adopt cosmiconfig would be https://github.com/xojs/xo/pull/279#issuecomment-356021126

This is now accepted. See https://github.com/xojs/xo/pull/279#issuecomment-407250935.

@issuehuntfest has funded $80.00 to this issue. See it on IssueHunt

A global configuration, which is referenced in package.json would be a nice option. I want to start working on a solution.

@bunysae I'm not interested in supporting global config like that (https://github.com/xojs/xo/issues/250 what I will accept). That comes with a lot of surprising downsides. This issue is about supporting external (local) config file.

Okay i will support local and global shareable files as mentioned in your comment.

@sindresorhus has rewarded $72.00 to @pvdlg. See it on IssueHunt

  • :moneybag: Total deposit: $80.00
  • :tada: Repository reward(0%): $0.00
  • :wrench: Service fee(10%): $8.00
Was this page helpful?
0 / 5 - 0 ratings

Related issues

lagden picture lagden  Â·  3Comments

SamVerschueren picture SamVerschueren  Â·  4Comments

SteveALee picture SteveALee  Â·  5Comments

sindresorhus picture sindresorhus  Â·  5Comments

niftylettuce picture niftylettuce  Â·  6Comments