Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prettierx: option to import on one line in JS&TS (#265)
* add option to skip multi-line import formatting in JS/TS * use join to support multiple imports on the same line * keep the test case in tests/import_formatting * include test on Babel parsers in the test case * name the option as importFormatting, with choices: auto & oneline * no `since` specified for the new option (not needed for prettierx) Co-authored-by: Dmitry Koterov <dmitry.koterov@gmail.com> Co-authored-by: Christopher J. Brody <chris.brody+brodybits@gmail.com>
- Loading branch information
Showing
9 changed files
with
171 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`long_import.js 1`] = ` | ||
====================================options===================================== | ||
importFormatting: "oneline" | ||
parsers: ["babel", "babel-flow", "flow", "typescript"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
import abc, { Lorem, ipsum, dolor, sit, amet, consectetur, adipiscing, elit, sed, eiusmod, tempor, incididunt, ut, labore, et, magna } from "some-module"; | ||
import { Lorem, ipsum, dolor, sit, amet, consectetur, adipiscing, elit, sed, eiusmod, tempor, incididunt, ut, labore, et, magna } from "some-module"; | ||
=====================================output===================================== | ||
import abc, { Lorem, ipsum, dolor, sit, amet, consectetur, adipiscing, elit, sed, eiusmod, tempor, incididunt, ut, labore, et, magna } from "some-module"; | ||
import { Lorem, ipsum, dolor, sit, amet, consectetur, adipiscing, elit, sed, eiusmod, tempor, incididunt, ut, labore, et, magna } from "some-module"; | ||
================================================================================ | ||
`; | ||
|
||
exports[`long_import.js 2`] = ` | ||
====================================options===================================== | ||
importFormatting: "auto" | ||
parsers: ["babel", "babel-flow", "flow", "typescript"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
import abc, { Lorem, ipsum, dolor, sit, amet, consectetur, adipiscing, elit, sed, eiusmod, tempor, incididunt, ut, labore, et, magna } from "some-module"; | ||
import { Lorem, ipsum, dolor, sit, amet, consectetur, adipiscing, elit, sed, eiusmod, tempor, incididunt, ut, labore, et, magna } from "some-module"; | ||
=====================================output===================================== | ||
import abc, { | ||
Lorem, | ||
ipsum, | ||
dolor, | ||
sit, | ||
amet, | ||
consectetur, | ||
adipiscing, | ||
elit, | ||
sed, | ||
eiusmod, | ||
tempor, | ||
incididunt, | ||
ut, | ||
labore, | ||
et, | ||
magna | ||
} from "some-module"; | ||
import { | ||
Lorem, | ||
ipsum, | ||
dolor, | ||
sit, | ||
amet, | ||
consectetur, | ||
adipiscing, | ||
elit, | ||
sed, | ||
eiusmod, | ||
tempor, | ||
incididunt, | ||
ut, | ||
labore, | ||
et, | ||
magna | ||
} from "some-module"; | ||
================================================================================ | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
run_spec(__dirname, ["babel", "babel-flow", "flow", "typescript"], { | ||
importFormatting: "oneline" | ||
}); | ||
run_spec(__dirname, ["babel", "babel-flow", "flow", "typescript"], { | ||
importFormatting: "auto" | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import abc, { Lorem, ipsum, dolor, sit, amet, consectetur, adipiscing, elit, sed, eiusmod, tempor, incididunt, ut, labore, et, magna } from "some-module"; | ||
import { Lorem, ipsum, dolor, sit, amet, consectetur, adipiscing, elit, sed, eiusmod, tempor, incididunt, ut, labore, et, magna } from "some-module"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters