prettier-stylelint icon indicating copy to clipboard operation
prettier-stylelint copied to clipboard

Handle error when prettierOptions is passed as null

Open lachieh opened this issue 6 years ago • 5 comments

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.

lachieh avatar Feb 19 '19 15:02 lachieh

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%) :arrow_down:

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.

codecov-io avatar Feb 19 '19 16:02 codecov-io

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.

lachieh avatar Feb 19 '19 16:02 lachieh

I ran in to this problem and found https://github.com/prettier/prettier-atom/issues/471 which led me here.

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

lambert-velir avatar Oct 11 '19 20:10 lambert-velir

@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.

lachieh avatar Oct 13 '19 01:10 lachieh

@hugomrdias, can this be merged?

lambert-velir avatar Oct 22 '19 22:10 lambert-velir