From b58f9a33fad795fda15fd8ce703993820b362ddf Mon Sep 17 00:00:00 2001 From: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com> Date: Wed, 1 Mar 2023 14:36:14 +0100 Subject: [PATCH] fix(eslint-plugin): ignore select name within createFeature (#3788) Closes #3786 --- .../spec/rules/prefix-selectors-with-select.spec.ts | 9 +++++++++ .../src/rules/store/prefix-selectors-with-select.ts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/eslint-plugin/spec/rules/prefix-selectors-with-select.spec.ts b/modules/eslint-plugin/spec/rules/prefix-selectors-with-select.spec.ts index 8b33c691ed..959efdf484 100644 --- a/modules/eslint-plugin/spec/rules/prefix-selectors-with-select.spec.ts +++ b/modules/eslint-plugin/spec/rules/prefix-selectors-with-select.spec.ts @@ -25,6 +25,15 @@ const valid: () => RunTests['valid'] = () => [ `export const select_feature = createSelectorFactory(factoryFn)`, `export const select$feature = createSelectorFactory(factoryFn)`, `export const selectF01 = createSelector(factoryFn)`, + ` + export const authFeature = createFeature({ + name: 'auth', + reducer: authReducer, + extraSelectors: ({selectToken}) => ({ + selectIsAuthorized: createSelector(selectToken, token => !!token) + }), + }) + `, ]; const invalid: () => RunTests['invalid'] = () => [ diff --git a/modules/eslint-plugin/src/rules/store/prefix-selectors-with-select.ts b/modules/eslint-plugin/src/rules/store/prefix-selectors-with-select.ts index 36c7b57ad1..668aabc202 100644 --- a/modules/eslint-plugin/src/rules/store/prefix-selectors-with-select.ts +++ b/modules/eslint-plugin/src/rules/store/prefix-selectors-with-select.ts @@ -34,7 +34,7 @@ export default createRule({ defaultOptions: [], create: (context) => { return { - 'VariableDeclarator[id.name!=/^select[^a-z].+$/]:matches([id.typeAnnotation.typeAnnotation.typeName.name=/^MemoizedSelector(WithProps)?$/], :has(CallExpression[callee.name=/^(create(Feature)?Selector|createSelectorFactory)$/]))'({ + 'VariableDeclarator[id.name!=/^select[^a-z].+$/]:not(:has(Identifier[name="createFeature"])):matches([id.typeAnnotation.typeAnnotation.typeName.name=/^MemoizedSelector(WithProps)?$/], :has(CallExpression[callee.name=/^(create(Feature)?Selector|createSelectorFactory)$/]))'({ id, }: TSESTree.VariableDeclarator & { id: TSESTree.Identifier }) { const suggestedName = getSuggestedName(id.name);