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

Support plugin config in the extends option #162

Merged
merged 5 commits into from
Nov 13, 2016
Merged

Support plugin config in the extends option #162

merged 5 commits into from
Nov 13, 2016

Conversation

dennisschroer
Copy link
Contributor

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 with eslint-config- and absolute/relative paths. These plugin configs are prefixed with plugin:, 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 prepending eslint-config- if that is not the case.

@@ -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) {
Copy link
Member

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');
Copy link
Member

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');
Copy link
Member

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.

@sindresorhus sindresorhus changed the title Feature/extend plugin config Support plugin config in the extends option Nov 13, 2016
@sindresorhus sindresorhus merged commit 0b6e8b3 into xojs:master Nov 13, 2016
@sindresorhus
Copy link
Member

Thanks :)

@dennisschroer
Copy link
Contributor Author

No problem 👍

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

Successfully merging this pull request may close these issues.

2 participants