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

Custom Fallback Options if a Setting is Not Inferrable from ESlint #72

Closed
robwise opened this issue Apr 22, 2017 · 3 comments · Fixed by #73
Closed

Custom Fallback Options if a Setting is Not Inferrable from ESlint #72

robwise opened this issue Apr 22, 2017 · 3 comments · Fixed by #73

Comments

@robwise
Copy link
Contributor

robwise commented Apr 22, 2017

This is, admittedly, purely needed for prettier-atom. In prettier-atom, if you turn ESlint integration on, it's going to stay on regardless of whether the project you've got open actually has all prettier-related rules set in their config.

If the project doesn't have an ESlint rule needed for prettier, users are wanting to fall back to the prettier setting they've set inside of their prettier-atom config instead of falling back to the default value for that prettier option (which is how it currently works if I'm not mistaken). If I could pass fall-back options to prettier-eslint when using it to format, that would be great. Note that this is different than the current API which only allows manual overrides as opposed to fall-backs.

Any thoughts on adding this to the API?

@robwise robwise changed the title Custom Fallback Options if ESlint Config Not Found Custom Fallback Options if a Setting is Not Inferrable from ESlint Apr 22, 2017
@kentcdodds
Copy link
Member

I think this is great. What if we did added prettierFallbackOptions? Then we could use that here. I think that it would be based on whether the value is RULE_DISABLED then we'd use the fallback. Maybe @briandipalma can weigh in here with a suggestion.

But in any case, I'd be thrilled to accept a PR for this. I would love this functionality myself!

@robwise
Copy link
Contributor Author

robwise commented Apr 22, 2017

I'm looking at the code and trying to figure out where it would go, I think RULE_DISABLED is only when the rule is set to 0 or off. If the rule can't be found in ESlint, it seems to be supplied a default value when calling getRuleValue:

function getRuleValue(rules, name, defaultValue, objPath) {

I'm not totally sure how I'd hook in here

@kentcdodds
Copy link
Member

Right here we log if the rule's not been configured. Actually if you pop open Atom devtools and enter: process.env.LOG_LEVEL = 'trace' then run format it'll give you a lot of handy info, like this:

screen shot 2017-04-21 at 8 20 23 pm

That might be helpful...

robwise added a commit to robwise/prettier-eslint that referenced this issue Apr 22, 2017
Some users may want to be able to fallback to specific prettier options only in the case that the
rule cannot be inferred from the corresponding ESlint rule. We add a `fallbackPrettierOptions` to
the API to allow this. This is different than `prettierOptions` because those always override the
eslint rule, whereas fallback options are only used if the eslint rule is not found. If a fallback
option is not provided and an eslint rule is not found, the default prettier option is used as was
always the case.

Resolves prettier#72
robwise added a commit to robwise/prettier-eslint that referenced this issue Apr 22, 2017
Some users may want to be able to fallback to specific prettier options only in the case that the
rule cannot be inferred from the corresponding ESlint rule. We add a `fallbackPrettierOptions` to
the API to allow this. This is different than `prettierOptions` because those always override the
eslint rule, whereas fallback options are only used if the eslint rule is not found. If a fallback
option is not provided and an eslint rule is not found, the default prettier option is used as was
always the case.

Resolves prettier#72
kentcdodds pushed a commit that referenced this issue Apr 23, 2017
…ule (#73)

* docs(contributing): use yarn instead of npm and fix typo

* feat(fallback-options): allow passing custom fallbacks if no eslint rule

Some users may want to be able to fallback to specific prettier options only in the case that the
rule cannot be inferred from the corresponding ESlint rule. We add a `fallbackPrettierOptions` to
the API to allow this. This is different than `prettierOptions` because those always override the
eslint rule, whereas fallback options are only used if the eslint rule is not found. If a fallback
option is not provided and an eslint rule is not found, the default prettier option is used as was
always the case.

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

Successfully merging a pull request may close this issue.

2 participants