[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

Handle error when prettierOptions is passed as null #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Handle error when prettierOptions is passed as null #30

wants to merge 1 commit into from

Conversation

lachieh
Copy link
@lachieh lachieh commented Feb 19, 2019

In some instances, prettierOptions can be passed as null, instead of being left undefined. This will cause an error as detailed in #9.

This PR adds a check to on the parameter to see if it is null and sets it to an empty object if so. This closes #9.

Further testing may be required.

In some instances, `prettierOptions` can be passed as null, instead of being left undefined. This will cause an error as detailed in #9.

This PR adds a check to on the parameter to see if it is null and sets it to an empty object if so. This closes #9.

Further testing may be required.
@codecov-io
Copy link
codecov-io commented Feb 19, 2019

Codecov Report

Merging #30 into master will decrease coverage by 1.81%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #30      +/-   ##
==========================================
- Coverage   98.03%   96.22%   -1.82%     
==========================================
  Files           2        2              
  Lines          51       53       +2     
==========================================
+ Hits           50       51       +1     
- Misses          1        2       +1
Impacted Files Coverage Δ
src/index.js 96.15% <50%> (-1.85%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2e37e73...e2b0c1d. Read the comment docs.

@lachieh
Copy link
Author
lachieh commented Feb 19, 2019

To improve code coverage, this

if (prettierOptions === null) {
    prettierOptions = {};
}

could be changed to this

prettierOptions = prettierOptions === null ? {} : prettierOptions;

I'm not sure that this is a better or more readable solution, though.

@lambert-velir
Copy link

I ran in to this problem and found prettier/prettier-atom#471 which led me here.

@lachieh, can this be merged? I'd prefer not to have to put "prettier": {} in my package.json

@lachieh
Copy link
Author
lachieh commented Oct 13, 2019

@lambert-velir that would be up to @hugomrdias. I don't have a close familiarity with the project so not sure if there are extra tests that would need to cover this.

I came across this because of the VSCode extension, so it's obviously affecting multiple editors.

@lambert-velir
Copy link

@hugomrdias, can this be merged?

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

Successfully merging this pull request may close these issues.

Cannot set property 'singleQuote' of null
3 participants