Skip to content

Commit

Permalink
fix(javascript): handle createSelector as function composition (#5430)
Browse files Browse the repository at this point in the history
fixes #5285
  • Loading branch information
ThiefMaster authored and suchipi committed Nov 10, 2018
1 parent 164801a commit 6dcc7ed
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/language-js/printer-estree.js
Expand Up @@ -3780,7 +3780,8 @@ const functionCompositionFunctionNames = new Set([
"composeK", // Ramda
"flow", // Lodash
"flowRight", // Lodash
"connect" // Redux
"connect", // Redux
"createSelector" // Reselect
]);

function isFunctionCompositionFunction(node) {
Expand Down
29 changes: 29 additions & 0 deletions tests/functional_composition/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -390,6 +390,35 @@ const ArtistInput = connect(
`;

exports[`reselect_createselector.js - flow-verify 1`] = `
import { createSelector } from 'reselect';
const resolve = createSelector(
getIds,
getObjects,
(ids, objects) => ids.map(id => objects[id])
);
const resolve = createSelector(
[getIds, getObjects],
(ids, objects) => ids.map(id => objects[id])
);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import { createSelector } from "reselect";
const resolve = createSelector(
getIds,
getObjects,
(ids, objects) => ids.map(id => objects[id])
);
const resolve = createSelector(
[getIds, getObjects],
(ids, objects) => ids.map(id => objects[id])
);
`;

exports[`rxjs_pipe.js - flow-verify 1`] = `
import { range } from 'rxjs/observable/range';
import { map, filter, scan } from 'rxjs/operators';
Expand Down
12 changes: 12 additions & 0 deletions tests/functional_composition/reselect_createselector.js
@@ -0,0 +1,12 @@
import { createSelector } from 'reselect';

const resolve = createSelector(
getIds,
getObjects,
(ids, objects) => ids.map(id => objects[id])
);

const resolve = createSelector(
[getIds, getObjects],
(ids, objects) => ids.map(id => objects[id])
);

0 comments on commit 6dcc7ed

Please sign in to comment.