Skip to content

Commit

Permalink
fix javascript tests by removing type annotations they contained (oops)
Browse files Browse the repository at this point in the history
  • Loading branch information
electrovir committed Oct 22, 2023
1 parent e5f28f3 commit 2b8eb16
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 30 deletions.
6 changes: 0 additions & 6 deletions src/preprocessing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ export function wrapParser(originalParser: Parser, parserName: string) {
processedText,
{
...options,
...((pluginWithPreprocessor as any)?.name?.includes(
'prettier-plugin-organize-imports',
) &&
options.filepath?.endsWith('.js.flow') && {
filepath: options.filepath.slice(0, -5),
}),
plugins: options.plugins.filter(
(plugin) => (plugin as any).pluginMarker !== pluginMarker,
),
Expand Down
48 changes: 24 additions & 24 deletions src/test/javascript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -741,16 +741,16 @@ const javascriptTests: MultilineArrayTest[] = [
it: 'empty array',
// prettier-ignore
code: `
const myVar1: string[] = [];
const myVar1 = [];
`,
},
{
it: 'single element array on one line',
// prettier-ignore
code: `let anotherThing: string[] = ['1 1'];`,
code: `let anotherThing = ['1 1'];`,
// prettier-ignore
expect: `
let anotherThing: string[] = [
let anotherThing = [
'1 1',
];
`,
Expand All @@ -762,11 +762,11 @@ const javascriptTests: MultilineArrayTest[] = [
it: 'single element array on multiple lines',
// prettier-ignore
code: `
let anotherThing: string[] = ['1 1'
let anotherThing = ['1 1'
];`,
// prettier-ignore
expect: `
let anotherThing: string[] = [
let anotherThing = [
'1 1',
];
`,
Expand All @@ -778,24 +778,24 @@ const javascriptTests: MultilineArrayTest[] = [
it: 'multiple different styled arrays all together',
// prettier-ignore
code: `
const myVar2: string[] = [];
let anotherThing: string[] = ['1 1'];
let anotherThing2: string[] = ['1 1'
const myVar2 = [];
let anotherThing = ['1 1'];
let anotherThing2 = ['1 1'
];
const also: string[] = [
const also = [
'2, 1',
'2, 2',
];`,
// prettier-ignore
expect: `
const myVar2: string[] = [];
let anotherThing: string[] = [
const myVar2 = [];
let anotherThing = [
'1 1',
];
let anotherThing2: string[] = [
let anotherThing2 = [
'1 1',
];
const also: string[] = [
const also = [
'2, 1',
'2, 2',
];
Expand All @@ -807,10 +807,10 @@ const javascriptTests: MultilineArrayTest[] = [
{
it: 'single element string array with type definition',
// prettier-ignore
code: `const myVar: string[] = ['hello'];`,
code: `const myVar = ['hello'];`,
// prettier-ignore
expect: `
const myVar: string[] = [
const myVar = [
'hello',
];
`,
Expand All @@ -821,10 +821,10 @@ const javascriptTests: MultilineArrayTest[] = [
{
it: 'double element string array with type definition',
// prettier-ignore
code: `const myVar: string[] = ['hello', 'there'];`,
code: `const myVar = ['hello', 'there'];`,
// prettier-ignore
expect: `
const myVar: string[] = [
const myVar = [
'hello',
'there',
];
Expand All @@ -837,25 +837,25 @@ const javascriptTests: MultilineArrayTest[] = [
it: 'non-array string assignment',
// prettier-ignore
code: `
const myVar:string=
const myVar =
'hello';`,
// prettier-ignore
expect: `
const myVar: string = 'hello';
const myVar = 'hello';
`,
},
{
it: 'non-array single line object assignment',
// prettier-ignore
code: `
const myVar: object = {a: 'here', b: 'there'};
const myVar = {a: 'here', b: 'there'};
`,
},
{
it: 'non-array multi-line object assignment',
// prettier-ignore
code: `
const myVar: object = {
const myVar = {
a: 'here',
b: 'there',
};
Expand Down Expand Up @@ -907,14 +907,14 @@ const javascriptTests: MultilineArrayTest[] = [
it: 'original parser with single line object assignment',
// prettier-ignore
code: `
const myVar: object = {a: 'where', b: 'everywhere'};
const myVar = {a: 'where', b: 'everywhere'};
`,
},
{
it: 'original parser with multi-line object assignment',
// prettier-ignore
code: `
const myVar: object = {
const myVar = {
a: 'where',
b: 'everywhere',
};
Expand All @@ -926,5 +926,5 @@ const javascriptTests: MultilineArrayTest[] = [
// This worked previously, because prettier/babel used to always recognize flow syntax.
// See: https://prettier.io/blog/2023/07/05/3.0.0#remove-flow-syntax-support-from-babel-parser-14314httpsgithubcomprettierprettierpull14314-by-fiskerhttpsgithubcomfisker-thorn0httpsgithubcomthorn0
describe('javascript multiline array formatting', () => {
runTests('.js.flow', javascriptTests, 'babel');
runTests('.js', javascriptTests, 'babel');
});

0 comments on commit 2b8eb16

Please sign in to comment.