prettier-stylelint
prettier-stylelint copied to clipboard
Handle error when prettierOptions is passed as null
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 Report
Merging #30 into master will decrease coverage by
1.81%. The diff coverage is50%.
@@ 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 dataPowered by Codecov. Last update 2e37e73...e2b0c1d. Read the comment docs.
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.
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 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.
@hugomrdias, can this be merged?