Skip to content

Commit

Permalink
fix(eslint-plugin): ignore select name within createFeature (#3788)
Browse files Browse the repository at this point in the history
Closes #3786
  • Loading branch information
timdeschryver authored Mar 1, 2023
1 parent 6d615b3 commit b58f9a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = () => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default createRule<Options, MessageIds>({
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);
Expand Down

0 comments on commit b58f9a3

Please sign in to comment.