Skip to content

Commit 0771220

Browse files
43081jfabiospampinato
authored andcommitted
Ported test suite: with-parser-inference
1 parent a890c1b commit 0771220

File tree

4 files changed

+190
-0
lines changed

4 files changed

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

0 commit comments

Comments
 (0)