Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle reselect's createSelector as function composition #5430

Merged
merged 1 commit into from Nov 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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])
);