Skip to content

Commit eda0a09

Browse files
authored
Ported test suite: with-parser-inference
1 parent a890c1b commit eda0a09

File tree

4 files changed

+180
-0
lines changed

4 files changed

+180
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* JavaScript */
2+
"use strict";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* Stylesheet */
2+
* {
3+
outline: none;
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`infers parser from filename (.prettierrc) (stdout) 1`] = `"{}"`;
4+
5+
exports[`infers parser from filename (.stylelintrc YAML) (stdout) 1`] = `"extends: """`;
6+
7+
exports[`infers parser from filename (.stylelintrc) (stdout) 1`] = `"{}"`;
8+
9+
exports[`infers parser from filename (jakefile) (stdout) 1`] = `"let foo = (x = 1) => x;"`;
10+
11+
exports[`infers parser from filename (lintstagedrc YAML) (stdout) 1`] = `
12+
""*":
13+
- your-cmd"
14+
`;
15+
16+
exports[`infers parser from filename (lintstagedrc) (stdout) 1`] = `"{ "*": "your-cmd" }"`;
17+
18+
exports[`infers parser from filename (swcrc) (stdout) 1`] = `
19+
"{
20+
"jsc": {
21+
// Requires v1.2.50 or upper and requires target to be es2016 or upper.
22+
"keepClassNames": false
23+
}
24+
}"
25+
`;
26+
27+
exports[`infers postcss parser (stderr) 1`] = `""`;
28+
29+
exports[`infers postcss parser (stdout) 1`] = `
30+
"/* JavaScript */
31+
"use strict";
32+
/* Stylesheet */
33+
* {
34+
outline: none;
35+
}"
36+
`;
37+
38+
exports[`infers postcss parser (write) 1`] = `[]`;
39+
40+
exports[`infers postcss parser with --check (stderr) 1`] = `""`;
41+
42+
exports[`infers postcss parser with --check (stdout) 1`] = `
43+
"Checking formatting...
44+
All matched files use Prettier code style!"
45+
`;
46+
47+
exports[`infers postcss parser with --check (write) 1`] = `[]`;
48+
49+
exports[`infers postcss parser with --list-different (stderr) 1`] = `""`;
50+
51+
exports[`infers postcss parser with --list-different (stdout) 1`] = `""`;
52+
53+
exports[`infers postcss parser with --list-different (write) 1`] = `[]`;
+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import { runCli } from "../utils";
2+
3+
describe("infers postcss parser", () => {
4+
runCli("with-parser-inference", ["--end-of-line", "lf", "*"]).test({
5+
status: 0,
6+
});
7+
});
8+
9+
describe("infers postcss parser with --check", () => {
10+
runCli("with-parser-inference", ["--check", "*"]).test({
11+
status: 0,
12+
});
13+
});
14+
15+
describe("infers postcss parser with --list-different", () => {
16+
runCli("with-parser-inference", ["--list-different", "*"]).test({
17+
status: 0,
18+
});
19+
});
20+
21+
describe("infers parser from filename (.prettierrc)", () => {
22+
runCli("with-parser-inference", [
23+
"--stdin-filepath",
24+
"x/y/.prettierrc",
25+
], {
26+
input: " { } ",
27+
}).test({
28+
status: 0,
29+
stderr: "",
30+
write: [],
31+
});
32+
});
33+
34+
describe("infers parser from filename (.stylelintrc)", () => {
35+
runCli("with-parser-inference", [
36+
"--stdin-filepath",
37+
"x/y/.stylelintrc",
38+
], {
39+
input: " { } ",
40+
}).test({
41+
status: 0,
42+
stderr: "",
43+
write: [],
44+
});
45+
});
46+
47+
describe("infers parser from filename (.stylelintrc YAML)", () => {
48+
runCli("with-parser-inference", [
49+
"--stdin-filepath",
50+
"x/y/.stylelintrc",
51+
], {
52+
input: " extends: '' ",
53+
}).test({
54+
status: 0,
55+
stderr: "",
56+
write: [],
57+
});
58+
});
59+
60+
describe("infers parser from filename (jakefile)", () => {
61+
runCli("with-parser-inference", [
62+
"--stdin-filepath",
63+
"x/y/Jakefile",
64+
], {
65+
input: "let foo = ( x = 1 ) => x",
66+
}).test({
67+
status: 0,
68+
stderr: "",
69+
write: [],
70+
});
71+
});
72+
73+
describe("infers parser from filename (swcrc)", () => {
74+
runCli("with-parser-inference", [
75+
"--stdin-filepath",
76+
"x/y/.swcrc",
77+
], {
78+
input:
79+
/* indent */ `
80+
{
81+
"jsc": {
82+
// Requires v1.2.50 or upper and requires target to be es2016 or upper.
83+
"keepClassNames": false
84+
}}
85+
`,
86+
}).test({
87+
status: 0,
88+
stderr: "",
89+
write: [],
90+
});
91+
});
92+
93+
describe("infers parser from filename (lintstagedrc)", () => {
94+
runCli("with-parser-inference", [
95+
"--stdin-filepath",
96+
"x/y/.lintstagedrc",
97+
], {
98+
input: " { '*': 'your-cmd' } ",
99+
}).test({
100+
status: 0,
101+
stderr: "",
102+
write: [],
103+
});
104+
});
105+
106+
describe("infers parser from filename (lintstagedrc YAML)", () => {
107+
runCli("with-parser-inference", [
108+
"--stdin-filepath",
109+
"x/y/.lintstagedrc",
110+
], {
111+
input:
112+
/* indent */ `
113+
'*':
114+
- your-cmd
115+
`,
116+
}).test({
117+
status: 0,
118+
stderr: "",
119+
write: [],
120+
});
121+
});

0 commit comments

Comments
 (0)