Skip to content

Commit

Permalink
Fix lint problems and enable linting on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
thorn0 committed Dec 10, 2022
1 parent 4383544 commit f401932
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 28 deletions.
4 changes: 2 additions & 2 deletions packages/toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@
"yargs": "^15.3.1"
},
"scripts": {
"build-ci": "yarn rimraf dist && yarn tsc && node scripts/cli.js --skipExtraction",
"build-ci": "yarn rimraf dist && yarn tsc && yarn lint && node scripts/cli.js --skipExtraction",
"build-prepare": "npm run build-ci",
"build": "yarn rimraf dist && yarn tsc && node scripts/cli.js --local --skipExtraction",
"build-only": "yarn rimraf dist && yarn tsc && node scripts/cli.js --skipExtraction",
"format": "prettier --write \"(src|examples)/**/*.{ts,tsx}\" \"**/*.md\"",
"format:check": "prettier --list-different \"(src|examples)/**/*.{ts,tsx}\" \"docs/*/**.md\"",
"lint": "eslint src examples",
"lint": "eslint src",
"test": "jest --runInBand",
"type-tests": "yarn tsc -p src/tests/tsconfig.typetests.json && yarn tsc -p src/query/tests/tsconfig.typetests.json",
"prepack": "npm run build-prepare"
Expand Down
16 changes: 8 additions & 8 deletions packages/toolkit/src/listenerMiddleware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,14 @@ export const createListenerEntry: TypedCreateListenerEntry<unknown> = (
return entry
}

const cancelActiveListeners = (
entry: ListenerEntry<unknown, Dispatch<AnyAction>>
) => {
entry.pending.forEach((controller) => {
abortControllerWithReason(controller, listenerCancelled)
})
}

const createClearListenerMiddleware = (
listenerMap: Map<string, ListenerEntry>
) => {
Expand Down Expand Up @@ -281,14 +289,6 @@ const defaultErrorHandler: ListenerErrorHandler = (...args: unknown[]) => {
console.error(`${alm}/error`, ...args)
}

const cancelActiveListeners = (
entry: ListenerEntry<unknown, Dispatch<AnyAction>>
) => {
entry.pending.forEach((controller) => {
abortControllerWithReason(controller, listenerCancelled)
})
}

/**
* @public
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import type {
Subscribers,
} from '../apiState'
import { produceWithPatches } from 'immer'
import { createSlice, PayloadAction, AnyAction } from '@reduxjs/toolkit'
import type { AnyAction } from '@reduxjs/toolkit';
import { createSlice, PayloadAction } from '@reduxjs/toolkit'

// Copied from https://github.com/feross/queue-microtask
let promise: Promise<any>
Expand Down
7 changes: 4 additions & 3 deletions packages/toolkit/src/query/core/buildThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ import type {
QueryActionCreatorResult,
} from './buildInitiate'
import { forceQueryFnSymbol, isUpsertQuery } from './buildInitiate'
import {
import type {
AssertTagTypes,
EndpointDefinition,
EndpointDefinitions,
isQueryDefinition,
MutationDefinition,
QueryArgFrom,
QueryDefinition,
ResultTypeFrom,
ResultTypeFrom} from '../endpointDefinitions';
import {
isQueryDefinition
} from '../endpointDefinitions'
import { calculateProvidedBy } from '../endpointDefinitions'
import type { AsyncThunkPayloadCreator, Draft } from '@reduxjs/toolkit'
Expand Down
5 changes: 3 additions & 2 deletions packages/toolkit/src/query/createApi.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { Api, ApiContext, Module, ModuleName } from './apiTypes'
import type { CombinedState } from './core/apiState'
import type { BaseQueryArg, BaseQueryFn } from './baseQueryTypes'
import type {
SerializeQueryArgs} from './defaultSerializeQueryArgs';
import {
defaultSerializeQueryArgs,
SerializeQueryArgs,
defaultSerializeQueryArgs
} from './defaultSerializeQueryArgs'
import type {
EndpointBuilder,
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/query/endpointDefinitions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AnyAction, ThunkDispatch } from '@reduxjs/toolkit'
import { SerializeQueryArgs } from './defaultSerializeQueryArgs'
import type { SerializeQueryArgs } from './defaultSerializeQueryArgs'
import type { QuerySubState, RootState } from './core/apiState'
import type {
BaseQueryExtraOptions,
Expand Down
5 changes: 3 additions & 2 deletions packages/toolkit/src/query/react/ApiProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { configureStore } from '@reduxjs/toolkit'
import { Context, useEffect } from 'react'
import type { Context } from 'react'
import { useEffect } from 'react'
import React from 'react'
import type { ReactReduxContextValue } from 'react-redux'
import { Provider } from 'react-redux'
Expand Down Expand Up @@ -50,7 +51,7 @@ export function ApiProvider<A extends Api<any, {}, any, any>>(props: {
props.setupListeners === false
? undefined
: setupListeners(store.dispatch, props.setupListeners),
[props.setupListeners]
[props.setupListeners, store.dispatch]
)

return (
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/query/retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
BaseQueryExtraOptions,
BaseQueryFn,
} from './baseQueryTypes'
import { FetchBaseQueryError } from './fetchBaseQuery'
import type { FetchBaseQueryError } from './fetchBaseQuery'
import { HandledError } from './HandledError'

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/toolkit/src/query/tests/buildHooks.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ import {
import { server } from './mocks/server'
import type { AnyAction } from 'redux'
import type { SubscriptionOptions } from '@reduxjs/toolkit/dist/query/core/apiState'
import type {
SerializedError} from '@reduxjs/toolkit';
import {
createListenerMiddleware,
SerializedError,
configureStore,
} from '@reduxjs/toolkit'
import { renderHook } from '@testing-library/react'
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/query/tests/createApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from './helpers'
import { server } from './mocks/server'
import { rest } from 'msw'
import { SerializeQueryArgs } from '../defaultSerializeQueryArgs'
import type { SerializeQueryArgs } from '../defaultSerializeQueryArgs'
import { string } from 'yargs'

const originalEnv = process.env.NODE_ENV
Expand Down
5 changes: 3 additions & 2 deletions packages/toolkit/src/tests/autoBatchEnhancer.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { configureStore } from '../configureStore'
import { createSlice } from '../createSlice'
import type {
AutoBatchOptions} from '../autoBatchEnhancer';
import {
autoBatchEnhancer,
prepareAutoBatched,
AutoBatchOptions,
prepareAutoBatched
} from '../autoBatchEnhancer'
import { delay } from '../utils'
import { debounce } from 'lodash'
Expand Down
6 changes: 3 additions & 3 deletions packages/toolkit/src/tests/configureStore.typetest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import type {
StoreEnhancer
} from 'redux'
import { applyMiddleware } from 'redux'
import type { PayloadAction } from '@reduxjs/toolkit'
import type { PayloadAction ,
ConfigureStoreOptions} from '@reduxjs/toolkit'
import {
configureStore,
getDefaultMiddleware,
createSlice,
ConfigureStoreOptions,
createSlice
} from '@reduxjs/toolkit'
import type { ThunkMiddleware, ThunkAction, ThunkDispatch } from 'redux-thunk'
import thunk from 'redux-thunk'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export const rootReducer = combineSlices(sliceA, sliceB, {
// fileC.ts
// "naive" approach

import { rootReducer, RootState } from './reducer'
import type { RootState } from './reducer';
import { rootReducer } from './reducer'
import { createSlice } from '@reduxjs/toolkit'

interface SliceCState {
Expand Down

0 comments on commit f401932

Please sign in to comment.