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

Format all files #712

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
},
"rules": {
"array-bracket-spacing": [0],
"comma-dangle": [2, "never"],
"eol-last": 2,
"no-multiple-empty-lines": 2,
"object-curly-spacing": [2, "always"],
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test-types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ jobs:
'node-standard',
'node-esm',
'react-native',
'expo'
'expo',
]
steps:
- name: Checkout repo
Expand Down
1 change: 0 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"arrowParens": "avoid"
}
18 changes: 9 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const mySelector = createSelector(
values => {
console.log('calling..')
return values.reduce((acc, val) => acc + val, 0)
}
},
)

var createSelector = require('./dist/reselect.js').createSelector
Expand All @@ -50,7 +50,7 @@ const mySelector = createSelector(
values => {
console.log('calling..')
return values.reduce((acc, val) => acc + val, 0)
}
},
)

var state1 = { values: [1, 2, 3, 4, 5, 6, 7, 8, 9] }
Expand Down Expand Up @@ -189,8 +189,8 @@ const structuredSelector = createSelector(
(a, b, c) => ({
a,
b,
c
})
c,
}),
)
```

Expand All @@ -202,7 +202,7 @@ const mySelectorB = state => state.b

const structuredSelector = createStructuredSelector({
x: mySelectorA,
y: mySelectorB
y: mySelectorB,
})

const result = structuredSelector({ a: 1, b: 2 }) // will produce {x: 1, y: 2}
Expand Down Expand Up @@ -256,7 +256,7 @@ Selector creators can receive a variadic number of dependencies as well as an ar
```js
const selector = createSelector(
[state => state.a, state => state.b],
(a, b) => a * b
(a, b) => a * b,
)
```

Expand All @@ -266,7 +266,7 @@ const selector = createSelector(
const selector = createSelector(
state => state.a,
state => state.b,
(a, b) => a * b
(a, b) => a * b,
)
```

Expand All @@ -279,7 +279,7 @@ const selector = createSelector(
state => state.a,
(state, props) => state.b * props.c,
(_, props) => props.d,
(a, bc, d) => a + bc + d
(a, bc, d) => a + bc + d,
)
```

Expand All @@ -297,7 +297,7 @@ const selector = customSelectorCreator(
(a, b) => {
called++
return a + b
}
},
)
assert.equal(selector({ a: 1, b: 2 }), 3)
assert.equal(selector({ a: 1, b: 2 }), 3)
Expand Down
10 changes: 5 additions & 5 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# CREDITS

* Based on a proposal for Redux by [Robert Binna](https://github.com/speedskater) and Philip Spitzlinger.
- Based on a proposal for Redux by [Robert Binna](https://github.com/speedskater) and Philip Spitzlinger.
Lots of the basic structure of the code is thanks to this.

* Refactored into reselect library by Martijn Faassen and Lee Bannard
- Refactored into reselect library by Martijn Faassen and Lee Bannard
at the React Europe Hackathon 2015. Also added tests.

* Contributors: Lee Bannard, Martijn Faassen, Robert Binna, Alex
- Contributors: Lee Bannard, Martijn Faassen, Robert Binna, Alex
Guerra, ryanatkn, Adam Royle, Christian Schuhmann, Jason Huang,
Daniel Barreto, Mihail Diordiev, Daniela Borges, Philip Spitzlinger,
C. T. Lin, SpainTrain, Mark Dalgleish, Brian Ng, 长天之云, Michael Lancaster,
Expand All @@ -19,6 +19,6 @@
Whien, Sergei Egorov, Jim Bolla, Carl Bernardo, Daniel Lytkin, John Haley,
alex3165,

* Inspired by getters in Nuclear.js and subscriptions in re-frame.
- Inspired by getters in Nuclear.js and subscriptions in re-frame.

* Special thanks to [David Edmonson](https://github.com/threehams) for maintaining the Typescript type definitions.
- Special thanks to [David Edmonson](https://github.com/threehams) for maintaining the Typescript type definitions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ interface RootState {
const state: RootState = {
todos: [
{ id: 0, completed: false },
{ id: 1, completed: true }
{ id: 1, completed: true },
],
alerts: [
{ id: 0, read: false },
{ id: 1, read: true }
]
{ id: 1, read: true },
],
}

const selectCompletedTodos = (state: RootState) => {
Expand All @@ -88,7 +88,7 @@ const memoizedSelectCompletedTodos = createSelector(
todos => {
console.log('memoized selector ran')
return todos.filter(todo => todo.completed === true)
}
},
)

memoizedSelectCompletedTodos(state) // memoized selector ran
Expand All @@ -98,7 +98,7 @@ memoizedSelectCompletedTodos(state)
console.log(selectCompletedTodos(state) === selectCompletedTodos(state)) //=> false

console.log(
memoizedSelectCompletedTodos(state) === memoizedSelectCompletedTodos(state)
memoizedSelectCompletedTodos(state) === memoizedSelectCompletedTodos(state),
) //=> true
```

Expand All @@ -121,7 +121,7 @@ The below example serves as a visual aid:
```ts
const outputSelector = createSelector(
[inputSelector1, inputSelector2, inputSelector3], // synonymous with `dependencies`.
resultFunc // Result function
resultFunc, // Result function
)
```

Expand Down
8 changes: 4 additions & 4 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
comment:
layout: "reach, diff, flags, files"
layout: 'reach, diff, flags, files'
behavior: default
require_changes: false # if true: only post the comment if coverage changes
require_base: no # [yes :: must have a base report to post]
require_head: no # [yes :: must have a head report to post]
require_changes: false # if true: only post the comment if coverage changes
require_base: no # [yes :: must have a base report to post]
require_head: no # [yes :: must have a head report to post]
2 changes: 1 addition & 1 deletion docs/examples/FAQ/createCurriedSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const createCurriedSelector = <
InputSelectors extends SelectorArray,
Result,
OverrideMemoizeFunction extends UnknownMemoizer = typeof weakMapMemoize,
OverrideArgsMemoizeFunction extends UnknownMemoizer = typeof weakMapMemoize
OverrideArgsMemoizeFunction extends UnknownMemoizer = typeof weakMapMemoize,
>(
...args: Parameters<
typeof createSelector<
Expand Down
16 changes: 8 additions & 8 deletions docs/examples/FAQ/createParametricSelectorHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,31 @@ const state: RootState = {
id: 0,
completed: false,
title: 'Figure out if plants are really plotting world domination.',
description: 'They may be.'
description: 'They may be.',
},
{
id: 1,
completed: true,
title: 'Practice telekinesis for 15 minutes',
description: 'Just do it'
}
description: 'Just do it',
},
],
alerts: [
{ id: 0, read: false },
{ id: 1, read: true }
]
{ id: 1, read: true },
],
}

const selectTodoById = createSelector(
[(state: RootState) => state.todos, (state: RootState, id: number) => id],
(todos, id) => todos.find(todo => todo.id === id)
(todos, id) => todos.find(todo => todo.id === id),
)

export const createParametricSelectorHook = <
Result,
Params extends readonly unknown[]
Params extends readonly unknown[],
>(
selector: (state: RootState, ...params: Params) => Result
selector: (state: RootState, ...params: Params) => Result,
) => {
return (...args: Params) => {
return useSelector((state: RootState) => selector(state, ...args))
Expand Down
8 changes: 4 additions & 4 deletions docs/examples/FAQ/currySelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export const currySelector = <
State,
Result,
Params extends readonly any[],
AdditionalFields
AdditionalFields,
>(
selector: ((state: State, ...args: Params) => Result) & AdditionalFields
selector: ((state: State, ...args: Params) => Result) & AdditionalFields,
) => {
const curriedSelector = (...args: Params) => {
return (state: State) => {
Expand All @@ -20,6 +20,6 @@ export const currySelector = <
const selectTodoByIdCurried = currySelector(
createSelector(
[(state: RootState) => state.todos, (state: RootState, id: number) => id],
(todos, id) => todos.find(todo => todo.id === id)
)
(todos, id) => todos.find(todo => todo.id === id),
),
)
10 changes: 5 additions & 5 deletions docs/examples/FAQ/howToTest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ interface RootState {
const state: RootState = {
todos: [
{ id: 0, completed: false },
{ id: 1, completed: true }
{ id: 1, completed: true },
],
alerts: [
{ id: 0, read: false },
{ id: 1, read: true }
]
{ id: 1, read: true },
],
}

// With `Vitest` or `Jest`
test('selector unit test', () => {
const selectTodoIds = createSelector(
[(state: RootState) => state.todos],
todos => todos.map(({ id }) => id)
todos => todos.map(({ id }) => id),
)
const firstResult = selectTodoIds(state)
const secondResult = selectTodoIds(state)
Expand All @@ -42,7 +42,7 @@ test('selector unit test', () => {
test('selector unit test', () => {
const selectTodoIds = createSelector(
[(state: RootState) => state.todos],
todos => todos.map(({ id }) => id)
todos => todos.map(({ id }) => id),
)
const firstResult = selectTodoIds(state)
const secondResult = selectTodoIds(state)
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/FAQ/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ const identity = <Func extends (...args: any[]) => any>(func: Func) => func

const createNonMemoizedSelector = createSelectorCreator({
memoize: identity,
argsMemoize: identity
argsMemoize: identity,
})
8 changes: 4 additions & 4 deletions docs/examples/FAQ/selectorRecomputing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface RootState {
const selectAlertsByType = createSelector(
[
(state: RootState) => state.alerts,
(state: RootState, type: string) => type
(state: RootState, type: string) => type,
],
(alerts, type) => alerts.filter(todo => todo.type === type),
{
Expand All @@ -20,7 +20,7 @@ const selectAlertsByType = createSelector(
console.log('Changed argument:', a, 'to', b)
}
return a === b
}
}
}
},
},
},
)
10 changes: 5 additions & 5 deletions docs/examples/basicUsage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ interface RootState {
const state: RootState = {
todos: [
{ id: 0, completed: false },
{ id: 1, completed: true }
{ id: 1, completed: true },
],
alerts: [
{ id: 0, read: false },
{ id: 1, read: true }
]
{ id: 1, read: true },
],
}

const selectCompletedTodos = (state: RootState) => {
Expand All @@ -30,7 +30,7 @@ const memoizedSelectCompletedTodos = createSelector(
todos => {
console.log('memoized selector ran')
return todos.filter(todo => todo.completed === true)
}
},
)

memoizedSelectCompletedTodos(state) // memoized selector ran
Expand All @@ -40,5 +40,5 @@ memoizedSelectCompletedTodos(state)
console.log(selectCompletedTodos(state) === selectCompletedTodos(state)) //=> false

console.log(
memoizedSelectCompletedTodos(state) === memoizedSelectCompletedTodos(state)
memoizedSelectCompletedTodos(state) === memoizedSelectCompletedTodos(state),
) //=> true
2 changes: 1 addition & 1 deletion docs/examples/createSelector/annotateResultFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ const selectTodoIds = createAppSelector(
// ❌ Known limitation: Parameter types are not inferred in this scenario
// so you will have to manually annotate them.
// highlight-start
(todos: Todo[]) => todos.map(({ id }) => id)
(todos: Todo[]) => todos.map(({ id }) => id),
// highlight-end
)
12 changes: 6 additions & 6 deletions docs/examples/createSelector/createAppSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ export const createAppSelector = createSelectorCreator({
memoizeOptions: {
maxSize: 10,
equalityCheck: shallowEqual,
resultEqualityCheck: shallowEqual
resultEqualityCheck: shallowEqual,
},
argsMemoizeOptions: {
isEqual: shallowEqual,
maxSize: 10
maxSize: 10,
},
devModeChecks: {
identityFunctionCheck: 'never',
inputStabilityCheck: 'always'
}
inputStabilityCheck: 'always',
},
}).withTypes<RootState>()

const selectReadAlerts = createAppSelector(
[
// Type of `state` is set to `RootState`, no need to manually set the type
// highlight-start
state => state.alerts
state => state.alerts,
// highlight-end
],
alerts => alerts.filter(({ read }) => read)
alerts => alerts.filter(({ read }) => read),
)
4 changes: 2 additions & 2 deletions docs/examples/createSelector/withTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const selectTodoIds = createAppSelector(
[
// Type of `state` is set to `RootState`, no need to manually set the type
// highlight-start
state => state.todos
state => state.todos,
// highlight-end
],
todos => todos.map(({ id }) => id)
todos => todos.map(({ id }) => id),
)
2 changes: 1 addition & 1 deletion docs/examples/createStructuredSelector/MyComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Props {

const MyComponent: FC<Props> = ({ id }) => {
const { todos, alerts, todoById } = useSelector((state: RootState) =>
structuredSelector(state, id)
structuredSelector(state, id),
)

return (
Expand Down
Loading