Merge branch 'main' into next-rebase
# Conflicts: # .eslintrc.cjs # package.json # scripts/build/bundler.mjs # scripts/build/config.mjs # scripts/build/esbuild-plugins/replace-module.mjs # src/cli/file-info.js # src/cli/find-config-path.js # src/cli/index.js
This commit is contained in:
commit
a21dfbfa21
50 files changed
+1519
-355
No files matched your search
@@ -110,3 +110,52 @@ const map: Map<Function, Foo<S>> = new Map();
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`issue-12413.js format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["babel-flow", "flow"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
let emit =
|
||||
defineEmits<{ (event: "ready", canvas: HTMLCanvasElement): void; (event:"resize",canvas:HTMLCanvasElement):void; }>();
|
||||
|
||||
let abc =
|
||||
func<{a:2,b:3,d:78,e:9,f:8,g:7,h:6,i:5,j:4,k:3,l:2,m:1,n:0,o:9,p:8,q:7,r:6,s:5,t:4,u:3,v:2,w:1,x:0,y:9,z:8}>();
|
||||
|
||||
=====================================output=====================================
|
||||
let emit = defineEmits<{
|
||||
(event: "ready", canvas: HTMLCanvasElement): void,
|
||||
(event: "resize", canvas: HTMLCanvasElement): void,
|
||||
}>();
|
||||
|
||||
let abc = func<{
|
||||
a: 2,
|
||||
b: 3,
|
||||
d: 78,
|
||||
e: 9,
|
||||
f: 8,
|
||||
g: 7,
|
||||
h: 6,
|
||||
i: 5,
|
||||
j: 4,
|
||||
k: 3,
|
||||
l: 2,
|
||||
m: 1,
|
||||
n: 0,
|
||||
o: 9,
|
||||
p: 8,
|
||||
q: 7,
|
||||
r: 6,
|
||||
s: 5,
|
||||
t: 4,
|
||||
u: 3,
|
||||
v: 2,
|
||||
w: 1,
|
||||
x: 0,
|
||||
y: 9,
|
||||
z: 8,
|
||||
}>();
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
@@ -0,0 +1,5 @@
|
||||
let emit =
|
||||
defineEmits<{ (event: "ready", canvas: HTMLCanvasElement): void; (event:"resize",canvas:HTMLCanvasElement):void; }>();
|
||||
|
||||
let abc =
|
||||
func<{a:2,b:3,d:78,e:9,f:8,g:7,h:6,i:5,j:4,k:3,l:2,m:1,n:0,o:9,p:8,q:7,r:6,s:5,t:4,u:3,v:2,w:1,x:0,y:9,z:8}>();
|
||||
@@ -15,7 +15,7 @@ exports[`snippet: #0 [acorn] format 2`] = `
|
||||
`;
|
||||
|
||||
exports[`snippet: #0 [babel] format 1`] = `
|
||||
"'await' is not allowed in async function parameters. (2:20)
|
||||
"'await' is only allowed within async functions and at the top levels of modules. (2:20)
|
||||
1 | async function foo() {
|
||||
> 2 | function bar(x = await 2) {}
|
||||
| ^
|
||||
|
||||
@@ -8,7 +8,7 @@ exports[`invalid-const.js [acorn] format 1`] = `
|
||||
`;
|
||||
|
||||
exports[`invalid-const.js [babel] format 1`] = `
|
||||
"'Const declarations' require an initialization value. (1:10)
|
||||
"Missing initializer in const declaration. (1:10)
|
||||
> 1 | const foo;
|
||||
| ^
|
||||
2 |"
|
||||
|
||||
@@ -443,6 +443,55 @@ const map: Map<Function, Foo<S>> = new Map();
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`issue-12413.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
let emit =
|
||||
defineEmits<{ (event: "ready", canvas: HTMLCanvasElement): void; (event:"resize",canvas:HTMLCanvasElement):void; }>();
|
||||
|
||||
let abc =
|
||||
func<{a:2,b:3,d:78,e:9,f:8,g:7,h:6,i:5,j:4,k:3,l:2,m:1,n:0,o:9,p:8,q:7,r:6,s:5,t:4,u:3,v:2,w:1,x:0,y:9,z:8}>();
|
||||
|
||||
=====================================output=====================================
|
||||
let emit = defineEmits<{
|
||||
(event: "ready", canvas: HTMLCanvasElement): void;
|
||||
(event: "resize", canvas: HTMLCanvasElement): void;
|
||||
}>();
|
||||
|
||||
let abc = func<{
|
||||
a: 2;
|
||||
b: 3;
|
||||
d: 78;
|
||||
e: 9;
|
||||
f: 8;
|
||||
g: 7;
|
||||
h: 6;
|
||||
i: 5;
|
||||
j: 4;
|
||||
k: 3;
|
||||
l: 2;
|
||||
m: 1;
|
||||
n: 0;
|
||||
o: 9;
|
||||
p: 8;
|
||||
q: 7;
|
||||
r: 6;
|
||||
s: 5;
|
||||
t: 4;
|
||||
u: 3;
|
||||
v: 2;
|
||||
w: 1;
|
||||
x: 0;
|
||||
y: 9;
|
||||
z: 8;
|
||||
}>();
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`lone-arg.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript"]
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
let emit =
|
||||
defineEmits<{ (event: "ready", canvas: HTMLCanvasElement): void; (event:"resize",canvas:HTMLCanvasElement):void; }>();
|
||||
|
||||
let abc =
|
||||
func<{a:2,b:3,d:78,e:9,f:8,g:7,h:6,i:5,j:4,k:3,l:2,m:1,n:0,o:9,p:8,q:7,r:6,s:5,t:4,u:3,v:2,w:1,x:0,y:9,z:8}>();
|
||||
+2
-2
@@ -53,9 +53,9 @@ for (var of of) {
|
||||
`;
|
||||
|
||||
exports[`parserForInStatement2.ts [babel-ts] format 1`] = `
|
||||
"Missing semicolon. (1:12)
|
||||
"Unexpected keyword 'in'. (1:10)
|
||||
> 1 | for (var in X) {
|
||||
| ^
|
||||
| ^
|
||||
2 | }
|
||||
3 |"
|
||||
`;
|
||||
|
||||
@@ -11,7 +11,7 @@ abstract
|
||||
class X {}
|
||||
|
||||
const
|
||||
abstract
|
||||
abstract = 1;
|
||||
class Y {}
|
||||
|
||||
export let
|
||||
@@ -26,7 +26,7 @@ export class Y {}
|
||||
var abstract;
|
||||
class X {}
|
||||
|
||||
const abstract;
|
||||
const abstract = 1;
|
||||
class Y {}
|
||||
|
||||
export let abstract;
|
||||
|
||||
@@ -3,7 +3,7 @@ abstract
|
||||
class X {}
|
||||
|
||||
const
|
||||
abstract
|
||||
abstract = 1;
|
||||
class Y {}
|
||||
|
||||
export let
|
||||
|
||||
@@ -26,7 +26,7 @@ class MyComponent {
|
||||
ngModel!: ng.INgModelController;
|
||||
}
|
||||
|
||||
const x!: string
|
||||
const x!: string = '';
|
||||
|
||||
var y!: MyComponent
|
||||
|
||||
@@ -35,7 +35,7 @@ class MyComponent {
|
||||
ngModel!: ng.INgModelController;
|
||||
}
|
||||
|
||||
const x!: string;
|
||||
const x!: string = "";
|
||||
|
||||
var y!: MyComponent;
|
||||
|
||||
@@ -57,9 +57,9 @@ class Foo {
|
||||
}
|
||||
|
||||
let a! = x
|
||||
const b!
|
||||
const b! = x
|
||||
var c/* */! = x
|
||||
export const d!
|
||||
export const d! = x
|
||||
|
||||
=====================================output=====================================
|
||||
class Foo {
|
||||
@@ -71,9 +71,9 @@ class Foo {
|
||||
}
|
||||
|
||||
let a! = x;
|
||||
const b!;
|
||||
const b! = x;
|
||||
var c! /* */ = x;
|
||||
export const d!;
|
||||
export const d! = x;
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
@@ -2,6 +2,6 @@ class MyComponent {
|
||||
ngModel!: ng.INgModelController;
|
||||
}
|
||||
|
||||
const x!: string
|
||||
const x!: string = '';
|
||||
|
||||
var y!: MyComponent
|
||||
@@ -7,6 +7,6 @@ class Foo {
|
||||
}
|
||||
|
||||
let a! = x
|
||||
const b!
|
||||
const b! = x
|
||||
var c/* */! = x
|
||||
export const d!
|
||||
export const d! = x
|
||||
@@ -281,10 +281,20 @@ This option cannot be used with --range-start and --range-end.",
|
||||
"description": "Custom directory that contains prettier plugins in node_modules subdirectory.
|
||||
Overrides default behavior when plugins are searched relatively to the location of Prettier.
|
||||
Multiple values are accepted.",
|
||||
"items": Object {
|
||||
"type": "string",
|
||||
},
|
||||
"type": "array",
|
||||
"oneOf": Array [
|
||||
Object {
|
||||
"items": Object {
|
||||
"type": "string",
|
||||
},
|
||||
"type": "array",
|
||||
},
|
||||
Object {
|
||||
"description": "Disable plugin autoloading.",
|
||||
"enum": Array [
|
||||
false,
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
"plugins": Object {
|
||||
"default": Array [],
|
||||
|
||||
@@ -35,6 +35,85 @@ describe("Should use default level logger to log `--loglevel` error", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("loglevel should not effect information print", () => {
|
||||
for (const { argv, runOptions, assertOptions } of [
|
||||
{
|
||||
argv: ["--version"],
|
||||
assertOptions: {
|
||||
stdout(value) {
|
||||
expect(value).not.toBe("");
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
argv: ["--help"],
|
||||
assertOptions: {
|
||||
stdout(value) {
|
||||
expect(value.includes("-v, --version")).toBe(true);
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
argv: ["--help", "write"],
|
||||
assertOptions: {
|
||||
stdout(value) {
|
||||
expect(value.startsWith("-w, --write")).toBe(true);
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
argv: ["--support-info"],
|
||||
assertOptions: {
|
||||
stdout(value) {
|
||||
expect(JSON.parse(value)).toBeDefined();
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
argv: ["--find-config-path", "any-file"],
|
||||
assertOptions: {
|
||||
stdout: ".prettierrc\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
argv: ["--file-info", "any-js-file.js"],
|
||||
assertOptions: {
|
||||
stdout(value) {
|
||||
expect(JSON.parse(value)).toEqual({
|
||||
ignored: false,
|
||||
inferredParser: "babel",
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
argv: [],
|
||||
runOptions: { isTTY: true },
|
||||
assertOptions: {
|
||||
status: "non-zero",
|
||||
stdout(value) {
|
||||
expect(value.includes("-v, --version")).toBe(true);
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
argv: ["--parser", "babel"],
|
||||
runOptions: { input: "foo" },
|
||||
assertOptions: { stdout: "foo;\n" },
|
||||
},
|
||||
]) {
|
||||
runPrettier("cli/loglevel", ["--loglevel", "silent", ...argv], {
|
||||
...runOptions,
|
||||
title: argv.join(" "),
|
||||
}).test({
|
||||
stderr: "",
|
||||
status: 0,
|
||||
write: [],
|
||||
...assertOptions,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
async function runPrettierWithLogLevel(logLevel, patterns) {
|
||||
const result = await runPrettier("cli/loglevel", [
|
||||
"--loglevel",
|
||||
|
||||
@@ -180,7 +180,7 @@ function runPrettier(dir, args = [], options = {}) {
|
||||
|
||||
function testResult(testOptions) {
|
||||
for (const name of ["status", "stdout", "stderr", "write"]) {
|
||||
test(`(${name})`, async () => {
|
||||
test(`${options.title || ""}(${name})`, async () => {
|
||||
const result = await runCli();
|
||||
const value =
|
||||
// \r is trimmed from jest snapshots by default;
|
||||
@@ -194,6 +194,8 @@ function runPrettier(dir, args = [], options = {}) {
|
||||
if (name in testOptions) {
|
||||
if (name === "status" && testOptions[name] === "non-zero") {
|
||||
expect(value).not.toBe(0);
|
||||
} else if (typeof testOptions[name] === "function") {
|
||||
testOptions[name](value);
|
||||
} else {
|
||||
expect(value).toEqual(testOptions[name]);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user