arrow functions formatting tests
ADD
packages/@romejs/js-formatter/test-fixtures/arrow/arrow-call/input.js
+const testResults = results.testResults.map(testResult =>
+ formatResult(testResult, formatter, reporter)
+ );
+
+ it('mocks regexp instances', () => {
+ expect(
+ () => moduleMocker.generateFromMetadata(moduleMocker.getMetadata(/a/)),
+ ).not.toThrow();
+ });
+
+ expect(() => asyncRequest({ url: "/test-endpoint" }))
+ .toThrowError(/Required parameter/);
+
+ expect(() => asyncRequest({ url: "/test-endpoint-but-with-a-long-url" }))
+ .toThrowError(/Required parameter/);
+
+ expect(() => asyncRequest({ url: "/test-endpoint-but-with-a-suuuuuuuuper-long-url" }))
+ .toThrowError(/Required parameter/);
+
+ expect(() => asyncRequest({ type: "foo", url: "/test-endpoint" }))
+ .not.toThrowError();
+
+ expect(() => asyncRequest({ type: "foo", url: "/test-endpoint-but-with-a-long-url" }))
+ .not.toThrowError();
+
+ const a = Observable
+ .fromPromise(axiosInstance.post('/carts/mine'))
+ .map((response) => response.data)
+
+ const b = Observable.fromPromise(axiosInstance.get(url))
+ .map((response) => response.data)
+
+ func(
+ veryLoooooooooooooooooooooooongName,
+ veryLooooooooooooooooooooooooongName =>
+ veryLoooooooooooooooongName.something()
+ );
+
+ const composition = (ViewComponent, ContainerComponent) =>
+ class extends React.Component {
+ static propTypes = {};
+ };
+
+ promise.then(result => result.veryLongVariable.veryLongPropertyName > someOtherVariable ? "ok" : "fail");
\ No newline at end of file

ADD
packages/@romejs/js-formatter/test-fixtures/arrow/arrow-call/output.js
+const testResults = results.testResults.map((testResult) => formatResult(testResult, formatter, reporter));
+
+it('mocks regexp instances', () => {
+ expect(() => moduleMocker.generateFromMetadata(moduleMocker.getMetadata(/a/))).not.toThrow();
+});
+
+expect(() => asyncRequest({url: '/test-endpoint'})).toThrowError(/Required parameter/);
+
+expect(() => asyncRequest({url: '/test-endpoint-but-with-a-long-url'})).toThrowError(/Required parameter/);
+
+expect(() => asyncRequest({url: '/test-endpoint-but-with-a-suuuuuuuuper-long-url'})).toThrowError(/Required parameter/);
+
+expect(() => asyncRequest({type: 'foo', url: '/test-endpoint'})).not.toThrowError();
+
+expect(() => asyncRequest({type: 'foo', url: '/test-endpoint-but-with-a-long-url'})).not.toThrowError();
+
+const a = Observable.fromPromise(axiosInstance.post('/carts/mine')).map((response) => response.data);
+
+const b = Observable.fromPromise(axiosInstance.get(url)).map((response) => response.data);
+
+func(veryLoooooooooooooooooooooooongName, (veryLooooooooooooooooooooooooongName) => veryLoooooooooooooooongName.something());
+
+const composition = (ViewComponent, ContainerComponent) => class extends React.Component {
+ static propTypes = {};
+};
+
+promise.then((result) => result.veryLongVariable.veryLongPropertyName > someOtherVariable ? 'ok' : 'fail');

ADD
packages/@romejs/js-formatter/test-fixtures/arrow/currying/input.js
+const fn = b => c => d => {
+ return 3;
+};
+
+const foo = (a, b) => c => d => {
+ return 3;
+};
+
+const bar = a => b => c => a + b + c
+
+const mw = store => next => action => {
+ return next(action)
+}
+
+const middleware = options => (req, res, next) => {
+ // ...
+};
\ No newline at end of file

ADD
packages/@romejs/js-formatter/test-fixtures/arrow/currying/output.js
+const fn = (b) => (c) => (d) => {
+ return 3;
+};
+
+const foo = (a, b) => (c) => (d) => {
+ return 3;
+};
+
+const bar = (a) => (b) => (c) => a + b + c;
+
+const mw = (store) => (next) => (action) => {
+ return next(action);
+};
+
+const middleware = (options) => (req, res, next
+// ...
+) => {
+};

ADD
packages/@romejs/js-formatter/test-fixtures/arrow/nested/input.js
+Seq(typeDef.interface.groups).forEach(group =>
+ Seq(group.members).forEach((member, memberName) =>
+ markdownDoc(
+ member.doc,
+ { typePath: typePath.concat(memberName.slice(1)),
+ signatures: member.signatures }
+ )
+ )
+)
+
+const promiseFromCallback = fn =>
+ new Promise((resolve, reject) =>
+ fn((err, result) => {
+ if (err) return reject(err);
+ return resolve(result);
+ })
+ );
+
+runtimeAgent.getProperties(
+ objectId,
+ false, // ownProperties
+ false, // accessorPropertiesOnly
+ false, // generatePreview
+ (error, properties, internalProperties) => {
+ return 1
+ },
+);
\ No newline at end of file

ADD
packages/@romejs/js-formatter/test-fixtures/arrow/nested/output.js
+Seq(typeDef.interface.groups).forEach((group) => Seq(group.members).forEach((member, memberName) => markdownDoc(member.doc, {
+ typePath: typePath.concat(memberName.slice(1)),
+ signatures: member.signatures,
+})));
+
+const promiseFromCallback = (fn) => new Promise((resolve, reject) => fn((err, result) => {
+ if (err) return reject(err);
+ return resolve(result);
+}));
+
+runtimeAgent.getProperties(objectId, false, // ownProperties
+false, // accessorPropertiesOnly
+false, // generatePreview
+(error, properties, internalProperties) => {
+ return 1;
+});

ADD
packages/@romejs/js-formatter/test-fixtures/arrow/params/input.js
+fooooooooooooooooooooooooooooooooooooooooooooooooooo(action => next =>
+ dispatch(action),
+);
+
+foo(
+ ({
+ a,
+
+ b
+ }) => {}
+);
+
+foo(
+ ({
+ a,
+ b
+
+ }) => {}
+);
+
+foo(
+ ({
+ a,
+ b
+ }) => {}
+);
+
+foo(
+ a,
+ ({
+ a,
+
+ b
+ }) => {}
+)
+
+foo(
+ ({
+ a,
+
+ b
+ }) => a
+);
+
+foo(
+ ({
+ a,
+ b
+ }) => a
+);
+
+foo(
+ ({
+ a,
+ b
+
+ }) => a
+);
+
+foo(
+ ({
+ a: {
+ a,
+
+ b
+ }
+ }) => {}
+);
+
+foo(
+ ({
+ a: {
+ b: {
+ c,
+
+ d
+ }
+ }
+ }) => {}
+);
+
+foo(
+ ({
+ a: {
+ b: {
+ c: {
+ d,
+
+ e
+ }
+ }
+ }
+ }) => {}
+);
+
+foo(
+ ({
+ a: {
+ a,
+
+ b
+ }
+ }) => a
+);
+
+foo(
+ ({
+ a: {
+ b: {
+ c,
+
+ d
+ }
+ }
+ }) => a
+);
+
+foo(
+ ({
+ a: {
+ b: {
+ c: {
+ d,
+
+ e
+ }
+ }
+ }
+ }) => a
+);
+
+foo(
+ ([
+ {
+ a: {
+ b: {
+ c: {
+ d,
+
+ e
+ }
+ }
+ }
+ }
+ ]) => {}
+);
+
+foo(
+ ([
+ ...{
+ a: {
+ b: {
+ c: {
+ d,
+
+ e
+ }
+ }
+ }
+ }
+ ]) => {}
+);
+
+foo(
+ (
+ n = {
+ a: {
+ b: {
+ c: {
+ d,
+
+ e
+ }
+ }
+ }
+ }
+ ) => {}
+);
+
+foo(
+ ({
+ x: [
+ {
+ a,
+
+ b
+ }
+ ]
+ }) => {}
+);
+
+foo(
+ (
+ a = [
+ {
+ a,
+
+ b
+ }
+ ]
+ ) => a
+);
+
+foo(
+ ([
+ [
+ {
+ a,
+
+ b
+ }
+ ]
+ ]) => {}
+);
+
+foo(
+ ([
+ [
+ [
+ [
+ {
+ a,
+ b: {
+ c,
+ d: {
+ e,
+
+ f
+ }
+ }
+ }
+ ]
+ ]
+ ]
+ ]) => {}
+);
+
+foo(
+ (
+ ...{
+ a,
+
+ b
+ }
+ ) => {}
+);
+
+foo(
+ (
+ ...[
+ {
+ a,
+
+ b
+ }
+ ]
+ ) => {}
+);
+
+foo(
+ ([
+ ...[
+ {
+ a,
+
+ b
+ }
+ ]
+ ]) => {}
+);
+
+foo(
+ (
+ a = [{
+ a,
+
+ b
+ }]
+ ) => {}
+);
+
+foo(
+ (
+ a = (({
+ a,
+
+ b
+ }) => {})()
+ ) => {}
+);
+
+foo(
+ (
+ a = f({
+ a,
+
+ b
+ })
+ ) => {}
+);
+
+foo(
+ (
+ a = ({
+ a,
+
+ b
+ }) => {}
+ ) => {}
+);
+
+foo(
+ (
+ a = 1 +
+ f({
+ a,
+
+ b
+ })
+ ) => {}
+);
\ No newline at end of file

ADD
packages/@romejs/js-formatter/test-fixtures/arrow/params/output.js
+fooooooooooooooooooooooooooooooooooooooooooooooooooo((action) => (next) => dispatch(action));
+
+foo(({
+ a,
+
+ b,
+}) => {});
+
+foo(({
+ a,
+ b,
+}) => {});
+
+foo(({
+ a,
+ b,
+}) => {});
+
+foo(a, ({
+ a,
+
+ b,
+}) => {});
+
+foo(({
+ a,
+
+ b,
+}) => a);
+
+foo(({
+ a,
+ b,
+}) => a);
+
+foo(({
+ a,
+ b,
+}) => a);
+
+foo(({
+ a: {
+ a,
+
+ b,
+ },
+}) => {});
+
+foo(({
+ a: {
+ b: {
+ c,
+
+ d,
+ },
+ },
+}) => {});
+
+foo(({
+ a: {
+ b: {
+ c: {
+ d,
+
+ e,
+ },
+ },
+ },
+}) => {});
+
+foo(({
+ a: {
+ a,
+
+ b,
+ },
+}) => a);
+
+foo(({
+ a: {
+ b: {
+ c,
+
+ d,
+ },
+ },
+}) => a);
+
+foo(({
+ a: {
+ b: {
+ c: {
+ d,
+
+ e,
+ },
+ },
+ },
+}) => a);
+
+foo(([
+ {
+ a: {
+ b: {
+ c: {
+ d,
+
+ e,
+ },
+ },
+ },
+ },
+]) => {});
+
+foo(([
+
+...{
+ a: {
+ b: {
+ c: {
+ d,
+
+ e,
+ },
+ },
+ },
+}]) => {});
+
+foo((n = {
+ a: {
+ b: {
+ c: {
+ d,
+
+ e,
+ },
+ },
+ },
+}) => {});
+
+foo(({
+ x: [
+ {
+ a,
+
+ b,
+ },
+ ],
+}) => {});
+
+foo((a = [
+ {
+ a,
+
+ b,
+ },
+]) => a);
+
+foo(([
+ [
+ {
+ a,
+
+ b,
+ },
+ ],
+]) => {});
+
+foo(([
+ [
+ [
+ [
+ {
+ a,
+ b: {
+ c,
+ d: {
+ e,
+
+ f,
+ },
+ },
+ },
+ ],
+ ],
+ ],
+]) => {});
+
+foo((...{
+ a,
+
+ b,
+}) => {});
+
+foo((...[
+ {
+ a,
+
+ b,
+ },
+]) => {});
+
+foo(([
+
+...[
+ {
+ a,
+
+ b,
+ },
+]]) => {});
+
+foo((a = [
+ {
+ a,
+
+ b,
+ },
+]) => {});
+
+foo((a = (({
+ a,
+
+ b,
+}) => {})()) => {});
+
+foo((a = f({
+ a,
+
+ b,
+})) => {});
+
+foo((a = ({
+ a,
+
+ b,
+}) => {}) => {});
+
+foo((a = 1 + f({
+ a,
+
+ b,
+})) => {});

arrow functions formatting tests