2113 lines
34 KiB
Plaintext
2113 lines
34 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||
|
||
exports[`assignment-pattern.js - flow-verify 1`] = `
|
||
const { a /* comment */ = 1 } = b;
|
||
|
||
const { c = 1 /* comment */ } = d;
|
||
|
||
let {a //comment
|
||
= b} = c
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
const { a /* comment */ = 1 } = b;
|
||
|
||
const { c = 1 /* comment */ } = d;
|
||
|
||
let {
|
||
a = b //comment
|
||
} = c;
|
||
|
||
`;
|
||
|
||
exports[`before-comma.js - flow-verify 1`] = `
|
||
const foo = {
|
||
a: 'a' /* comment for this line */,
|
||
|
||
/* Section B */
|
||
b: 'b',
|
||
};
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
const foo = {
|
||
a: "a" /* comment for this line */,
|
||
|
||
/* Section B */
|
||
b: "b"
|
||
};
|
||
|
||
`;
|
||
|
||
exports[`binary-expressions.js - flow-verify 1`] = `
|
||
function addition() {
|
||
0
|
||
// Comment
|
||
+ x
|
||
}
|
||
|
||
function multiplication() {
|
||
0
|
||
// Comment
|
||
* x
|
||
}
|
||
|
||
function division() {
|
||
0
|
||
// Comment
|
||
/ x
|
||
}
|
||
|
||
function substraction() {
|
||
0
|
||
// Comment
|
||
- x
|
||
}
|
||
|
||
function remainder() {
|
||
0
|
||
// Comment
|
||
% x
|
||
}
|
||
|
||
function exponentiation() {
|
||
0
|
||
// Comment
|
||
** x
|
||
}
|
||
|
||
function leftShift() {
|
||
0
|
||
// Comment
|
||
<< x
|
||
}
|
||
|
||
function rightShift() {
|
||
0
|
||
// Comment
|
||
>> x
|
||
}
|
||
|
||
function unsignedRightShift() {
|
||
0
|
||
// Comment
|
||
>>> x
|
||
}
|
||
|
||
function bitwiseAnd() {
|
||
0
|
||
// Comment
|
||
& x
|
||
}
|
||
|
||
function bitwiseOr() {
|
||
0
|
||
// Comment
|
||
| x
|
||
}
|
||
|
||
function bitwiseXor() {
|
||
0
|
||
// Comment
|
||
^ x
|
||
}
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
function addition() {
|
||
0 +
|
||
// Comment
|
||
x;
|
||
}
|
||
|
||
function multiplication() {
|
||
0 *
|
||
// Comment
|
||
x;
|
||
}
|
||
|
||
function division() {
|
||
0 /
|
||
// Comment
|
||
x;
|
||
}
|
||
|
||
function substraction() {
|
||
0 -
|
||
// Comment
|
||
x;
|
||
}
|
||
|
||
function remainder() {
|
||
0 %
|
||
// Comment
|
||
x;
|
||
}
|
||
|
||
function exponentiation() {
|
||
0 **
|
||
// Comment
|
||
x;
|
||
}
|
||
|
||
function leftShift() {
|
||
0 <<
|
||
// Comment
|
||
x;
|
||
}
|
||
|
||
function rightShift() {
|
||
0 >>
|
||
// Comment
|
||
x;
|
||
}
|
||
|
||
function unsignedRightShift() {
|
||
0 >>>
|
||
// Comment
|
||
x;
|
||
}
|
||
|
||
function bitwiseAnd() {
|
||
0 &
|
||
// Comment
|
||
x;
|
||
}
|
||
|
||
function bitwiseOr() {
|
||
0 |
|
||
// Comment
|
||
x;
|
||
}
|
||
|
||
function bitwiseXor() {
|
||
0 ^
|
||
// Comment
|
||
x;
|
||
}
|
||
|
||
`;
|
||
|
||
exports[`blank.js - flow-verify 1`] = `
|
||
// This file only
|
||
// has comments. This comment
|
||
// should still exist
|
||
//
|
||
// when printed.
|
||
|
||
/**
|
||
* @typedef {DataDrivenMapping|ConstantMapping} Mapping
|
||
*/
|
||
/**
|
||
* @typedef {Object.<String, Mapping>} ConfigurationMapping
|
||
*/
|
||
|
||
/**
|
||
* @typedef {Function} D3Scale - a D3 scale
|
||
* @property {Function} ticks
|
||
* @property {Function} tickFormat
|
||
*/
|
||
// comment
|
||
|
||
// comment
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
// This file only
|
||
// has comments. This comment
|
||
// should still exist
|
||
//
|
||
// when printed.
|
||
|
||
/**
|
||
* @typedef {DataDrivenMapping|ConstantMapping} Mapping
|
||
*/
|
||
/**
|
||
* @typedef {Object.<String, Mapping>} ConfigurationMapping
|
||
*/
|
||
|
||
/**
|
||
* @typedef {Function} D3Scale - a D3 scale
|
||
* @property {Function} ticks
|
||
* @property {Function} tickFormat
|
||
*/
|
||
// comment
|
||
|
||
// comment
|
||
|
||
`;
|
||
|
||
exports[`break-continue-statements.js - flow-verify 1`] = `
|
||
for (;;) {
|
||
break /* comment */;
|
||
continue /* comment */;
|
||
}
|
||
|
||
loop: for (;;) {
|
||
break /* comment */ loop;
|
||
break loop /* comment */;
|
||
continue /* comment */ loop;
|
||
continue loop /* comment */;
|
||
}
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
for (;;) {
|
||
break; /* comment */
|
||
continue; /* comment */
|
||
}
|
||
|
||
loop: for (;;) {
|
||
break /* comment */ loop;
|
||
break loop /* comment */;
|
||
continue /* comment */ loop;
|
||
continue loop /* comment */;
|
||
}
|
||
|
||
`;
|
||
|
||
exports[`call_comment.js - flow-verify 1`] = `
|
||
render( // Warm any cache
|
||
<ChildUpdates renderAnchor={true} anchorClassOn={true} />,
|
||
container
|
||
);
|
||
|
||
React.render( // Warm any cache
|
||
<ChildUpdates renderAnchor={true} anchorClassOn={true} />,
|
||
container
|
||
);
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
render(
|
||
// Warm any cache
|
||
<ChildUpdates renderAnchor={true} anchorClassOn={true} />,
|
||
container
|
||
);
|
||
|
||
React.render(
|
||
// Warm any cache
|
||
<ChildUpdates renderAnchor={true} anchorClassOn={true} />,
|
||
container
|
||
);
|
||
|
||
`;
|
||
|
||
exports[`closure-compiler-type-cast.js - flow-verify 1`] = `
|
||
// test to make sure comments are attached correctly
|
||
let inlineComment = /* some comment */ (
|
||
someReallyLongFunctionCall(withLots, ofArguments));
|
||
|
||
let object = {
|
||
key: /* some comment */ (someReallyLongFunctionCall(withLots, ofArguments))
|
||
};
|
||
|
||
// preserve parens only for type casts
|
||
let assignment = /** @type {string} */ (getValue());
|
||
|
||
functionCall(1 + /** @type {string} */ (value), /** @type {!Foo} */ ({}));
|
||
|
||
function returnValue() {
|
||
return /** @type {!Array.<string>} */ (['hello', 'you']);
|
||
}
|
||
|
||
var newArray = /** @type {array} */ (numberOrString).map(x => x);
|
||
var newArray = /** @type {array} */ ((numberOrString)).map(x => x);
|
||
var newArray = /** @type {array} */ ((numberOrString).map(x => x));
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
// test to make sure comments are attached correctly
|
||
let inlineComment = /* some comment */ someReallyLongFunctionCall(
|
||
withLots,
|
||
ofArguments
|
||
);
|
||
|
||
let object = {
|
||
key: /* some comment */ someReallyLongFunctionCall(withLots, ofArguments)
|
||
};
|
||
|
||
// preserve parens only for type casts
|
||
let assignment = /** @type {string} */ (getValue());
|
||
|
||
functionCall(1 + /** @type {string} */ (value), /** @type {!Foo} */ ({}));
|
||
|
||
function returnValue() {
|
||
return /** @type {!Array.<string>} */ (["hello", "you"]);
|
||
}
|
||
|
||
var newArray = /** @type {array} */ (numberOrString).map(x => x);
|
||
var newArray = /** @type {array} */ (numberOrString).map(x => x);
|
||
var newArray = /** @type {array} */ (numberOrString.map(x => x));
|
||
|
||
`;
|
||
|
||
exports[`dangling.js - flow-verify 1`] = `
|
||
var x = {/* dangling */};
|
||
var x = {
|
||
// dangling
|
||
};
|
||
var x = [/* dangling */];
|
||
function x() {
|
||
/* dangling */
|
||
}
|
||
new Thing(/* dangling */);
|
||
Thing(/* dangling */);
|
||
declare class Foo extends Qux<string> {/* dangling */}
|
||
export /* dangling */{};
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
var x = {
|
||
/* dangling */
|
||
};
|
||
var x = {
|
||
// dangling
|
||
};
|
||
var x = [
|
||
/* dangling */
|
||
];
|
||
function x() {
|
||
/* dangling */
|
||
}
|
||
new Thing(/* dangling */);
|
||
Thing(/* dangling */);
|
||
declare class Foo extends Qux<string> {
|
||
/* dangling */
|
||
}
|
||
export /* dangling */{};
|
||
|
||
`;
|
||
|
||
exports[`dangling_array.js - flow-verify 1`] = `
|
||
expect(() => {}).toTriggerReadyStateChanges([
|
||
// Nothing.
|
||
]);
|
||
|
||
[1 /* first comment */, 2 /* second comment */, 3];
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
expect(() => {}).toTriggerReadyStateChanges([
|
||
// Nothing.
|
||
]);
|
||
|
||
[1 /* first comment */, 2 /* second comment */, 3];
|
||
|
||
`;
|
||
|
||
exports[`dangling_for.js - flow-verify 1`] = `
|
||
for // comment
|
||
(;;);
|
||
|
||
for /* comment */(;;);
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
// comment
|
||
for (;;);
|
||
|
||
/* comment */
|
||
for (;;);
|
||
|
||
`;
|
||
|
||
exports[`dynamic_imports.js - flow-verify 1`] = `
|
||
import(/* Hello */ 'something')
|
||
|
||
import('something' /* Hello */)
|
||
|
||
import(/* Hello */ 'something' /* Hello */)
|
||
|
||
import('something' /* Hello */ + 'else')
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
import(/* Hello */ "something");
|
||
|
||
import("something" /* Hello */);
|
||
|
||
import(/* Hello */ "something" /* Hello */);
|
||
|
||
import("something" /* Hello */ + "else");
|
||
|
||
`;
|
||
|
||
exports[`export.js - flow-verify 1`] = `
|
||
export //comment
|
||
{}
|
||
|
||
export /* comment */ {};
|
||
|
||
export {
|
||
foo // comment
|
||
}
|
||
|
||
export {
|
||
// comment
|
||
bar
|
||
}
|
||
|
||
export {
|
||
fooo, // comment
|
||
barr, // comment
|
||
}
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
export //comment
|
||
{};
|
||
|
||
export /* comment */{};
|
||
|
||
export {
|
||
foo // comment
|
||
};
|
||
|
||
export {
|
||
// comment
|
||
bar
|
||
};
|
||
|
||
export {
|
||
fooo, // comment
|
||
barr // comment
|
||
};
|
||
|
||
`;
|
||
|
||
exports[`first-line.js - flow-verify 1`] = `
|
||
a // comment
|
||
b
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
a; // comment
|
||
b;
|
||
|
||
`;
|
||
|
||
exports[`flow_union.js - flow-verify 1`] = `
|
||
type UploadState<E, EM, D>
|
||
// The upload hasnt begun yet
|
||
= {type: "Not_begun"}
|
||
// The upload timed out
|
||
| {type: "Timed_out"}
|
||
// Failed somewhere on the line
|
||
| {type: "Failed", error: E, errorMsg: EM}
|
||
// Uploading to aws3 and CreatePostMutation succeeded
|
||
| {type: "Success", data: D};
|
||
|
||
type UploadState<E, EM, D>
|
||
// The upload hasnt begun yet
|
||
= A
|
||
// The upload timed out
|
||
| B
|
||
// Failed somewhere on the line
|
||
| C
|
||
// Uploading to aws3 and CreatePostMutation succeeded
|
||
| D;
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
type UploadState<E, EM, D> =
|
||
// The upload hasnt begun yet
|
||
| { type: "Not_begun" }
|
||
// The upload timed out
|
||
| { type: "Timed_out" }
|
||
// Failed somewhere on the line
|
||
| { type: "Failed", error: E, errorMsg: EM }
|
||
// Uploading to aws3 and CreatePostMutation succeeded
|
||
| { type: "Success", data: D };
|
||
|
||
type UploadState<E, EM, D> =
|
||
// The upload hasnt begun yet
|
||
| A
|
||
// The upload timed out
|
||
| B
|
||
// Failed somewhere on the line
|
||
| C
|
||
// Uploading to aws3 and CreatePostMutation succeeded
|
||
| D;
|
||
|
||
`;
|
||
|
||
exports[`function-declaration.js - flow-verify 1`] = `
|
||
function a(/* comment */) {} // comment
|
||
function b() {} // comment
|
||
function c(/* comment */ argA, argB, argC) {} // comment
|
||
call((/*object*/ row) => {});
|
||
KEYPAD_NUMBERS.map(num => ( // Buttons 0-9
|
||
<div />
|
||
));
|
||
|
||
function f /* f */() {}
|
||
function f (/* args */) {}
|
||
function f () /* returns */ {}
|
||
function f /* f */(/* args */) /* returns */ {}
|
||
|
||
function f /* f */(/* a */ a) {}
|
||
function f /* f */(a /* a */) {}
|
||
function f /* f */(/* a */ a) /* returns */ {}
|
||
|
||
const obj = {
|
||
f1 /* f */() {},
|
||
f2 (/* args */) {},
|
||
f3 () /* returns */ {},
|
||
f4 /* f */(/* args */) /* returns */ {},
|
||
};
|
||
|
||
(function f /* f */() {})();
|
||
(function f (/* args */) {})();
|
||
(function f () /* returns */ {})();
|
||
(function f /* f */(/* args */) /* returns */ {})();
|
||
|
||
class C {
|
||
f/* f */() {}
|
||
}
|
||
class C {
|
||
f(/* args */) {}
|
||
}
|
||
class C {
|
||
f() /* returns */ {}
|
||
}
|
||
class C {
|
||
f/* f */(/* args */) /* returns */ {}
|
||
}
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
function a(/* comment */) {} // comment
|
||
function b() {} // comment
|
||
function c(/* comment */ argA, argB, argC) {} // comment
|
||
call((/*object*/ row) => {});
|
||
KEYPAD_NUMBERS.map((
|
||
num // Buttons 0-9
|
||
) => <div />);
|
||
|
||
function f /* f */() {}
|
||
function f(/* args */) {}
|
||
function f() /* returns */ {}
|
||
function f /* f */(/* args */) /* returns */ {}
|
||
|
||
function f /* f */(/* a */ a) {}
|
||
function f /* f */(a /* a */) {}
|
||
function f /* f */(/* a */ a) /* returns */ {}
|
||
|
||
const obj = {
|
||
f1 /* f */() {},
|
||
f2(/* args */) {},
|
||
f3() /* returns */ {},
|
||
f4 /* f */(/* args */) /* returns */ {}
|
||
};
|
||
|
||
(function f /* f */() {})();
|
||
(function f(/* args */) {})();
|
||
(function f() /* returns */ {})();
|
||
(function f /* f */(/* args */) /* returns */ {})();
|
||
|
||
class C {
|
||
f /* f */() {}
|
||
}
|
||
class C {
|
||
f(/* args */) {}
|
||
}
|
||
class C {
|
||
f() /* returns */ {}
|
||
}
|
||
class C {
|
||
f /* f */(/* args */) /* returns */ {}
|
||
}
|
||
|
||
`;
|
||
|
||
exports[`if.js - flow-verify 1`] = `
|
||
if (1)
|
||
// comment
|
||
{
|
||
false
|
||
}
|
||
// comment
|
||
else if (2)
|
||
true
|
||
// multi
|
||
// ple
|
||
// lines
|
||
else if (3)
|
||
// existing comment
|
||
true
|
||
// okay?
|
||
else if (4) {
|
||
// empty with existing comment
|
||
}
|
||
// comment
|
||
else {
|
||
}
|
||
|
||
if (5) // comment
|
||
true
|
||
|
||
if (6) // comment
|
||
{true}
|
||
else if (7) // comment
|
||
true
|
||
else // comment
|
||
{true}
|
||
|
||
if (8) // comment
|
||
// comment
|
||
{true}
|
||
else if (9) // comment
|
||
// comment
|
||
true
|
||
else // comment
|
||
// comment
|
||
{true}
|
||
|
||
if (10) /* comment */ // comment
|
||
{true}
|
||
else if (11) /* comment */
|
||
true
|
||
else if (12) // comment /* comment */ // comment
|
||
true
|
||
else if (13) /* comment */ /* comment */ // comment
|
||
true
|
||
else /* comment */
|
||
{true}
|
||
|
||
if (14) // comment
|
||
/* comment */
|
||
// comment
|
||
{true}
|
||
else if (15) // comment
|
||
/* comment */
|
||
/* comment */ // comment
|
||
true
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
if (1) {
|
||
// comment
|
||
false;
|
||
}
|
||
// comment
|
||
else if (2) true;
|
||
// multi
|
||
// ple
|
||
// lines
|
||
else if (3)
|
||
// existing comment
|
||
true;
|
||
// okay?
|
||
else if (4) {
|
||
// empty with existing comment
|
||
}
|
||
// comment
|
||
else {
|
||
}
|
||
|
||
if (5)
|
||
// comment
|
||
true;
|
||
|
||
if (6) {
|
||
// comment
|
||
true;
|
||
} else if (7)
|
||
// comment
|
||
true;
|
||
// comment
|
||
else {
|
||
true;
|
||
}
|
||
|
||
if (8) {
|
||
// comment
|
||
// comment
|
||
true;
|
||
} else if (9)
|
||
// comment
|
||
// comment
|
||
true;
|
||
// comment
|
||
// comment
|
||
else {
|
||
true;
|
||
}
|
||
|
||
if (10) {
|
||
/* comment */ // comment
|
||
true;
|
||
} else if (11)
|
||
/* comment */
|
||
true;
|
||
else if (12)
|
||
// comment /* comment */ // comment
|
||
true;
|
||
else if (13)
|
||
/* comment */ /* comment */ // comment
|
||
true;
|
||
/* comment */ else {
|
||
true;
|
||
}
|
||
|
||
if (14) {
|
||
// comment
|
||
/* comment */
|
||
// comment
|
||
true;
|
||
} else if (15)
|
||
// comment
|
||
/* comment */
|
||
/* comment */ // comment
|
||
true;
|
||
|
||
`;
|
||
|
||
exports[`issues.js - flow-verify 1`] = `
|
||
// Does not need to break as it fits in 80 columns
|
||
this.call(a, /* comment */ b);
|
||
|
||
function f(
|
||
someReallyLongArgument: WithSomeLongType,
|
||
someReallyLongArgument2: WithSomeLongType,
|
||
// Trailing comment should stay after
|
||
) {}
|
||
|
||
// Comments should either stay at the end of the line or always before, but
|
||
// not one before and one after.
|
||
throw new ProcessSystemError({
|
||
code: acc.error.code, // Alias of errno
|
||
originalError: acc.error, // Just in case.
|
||
});
|
||
|
||
// Adding a comment stops the pretty printing process and everything is
|
||
// squished in a single line afterward
|
||
export type BuckWebSocketMessage = {
|
||
// Not actually from Buck - this is to let the receiver know that the socket is connected.
|
||
type: 'SocketConnected',
|
||
} | {
|
||
type: 'BuildProgressUpdated',
|
||
progressValue: number,
|
||
} | {
|
||
type: 'BuildFinished',
|
||
exitCode: number,
|
||
} | {
|
||
type: 'BuildStarted',
|
||
} | {
|
||
type: 'ParseStarted',
|
||
} | {
|
||
type: 'ParseFinished',
|
||
} | {
|
||
type: 'RunStarted',
|
||
} | {
|
||
type: 'RunComplete',
|
||
};
|
||
|
||
// Missing one level of indentation because of the comment
|
||
const rootEpic = (actions, store) => (
|
||
combineEpics(...epics)(actions, store)
|
||
// Log errors and continue.
|
||
.catch((err, stream) => {
|
||
getLogger().error(err);
|
||
return stream;
|
||
})
|
||
);
|
||
|
||
// Two extra levels of indentation because of the comment
|
||
export type AsyncExecuteOptions = child_process$execFileOpts & {
|
||
// The contents to write to stdin.
|
||
stdin?: ?string,
|
||
dontLogInNuclide?: ?boolean,
|
||
};
|
||
|
||
// optional trailing comma gets moved all the way to the beginning
|
||
const regex = new RegExp(
|
||
'^\\\\s*' + // beginning of the line
|
||
'name\\\\s*=\\\\s*' + // name =
|
||
'[\\'"]' + // opening quotation mark
|
||
escapeStringRegExp(target.name) + // target name
|
||
'[\\'"]' + // closing quotation mark
|
||
',?$', // optional trailing comma
|
||
);
|
||
|
||
// The comment is moved and doesn't trigger the eslint rule anymore
|
||
import path from 'path'; // eslint-disable-line nuclide-internal/prefer-nuclide-uri
|
||
|
||
// Comments disappear in-between MemberExpressions
|
||
Observable.of(process)
|
||
// Don't complete until we say so!
|
||
.merge(Observable.never())
|
||
// Get the errors.
|
||
.takeUntil(throwOnError ? errors.flatMap(Observable.throw) : errors)
|
||
.takeUntil(exit);
|
||
|
||
// Comments disappear inside of JSX
|
||
<div>
|
||
{/* Some comment */}
|
||
</div>;
|
||
|
||
// Comments in JSX tag are placed in a non optimal way
|
||
<div
|
||
// comment
|
||
/>;
|
||
|
||
// Comments disappear in empty blocks
|
||
if (1) {
|
||
// Comment
|
||
}
|
||
|
||
// Comments trigger invalid JavaScript in-between else if
|
||
if (1) {
|
||
}
|
||
// Comment
|
||
else {
|
||
|
||
}
|
||
|
||
// The comment makes the line break in a weird way
|
||
const result = asyncExecute('non_existing_command', /* args */ []);
|
||
|
||
// The closing paren is printed on the same line as the comment
|
||
foo({}
|
||
// Hi
|
||
);
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
// Does not need to break as it fits in 80 columns
|
||
this.call(a, /* comment */ b);
|
||
|
||
function f(
|
||
someReallyLongArgument: WithSomeLongType,
|
||
someReallyLongArgument2: WithSomeLongType
|
||
// Trailing comment should stay after
|
||
) {}
|
||
|
||
// Comments should either stay at the end of the line or always before, but
|
||
// not one before and one after.
|
||
throw new ProcessSystemError({
|
||
code: acc.error.code, // Alias of errno
|
||
originalError: acc.error // Just in case.
|
||
});
|
||
|
||
// Adding a comment stops the pretty printing process and everything is
|
||
// squished in a single line afterward
|
||
export type BuckWebSocketMessage =
|
||
| {
|
||
// Not actually from Buck - this is to let the receiver know that the socket is connected.
|
||
type: "SocketConnected"
|
||
}
|
||
| {
|
||
type: "BuildProgressUpdated",
|
||
progressValue: number
|
||
}
|
||
| {
|
||
type: "BuildFinished",
|
||
exitCode: number
|
||
}
|
||
| {
|
||
type: "BuildStarted"
|
||
}
|
||
| {
|
||
type: "ParseStarted"
|
||
}
|
||
| {
|
||
type: "ParseFinished"
|
||
}
|
||
| {
|
||
type: "RunStarted"
|
||
}
|
||
| {
|
||
type: "RunComplete"
|
||
};
|
||
|
||
// Missing one level of indentation because of the comment
|
||
const rootEpic = (actions, store) =>
|
||
combineEpics(...epics)(actions, store)
|
||
// Log errors and continue.
|
||
.catch((err, stream) => {
|
||
getLogger().error(err);
|
||
return stream;
|
||
});
|
||
|
||
// Two extra levels of indentation because of the comment
|
||
export type AsyncExecuteOptions = child_process$execFileOpts & {
|
||
// The contents to write to stdin.
|
||
stdin?: ?string,
|
||
dontLogInNuclide?: ?boolean
|
||
};
|
||
|
||
// optional trailing comma gets moved all the way to the beginning
|
||
const regex = new RegExp(
|
||
"^\\\\s*" + // beginning of the line
|
||
"name\\\\s*=\\\\s*" + // name =
|
||
"['\\"]" + // opening quotation mark
|
||
escapeStringRegExp(target.name) + // target name
|
||
"['\\"]" + // closing quotation mark
|
||
",?$" // optional trailing comma
|
||
);
|
||
|
||
// The comment is moved and doesn't trigger the eslint rule anymore
|
||
import path from "path"; // eslint-disable-line nuclide-internal/prefer-nuclide-uri
|
||
|
||
// Comments disappear in-between MemberExpressions
|
||
Observable.of(process)
|
||
// Don't complete until we say so!
|
||
.merge(Observable.never())
|
||
// Get the errors.
|
||
.takeUntil(throwOnError ? errors.flatMap(Observable.throw) : errors)
|
||
.takeUntil(exit);
|
||
|
||
// Comments disappear inside of JSX
|
||
<div>{/* Some comment */}</div>;
|
||
|
||
// Comments in JSX tag are placed in a non optimal way
|
||
<div
|
||
// comment
|
||
/>;
|
||
|
||
// Comments disappear in empty blocks
|
||
if (1) {
|
||
// Comment
|
||
}
|
||
|
||
// Comments trigger invalid JavaScript in-between else if
|
||
if (1) {
|
||
}
|
||
// Comment
|
||
else {
|
||
}
|
||
|
||
// The comment makes the line break in a weird way
|
||
const result = asyncExecute("non_existing_command", /* args */ []);
|
||
|
||
// The closing paren is printed on the same line as the comment
|
||
foo(
|
||
{}
|
||
// Hi
|
||
);
|
||
|
||
`;
|
||
|
||
exports[`jsx.js - flow-verify 1`] = `
|
||
<div>
|
||
{
|
||
/* comment */
|
||
}
|
||
</div>;
|
||
|
||
<div>
|
||
{/* comment */
|
||
}
|
||
</div>;
|
||
|
||
<div>
|
||
{/* comment
|
||
*/
|
||
}
|
||
</div>;
|
||
|
||
<div>
|
||
{a/* comment
|
||
*/
|
||
}
|
||
</div>;
|
||
|
||
<div>
|
||
{/* comment
|
||
*/
|
||
a
|
||
}
|
||
</div>;
|
||
|
||
<div>
|
||
{/* comment */
|
||
}
|
||
</div>;
|
||
|
||
<div>
|
||
{/* comment */}
|
||
</div>;
|
||
|
||
<div>
|
||
{
|
||
// single line comment
|
||
}
|
||
</div>;
|
||
|
||
<div>
|
||
{
|
||
// multiple line comments 1
|
||
// multiple line comments 2
|
||
}
|
||
</div>;
|
||
|
||
<div>
|
||
{
|
||
// multiple mixed comments 1
|
||
/* multiple mixed comments 2 */
|
||
/* multiple mixed comments 3 */
|
||
// multiple mixed comments 4
|
||
}
|
||
</div>;
|
||
|
||
<div>
|
||
{
|
||
// Some very v ery very very merry (xmas) very very long line to break line width limit
|
||
}
|
||
</div>;
|
||
|
||
<div>{/*<div> Some very v ery very very long line to break line width limit </div>*/}</div>;
|
||
|
||
<div>
|
||
{/**
|
||
* JSDoc-y comment in JSX. I wonder what will happen to it?
|
||
*/}
|
||
</div>;
|
||
|
||
<div>
|
||
{
|
||
/**
|
||
* Another JSDoc comment in JSX.
|
||
*/
|
||
}
|
||
</div>;
|
||
|
||
<div
|
||
/**
|
||
* Handles clicks.
|
||
*/
|
||
onClick={() => {}}>
|
||
|
||
</div>;
|
||
|
||
<div
|
||
// comment
|
||
>
|
||
{foo}
|
||
</div>;
|
||
|
||
<div
|
||
className="foo" // comment
|
||
>
|
||
{foo}
|
||
</div>;
|
||
|
||
<div
|
||
className="foo"
|
||
// comment
|
||
>
|
||
{foo}
|
||
</div>;
|
||
|
||
<div // comment
|
||
id="foo"
|
||
>
|
||
{children}
|
||
</div>;
|
||
|
||
<Wrapper>
|
||
{}
|
||
<Component />
|
||
</Wrapper>
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
<div>{/* comment */}</div>;
|
||
|
||
<div>{/* comment */}</div>;
|
||
|
||
<div>
|
||
{/* comment
|
||
*/}
|
||
</div>;
|
||
|
||
<div>
|
||
{
|
||
a
|
||
/* comment
|
||
*/
|
||
}
|
||
</div>;
|
||
|
||
<div>
|
||
{
|
||
/* comment
|
||
*/
|
||
a
|
||
}
|
||
</div>;
|
||
|
||
<div>{/* comment */}</div>;
|
||
|
||
<div>{/* comment */}</div>;
|
||
|
||
<div>
|
||
{
|
||
// single line comment
|
||
}
|
||
</div>;
|
||
|
||
<div>
|
||
{
|
||
// multiple line comments 1
|
||
// multiple line comments 2
|
||
}
|
||
</div>;
|
||
|
||
<div>
|
||
{
|
||
// multiple mixed comments 1
|
||
/* multiple mixed comments 2 */
|
||
/* multiple mixed comments 3 */
|
||
// multiple mixed comments 4
|
||
}
|
||
</div>;
|
||
|
||
<div>
|
||
{
|
||
// Some very v ery very very merry (xmas) very very long line to break line width limit
|
||
}
|
||
</div>;
|
||
|
||
<div>
|
||
{/*<div> Some very v ery very very long line to break line width limit </div>*/}
|
||
</div>;
|
||
|
||
<div>
|
||
{/**
|
||
* JSDoc-y comment in JSX. I wonder what will happen to it?
|
||
*/}
|
||
</div>;
|
||
|
||
<div>
|
||
{/**
|
||
* Another JSDoc comment in JSX.
|
||
*/}
|
||
</div>;
|
||
|
||
<div
|
||
/**
|
||
* Handles clicks.
|
||
*/
|
||
onClick={() => {}}
|
||
/>;
|
||
|
||
<div
|
||
// comment
|
||
>
|
||
{foo}
|
||
</div>;
|
||
|
||
<div
|
||
className="foo" // comment
|
||
>
|
||
{foo}
|
||
</div>;
|
||
|
||
<div
|
||
className="foo"
|
||
// comment
|
||
>
|
||
{foo}
|
||
</div>;
|
||
|
||
<div // comment
|
||
id="foo"
|
||
>
|
||
{children}
|
||
</div>;
|
||
|
||
<Wrapper>
|
||
{}
|
||
<Component />
|
||
</Wrapper>;
|
||
|
||
`;
|
||
|
||
exports[`last-arg.js - flow-verify 1`] = `
|
||
type f = (
|
||
currentRequest: {a: number},
|
||
// TODO this is a very very very very long comment that makes it go > 80 columns
|
||
) => number;
|
||
|
||
f = (
|
||
currentRequest: {a: number},
|
||
// TODO this is a very very very very long comment that makes it go > 80 columns
|
||
): number => {};
|
||
|
||
f = (
|
||
currentRequest: {a: number},
|
||
// TODO this is a very very very very long comment that makes it go > 80 columns
|
||
) => {};
|
||
|
||
f = function(
|
||
currentRequest: {a: number},
|
||
// TODO this is a very very very very long comment that makes it go > 80 columns
|
||
) {};
|
||
|
||
class X {
|
||
f(
|
||
currentRequest: {a: number},
|
||
// TODO this is a very very very very long comment that makes it go > 80 columns
|
||
) {}
|
||
}
|
||
|
||
function f(
|
||
a: number
|
||
// some comment here
|
||
): number {
|
||
return a + 1;
|
||
}
|
||
|
||
var x = {
|
||
getSectionMode(
|
||
pageMetaData: PageMetaData,
|
||
sectionMetaData: SectionMetaData
|
||
/* $FlowFixMe This error was exposed while converting keyMirror
|
||
* to keyMirrorRecursive */
|
||
): $Enum<SectionMode> {
|
||
}
|
||
}
|
||
|
||
class X {
|
||
getSectionMode(
|
||
pageMetaData: PageMetaData,
|
||
sectionMetaData: SectionMetaData = ['unknown']
|
||
/* $FlowFixMe This error was exposed while converting keyMirror
|
||
* to keyMirrorRecursive */
|
||
): $Enum<SectionMode> {
|
||
}
|
||
}
|
||
|
||
class Foo {
|
||
a(lol /*string*/) {}
|
||
|
||
b(lol /*string*/
|
||
) {}
|
||
|
||
d(
|
||
lol /*string*/,
|
||
lol2 /*string*/,
|
||
lol3 /*string*/,
|
||
lol4 /*string*/
|
||
) {}
|
||
|
||
d(
|
||
lol /*string*/,
|
||
lol2 /*string*/,
|
||
lol3 /*string*/,
|
||
lol4 /*string*/
|
||
) /*string*/ {}
|
||
|
||
// prettier-ignore
|
||
c(lol /*string*/
|
||
) {}
|
||
|
||
// prettier-ignore
|
||
d(
|
||
lol /*string*/,
|
||
lol2 /*string*/,
|
||
lol3 /*string*/,
|
||
lol4 /*string*/
|
||
) {}
|
||
|
||
// prettier-ignore
|
||
e(
|
||
lol /*string*/,
|
||
lol2 /*string*/,
|
||
lol3 /*string*/,
|
||
lol4 /*string*/
|
||
) {} /* string*/
|
||
}
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
type f = (
|
||
currentRequest: { a: number }
|
||
// TODO this is a very very very very long comment that makes it go > 80 columns
|
||
) => number;
|
||
|
||
f = (
|
||
currentRequest: { a: number }
|
||
// TODO this is a very very very very long comment that makes it go > 80 columns
|
||
): number => {};
|
||
|
||
f = (
|
||
currentRequest: { a: number }
|
||
// TODO this is a very very very very long comment that makes it go > 80 columns
|
||
) => {};
|
||
|
||
f = function(
|
||
currentRequest: { a: number }
|
||
// TODO this is a very very very very long comment that makes it go > 80 columns
|
||
) {};
|
||
|
||
class X {
|
||
f(
|
||
currentRequest: { a: number }
|
||
// TODO this is a very very very very long comment that makes it go > 80 columns
|
||
) {}
|
||
}
|
||
|
||
function f(
|
||
a: number
|
||
// some comment here
|
||
): number {
|
||
return a + 1;
|
||
}
|
||
|
||
var x = {
|
||
getSectionMode(
|
||
pageMetaData: PageMetaData,
|
||
sectionMetaData: SectionMetaData
|
||
/* $FlowFixMe This error was exposed while converting keyMirror
|
||
* to keyMirrorRecursive */
|
||
): $Enum<SectionMode> {}
|
||
};
|
||
|
||
class X {
|
||
getSectionMode(
|
||
pageMetaData: PageMetaData,
|
||
sectionMetaData: SectionMetaData = ["unknown"]
|
||
/* $FlowFixMe This error was exposed while converting keyMirror
|
||
* to keyMirrorRecursive */
|
||
): $Enum<SectionMode> {}
|
||
}
|
||
|
||
class Foo {
|
||
a(lol /*string*/) {}
|
||
|
||
b(lol /*string*/) {}
|
||
|
||
d(lol /*string*/, lol2 /*string*/, lol3 /*string*/, lol4 /*string*/) {}
|
||
|
||
d(
|
||
lol /*string*/,
|
||
lol2 /*string*/,
|
||
lol3 /*string*/,
|
||
lol4 /*string*/
|
||
) /*string*/ {}
|
||
|
||
// prettier-ignore
|
||
c(lol /*string*/
|
||
) {}
|
||
|
||
// prettier-ignore
|
||
d(
|
||
lol /*string*/,
|
||
lol2 /*string*/,
|
||
lol3 /*string*/,
|
||
lol4 /*string*/
|
||
) {}
|
||
|
||
// prettier-ignore
|
||
e(
|
||
lol /*string*/,
|
||
lol2 /*string*/,
|
||
lol3 /*string*/,
|
||
lol4 /*string*/
|
||
) {} /* string*/
|
||
}
|
||
|
||
`;
|
||
|
||
exports[`preserve-new-line-last.js - flow-verify 1`] = `
|
||
function f() {
|
||
a
|
||
/* eslint-disable */
|
||
}
|
||
|
||
function f() {
|
||
a
|
||
|
||
/* eslint-disable */
|
||
}
|
||
|
||
function name() {
|
||
// comment1
|
||
func1()
|
||
|
||
// comment2
|
||
func2()
|
||
|
||
// comment3 why func3 commented
|
||
// func3()
|
||
}
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
function f() {
|
||
a;
|
||
/* eslint-disable */
|
||
}
|
||
|
||
function f() {
|
||
a;
|
||
|
||
/* eslint-disable */
|
||
}
|
||
|
||
function name() {
|
||
// comment1
|
||
func1();
|
||
|
||
// comment2
|
||
func2();
|
||
|
||
// comment3 why func3 commented
|
||
// func3()
|
||
}
|
||
|
||
`;
|
||
|
||
exports[`return-statement.js - flow-verify 1`] = `
|
||
function jsx() {
|
||
return (
|
||
// Comment
|
||
<div />
|
||
);
|
||
}
|
||
|
||
function unary() {
|
||
return (
|
||
// Comment
|
||
!!x
|
||
);
|
||
}
|
||
|
||
function numericLiteralNoParen() {
|
||
return 1337; // Comment
|
||
}
|
||
|
||
function logical() {
|
||
return (
|
||
// Reason for 42
|
||
42
|
||
) && 84
|
||
}
|
||
|
||
function binary() {
|
||
return (
|
||
// Reason for 42
|
||
42
|
||
) * 84
|
||
}
|
||
|
||
function binaryInBinaryLeft() {
|
||
return (
|
||
// Reason for 42
|
||
42
|
||
) * 84 + 2
|
||
}
|
||
|
||
function binaryInBinaryRight() {
|
||
return (
|
||
// Reason for 42
|
||
42
|
||
) + 84 * 2
|
||
}
|
||
|
||
function conditional() {
|
||
return (
|
||
// Reason for 42
|
||
42
|
||
) ? 1 : 2
|
||
}
|
||
|
||
function binaryInConditional() {
|
||
return (
|
||
// Reason for 42
|
||
42
|
||
) * 3 ? 1 : 2
|
||
}
|
||
|
||
function call() {
|
||
return (
|
||
// Reason for a
|
||
a
|
||
)()
|
||
}
|
||
|
||
function memberInside() {
|
||
return (
|
||
// Reason for a.b
|
||
a.b
|
||
).c
|
||
}
|
||
|
||
function memberOutside() {
|
||
return (
|
||
// Reason for a
|
||
a
|
||
).b.c
|
||
}
|
||
|
||
function memberInAndOutWithCalls() {
|
||
return (
|
||
// Reason for a
|
||
aFunction.b()
|
||
).c.d()
|
||
}
|
||
|
||
function excessiveEverything() {
|
||
return (
|
||
// Reason for stuff
|
||
a.b() * 3 + 4 ? (a\`hi\`, 1) ? 1 : 1 : 1
|
||
)
|
||
}
|
||
|
||
// See https://github.com/prettier/prettier/issues/2392
|
||
// function sequenceExpression() {
|
||
// return (
|
||
// // Reason for a
|
||
// a
|
||
// ), b
|
||
// }
|
||
|
||
function sequenceExpressionInside() {
|
||
return ( // Reason for a
|
||
a, b
|
||
);
|
||
}
|
||
|
||
function taggedTemplate() {
|
||
return (
|
||
// Reason for a
|
||
a
|
||
)\`b\`
|
||
}
|
||
|
||
function inlineComment() {
|
||
return (
|
||
/* hi */ 42
|
||
) || 42
|
||
}
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
function jsx() {
|
||
return (
|
||
// Comment
|
||
<div />
|
||
);
|
||
}
|
||
|
||
function unary() {
|
||
return (
|
||
// Comment
|
||
!!x
|
||
);
|
||
}
|
||
|
||
function numericLiteralNoParen() {
|
||
return 1337; // Comment
|
||
}
|
||
|
||
function logical() {
|
||
return (
|
||
// Reason for 42
|
||
42 && 84
|
||
);
|
||
}
|
||
|
||
function binary() {
|
||
return (
|
||
// Reason for 42
|
||
42 * 84
|
||
);
|
||
}
|
||
|
||
function binaryInBinaryLeft() {
|
||
return (
|
||
// Reason for 42
|
||
42 *
|
||
84 +
|
||
2
|
||
);
|
||
}
|
||
|
||
function binaryInBinaryRight() {
|
||
return (
|
||
// Reason for 42
|
||
42 +
|
||
84 * 2
|
||
);
|
||
}
|
||
|
||
function conditional() {
|
||
return (
|
||
// Reason for 42
|
||
42
|
||
? 1
|
||
: 2
|
||
);
|
||
}
|
||
|
||
function binaryInConditional() {
|
||
return (
|
||
// Reason for 42
|
||
42 * 3
|
||
? 1
|
||
: 2
|
||
);
|
||
}
|
||
|
||
function call() {
|
||
return (
|
||
// Reason for a
|
||
a()
|
||
);
|
||
}
|
||
|
||
function memberInside() {
|
||
return (
|
||
// Reason for a.b
|
||
a.b.c
|
||
);
|
||
}
|
||
|
||
function memberOutside() {
|
||
return (
|
||
// Reason for a
|
||
a.b.c
|
||
);
|
||
}
|
||
|
||
function memberInAndOutWithCalls() {
|
||
return (
|
||
aFunction
|
||
.b// Reason for a
|
||
()
|
||
.c.d()
|
||
);
|
||
}
|
||
|
||
function excessiveEverything() {
|
||
return (
|
||
// Reason for stuff
|
||
a.b() * 3 + 4 ? ((a\`hi\`, 1) ? 1 : 1) : 1
|
||
);
|
||
}
|
||
|
||
// See https://github.com/prettier/prettier/issues/2392
|
||
// function sequenceExpression() {
|
||
// return (
|
||
// // Reason for a
|
||
// a
|
||
// ), b
|
||
// }
|
||
|
||
function sequenceExpressionInside() {
|
||
return (
|
||
// Reason for a
|
||
a, b
|
||
);
|
||
}
|
||
|
||
function taggedTemplate() {
|
||
return (
|
||
// Reason for a
|
||
a\`b\`
|
||
);
|
||
}
|
||
|
||
function inlineComment() {
|
||
return /* hi */ 42 || 42;
|
||
}
|
||
|
||
`;
|
||
|
||
exports[`single-star-jsdoc.js - flow-verify 1`] = `
|
||
/*
|
||
* Looking good!
|
||
*/
|
||
|
||
if(true) {
|
||
/*
|
||
* Oh no
|
||
*/
|
||
}
|
||
|
||
/** first line
|
||
* second line
|
||
* third line */
|
||
|
||
/* first line
|
||
* second line
|
||
* third line */
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
/*
|
||
* Looking good!
|
||
*/
|
||
|
||
if (true) {
|
||
/*
|
||
* Oh no
|
||
*/
|
||
}
|
||
|
||
/** first line
|
||
* second line
|
||
* third line */
|
||
|
||
/* first line
|
||
* second line
|
||
* third line */
|
||
|
||
`;
|
||
|
||
exports[`switch.js - flow-verify 1`] = `
|
||
switch (node && node.type) {
|
||
case "Property":
|
||
case "MethodDefinition":
|
||
prop = node.key;
|
||
break;
|
||
|
||
case "MemberExpression":
|
||
prop = node.property;
|
||
break;
|
||
|
||
// no default
|
||
}
|
||
|
||
switch (foo) {
|
||
case "bar":
|
||
doThing()
|
||
|
||
// no default
|
||
}
|
||
|
||
switch (foo) {
|
||
case "bar": //comment
|
||
doThing(); //comment
|
||
|
||
case "baz":
|
||
doOtherThing(); //comment
|
||
|
||
}
|
||
|
||
switch (foo) {
|
||
case "bar": {
|
||
doThing();
|
||
} //comment
|
||
|
||
case "baz": {
|
||
doThing();
|
||
} //comment
|
||
}
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
switch (node && node.type) {
|
||
case "Property":
|
||
case "MethodDefinition":
|
||
prop = node.key;
|
||
break;
|
||
|
||
case "MemberExpression":
|
||
prop = node.property;
|
||
break;
|
||
|
||
// no default
|
||
}
|
||
|
||
switch (foo) {
|
||
case "bar":
|
||
doThing();
|
||
|
||
// no default
|
||
}
|
||
|
||
switch (foo) {
|
||
case "bar": //comment
|
||
doThing(); //comment
|
||
|
||
case "baz":
|
||
doOtherThing(); //comment
|
||
}
|
||
|
||
switch (foo) {
|
||
case "bar": {
|
||
doThing();
|
||
} //comment
|
||
|
||
case "baz": {
|
||
doThing();
|
||
} //comment
|
||
}
|
||
|
||
`;
|
||
|
||
exports[`template-literal.js - flow-verify 1`] = `
|
||
\`
|
||
\${a // comment
|
||
}
|
||
|
||
\${b /* comment */}
|
||
|
||
\${/* comment */ c /* comment */}
|
||
|
||
\${// comment
|
||
d //comment
|
||
};
|
||
\`
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
\`
|
||
\${
|
||
a // comment
|
||
}
|
||
|
||
\${b /* comment */}
|
||
|
||
\${/* comment */ c /* comment */}
|
||
|
||
\${
|
||
// comment
|
||
d //comment
|
||
};
|
||
\`;
|
||
|
||
`;
|
||
|
||
exports[`trailing_space.js - flow-verify 1`] = `
|
||
#!/there/is-space-here->
|
||
|
||
// Do not trim trailing whitespace from this source file!
|
||
|
||
// There is some space here ->
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
#!/there/is-space-here->
|
||
|
||
// Do not trim trailing whitespace from this source file!
|
||
|
||
// There is some space here ->
|
||
|
||
`;
|
||
|
||
exports[`trailing-jsdocs.js - flow-verify 1`] = `
|
||
const CONNECTION_STATUS = exports.CONNECTION_STATUS = {
|
||
CLOSED: Object.freeze({ kind: 'CLOSED' }),
|
||
CONNECTED: Object.freeze({ kind: 'CONNECTED' }),
|
||
CONNECTING: Object.freeze({ kind: 'CONNECTING' }),
|
||
NOT_CONNECTED: Object.freeze({ kind: 'NOT_CONNECTED' }) };
|
||
|
||
/* A comment */ /**
|
||
* A type that can be written to a buffer.
|
||
*/ /**
|
||
* Describes the connection status of a ReactiveSocket/DuplexConnection.
|
||
* - NOT_CONNECTED: no connection established or pending.
|
||
* - CONNECTING: when \`connect()\` has been called but a connection is not yet
|
||
* established.
|
||
* - CONNECTED: when a connection is established.
|
||
* - CLOSED: when the connection has been explicitly closed via \`close()\`.
|
||
* - ERROR: when the connection has been closed for any other reason.
|
||
*/ /**
|
||
* A contract providing different interaction models per the [ReactiveSocket protocol]
|
||
* (https://github.com/ReactiveSocket/reactivesocket/blob/master/Protocol.md).
|
||
*/ /**
|
||
* A single unit of data exchanged between the peers of a \`ReactiveSocket\`.
|
||
*/
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
const CONNECTION_STATUS = (exports.CONNECTION_STATUS = {
|
||
CLOSED: Object.freeze({ kind: "CLOSED" }),
|
||
CONNECTED: Object.freeze({ kind: "CONNECTED" }),
|
||
CONNECTING: Object.freeze({ kind: "CONNECTING" }),
|
||
NOT_CONNECTED: Object.freeze({ kind: "NOT_CONNECTED" })
|
||
});
|
||
|
||
/* A comment */
|
||
/**
|
||
* A type that can be written to a buffer.
|
||
*/
|
||
/**
|
||
* Describes the connection status of a ReactiveSocket/DuplexConnection.
|
||
* - NOT_CONNECTED: no connection established or pending.
|
||
* - CONNECTING: when \`connect()\` has been called but a connection is not yet
|
||
* established.
|
||
* - CONNECTED: when a connection is established.
|
||
* - CLOSED: when the connection has been explicitly closed via \`close()\`.
|
||
* - ERROR: when the connection has been closed for any other reason.
|
||
*/
|
||
/**
|
||
* A contract providing different interaction models per the [ReactiveSocket protocol]
|
||
* (https://github.com/ReactiveSocket/reactivesocket/blob/master/Protocol.md).
|
||
*/
|
||
/**
|
||
* A single unit of data exchanged between the peers of a \`ReactiveSocket\`.
|
||
*/
|
||
|
||
`;
|
||
|
||
exports[`try.js - flow-verify 1`] = `
|
||
// Comment 1
|
||
try { // Comment 2
|
||
// Comment 3
|
||
}
|
||
// Comment 4
|
||
catch(e) { // Comment 5
|
||
// Comment 6
|
||
}
|
||
// Comment 7
|
||
finally { // Comment 8
|
||
// Comment 9
|
||
}
|
||
// Comment 10
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
// Comment 1
|
||
try {
|
||
// Comment 2
|
||
// Comment 3
|
||
} catch (e) {
|
||
// Comment 4
|
||
// Comment 5
|
||
// Comment 6
|
||
} finally {
|
||
// Comment 7
|
||
// Comment 8
|
||
// Comment 9
|
||
}
|
||
// Comment 10
|
||
|
||
`;
|
||
|
||
exports[`variable_declarator.js - flow-verify 1`] = `
|
||
let obj = // Comment
|
||
{
|
||
key: 'val'
|
||
}
|
||
|
||
let obj // Comment
|
||
= {
|
||
key: 'val'
|
||
}
|
||
|
||
let obj = { // Comment
|
||
key: 'val'
|
||
}
|
||
|
||
let obj = {
|
||
// Comment
|
||
key: 'val'
|
||
}
|
||
|
||
let obj = // Comment
|
||
[
|
||
'val'
|
||
]
|
||
|
||
let obj // Comment
|
||
= [
|
||
'val'
|
||
]
|
||
|
||
let obj = [ // Comment
|
||
'val'
|
||
]
|
||
|
||
let obj = [
|
||
// Comment
|
||
'val'
|
||
]
|
||
|
||
let obj = // Comment
|
||
\`val\`;
|
||
|
||
let obj = // Comment
|
||
\`
|
||
val
|
||
val
|
||
\`;
|
||
|
||
let obj = // Comment
|
||
tag\`val\`;
|
||
|
||
let obj = // Comment
|
||
tag\`
|
||
val
|
||
val
|
||
\`;
|
||
|
||
let // Comment
|
||
foo = 'val';
|
||
|
||
let // Comment
|
||
foo = 'val',
|
||
bar = 'val';
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
let obj =
|
||
// Comment
|
||
{
|
||
key: "val"
|
||
};
|
||
|
||
let obj =
|
||
// Comment
|
||
{
|
||
key: "val"
|
||
};
|
||
|
||
let obj = {
|
||
// Comment
|
||
key: "val"
|
||
};
|
||
|
||
let obj = {
|
||
// Comment
|
||
key: "val"
|
||
};
|
||
|
||
let obj =
|
||
// Comment
|
||
["val"];
|
||
|
||
let obj =
|
||
// Comment
|
||
["val"];
|
||
|
||
let obj = [
|
||
// Comment
|
||
"val"
|
||
];
|
||
|
||
let obj = [
|
||
// Comment
|
||
"val"
|
||
];
|
||
|
||
let obj =
|
||
// Comment
|
||
\`val\`;
|
||
|
||
let obj =
|
||
// Comment
|
||
\`
|
||
val
|
||
val
|
||
\`;
|
||
|
||
let obj =
|
||
// Comment
|
||
tag\`val\`;
|
||
|
||
let obj =
|
||
// Comment
|
||
tag\`
|
||
val
|
||
val
|
||
\`;
|
||
|
||
let // Comment
|
||
foo = "val";
|
||
|
||
let // Comment
|
||
foo = "val",
|
||
bar = "val";
|
||
|
||
`;
|
||
|
||
exports[`while.js - flow-verify 1`] = `
|
||
while(
|
||
true
|
||
// Comment
|
||
) {}
|
||
|
||
while(true)// Comment
|
||
{}
|
||
|
||
while(true){}// Comment
|
||
|
||
while(true)/*Comment*/{}
|
||
|
||
while(
|
||
true // Comment
|
||
&& true // Comment
|
||
){}
|
||
|
||
while(true) {} // comment
|
||
|
||
while(true) /* comment */ ++x;
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
while (
|
||
true
|
||
// Comment
|
||
) {}
|
||
|
||
while (true) {
|
||
// Comment
|
||
}
|
||
|
||
while (true) {} // Comment
|
||
|
||
while (true) {
|
||
/*Comment*/
|
||
}
|
||
|
||
while (
|
||
true && // Comment
|
||
true // Comment
|
||
) {}
|
||
|
||
while (true) {} // comment
|
||
|
||
while (true) /* comment */ ++x;
|
||
|
||
`;
|