-
-
Notifications
You must be signed in to change notification settings - Fork 291
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
Support plugin config in the extends
option
#162
Support plugin config in the extends
option
#162
Conversation
@@ -145,6 +145,11 @@ function buildConfig(opts) { | |||
return name; | |||
} | |||
|
|||
// don't do anything if it's a config from a plugin | |||
if (name.indexOf('plugin:') === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use String#startsWith
const config = manager.buildConfig({extends: extendsOption}); | ||
t.is(config.baseConfig.extends[config.baseConfig.extends.length - 3], 'plugin:foo/bar'); | ||
t.is(config.baseConfig.extends[config.baseConfig.extends.length - 2], 'cwd/eslint-config-foo-bar'); | ||
t.is(config.baseConfig.extends[config.baseConfig.extends.length - 1], 'cwd/eslint-config-foo-bar-two'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too much boilerplate. Put config.baseConfig.extends
in a variable and use it.
const extendsConfig = config.baseConfig.extends; | ||
t.is(extendsConfig[extendsConfig.length - 3], 'plugin:foo/bar'); | ||
t.is(extendsConfig[extendsConfig.length - 2], 'cwd/eslint-config-foo-bar'); | ||
t.is(extendsConfig[extendsConfig.length - 1], 'cwd/eslint-config-foo-bar-two'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, would be even nicer to just Array#slice()
off the items we want an do an t.deepEqual
.
extends
option
Thanks :) |
No problem 👍 |
Current issue
XO allows to specify sharable configs to override any of the default rules link. However, in ESLint it is allowed to use configs shared by plugins (prefixed with
eslint-plugin-
, next to shared configs (prefixed witheslint-config-
and absolute/relative paths. These plugin configs are prefixed withplugin:
, see here.Contribution
This PR allows to specify such plugin configs in the XO configuration, by checking whether the name starts with
plugin:
and only prependingeslint-config-
if that is not the case.