Skip to content

Commit

Permalink
refactor: update some typing and remove eslint ignore comments (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamogbz committed Sep 21, 2020
1 parent de2729e commit 68891f7
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = {
sourceType: "module",
},
rules: {
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": [
1,
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
Expand Down
2 changes: 1 addition & 1 deletion src/components/Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function Provider<S, T extends string, P>({
React.useEffect(
function enhanceAndIntialise() {
const enhanced = root.enhancer?.(observable) ?? observable;
setEnhanced?.(enhanced);
setEnhanced!(enhanced);
enhanced.dispatch(createAction<T, P, S>(ActionTypes.INIT as T)());
},
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";
import { GlobalContext } from "..";

export function useSelector<S, R, T extends string, P>(
selector: Nullable<Selector<S, R, T, P>>,
selector?: Selector<S, R, T, P>,
Context?: Context<S, T, P>,
): Nullable<R> {
const { state } = React.useContext(Context ?? GlobalContext);
Expand Down
3 changes: 1 addition & 2 deletions src/utils/applyMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ export function applyMiddleware<S, T extends string, P>(
...middlewares: Middleware<S, T, P>[]
): ContextEnhance<S, T, P> {
return function enhancer(context: ContextValue<S, T, P>) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function dispatchStub(...args: unknown[]): never {
function dispatchStub(): never {
throw new Error(
"Dispatching while constructing your middleware is not allowed. " +
"Other middleware would not be applied to this dispatch.",
Expand Down
2 changes: 1 addition & 1 deletion tests/createContext.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("createContext", () => {
);
const { result } = renderHook(() => React.useContext(Context));
const { enhancer, ...value } = result.current;
expect(enhancer?.(value)).toMatchObject(value);
expect(enhancer!(value)).toMatchObject(value);
});

it("has expected default context value", () => {
Expand Down
1 change: 0 additions & 1 deletion tests/hooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ describe("useAccessor", () => {
const [getter, setter] = result.current;
expect(getter()).toBe("initial value");
expect(setter).toBeUndefined();
setter?.("some value");
expect(getter()).toBe("initial value");
rerender("other value");
expect(getter()).toBe("other value");
Expand Down
3 changes: 1 addition & 2 deletions typings/observable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ interface SymbolConstructor {

// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Observable {
// eslint-disable-next-line @typescript-eslint/no-misused-new
constructor(subscriber: SubscriberFunction);
new (subscriber: SubscriberFunction);

// Subscribes to the sequence with an observer
subscribe(observer: Observer): Subscription;
Expand Down

0 comments on commit 68891f7

Please sign in to comment.