xojs/xo

Document how to use plugin configuration via ESLint

Closed this issue · 8 comments

eslint-config-xo can be used from eslint:

{
	"extends": "xo"
}

But it does not include the plugin config:

https://github.com/xojs/xo/blob/a30cf0b710063953a015066bdfd9514eab41900c/config/plugins.cjs

Is it possible to move it to eslint-config-xo and use it as such?

{
	"extends": [
		"xo",
		"xo/import",
		"xo/node",
		etc

		// or
		
		"xo/with-plugins",
	]
}

Same answer as #618 (comment)

Is it? I'm setting most plugin configuration via my custom config here, both via extend: [plugin:"import/recommended"] and by setting each rule:

https://github.com/fregante/eslint-config-pixiebrix/blob/60f5a8837066009757fc293faa65636ad57fde14/index.js#L27-L31

And then I'm just extending the single shared config as usual:

https://github.com/pixiebrix/pixiebrix-extension/blob/2914608a3c37ebd93fecc03781449b9f79acefd9/.eslintrc#L3-L6

I'm not even installing each plugin separately, they're part of eslint-config-pixiebrix’ dependencies

https://github.com/pixiebrix/pixiebrix-extension/blob/2914608a3c37ebd93fecc03781449b9f79acefd9/package.json#L217-L218

I think technically I could add xo as a dependency and use extend: ["./node_modules/xo/config/plugins.cjs"], but that obviously is a mess.

If it doesn't break the current usage, I'd move plugins.cjs to the eslint-config-xo package as its own file. XO can continue to import it as usual, I suppose, and others will be able too.

I know, but it works for me and I don't know why.

Either way, my suggestion was not to change the dependency setup, but just to move the file to the eslint-config-xo, which should still be fine for XO itself and has the potential of working for others through the config as well.

Even if it works for you, it's not something that is officially supported. I have wasted so much time on weird config resolution issues with XO and ESLint in the past year. I don't want to risk any more issues by moving the file out. I recommend just copy-pasting the useful stuff in plugins.js for now. This will all be fixed properly at some point.

I have wasted so much time on weird config resolution issues with XO and ESLint in the past year.

Speaking of which: 0.46.1 0.46.2 0.46.3 😅

I was having issues with it yesterday but did not have the time to investigate

Yeah... Try 0.46.3. It fixes it for sindresorhus/ow at least.