Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
fix: do not report on-function-explicit-return-type error when using …
Browse files Browse the repository at this point in the history
…immer (#23)
  • Loading branch information
jsaguet committed May 31, 2020
1 parent 084393f commit 0dcfd0f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/configs/recommended.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"ngrx/no-dispatch-in-effects": "error",
"ngrx/no-effect-decorator": "error",
"ngrx/no-effects-in-providers": "error",
"ngrx/use-selector-in-select": "error",
"ngrx/on-function-explicit-return-type": "error"
"ngrx/on-function-explicit-return-type": "error",
"ngrx/use-selector-in-select": "error"
}
}
8 changes: 4 additions & 4 deletions src/rules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import noEffectDecorator, {
import noEffectsInProviders, {
ruleName as noEffectsInProvidersRuleName,
} from './no-effects-in-providers'
import useSelectorInSelect, {
ruleName as useSelectorInSelectRuleName,
} from './use-selector-in-select'
import onFunctionExplicitReturnType, {
ruleName as onFunctionExplicitReturnTypeRuleName,
} from './on-function-explicit-return-type'
import useSelectorInSelect, {
ruleName as useSelectorInSelectRuleName,
} from './use-selector-in-select'

const ruleNames = {
actionHygieneRuleName,
Expand All @@ -38,8 +38,8 @@ const ruleNames = {
noDispatchInEffectsRuleName,
noEffectDecoratorRuleName,
noEffectsInProvidersRuleName,
useSelectorInSelectRuleName,
onFunctionExplicitReturnTypeRuleName,
useSelectorInSelectRuleName,
}

export const rules = {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/selectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ const storeSelect = `CallExpression[callee.object.name='store'][callee.property.

export const select = `${pipeableSelect} Literal, ${storeSelect} Literal, ${pipeableSelect} ArrowFunctionExpression, ${storeSelect} ArrowFunctionExpression`

export const onFunctionWithoutType = `CallExpression[callee.name='createReducer'] CallExpression[callee.name='on'] ArrowFunctionExpression:not([returnType.typeAnnotation],:has(CallExpression))`
export const onFunctionWithoutType = `CallExpression[callee.name='createReducer'] CallExpression[callee.name='on'] > ArrowFunctionExpression:not([returnType.typeAnnotation],:has(CallExpression))`
10 changes: 10 additions & 0 deletions tests/rules/on-function-explicit-return-type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ ruleTester().run(ruleName, rule, {
on(increment, s => incrementFunc(s)),
on(increment, (s): State => incrementFunc(s)),
)`,
`
const reducer = createReducer(
initialState,
on(
increment,
produce((draft: State, action) => {
draft.counter++;
}),
),
)`,
],
invalid: [
{
Expand Down

0 comments on commit 0dcfd0f

Please sign in to comment.