Repository: reduxjs/redux-toolkit (ts)

Issue:
Outdated documentation of immutable invariant options on the homepage
The [API reference on the homepage](https://redux-toolkit.js.org/api/getDefaultMiddleware#api-reference) currently states that the paths to ignore in the immutable state middleware can be configured with the `ignore` key. This is not true; when the middleware was merged in the most recent version, the key was renamed to `ignoredPaths`, relying on the old `ignore` key has no effect. (The new middleware also has a `warnAfter` key for what it's worth). The API reference on the homepage should be updated to avoid confusion. Also, it would probably be a good idea to treat `ignore` as an alias for `ignoredPaths` in order not to break backwards compatibility in a minor release.

Thanks a lot in advance!

Pull request description:
Update docs, add test, alias ignore->ignoredPaths
Fixes #491 

Patch:
diff --git a/docs/api/getDefaultMiddleware.md b/docs/api/getDefaultMiddleware.md
index ac51a106..bc9928a3 100644
--- a/docs/api/getDefaultMiddleware.md
+++ b/docs/api/getDefaultMiddleware.md
@@ -110,7 +110,8 @@ interface ThunkOptions<E = any> {
 
 interface ImmutableStateInvariantMiddlewareOptions {
   isImmutable?: (value: any) => boolean
-  ignore?: string[]
+  ignoredPaths?: string[]
+  warnAfter?: number
 }
 
 interface SerializableStateInvariantMiddlewareOptions {
@@ -132,10 +133,22 @@ interface SerializableStateInvariantMiddlewareOptions {
    */
   ignoredActions?: string[]
 
+  /**
+   * An array of dot-separated path strings to ignore when checking for serializability, Defaults to ['meta.arg']
+   * If you use this parameter, the default value 'meta.arg' will be removed, so we recommend re-adding it unless you
+   * specifically do not want to ignore it. Example: ['meta.arg', 'your.path', 'other.path', ...etc]
+   */
+  ignoredActionPaths?: string[]
+
   /**
    * An array of dot-separated path strings to ignore when checking for serializability, Defaults to []
    */
   ignoredPaths?: string[]
+
+  /**
+   * Execution time warning threshold. If the middleware takes longer than `warnAfter` ms, a warning will be displayed in the console. Defaults to 32
+   */
+  warnAfter?: number
 }
 
 interface GetDefaultMiddlewareOptions {
diff --git a/docs/api/otherExports.md b/docs/api/otherExports.md
index 4a5b5af9..8ef68663 100644
--- a/docs/api/otherExports.md
+++ b/docs/api/otherExports.md
@@ -80,9 +80,15 @@ function createSerializableStateInvariantMiddleware({
   // An array of action types to ignore when checking for serializability.
   // Defaults to []
   ignoredActions?: string[]
-  // An array of dot-separated path strings to ignore when checking for serializability.
-  // Defaults to []
+  // An array of dot-separated path strings to ignore when
+  // checking for serializability, Defaults to ['meta.arg']
+  ignoredActionPaths?: string[]
+  // An array of dot-separated path strings to ignore when
+  // checking for serializability, Defaults to []
   ignoredPaths?: string[]
+  // Execution time warning threshold. If the middleware takes longer
+  // than `warnAfter` ms, a warning will be displayed in the console. Defaults to 32
+  warnAfter?: number
 })
 ```
 
diff --git a/etc/redux-toolkit.api.md b/etc/redux-toolkit.api.md
index ee7be645..d6626a09 100644
--- a/etc/redux-toolkit.api.md
+++ b/etc/redux-toolkit.api.md
@@ -277,6 +277,8 @@ export type IdSelector<T> = (model: T) => EntityId;
 
 // @public
 export interface ImmutableStateInvariantMiddlewareOptions {
+    // (undocumented)
+    ignore?: string[];
     // (undocumented)
     ignoredPaths?: string[];
     // (undocumented)
diff --git a/src/immutableStateInvariantMiddleware.ts b/src/immutableStateInvariantMiddleware.ts
index 2a0f1687..0455306b 100644
--- a/src/immutableStateInvariantMiddleware.ts
+++ b/src/immutableStateInvariantMiddleware.ts
@@ -187,6 +187,7 @@ export interface ImmutableStateInvariantMiddlewareOptions {
   isImmutable?: IsImmutableFunc
   ignoredPaths?: string[]
   warnAfter?: number
+  ignore?: string[] // @deprecated. Use ignoredPaths
 }
 
 /**
@@ -205,11 +206,16 @@ export function createImmutableStateInvariantMiddleware(
     return () => next => action => next(action)
   }
 
-  const {
+  let {
     isImmutable = isImmutableDefault,
     ignoredPaths,
-    warnAfter = 32
+    warnAfter = 32,
+    ignore
   } = options
+
+  // Alias ignore->ignoredPaths, but prefer ignoredPaths if present
+  ignoredPaths = ignoredPaths || ignore
+
   const track = trackForMutations.bind(null, isImmutable, ignoredPaths)
 
   return ({ getState }) => {


Test patch:
diff --git a/src/immutableStateInvariantMiddleware.test.ts b/src/immutableStateInvariantMiddleware.test.ts
index 104e677d..ab89d71e 100644
--- a/src/immutableStateInvariantMiddleware.test.ts
+++ b/src/immutableStateInvariantMiddleware.test.ts
@@ -110,7 +110,7 @@ describe('createImmutableStateInvariantMiddleware', () => {
     }).not.toThrow()
   })
 
-  it('respects "ignore" option', () => {
+  it('respects "ignoredPaths" option', () => {
     const next: Dispatch = action => {
       state.foo.bar.push(5)
       return action
@@ -123,6 +123,19 @@ describe('createImmutableStateInvariantMiddleware', () => {
     }).not.toThrow()
   })
 
+  it('alias "ignore" to "ignoredPath" and respects option', () => {
+    const next: Dispatch = action => {
+      state.foo.bar.push(5)
+      return action
+    }
+
+    const dispatch = middleware({ ignore: ['foo.bar'] })(next)
+
+    expect(() => {
+      dispatch({ type: 'SOME_ACTION' })
+    }).not.toThrow()
+  })
+
   it('Should print a warning if execution takes too long', () => {
     state.foo.bar = new Array(10000).fill({ value: 'more' })