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 --print-config flag #529

Merged
merged 4 commits into from Apr 20, 2021
Merged

Add --print-config flag #529

merged 4 commits into from Apr 20, 2021

Conversation

andersk
Copy link
Contributor

@andersk andersk commented Apr 6, 2021

I often find myself needing this option to figure out which rules XO is using. If I learn about a new ESLint rule, I want to be able to check whether XO already enables it or something similar; if I upgrade XO, I want to be able to check whether it disabled any rules I was relying on; I want to be able to check that I configured overrides correctly and that it’s applied in the order I expect; etc.

This was largely based on #312 by @teehemkay.

cli-main.js Outdated Show resolved Hide resolved
cli-main.js Outdated
if (options.stdin) {
if (options.printConfig) {
if (input.length > 0) {
console.error('The `print-config` option must be used with exactly one file name');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.error('The `print-config` option must be used with exactly one file name');
console.error('The `--print-config` flag must be used with exactly one filename');

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message is confusing as it makes it sound like the user passed multiple filenames to --print-config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s exactly the mistake this is intended to catch: xo --print-config x.js y.js. (This is parsed as {flags: {printConfig: 'x.js'}, input: ['y.js']}, but a user who writes that probably doesn’t know that.)

cli-main.js Outdated Show resolved Hide resolved
test/cli-main.js Outdated Show resolved Hide resolved
test/print-config.js Outdated Show resolved Hide resolved
@sindresorhus sindresorhus changed the title Add --print-config option Add --print-config flag Apr 18, 2021
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Co-authored-by: teehemkay <tmk@exidia.com>
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Copy link
Contributor Author

@andersk andersk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied all changes and squashed them into the --print-config commit. I also added three new commits to consistently apply these changes elsewhere in the existing code.

@xojs xojs deleted a comment from codecov-io Apr 19, 2021
@xojs xojs deleted a comment from codecov-commenter Apr 19, 2021
@sindresorhus sindresorhus merged commit 7b8dc70 into xojs:main Apr 20, 2021
@sindresorhus
Copy link
Member

Looks good. Thank you 👍

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.

None yet

2 participants