Skip to content

Actually support plugins field in config#3584

Merged
azz merged 3 commits intoprettier:masterfrom
taion:plugins-option
Dec 28, 2017
Merged

Actually support plugins field in config#3584
azz merged 3 commits intoprettier:masterfrom
taion:plugins-option

Conversation

@taion
Copy link
Copy Markdown
Contributor

@taion taion commented Dec 26, 2017

No description provided.

@taion
Copy link
Copy Markdown
Contributor Author

taion commented Dec 26, 2017

Sec, this only squelches the warning. It doesn't actually work.

@taion
Copy link
Copy Markdown
Contributor Author

taion commented Dec 26, 2017

Still one more bug to fix here

@taion
Copy link
Copy Markdown
Contributor Author

taion commented Dec 26, 2017

Good to go now. cc @azz

This fixes the hidden README example for prettier-python. Not sure what the test coverage policy here looks like as I didn't see any for #3536.

Comment thread src/cli/util.js

const option = constant.detailedOptionMap[key];
let option = constant.detailedOptionMap[key];
if (type === "api" && option === undefined) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Otherwise we barf on unrecognized "plugins" in config file

Comment thread src/cli/util.js
return Object.keys(object || {}).reduce((output, key) => {
output[dashify(key)] = object[key];
const apiOption = constant.apiDetailedOptionMap[key];
const cliKey = apiOption ? apiOption.name : key;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Need to map "plugins" to "plugin", else it always gets clobbered (even if --plugin isn't specified on CLI)

Comment thread src/main/options.js
const normalized = Object.assign({}, options || {});
const filepath = normalized.filepath;

normalized.plugins = loadPlugins(normalized);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Need to load plugins first so getSupportInfo below can see Python

@azz
Copy link
Copy Markdown
Member

azz commented Dec 26, 2017

The original PR didn't have tests because it was largely just a refactor. We should start adding integration tests for this kind of thing.

@taion
Copy link
Copy Markdown
Contributor Author

taion commented Dec 26, 2017

What do you think of adding an issue to track that and tackling the testing separately?

On master right now, the plugins field in config files doesn't really work at all, and parser inference for languages from plugins also doesn't work.

It's not exactly a blocker, but it makes testing prettier-python take a bit more effort than it needs to.

Comment thread src/cli/constant.js

const apiDetailedOptionMap = detailedOptions.reduce(
(current, option) =>
option.forwardToApi && option.forwardToApi !== option.name
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Isn't forwardToApi true in a lot of places?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@azz azz merged commit b63c669 into prettier:master Dec 28, 2017
@taion taion deleted the plugins-option branch December 28, 2017 09:59
@duailibe duailibe added this to the 1.10 milestone Dec 30, 2017
@lock lock Bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 18, 2019
@lock lock Bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants