You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
difficulty:easyIssues that should be easy to fix. Resolve me on the train to work!help wantedWe're a small group who can't get to every issue promptly. We’d appreciate help fixing this issue!lang:javascriptIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.
or at the very least, whitelisted methods should be exposed through config.
I would LIKE my testing methods to be prettier-fied. Also, since 'skip' is not one of the whitelisted words, when my bot goes in to auto-skip flakey tests, all of a sudden I have tons of prettier lint errors.
Can you go to the playground, paste in a sample of code that reproduces the behavior, then click on “Copy markdown” and paste the result into your issue description?
To clarify, this would be more categorized as a critical feature request rather than a bug. I believe Prettier is performing as intended, I just don't like it's intentions... I will still attempt to include some sort of output.
yes, but test.skip is not a function of QUnit, while I would prefer to disable the whole whitelist, at the very least I would like to add skip() to it.
Maybe we should instead have it look for functions called with a string and a function. i.e. foo("test name", function () { /* test */ }).
That is already one of the conditions (function call with 2 arguments: first a string, second a function).. The other one is if the callee matches some conditions
I don't think a config option for this would be appropriate, but I think we could add support for a bare skip in unitTestRe, if that's common in QUnit.
Somewhat related... I have been selfishly wishing that prettier formatted my describeComponent helper with the isTestCall logic, but it didn't seem appropriate to do for such a small library.
@suchipi which of the config options do feel is not appropriate, printWidthWhitelist: 'disable', or having an printWidthWhitelistMethods: ['test', 'skip']
Personally, I feel like this whole feature is a bit of a kludge, which is kinda surfaced by @azz's suggested workaround. Specifically I take issue with the arbitrariness of the whitelisted method names and the effort that is going to be required to keep this up to date for every user's setup. It seems to me that removing the internal printWidthWhitelist list, and making it 100% configurable as I mentioned above would make it more clear to users what is going on...
I don't think either config option is appropriate. A project goal of prettier is to have very few configuration options and be opinionated, but still work well despite the lack of configuration. The special-case formatting for tests is a very fine-grained and scoped feature, and it does not feel appropriate to add an option for such a specific case when we have rejected adding options for other more broad cases, such as adding a space between the keyword function and the parameter list.
Prettier has chosen to format test methods this way because that's what users of jest, mocha, and jasmine requested, and often would have written by hand anyway. I recognize that the current behavior is inconsistent when using QUnit which is frustrating. I think the appropriate fix is to format skip like we do describe and it and etc, instead of making this behavior configurable.
Reacted by Jed Fox, Lucas Azzola and Lucas Duailibe
Hey, thanks for your response, I will submit a PR shortly.
As a parting comment, I'd like to say that I love opinionated and appreciate it it's value. I agree that either config option would not be in the best interest of Prettier, but perhaps the feature itself should be re-evaluated. It seems to simply be // disable-prettier-ing based on an arbitrary and not particularly well documented list of methods. I believe that more users, such as myself, will be using test suites that Prettier will feel compelled to support. This adds overhead. In the absence of such curation, users will begin to implement workarounds, as mentioned above, or just fork the repo.
difficulty:easyIssues that should be easy to fix. Resolve me on the train to work!help wantedWe're a small group who can't get to every issue promptly. We’d appreciate help fixing this issue!lang:javascriptIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.
Activity
j-f1 commentedon Jan 10, 2018
Can you go to the playground, paste in a sample of code that reproduces the behavior, then click on “Copy markdown” and paste the result into your issue description?
tmquinn commentedon Jan 10, 2018
This is not an issue, specifically with a bad transform. It's related to
prettier/src/language-js/printer-estree.js
Line 5123 in 0e0fa5c
#159
#953
j-f1 commentedon Jan 10, 2018
Can you still fill out an example so we make sure to fix the right issue and also so we have a test to prevent regressions?
tmquinn commentedon Jan 10, 2018
To clarify, this would be more categorized as a critical feature request rather than a bug. I believe Prettier is performing as intended, I just don't like it's intentions... I will still attempt to include some sort of output.
tmquinn commentedon Jan 10, 2018
Prettier 1.10.1
Playground link
Input:
Output:
Expected behavior:
This is the expected behavior
tmquinn commentedon Jan 10, 2018
Prettier 1.10.1
Playground link
Input:
Output:
Expected behavior:
This is how I want it to look, or at least have 'skip' added to the whitelist, or even better, expose the whitelist
j-f1 commentedon Jan 10, 2018
👍 Thanks for the examples!
Maybe we should instead have it look for functions called with a string and a function. i.e.
foo("test name", function () { /* test */ }).Also, note that
test.skipworks here:Prettier 1.10.1
Playground link
Input:
Output:
tmquinn commentedon Jan 11, 2018
yes, but test.skip is not a function of QUnit, while I would prefer to disable the whole whitelist, at the very least I would like to add skip() to it.
azz commentedon Jan 11, 2018
test.skip = skip?duailibe commentedon Jan 11, 2018
That is already one of the conditions (function call with 2 arguments: first a string, second a function).. The other one is if the callee matches some conditions
prettier/src/language-js/printer-estree.js
Lines 5123 to 5142 in d0d5845
suchipi commentedon Jan 11, 2018
I don't think a config option for this would be appropriate, but I think we could add support for a bare
skipinunitTestRe, if that's common in QUnit.Somewhat related... I have been selfishly wishing that prettier formatted my
describeComponenthelper with theisTestCalllogic, but it didn't seem appropriate to do for such a small library.j-f1 commentedon Jan 11, 2018
@suchipi What do you think about my comment above?
suchipi commentedon Jan 11, 2018
I think that heuristic would hit too many false positives, eg:
tmquinn commentedon Jan 12, 2018
@suchipi which of the config options do feel is not appropriate, printWidthWhitelist: 'disable', or having an printWidthWhitelistMethods: ['test', 'skip']
Personally, I feel like this whole feature is a bit of a kludge, which is kinda surfaced by @azz's suggested workaround. Specifically I take issue with the arbitrariness of the whitelisted method names and the effort that is going to be required to keep this up to date for every user's setup. It seems to me that removing the internal printWidthWhitelist list, and making it 100% configurable as I mentioned above would make it more clear to users what is going on...
suchipi commentedon Jan 12, 2018
I don't think either config option is appropriate. A project goal of prettier is to have very few configuration options and be opinionated, but still work well despite the lack of configuration. The special-case formatting for tests is a very fine-grained and scoped feature, and it does not feel appropriate to add an option for such a specific case when we have rejected adding options for other more broad cases, such as adding a space between the keyword
functionand the parameter list.Prettier has chosen to format test methods this way because that's what users of jest, mocha, and jasmine requested, and often would have written by hand anyway. I recognize that the current behavior is inconsistent when using QUnit which is frustrating. I think the appropriate fix is to format
skiplike we dodescribeanditand etc, instead of making this behavior configurable.azz commentedon Jan 12, 2018
Well put, @suchipi.
PRs to add
skip(string, function)to the special case list welcome.tmquinn commentedon Jan 12, 2018
Hey, thanks for your response, I will submit a PR shortly.
As a parting comment, I'd like to say that I love opinionated and appreciate it it's value. I agree that either config option would not be in the best interest of Prettier, but perhaps the feature itself should be re-evaluated. It seems to simply be // disable-prettier-ing based on an arbitrary and not particularly well documented list of methods. I believe that more users, such as myself, will be using test suites that Prettier will feel compelled to support. This adds overhead. In the absence of such curation, users will begin to implement workarounds, as mentioned above, or just fork the repo.
Add support for skip() (prettier#3706)
Add support for skip() (#3706) (#3735)