2017-06-06 17:24:56 +02:00
|
|
|
"use strict";
|
|
|
|
|
|
2020-09-18 14:05:29 +08:00
|
|
|
const prettier = require("prettier-local");
|
2022-02-10 10:12:31 +08:00
|
|
|
const runPrettier = require("../run-prettier.js");
|
2017-06-06 17:24:56 +02:00
|
|
|
|
2017-10-02 11:08:34 -05:00
|
|
|
describe("infers postcss parser", () => {
|
2018-11-14 07:55:50 -05:00
|
|
|
runPrettier("cli/with-parser-inference", ["--end-of-line", "lf", "*"]).test({
|
2017-10-02 11:08:34 -05:00
|
|
|
status: 0,
|
|
|
|
|
});
|
2017-06-06 17:24:56 +02:00
|
|
|
});
|
|
|
|
|
|
2018-12-19 14:03:30 +00:00
|
|
|
describe("infers postcss parser with --check", () => {
|
|
|
|
|
runPrettier("cli/with-parser-inference", ["--check", "*"]).test({
|
|
|
|
|
status: 0,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2017-10-02 11:08:34 -05:00
|
|
|
describe("infers postcss parser with --list-different", () => {
|
|
|
|
|
runPrettier("cli/with-parser-inference", ["--list-different", "*"]).test({
|
|
|
|
|
status: 0,
|
|
|
|
|
});
|
2017-06-06 17:24:56 +02:00
|
|
|
});
|
2017-11-03 18:06:25 +11:00
|
|
|
|
|
|
|
|
describe("infers parser from filename", () => {
|
|
|
|
|
test("json from .prettierrc", () => {
|
2021-10-04 07:46:38 +09:00
|
|
|
expect(prettier.format(" { } ", { filepath: "x/y/.prettierrc" })).toBe(
|
|
|
|
|
"{}\n"
|
|
|
|
|
);
|
2017-11-03 18:06:25 +11:00
|
|
|
});
|
|
|
|
|
|
2021-08-31 12:40:52 +08:00
|
|
|
test("json from .stylelintrc", () => {
|
2021-10-04 07:46:38 +09:00
|
|
|
expect(prettier.format(" { } ", { filepath: "x/y/.stylelintrc" })).toBe(
|
|
|
|
|
"{}\n"
|
|
|
|
|
);
|
2021-08-31 12:40:52 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("yaml from .stylelintrc", () => {
|
|
|
|
|
expect(
|
|
|
|
|
prettier.format(" extends: '' ", { filepath: "x/y/.stylelintrc" })
|
2021-10-04 07:46:38 +09:00
|
|
|
).toBe('extends: ""\n');
|
2021-08-31 12:40:52 +08:00
|
|
|
});
|
|
|
|
|
|
2018-12-27 08:05:19 -05:00
|
|
|
test("babel from Jakefile", () => {
|
2017-11-03 18:06:25 +11:00
|
|
|
expect(
|
|
|
|
|
prettier.format("let foo = ( x = 1 ) => x", { filepath: "x/y/Jakefile" })
|
2021-10-04 07:46:38 +09:00
|
|
|
).toBe("let foo = (x = 1) => x;\n");
|
2017-11-03 18:06:25 +11:00
|
|
|
});
|
2022-02-18 08:39:12 +09:00
|
|
|
|
|
|
|
|
test("json from .swcrc", () => {
|
|
|
|
|
expect(
|
|
|
|
|
prettier.format(
|
|
|
|
|
`
|
|
|
|
|
{
|
|
|
|
|
"jsc": {
|
|
|
|
|
// Requires v1.2.50 or upper and requires target to be es2016 or upper.
|
|
|
|
|
"keepClassNames": false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`,
|
|
|
|
|
{ filepath: "/path/to/.swcrc" }
|
|
|
|
|
)
|
|
|
|
|
).toBe(`{
|
|
|
|
|
"jsc": {
|
|
|
|
|
// Requires v1.2.50 or upper and requires target to be es2016 or upper.
|
|
|
|
|
"keepClassNames": false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`);
|
|
|
|
|
});
|
2017-11-03 18:06:25 +11:00
|
|
|
});
|