Socket
Socket
Sign inDemoInstall

@tanstack/eslint-plugin-query

Package Overview
Dependencies
Maintainers
2
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/eslint-plugin-query - npm Package Compare versions

Comparing version 5.51.1 to 5.51.7

16

dist/esm/rules/exhaustive-deps/exhaustive-deps.rule.js

@@ -45,3 +45,4 @@ import { ESLintUtils, AST_NODE_TYPES } from "@typescript-eslint/utils";

AST_NODE_TYPES.ArrowFunctionExpression,
AST_NODE_TYPES.FunctionExpression
AST_NODE_TYPES.FunctionExpression,
AST_NODE_TYPES.ConditionalExpression
])) {

@@ -67,3 +68,3 @@ return;

sourceCode: context.sourceCode,
node: queryFn.value
node: getQueryFnRelevantNode(queryFn)
});

@@ -75,3 +76,3 @@ const relevantRefs = externalRefs.filter(

scopeManager,
node: queryFn.value
node: getQueryFnRelevantNode(queryFn)
})

@@ -120,2 +121,11 @@ );

});
function getQueryFnRelevantNode(queryFn) {
if (queryFn.value.type !== AST_NODE_TYPES.ConditionalExpression) {
return queryFn.value;
}
if (queryFn.value.consequent.type === AST_NODE_TYPES.Identifier && queryFn.value.consequent.name === "skipToken") {
return queryFn.value.alternate;
}
return queryFn.value.consequent;
}
export {

@@ -122,0 +132,0 @@ name,

2

package.json
{
"name": "@tanstack/eslint-plugin-query",
"version": "5.51.1",
"version": "5.51.7",
"description": "ESLint plugin for TanStack Query",

@@ -5,0 +5,0 @@ "author": "Eliya Cohen",

@@ -405,2 +405,16 @@ import { RuleTester } from '@typescript-eslint/rule-tester'

},
{
name: 'queryFn as a ternary expression with dep and a skipToken',
code: normalizeIndent`
import { useQuery, skipToken } from "@tanstack/react-query";
const fetch = true
function Component({ id }) {
useQuery({
queryKey: [id],
queryFn: fetch ? () => Promise.resolve(id) : skipToken
})
}
`,
},
],

@@ -737,3 +751,23 @@ invalid: [

},
{
name: 'should fail if queryFn is a ternary expression with missing dep and a skipToken',
code: normalizeIndent`
import { useQuery, skipToken } from "@tanstack/react-query";
const fetch = true
function Component({ id }) {
useQuery({
queryKey: [],
queryFn: fetch ? () => Promise.resolve(id) : skipToken
})
}
`,
errors: [
{
messageId: 'missingDeps',
data: { deps: 'id' },
},
],
},
],
})

@@ -7,3 +7,3 @@ import { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils'

import { ExhaustiveDepsUtils } from './exhaustive-deps.utils'
import type { TSESLint } from '@typescript-eslint/utils'
import type { TSESLint, TSESTree } from '@typescript-eslint/utils'
import type { ExtraRuleDocs } from '../../types'

@@ -63,2 +63,3 @@

AST_NODE_TYPES.FunctionExpression,
AST_NODE_TYPES.ConditionalExpression,
])

@@ -93,3 +94,3 @@ ) {

sourceCode: context.sourceCode,
node: queryFn.value,
node: getQueryFnRelevantNode(queryFn),
})

@@ -102,3 +103,3 @@

scopeManager,
node: queryFn.value,
node: getQueryFnRelevantNode(queryFn),
}),

@@ -168,1 +169,16 @@ )

})
function getQueryFnRelevantNode(queryFn: TSESTree.Property) {
if (queryFn.value.type !== AST_NODE_TYPES.ConditionalExpression) {
return queryFn.value
}
if (
queryFn.value.consequent.type === AST_NODE_TYPES.Identifier &&
queryFn.value.consequent.name === 'skipToken'
) {
return queryFn.value.alternate
}
return queryFn.value.consequent
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc