@tanstack/eslint-plugin-query
Advanced tools
Comparing version 5.57.1 to 5.57.2
@@ -52,5 +52,8 @@ import { ESLintUtils, AST_NODE_TYPES } from "@typescript-eslint/utils"; | ||
return { name: p.argument.name, property: p }; | ||
} else { | ||
throw new Error("Unsupported spread element"); | ||
} else if (p.argument.type === AST_NODE_TYPES.CallExpression) { | ||
if (p.argument.callee.type === AST_NODE_TYPES.Identifier) { | ||
return { name: p.argument.callee.name, property: p }; | ||
} | ||
} | ||
throw new Error("Unsupported spread element"); | ||
} | ||
@@ -57,0 +60,0 @@ return []; |
{ | ||
"name": "@tanstack/eslint-plugin-query", | ||
"version": "5.57.1", | ||
"version": "5.57.2", | ||
"description": "ESLint plugin for TanStack Query", | ||
@@ -5,0 +5,0 @@ "author": "Eliya Cohen", |
@@ -16,2 +16,3 @@ import { RuleTester } from '@typescript-eslint/rule-tester' | ||
generatePermutations, | ||
normalizeIndent, | ||
} from './test-utils' | ||
@@ -23,3 +24,7 @@ import type { InfiniteQueryFunctions } from '../rules/infinite-query-property-order/constants' | ||
type CheckedProperties = (typeof checkedProperties)[number] | ||
const orderIndependentProps = ['queryKey', '...foo'] as const | ||
const orderIndependentProps = [ | ||
'queryKey', | ||
'...objectExpressionSpread', | ||
'...callExpressionSpread', | ||
] as const | ||
type OrderIndependentProps = (typeof orderIndependentProps)[number] | ||
@@ -89,3 +94,3 @@ | ||
invalid.indexOf('getPreviousPageParam'), | ||
) !== 1 && !invalid.includes('queryFn'), | ||
) !== 1, | ||
), | ||
@@ -128,2 +133,10 @@ ) | ||
const callExpressionSpread = normalizeIndent` | ||
...communitiesQuery({ | ||
filters: { | ||
...fieldValues, | ||
placementFormats: [], | ||
}, | ||
})` | ||
function getCode({ | ||
@@ -136,6 +149,7 @@ infiniteQueryFunction: infiniteQueryFunction, | ||
) { | ||
if (property.startsWith('...')) { | ||
return property | ||
} | ||
switch (property) { | ||
case '...objectExpressionSpread': | ||
return `...objectExpressionSpread` | ||
case '...callExpressionSpread': | ||
return callExpressionSpread | ||
case 'queryKey': | ||
@@ -150,4 +164,2 @@ return `queryKey: ['projects']` | ||
} | ||
return `${property}: () => null` | ||
} | ||
@@ -189,1 +201,26 @@ return ` | ||
}) | ||
// regression tests | ||
const regressionTestCases = { | ||
valid: [ | ||
{ | ||
name: 'should pass with call expression spread', | ||
code: normalizeIndent` | ||
import { useInfiniteQuery } from '@tanstack/react-query' | ||
const { data, isFetching, isLoading, hasNextPage, fetchNextPage } = | ||
useInfiniteQuery({ | ||
...communitiesQuery({ | ||
filters: { | ||
...fieldValues, | ||
placementFormats: [], | ||
}, | ||
}), | ||
refetchOnMount: false, | ||
})`, | ||
}, | ||
], | ||
invalid: [], | ||
} | ||
ruleTester.run(name, rule, regressionTestCases) |
@@ -68,5 +68,8 @@ import { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils' | ||
return { name: p.argument.name, property: p } | ||
} else { | ||
throw new Error('Unsupported spread element') | ||
} else if (p.argument.type === AST_NODE_TYPES.CallExpression) { | ||
if (p.argument.callee.type === AST_NODE_TYPES.Identifier) { | ||
return { name: p.argument.callee.name, property: p } | ||
} | ||
} | ||
throw new Error('Unsupported spread element') | ||
} | ||
@@ -73,0 +76,0 @@ return [] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
297326
4776