Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
chore: config lint script & fix rules
Browse files Browse the repository at this point in the history
  • Loading branch information
BPierrick committed Dec 2, 2021
1 parent eed5ef8 commit 39045e2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ module.exports = {
"no-unused-vars": "off",
"no-shadow": "off",
"@typescript-eslint/no-shadow": ["error"],
"@typescript-eslint/no-unused-vars": ["error", { varsIgnorePattern: "^_" }],
"@typescript-eslint/no-unused-vars": [
"error",
{ varsIgnorePattern: "^_", argsIgnorePattern: "^_" },
],
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": ["error"],
// React
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"lint": "eslint ./src --ext .js,.jsx,.ts,.tsx",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
Expand Down
60 changes: 30 additions & 30 deletions src/services/api/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ type ProvidesListFn<T> = <
error?: Error
) => CacheList<T, Results[number]["id"]>;

export const providesList = <T extends string>(type: T): ProvidesListFn<T> => (
results,
_error
) =>
results
? [{ type, id: "LIST" }, ...results.map(({ id }) => ({ type, id }))]
: [{ type, id: "LIST" }];
export const providesList =
<T extends string>(type: T): ProvidesListFn<T> =>
(results, _error) =>
results
? [{ type, id: "LIST" }, ...results.map(({ id }) => ({ type, id }))]
: [{ type, id: "LIST" }];

type ProvidesPaginatedListFn<T> = <
Results extends Item[],
Expand All @@ -30,18 +29,18 @@ type ProvidesPaginatedListFn<T> = <
error?: Error
) => CacheList<T, Results[number]["id"]>;

export const providesPaginatedList = <T extends string>(
type: T
): ProvidesPaginatedListFn<T> => (data, _error) =>
data?.results
? [
{ type, id: "LIST" },
...data.results.map(({ id }) => ({
type,
id,
})),
]
: [{ type, id: "LIST" }];
export const providesPaginatedList =
<T extends string>(type: T): ProvidesPaginatedListFn<T> =>
(data, _error) =>
data?.results
? [
{ type, id: "LIST" },
...data.results.map(({ id }) => ({
type,
id,
})),
]
: [{ type, id: "LIST" }];

type ProvidesOneFn<T> = <
Result,
Expand All @@ -53,17 +52,17 @@ type ProvidesOneFn<T> = <
arg: Arg
) => [CacheItem<T, Arg["id"]>];

export const providesOne = <T extends string>(type: T): ProvidesOneFn<T> => (
_result,
_error,
{ id }
) => [{ type, id }];
export const providesOne =
<T extends string>(type: T): ProvidesOneFn<T> =>
(_result, _error, { id }) =>
[{ type, id }];

type InvalidatesListFn<T> = () => [CacheItem<T, "LIST">];

export const invalidatesList = <T extends string>(
type: T
): InvalidatesListFn<T> => () => [{ type, id: "LIST" }];
export const invalidatesList =
<T extends string>(type: T): InvalidatesListFn<T> =>
() =>
[{ type, id: "LIST" }];

type InvalidatesOneFn<T> = <
Result,
Expand All @@ -75,6 +74,7 @@ type InvalidatesOneFn<T> = <
arg: Arg
) => [CacheItem<T, Arg["id"]>];

export const invalidatesOne = <T extends string>(
type: T
): InvalidatesOneFn<T> => (_result, _error, { id }) => [{ type, id }];
export const invalidatesOne =
<T extends string>(type: T): InvalidatesOneFn<T> =>
(_result, _error, { id }) =>
[{ type, id }];

0 comments on commit 39045e2

Please sign in to comment.