@openapi-qraft/eslint-plugin-query 2.15.0-beta.6 → 2.15.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/rules/no-rest-destructuring/no-rest-destructuring.rule.cjs.map +1 -1
- package/dist/cjs/rules/no-rest-destructuring/no-rest-destructuring.utils.cjs.map +1 -1
- package/dist/cjs/rules/no-unstable-deps/no-unstable-deps.rule.cjs.map +1 -1
- package/dist/cjs/rules.cjs.map +1 -1
- package/dist/cjs/utils/create-client-name-regex.cjs.map +1 -1
- package/dist/cjs/utils/get-docs-url.cjs.map +1 -1
- package/dist/cjs/utils/get-root-identifier.cjs.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/rules/no-rest-destructuring/no-rest-destructuring.rule.js +1 -1
- package/dist/esm/rules/no-rest-destructuring/no-rest-destructuring.rule.js.map +1 -1
- package/dist/esm/rules/no-rest-destructuring/no-rest-destructuring.utils.js.map +1 -1
- package/dist/esm/rules/no-unstable-deps/no-unstable-deps.rule.js +1 -1
- package/dist/esm/rules/no-unstable-deps/no-unstable-deps.rule.js.map +1 -1
- package/dist/esm/rules.js +4 -4
- package/dist/esm/rules.js.map +1 -1
- package/dist/esm/utils/create-client-name-regex.js.map +1 -1
- package/dist/esm/utils/get-docs-url.js.map +1 -1
- package/dist/esm/utils/get-root-identifier.js.map +1 -1
- package/dist/types/rules/no-rest-destructuring/no-rest-destructuring.rule.d.ts +3 -1
- package/dist/types/rules/no-rest-destructuring/no-rest-destructuring.rule.d.ts.map +1 -1
- package/dist/types/rules/no-unstable-deps/no-unstable-deps.rule.d.ts +3 -1
- package/dist/types/rules/no-unstable-deps/no-unstable-deps.rule.d.ts.map +1 -1
- package/dist/types/utils/get-docs-url.d.ts.map +1 -1
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @openapi-qraft/eslint-plugin-query
|
|
2
2
|
|
|
3
|
+
## 2.15.0-beta.7
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6a2f1ed: Updated repository dependencies to current compatible versions across the workspace.
|
|
8
|
+
- 55a23fd: Updated the openapi-typescript package to the current compatible version.
|
|
9
|
+
|
|
3
10
|
## 2.15.0-beta.6
|
|
4
11
|
|
|
5
12
|
## 2.15.0-beta.5
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["import type { RuleModule } from '@typescript-eslint/utils/ts-eslint';\nimport type { ESLint, Linter } from 'eslint';\nimport { rules } from './rules';\n\ntype RuleKey = keyof typeof rules;\n\nexport interface Plugin extends Omit<ESLint.Plugin, 'rules'> {\n rules: Record<RuleKey, RuleModule<any, any, any>>;\n configs: {\n recommended: ESLint.ConfigData;\n 'flat/recommended': Array<Linter.Config>;\n };\n}\n\nexport const plugin: Plugin = {\n meta: {\n name: '@openapi-qraft/eslint-plugin-query',\n },\n configs: {} as Plugin['configs'],\n rules,\n};\n\n// Assign configs here so we can reference `plugin`\nObject.assign(plugin.configs, {\n recommended: {\n plugins: ['@openapi-qraft/query'],\n rules: {\n '@openapi-qraft/query/no-rest-destructuring': 'warn',\n '@openapi-qraft/query/no-unstable-deps': 'error',\n },\n },\n 'flat/recommended': [\n {\n name: 'openapi-qraft/query/flat/recommended',\n plugins: {\n '@openapi-qraft/query': plugin,\n },\n rules: {\n '@openapi-qraft/query/no-rest-destructuring': 'warn',\n '@openapi-qraft/query/no-unstable-deps': 'error',\n },\n },\n ],\n});\n\n// Reexport rules & configs for the Legacy config\nexport { rules };\nexport const configs = plugin.configs;\n\n/**\n * @alias\n * @type {Plugin}\n **/\nexport default plugin;\n"],"names":["plugin","meta","name","configs","rules","Object","assign","recommended","plugins"],"mappings":";;;;;;MAcaA,
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["import type { RuleModule } from '@typescript-eslint/utils/ts-eslint';\nimport type { ESLint, Linter } from 'eslint';\nimport { rules } from './rules';\n\ntype RuleKey = keyof typeof rules;\n\nexport interface Plugin extends Omit<ESLint.Plugin, 'rules'> {\n rules: Record<RuleKey, RuleModule<any, any, any>>;\n configs: {\n recommended: ESLint.ConfigData;\n 'flat/recommended': Array<Linter.Config>;\n };\n}\n\nexport const plugin: Plugin = {\n meta: {\n name: '@openapi-qraft/eslint-plugin-query',\n },\n configs: {} as Plugin['configs'],\n rules,\n};\n\n// Assign configs here so we can reference `plugin`\nObject.assign(plugin.configs, {\n recommended: {\n plugins: ['@openapi-qraft/query'],\n rules: {\n '@openapi-qraft/query/no-rest-destructuring': 'warn',\n '@openapi-qraft/query/no-unstable-deps': 'error',\n },\n },\n 'flat/recommended': [\n {\n name: 'openapi-qraft/query/flat/recommended',\n plugins: {\n '@openapi-qraft/query': plugin,\n },\n rules: {\n '@openapi-qraft/query/no-rest-destructuring': 'warn',\n '@openapi-qraft/query/no-unstable-deps': 'error',\n },\n },\n ],\n});\n\n// Reexport rules & configs for the Legacy config\nexport { rules };\nexport const configs = plugin.configs;\n\n/**\n * @alias\n * @type {Plugin}\n **/\nexport default plugin;\n"],"names":["plugin","meta","name","configs","rules","Object","assign","recommended","plugins"],"mappings":";;;;;;MAcaA,MAAAA,GAAiB;IAC5BC,IAAAA,EAAM;QACJC,IAAAA,EAAM;AACR,KAAA;AACAC,IAAAA,OAAAA,EAAS,EAAC;AACVC,WAAAA;AACF;AAEA;AACAC,MAAAA,CAAOC,MAAM,CAACN,MAAAA,CAAOG,OAAO,EAAE;IAC5BI,WAAAA,EAAa;QACXC,OAAAA,EAAS;AAAC,YAAA;AAAuB,SAAA;QACjCJ,KAAAA,EAAO;YACL,4CAAA,EAA8C,MAAA;YAC9C,uCAAA,EAAyC;AAC3C;AACF,KAAA;IACA,kBAAA,EAAoB;AAClB,QAAA;YACEF,IAAAA,EAAM,sCAAA;YACNM,OAAAA,EAAS;gBACP,sBAAA,EAAwBR;AAC1B,aAAA;YACAI,KAAAA,EAAO;gBACL,4CAAA,EAA8C,MAAA;gBAC9C,uCAAA,EAAyC;AAC3C;AACF;AACD;AACH,CAAA,CAAA;AAIO,MAAMD,OAAAA,GAAUH,MAAAA,CAAOG;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-rest-destructuring.rule.cjs","sources":["../../../../src/rules/no-rest-destructuring/no-rest-destructuring.rule.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport type { ExtraRuleDocs } from '../../types';\nimport { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';\nimport { createClientNameRegex } from '../../utils/create-client-name-regex';\nimport { getDocsUrl } from '../../utils/get-docs-url';\nimport { getRootIdentifier } from '../../utils/get-root-identifier';\nimport { NoRestDestructuringUtils } from './no-rest-destructuring.utils';\n\nexport const name = 'no-rest-destructuring';\n\nconst createRule = ESLintUtils.RuleCreator<ExtraRuleDocs>(getDocsUrl);\n\nconst queryHooks = [\n 'useQuery',\n 'useQueries',\n 'useInfiniteQuery',\n 'useSuspenseQuery',\n 'useSuspenseQueries',\n 'useSuspenseInfiniteQuery',\n];\n\nexport const rule = createRule({\n name,\n meta: {\n type: 'problem',\n docs: {\n description: 'Disallows rest destructuring in queries',\n recommended: 'warn',\n },\n messages: {\n objectRestDestructure: `Object rest destructuring on a query will observe all changes to the query, leading to excessive re-renders.`,\n },\n schema: [\n {\n type: 'object',\n properties: {\n clientNamePattern: { type: 'string' },\n },\n additionalProperties: false,\n },\n ],\n },\n defaultOptions: [{}],\n\n create: (context) => {\n const option =\n (context.options[0] as { clientNamePattern?: string } | undefined) ?? {};\n\n const clientRegex = createClientNameRegex(option.clientNamePattern);\n\n const queryResultVariables = new Set<string>();\n\n return {\n CallExpression: (node) => {\n if (node.parent.type !== AST_NODE_TYPES.VariableDeclarator) return;\n\n const callee = node.callee;\n if (callee.type !== AST_NODE_TYPES.MemberExpression) return;\n const hookName = getHookNameIfTargetFromClient(clientRegex, callee);\n if (!hookName) return;\n const returnValue = node.parent.id;\n\n if (hookName !== 'useQueries' && hookName !== 'useSuspenseQueries') {\n if (NoRestDestructuringUtils.isObjectRestDestructuring(returnValue)) {\n return context.report({\n node: node.parent,\n messageId: 'objectRestDestructure',\n });\n }\n\n if (returnValue.type === AST_NODE_TYPES.Identifier) {\n queryResultVariables.add(returnValue.name);\n }\n\n return;\n }\n\n if (returnValue.type !== AST_NODE_TYPES.ArrayPattern) {\n if (returnValue.type === AST_NODE_TYPES.Identifier) {\n queryResultVariables.add(returnValue.name);\n }\n return;\n }\n\n returnValue.elements.forEach((queryResult) => {\n if (queryResult === null) {\n return;\n }\n if (NoRestDestructuringUtils.isObjectRestDestructuring(queryResult)) {\n context.report({\n node: queryResult,\n messageId: 'objectRestDestructure',\n });\n }\n });\n },\n\n VariableDeclarator: (node) => {\n if (\n node.init?.type === AST_NODE_TYPES.Identifier &&\n queryResultVariables.has(node.init.name) &&\n NoRestDestructuringUtils.isObjectRestDestructuring(node.id)\n ) {\n context.report({\n node,\n messageId: 'objectRestDestructure',\n });\n }\n },\n\n SpreadElement: (node) => {\n if (\n node.argument.type === AST_NODE_TYPES.Identifier &&\n queryResultVariables.has(node.argument.name)\n ) {\n context.report({\n node,\n messageId: 'objectRestDestructure',\n });\n }\n },\n };\n },\n});\n\nfunction getHookNameIfTargetFromClient(\n clientRegex: RegExp,\n callee: TSESTree.MemberExpression\n): string | undefined {\n if (callee.property.type !== AST_NODE_TYPES.Identifier) return;\n const name = callee.property.name;\n if (!queryHooks.includes(name)) return;\n const root = getRootIdentifier(callee.object);\n return root && clientRegex.test(root.name) ? name : undefined;\n}\n"],"names":["name","createRule","ESLintUtils","RuleCreator","getDocsUrl","queryHooks","rule","meta","type","docs","description","recommended","messages","objectRestDestructure","schema","properties","clientNamePattern","additionalProperties","defaultOptions","create","context","option","options","clientRegex","createClientNameRegex","queryResultVariables","Set","CallExpression","node","parent","AST_NODE_TYPES","VariableDeclarator","callee","MemberExpression","hookName","getHookNameIfTargetFromClient","returnValue","id","NoRestDestructuringUtils","isObjectRestDestructuring","report","messageId","Identifier","add","ArrayPattern","elements","forEach","queryResult","init","has","SpreadElement","argument","property","includes","root","getRootIdentifier","object","test","undefined"],"mappings":";;;;;;;;AAQO,MAAMA,OAAO
|
|
1
|
+
{"version":3,"file":"no-rest-destructuring.rule.cjs","sources":["../../../../src/rules/no-rest-destructuring/no-rest-destructuring.rule.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport type { ExtraRuleDocs } from '../../types';\nimport { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';\nimport { createClientNameRegex } from '../../utils/create-client-name-regex';\nimport { getDocsUrl } from '../../utils/get-docs-url';\nimport { getRootIdentifier } from '../../utils/get-root-identifier';\nimport { NoRestDestructuringUtils } from './no-rest-destructuring.utils';\n\nexport const name = 'no-rest-destructuring';\n\nconst createRule = ESLintUtils.RuleCreator<ExtraRuleDocs>(getDocsUrl);\n\nconst queryHooks = [\n 'useQuery',\n 'useQueries',\n 'useInfiniteQuery',\n 'useSuspenseQuery',\n 'useSuspenseQueries',\n 'useSuspenseInfiniteQuery',\n];\n\nexport const rule = createRule({\n name,\n meta: {\n type: 'problem',\n docs: {\n description: 'Disallows rest destructuring in queries',\n recommended: 'warn',\n },\n messages: {\n objectRestDestructure: `Object rest destructuring on a query will observe all changes to the query, leading to excessive re-renders.`,\n },\n schema: [\n {\n type: 'object',\n properties: {\n clientNamePattern: { type: 'string' },\n },\n additionalProperties: false,\n },\n ],\n },\n defaultOptions: [{}],\n\n create: (context) => {\n const option =\n (context.options[0] as { clientNamePattern?: string } | undefined) ?? {};\n\n const clientRegex = createClientNameRegex(option.clientNamePattern);\n\n const queryResultVariables = new Set<string>();\n\n return {\n CallExpression: (node) => {\n if (node.parent.type !== AST_NODE_TYPES.VariableDeclarator) return;\n\n const callee = node.callee;\n if (callee.type !== AST_NODE_TYPES.MemberExpression) return;\n const hookName = getHookNameIfTargetFromClient(clientRegex, callee);\n if (!hookName) return;\n const returnValue = node.parent.id;\n\n if (hookName !== 'useQueries' && hookName !== 'useSuspenseQueries') {\n if (NoRestDestructuringUtils.isObjectRestDestructuring(returnValue)) {\n return context.report({\n node: node.parent,\n messageId: 'objectRestDestructure',\n });\n }\n\n if (returnValue.type === AST_NODE_TYPES.Identifier) {\n queryResultVariables.add(returnValue.name);\n }\n\n return;\n }\n\n if (returnValue.type !== AST_NODE_TYPES.ArrayPattern) {\n if (returnValue.type === AST_NODE_TYPES.Identifier) {\n queryResultVariables.add(returnValue.name);\n }\n return;\n }\n\n returnValue.elements.forEach((queryResult) => {\n if (queryResult === null) {\n return;\n }\n if (NoRestDestructuringUtils.isObjectRestDestructuring(queryResult)) {\n context.report({\n node: queryResult,\n messageId: 'objectRestDestructure',\n });\n }\n });\n },\n\n VariableDeclarator: (node) => {\n if (\n node.init?.type === AST_NODE_TYPES.Identifier &&\n queryResultVariables.has(node.init.name) &&\n NoRestDestructuringUtils.isObjectRestDestructuring(node.id)\n ) {\n context.report({\n node,\n messageId: 'objectRestDestructure',\n });\n }\n },\n\n SpreadElement: (node) => {\n if (\n node.argument.type === AST_NODE_TYPES.Identifier &&\n queryResultVariables.has(node.argument.name)\n ) {\n context.report({\n node,\n messageId: 'objectRestDestructure',\n });\n }\n },\n };\n },\n});\n\nfunction getHookNameIfTargetFromClient(\n clientRegex: RegExp,\n callee: TSESTree.MemberExpression\n): string | undefined {\n if (callee.property.type !== AST_NODE_TYPES.Identifier) return;\n const name = callee.property.name;\n if (!queryHooks.includes(name)) return;\n const root = getRootIdentifier(callee.object);\n return root && clientRegex.test(root.name) ? name : undefined;\n}\n"],"names":["name","createRule","ESLintUtils","RuleCreator","getDocsUrl","queryHooks","rule","meta","type","docs","description","recommended","messages","objectRestDestructure","schema","properties","clientNamePattern","additionalProperties","defaultOptions","create","context","option","options","clientRegex","createClientNameRegex","queryResultVariables","Set","CallExpression","node","parent","AST_NODE_TYPES","VariableDeclarator","callee","MemberExpression","hookName","getHookNameIfTargetFromClient","returnValue","id","NoRestDestructuringUtils","isObjectRestDestructuring","report","messageId","Identifier","add","ArrayPattern","elements","forEach","queryResult","init","has","SpreadElement","argument","property","includes","root","getRootIdentifier","object","test","undefined"],"mappings":";;;;;;;;AAQO,MAAMA,OAAO;AAEpB,MAAMC,UAAAA,GAAaC,iBAAAA,CAAYC,WAAW,CAAgBC,qBAAAA,CAAAA;AAE1D,MAAMC,UAAAA,GAAa;AACjB,IAAA,UAAA;AACA,IAAA,YAAA;AACA,IAAA,kBAAA;AACA,IAAA,kBAAA;AACA,IAAA,oBAAA;AACA,IAAA;AACD,CAAA;AAEM,MAAMC,OAAOL,UAAAA,CAAW;AAC7BD,IAAAA,IAAAA;IACAO,IAAAA,EAAM;QACJC,IAAAA,EAAM,SAAA;QACNC,IAAAA,EAAM;YACJC,WAAAA,EAAa,yCAAA;YACbC,WAAAA,EAAa;AACf,SAAA;QACAC,QAAAA,EAAU;YACRC,qBAAAA,EAAuB,CAAC,4GAA4G;AACtI,SAAA;QACAC,MAAAA,EAAQ;AACN,YAAA;gBACEN,IAAAA,EAAM,QAAA;gBACNO,UAAAA,EAAY;oBACVC,iBAAAA,EAAmB;wBAAER,IAAAA,EAAM;AAAS;AACtC,iBAAA;gBACAS,oBAAAA,EAAsB;AACxB;AACD;AACH,KAAA;IACAC,cAAAA,EAAgB;QAAC;AAAG,KAAA;AAEpBC,IAAAA,MAAAA,EAAQ,CAACC,OAAAA,GAAAA;AACP,QAAA,MAAMC,SACJ,OAACD,CAAQE,OAAO,CAAC,CAAA,CAAE,IAAmD,EAAC;QAEzE,MAAMC,WAAAA,GAAcC,2CAAAA,CAAsBH,MAAAA,CAAOL,iBAAiB,CAAA;AAElE,QAAA,MAAMS,uBAAuB,IAAIC,GAAAA,EAAAA;QAEjC,OAAO;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,MAAM1C,IAAAA,GAAOgC,MAAAA,CAAOoB,QAAQ,CAACpD,IAAI;AACjC,IAAA,IAAI,CAACK,UAAAA,CAAWgD,QAAQ,CAACrD,IAAAA,CAAAA,EAAO;IAChC,MAAMsD,IAAAA,GAAOC,mCAAAA,CAAkBvB,MAAAA,CAAOwB,MAAM,CAAA;AAC5C,IAAA,OAAOF,QAAQ/B,WAAAA,CAAYkC,IAAI,CAACH,IAAAA,CAAKtD,IAAI,IAAIA,IAAAA,GAAO0D,SAAAA;AACtD;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-rest-destructuring.utils.cjs","sources":["../../../../src/rules/no-rest-destructuring/no-rest-destructuring.utils.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport { AST_NODE_TYPES } from '@typescript-eslint/utils';\n\nexport const NoRestDestructuringUtils = {\n isObjectRestDestructuring(node: TSESTree.Node): boolean {\n if (node.type !== AST_NODE_TYPES.ObjectPattern) {\n return false;\n }\n return node.properties.some((p) => p.type === AST_NODE_TYPES.RestElement);\n },\n};\n"],"names":["NoRestDestructuringUtils","isObjectRestDestructuring","node","type","AST_NODE_TYPES","ObjectPattern","properties","some","p","RestElement"],"mappings":";;;;MAGaA,
|
|
1
|
+
{"version":3,"file":"no-rest-destructuring.utils.cjs","sources":["../../../../src/rules/no-rest-destructuring/no-rest-destructuring.utils.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport { AST_NODE_TYPES } from '@typescript-eslint/utils';\n\nexport const NoRestDestructuringUtils = {\n isObjectRestDestructuring(node: TSESTree.Node): boolean {\n if (node.type !== AST_NODE_TYPES.ObjectPattern) {\n return false;\n }\n return node.properties.some((p) => p.type === AST_NODE_TYPES.RestElement);\n },\n};\n"],"names":["NoRestDestructuringUtils","isObjectRestDestructuring","node","type","AST_NODE_TYPES","ObjectPattern","properties","some","p","RestElement"],"mappings":";;;;MAGaA,wBAAAA,GAA2B;AACtCC,IAAAA,yBAAAA,CAAAA,CAA0BC,IAAmB,EAAA;AAC3C,QAAA,IAAIA,IAAAA,CAAKC,IAAI,KAAKC,oBAAAA,CAAeC,aAAa,EAAE;YAC9C,OAAO,KAAA;AACT,QAAA;QACA,OAAOH,IAAAA,CAAKI,UAAU,CAACC,IAAI,CAAC,CAACC,CAAAA,GAAMA,CAAAA,CAAEL,IAAI,KAAKC,oBAAAA,CAAeK,WAAW,CAAA;AAC1E,IAAA;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-unstable-deps.rule.cjs","sources":["../../../../src/rules/no-unstable-deps/no-unstable-deps.rule.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport type { ExtraRuleDocs } from '../../types';\nimport { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';\nimport { createClientNameRegex } from '../../utils/create-client-name-regex';\nimport { getDocsUrl } from '../../utils/get-docs-url';\nimport { getRootIdentifier } from '../../utils/get-root-identifier';\n\nexport const name = 'no-unstable-deps';\n\nexport const reactHookNames = ['useEffect', 'useCallback', 'useMemo'];\nexport const useQueryHookNames = [\n 'useQuery',\n 'useSuspenseQuery',\n 'useQueries',\n 'useSuspenseQueries',\n 'useInfiniteQuery',\n 'useSuspenseInfiniteQuery',\n];\nconst allHookNames = ['useMutation', ...useQueryHookNames];\nconst createRule = ESLintUtils.RuleCreator<ExtraRuleDocs>(getDocsUrl);\n\nexport const rule = createRule({\n name,\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Disallow putting the result of query hooks directly in a React hook dependency array',\n recommended: 'error',\n },\n messages: {\n noUnstableDeps: `The result of {{queryHook}} is not referentially stable, so don't pass it directly into the dependencies array of {{reactHook}}. Instead, destructure the return value of {{queryHook}} and pass the destructured values into the dependency array of {{reactHook}}.`,\n },\n schema: [\n {\n type: 'object',\n properties: {\n clientNamePattern: { type: 'string' },\n },\n additionalProperties: false,\n },\n ],\n },\n defaultOptions: [{}],\n\n create: (context) => {\n const option =\n (context.options[0] as { clientNamePattern?: string } | undefined) ?? {};\n const clientRegex = createClientNameRegex(option.clientNamePattern);\n\n const trackedVariables: Record<string, string> = {};\n const hookAliasMap: Record<string, string> = {};\n\n function getReactHook(node: TSESTree.CallExpression): string | undefined {\n if (node.callee.type === 'Identifier') {\n const calleeName = node.callee.name;\n if (reactHookNames.includes(calleeName) || calleeName in hookAliasMap) {\n // Return the actually used identifier (could be alias)\n return calleeName;\n }\n } else if (\n node.callee.type === 'MemberExpression' &&\n node.callee.object.type === 'Identifier' &&\n node.callee.object.name === 'React' &&\n node.callee.property.type === 'Identifier' &&\n reactHookNames.includes(node.callee.property.name)\n ) {\n return node.callee.property.name;\n }\n return undefined;\n }\n\n return {\n ImportDeclaration(node: TSESTree.ImportDeclaration) {\n if (\n node.specifiers.length > 0 &&\n node.importKind === 'value' &&\n node.source.value === 'React'\n ) {\n node.specifiers.forEach((specifier) => {\n if (\n specifier.type === AST_NODE_TYPES.ImportSpecifier &&\n specifier.imported.type === AST_NODE_TYPES.Identifier &&\n reactHookNames.includes(specifier.imported.name)\n ) {\n hookAliasMap[specifier.local.name] = specifier.imported.name;\n }\n });\n }\n },\n\n VariableDeclarator(node) {\n if (node.init?.type !== AST_NODE_TYPES.CallExpression) return;\n const hook = isQueryHookFromClient(clientRegex, node.init);\n if (!hook) return;\n if (node.id.type === AST_NODE_TYPES.Identifier) {\n trackedVariables[node.id.name] = hook;\n }\n },\n CallExpression: (node) => {\n const reactHook = getReactHook(node);\n if (!reactHook) return;\n if (node.arguments.length <= 1) return;\n if (node.arguments[1]?.type !== AST_NODE_TYPES.ArrayExpression) return;\n\n const depsArray = node.arguments[1].elements;\n depsArray.forEach((dep) => {\n if (dep?.type !== AST_NODE_TYPES.Identifier) return;\n const queryHook = trackedVariables[dep.name];\n if (!queryHook) return;\n context.report({\n node: dep,\n messageId: 'noUnstableDeps',\n data: {\n queryHook,\n reactHook,\n },\n });\n });\n },\n };\n },\n});\n\nfunction isQueryHookFromClient(\n clientRegex: RegExp,\n call: TSESTree.CallExpression\n): string | null {\n if (call.callee.type !== AST_NODE_TYPES.MemberExpression) return null;\n const member = call.callee;\n if (member.property.type !== AST_NODE_TYPES.Identifier) return null;\n const hook = member.property.name;\n if (!allHookNames.includes(hook)) return null;\n const root = getRootIdentifier(member.object);\n if (!root) return null;\n return clientRegex.test(root.name) ? hook : null;\n}\n"],"names":["name","reactHookNames","useQueryHookNames","allHookNames","createRule","ESLintUtils","RuleCreator","getDocsUrl","rule","meta","type","docs","description","recommended","messages","noUnstableDeps","schema","properties","clientNamePattern","additionalProperties","defaultOptions","create","context","option","options","clientRegex","createClientNameRegex","trackedVariables","hookAliasMap","getReactHook","node","callee","calleeName","includes","object","property","undefined","ImportDeclaration","specifiers","length","importKind","source","value","forEach","specifier","AST_NODE_TYPES","ImportSpecifier","imported","Identifier","local","VariableDeclarator","init","CallExpression","hook","isQueryHookFromClient","id","reactHook","arguments","ArrayExpression","depsArray","elements","dep","queryHook","report","messageId","data","call","MemberExpression","member","root","getRootIdentifier","test"],"mappings":";;;;;;;AAOO,MAAMA,OAAO,mBAAmB;MAE1BC,cAAiB,GAAA;AAAC,IAAA,WAAA;AAAa,IAAA,aAAA;AAAe,IAAA,SAAA;EAAW;MACzDC,iBAAoB,GAAA;AAC/B,IAAA,UAAA;AACA,IAAA,kBAAA;AACA,IAAA,YAAA;AACA,IAAA,oBAAA;AACA,IAAA,kBAAA;AACA,IAAA,0BAAA;EACA;AACF,MAAMC,YAAe,GAAA;AAAC,IAAA,aAAA;AAAkBD,IAAAA,GAAAA,iBAAAA;AAAkB,CAAA,CAAA;AAC1D,MAAME,UAAAA,GAAaC,iBAAYC,CAAAA,WAAW,CAAgBC,qBAAAA,CAAAA,CAAAA;AAEnD,MAAMC,OAAOJ,UAAW,CAAA;AAC7BJ,IAAAA,IAAAA;IACAS,IAAM,EAAA;QACJC,IAAM,EAAA,SAAA;QACNC,IAAM,EAAA;YACJC,WACE,EAAA,sFAAA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IAAAA,CAAKnC,MAAM,CAACrB,IAAI,KAAKmC,oBAAesB,CAAAA,gBAAgB,EAAE,OAAO,IAAA,CAAA;IACjE,MAAMC,MAAAA,GAASF,KAAKnC,MAAM,CAAA;IAC1B,IAAIqC,MAAAA,CAAOjC,QAAQ,CAACzB,IAAI,KAAKmC,oBAAeG,CAAAA,UAAU,EAAE,OAAO,IAAA,CAAA;AAC/D,IAAA,MAAMK,IAAOe,GAAAA,MAAAA,CAAOjC,QAAQ,CAACnC,IAAI,CAAA;AACjC,IAAA,IAAI,CAACG,YAAAA,CAAa8B,QAAQ,CAACoB,OAAO,OAAO,IAAA,CAAA;IACzC,MAAMgB,IAAAA,GAAOC,mCAAkBF,CAAAA,MAAAA,CAAOlC,MAAM,CAAA,CAAA;IAC5C,IAAI,CAACmC,MAAM,OAAO,IAAA,CAAA;AAClB,IAAA,OAAO5C,YAAY8C,IAAI,CAACF,IAAKrE,CAAAA,IAAI,IAAIqD,IAAO,GAAA,IAAA,CAAA;AAC9C;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"no-unstable-deps.rule.cjs","sources":["../../../../src/rules/no-unstable-deps/no-unstable-deps.rule.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport type { ExtraRuleDocs } from '../../types';\nimport { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';\nimport { createClientNameRegex } from '../../utils/create-client-name-regex';\nimport { getDocsUrl } from '../../utils/get-docs-url';\nimport { getRootIdentifier } from '../../utils/get-root-identifier';\n\nexport const name = 'no-unstable-deps';\n\nexport const reactHookNames = ['useEffect', 'useCallback', 'useMemo'];\nexport const useQueryHookNames = [\n 'useQuery',\n 'useSuspenseQuery',\n 'useQueries',\n 'useSuspenseQueries',\n 'useInfiniteQuery',\n 'useSuspenseInfiniteQuery',\n];\nconst allHookNames = ['useMutation', ...useQueryHookNames];\nconst createRule = ESLintUtils.RuleCreator<ExtraRuleDocs>(getDocsUrl);\n\nexport const rule = createRule({\n name,\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Disallow putting the result of query hooks directly in a React hook dependency array',\n recommended: 'error',\n },\n messages: {\n noUnstableDeps: `The result of {{queryHook}} is not referentially stable, so don't pass it directly into the dependencies array of {{reactHook}}. Instead, destructure the return value of {{queryHook}} and pass the destructured values into the dependency array of {{reactHook}}.`,\n },\n schema: [\n {\n type: 'object',\n properties: {\n clientNamePattern: { type: 'string' },\n },\n additionalProperties: false,\n },\n ],\n },\n defaultOptions: [{}],\n\n create: (context) => {\n const option =\n (context.options[0] as { clientNamePattern?: string } | undefined) ?? {};\n const clientRegex = createClientNameRegex(option.clientNamePattern);\n\n const trackedVariables: Record<string, string> = {};\n const hookAliasMap: Record<string, string> = {};\n\n function getReactHook(node: TSESTree.CallExpression): string | undefined {\n if (node.callee.type === 'Identifier') {\n const calleeName = node.callee.name;\n if (reactHookNames.includes(calleeName) || calleeName in hookAliasMap) {\n // Return the actually used identifier (could be alias)\n return calleeName;\n }\n } else if (\n node.callee.type === 'MemberExpression' &&\n node.callee.object.type === 'Identifier' &&\n node.callee.object.name === 'React' &&\n node.callee.property.type === 'Identifier' &&\n reactHookNames.includes(node.callee.property.name)\n ) {\n return node.callee.property.name;\n }\n return undefined;\n }\n\n return {\n ImportDeclaration(node: TSESTree.ImportDeclaration) {\n if (\n node.specifiers.length > 0 &&\n node.importKind === 'value' &&\n node.source.value === 'React'\n ) {\n node.specifiers.forEach((specifier) => {\n if (\n specifier.type === AST_NODE_TYPES.ImportSpecifier &&\n specifier.imported.type === AST_NODE_TYPES.Identifier &&\n reactHookNames.includes(specifier.imported.name)\n ) {\n hookAliasMap[specifier.local.name] = specifier.imported.name;\n }\n });\n }\n },\n\n VariableDeclarator(node) {\n if (node.init?.type !== AST_NODE_TYPES.CallExpression) return;\n const hook = isQueryHookFromClient(clientRegex, node.init);\n if (!hook) return;\n if (node.id.type === AST_NODE_TYPES.Identifier) {\n trackedVariables[node.id.name] = hook;\n }\n },\n CallExpression: (node) => {\n const reactHook = getReactHook(node);\n if (!reactHook) return;\n if (node.arguments.length <= 1) return;\n if (node.arguments[1]?.type !== AST_NODE_TYPES.ArrayExpression) return;\n\n const depsArray = node.arguments[1].elements;\n depsArray.forEach((dep) => {\n if (dep?.type !== AST_NODE_TYPES.Identifier) return;\n const queryHook = trackedVariables[dep.name];\n if (!queryHook) return;\n context.report({\n node: dep,\n messageId: 'noUnstableDeps',\n data: {\n queryHook,\n reactHook,\n },\n });\n });\n },\n };\n },\n});\n\nfunction isQueryHookFromClient(\n clientRegex: RegExp,\n call: TSESTree.CallExpression\n): string | null {\n if (call.callee.type !== AST_NODE_TYPES.MemberExpression) return null;\n const member = call.callee;\n if (member.property.type !== AST_NODE_TYPES.Identifier) return null;\n const hook = member.property.name;\n if (!allHookNames.includes(hook)) return null;\n const root = getRootIdentifier(member.object);\n if (!root) return null;\n return clientRegex.test(root.name) ? hook : null;\n}\n"],"names":["name","reactHookNames","useQueryHookNames","allHookNames","createRule","ESLintUtils","RuleCreator","getDocsUrl","rule","meta","type","docs","description","recommended","messages","noUnstableDeps","schema","properties","clientNamePattern","additionalProperties","defaultOptions","create","context","option","options","clientRegex","createClientNameRegex","trackedVariables","hookAliasMap","getReactHook","node","callee","calleeName","includes","object","property","undefined","ImportDeclaration","specifiers","length","importKind","source","value","forEach","specifier","AST_NODE_TYPES","ImportSpecifier","imported","Identifier","local","VariableDeclarator","init","CallExpression","hook","isQueryHookFromClient","id","reactHook","arguments","ArrayExpression","depsArray","elements","dep","queryHook","report","messageId","data","call","MemberExpression","member","root","getRootIdentifier","test"],"mappings":";;;;;;;AAOO,MAAMA,OAAO;MAEPC,cAAAA,GAAiB;AAAC,IAAA,WAAA;AAAa,IAAA,aAAA;AAAe,IAAA;;MAC9CC,iBAAAA,GAAoB;AAC/B,IAAA,UAAA;AACA,IAAA,kBAAA;AACA,IAAA,YAAA;AACA,IAAA,oBAAA;AACA,IAAA,kBAAA;AACA,IAAA;;AAEF,MAAMC,YAAAA,GAAe;A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SAAA;AACF,IAAA;AACF,CAAA;AAEA,SAASF,qBAAAA,CACP7B,WAAmB,EACnByC,IAA6B,EAAA;IAE7B,IAAIA,IAAAA,CAAKnC,MAAM,CAACrB,IAAI,KAAKmC,oBAAAA,CAAesB,gBAAgB,EAAE,OAAO,IAAA;IACjE,MAAMC,MAAAA,GAASF,KAAKnC,MAAM;IAC1B,IAAIqC,MAAAA,CAAOjC,QAAQ,CAACzB,IAAI,KAAKmC,oBAAAA,CAAeG,UAAU,EAAE,OAAO,IAAA;AAC/D,IAAA,MAAMK,IAAAA,GAAOe,MAAAA,CAAOjC,QAAQ,CAACnC,IAAI;AACjC,IAAA,IAAI,CAACG,YAAAA,CAAa8B,QAAQ,CAACoB,OAAO,OAAO,IAAA;IACzC,MAAMgB,IAAAA,GAAOC,mCAAAA,CAAkBF,MAAAA,CAAOlC,MAAM,CAAA;IAC5C,IAAI,CAACmC,MAAM,OAAO,IAAA;AAClB,IAAA,OAAO5C,YAAY8C,IAAI,CAACF,IAAAA,CAAKrE,IAAI,IAAIqD,IAAAA,GAAO,IAAA;AAC9C;;;;;;;"}
|
package/dist/cjs/rules.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.cjs","sources":["../../src/rules.ts"],"sourcesContent":["import type { ESLintUtils } from '@typescript-eslint/utils';\nimport type { ExtraRuleDocs } from './types';\nimport * as noRestDestructuring from './rules/no-rest-destructuring/no-rest-destructuring.rule';\nimport * as noUnstableDeps from './rules/no-unstable-deps/no-unstable-deps.rule';\n\nexport const rules: Record<\n string,\n ESLintUtils.RuleModule<\n string,\n ReadonlyArray<unknown>,\n ExtraRuleDocs,\n ESLintUtils.RuleListener\n >\n> = {\n [noRestDestructuring.name]: noRestDestructuring.rule,\n [noUnstableDeps.name]: noUnstableDeps.rule,\n};\n"],"names":["rules","noRestDestructuring","noUnstableDeps"],"mappings":";;;;;MAKaA,
|
|
1
|
+
{"version":3,"file":"rules.cjs","sources":["../../src/rules.ts"],"sourcesContent":["import type { ESLintUtils } from '@typescript-eslint/utils';\nimport type { ExtraRuleDocs } from './types';\nimport * as noRestDestructuring from './rules/no-rest-destructuring/no-rest-destructuring.rule';\nimport * as noUnstableDeps from './rules/no-unstable-deps/no-unstable-deps.rule';\n\nexport const rules: Record<\n string,\n ESLintUtils.RuleModule<\n string,\n ReadonlyArray<unknown>,\n ExtraRuleDocs,\n ESLintUtils.RuleListener\n >\n> = {\n [noRestDestructuring.name]: noRestDestructuring.rule,\n [noUnstableDeps.name]: noUnstableDeps.rule,\n};\n"],"names":["rules","noRestDestructuring","noUnstableDeps"],"mappings":";;;;;MAKaA,KAAAA,GAQT;AACF,IAAA,CAACC,6BAAwB,GAAGA,6BAAwB;AACpD,IAAA,CAACC,wBAAmB,GAAGA;AACzB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-client-name-regex.cjs","sources":["../../../src/utils/create-client-name-regex.ts"],"sourcesContent":["export function createClientNameRegex(clientNamePattern: string | undefined) {\n clientNamePattern = clientNamePattern?.trim();\n\n if (clientNamePattern) {\n // Check if pattern is in regex format: /pattern/flags\n const regexMatch = clientNamePattern.match(/^\\/(.*)\\/([gimuy]*)$/);\n\n if (regexMatch) {\n const regexPattern = regexMatch[1].trim();\n const flags = regexMatch[2];\n\n // Validate that regex pattern is not empty or whitespace-only\n if (regexPattern === '') {\n throw new Error(\n 'clientNamePattern cannot be empty or contain only whitespace'\n );\n }\n\n return new RegExp(regexPattern, flags);\n }\n\n // Fallback to treating as plain string pattern\n return new RegExp(clientNamePattern);\n } else if (clientNamePattern === '') {\n throw new Error(\n 'clientNamePattern cannot be empty or contain only whitespace'\n );\n }\n\n // Default if no pattern provided\n return /qraft|api/i;\n}\n"],"names":["createClientNameRegex","clientNamePattern","trim","regexMatch","match","regexPattern","flags","Error","RegExp"],"mappings":";;AAAO,SAASA,sBAAsBC,iBAAqC,EAAA;AACzEA,IAAAA,iBAAAA,GAAoBA,
|
|
1
|
+
{"version":3,"file":"create-client-name-regex.cjs","sources":["../../../src/utils/create-client-name-regex.ts"],"sourcesContent":["export function createClientNameRegex(clientNamePattern: string | undefined) {\n clientNamePattern = clientNamePattern?.trim();\n\n if (clientNamePattern) {\n // Check if pattern is in regex format: /pattern/flags\n const regexMatch = clientNamePattern.match(/^\\/(.*)\\/([gimuy]*)$/);\n\n if (regexMatch) {\n const regexPattern = regexMatch[1].trim();\n const flags = regexMatch[2];\n\n // Validate that regex pattern is not empty or whitespace-only\n if (regexPattern === '') {\n throw new Error(\n 'clientNamePattern cannot be empty or contain only whitespace'\n );\n }\n\n return new RegExp(regexPattern, flags);\n }\n\n // Fallback to treating as plain string pattern\n return new RegExp(clientNamePattern);\n } else if (clientNamePattern === '') {\n throw new Error(\n 'clientNamePattern cannot be empty or contain only whitespace'\n );\n }\n\n // Default if no pattern provided\n return /qraft|api/i;\n}\n"],"names":["createClientNameRegex","clientNamePattern","trim","regexMatch","match","regexPattern","flags","Error","RegExp"],"mappings":";;AAAO,SAASA,sBAAsBC,iBAAqC,EAAA;AACzEA,IAAAA,iBAAAA,GAAoBA,iBAAAA,EAAmBC,IAAAA,EAAAA;AAEvC,IAAA,IAAID,iBAAAA,EAAmB;;QAErB,MAAME,UAAAA,GAAaF,iBAAAA,CAAkBG,KAAK,CAAC,sBAAA,CAAA;AAE3C,QAAA,IAAID,UAAAA,EAAY;AACd,YAAA,MAAME,YAAAA,GAAeF,UAAU,CAAC,CAAA,CAAE,CAACD,IAAI,EAAA;YACvC,MAAMI,KAAAA,GAAQH,UAAU,CAAC,CAAA,CAAE;;AAG3B,YAAA,IAAIE,iBAAiB,EAAA,EAAI;AACvB,gBAAA,MAAM,IAAIE,KAAAA,CACR,8DAAA,CAAA;AAEJ,YAAA;YAEA,OAAO,IAAIC,OAAOH,YAAAA,EAAcC,KAAAA,CAAAA;AAClC,QAAA;;AAGA,QAAA,OAAO,IAAIE,MAAAA,CAAOP,iBAAAA,CAAAA;IACpB,CAAA,MAAO,IAAIA,sBAAsB,EAAA,EAAI;AACnC,QAAA,MAAM,IAAIM,KAAAA,CACR,8DAAA,CAAA;AAEJ,IAAA;;IAGA,OAAO,YAAA;AACT;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-docs-url.cjs","sources":["../../../src/utils/get-docs-url.ts"],"sourcesContent":["export const getDocsUrl = (ruleName: string): string =>\n `https://openapi-qraft.github.io/openapi-qraft/docs/eslint/${ruleName}`;\n"],"names":["getDocsUrl","ruleName"],"mappings":";;AAAO,MAAMA,aAAa,CAACC,QAAAA,GACzB,CAAC,0DAA0D,EAAEA
|
|
1
|
+
{"version":3,"file":"get-docs-url.cjs","sources":["../../../src/utils/get-docs-url.ts"],"sourcesContent":["export const getDocsUrl = (ruleName: string): string =>\n `https://openapi-qraft.github.io/openapi-qraft/docs/eslint/${ruleName}`;\n"],"names":["getDocsUrl","ruleName"],"mappings":";;AAAO,MAAMA,aAAa,CAACC,QAAAA,GACzB,CAAC,0DAA0D,EAAEA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-root-identifier.cjs","sources":["../../../src/utils/get-root-identifier.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport { AST_NODE_TYPES } from '@typescript-eslint/utils';\n\nexport function getRootIdentifier(\n node: TSESTree.Node\n): TSESTree.Identifier | undefined {\n let current: TSESTree.Node | undefined = node;\n while (\n current.type === AST_NODE_TYPES.MemberExpression ||\n current.type === AST_NODE_TYPES.TSNonNullExpression ||\n current.type === AST_NODE_TYPES.ChainExpression\n ) {\n if (current.type === AST_NODE_TYPES.MemberExpression) {\n current = current.object;\n continue;\n }\n if (current.type === AST_NODE_TYPES.TSNonNullExpression) {\n current = current.expression;\n continue;\n }\n\n current = current.expression;\n }\n return current.type === AST_NODE_TYPES.Identifier ? current : undefined;\n}\n"],"names":["getRootIdentifier","node","current","type","AST_NODE_TYPES","MemberExpression","TSNonNullExpression","ChainExpression","object","expression","Identifier","undefined"],"mappings":";;;;AAGO,SAASA,kBACdC,IAAmB,EAAA;AAEnB,IAAA,IAAIC,
|
|
1
|
+
{"version":3,"file":"get-root-identifier.cjs","sources":["../../../src/utils/get-root-identifier.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport { AST_NODE_TYPES } from '@typescript-eslint/utils';\n\nexport function getRootIdentifier(\n node: TSESTree.Node\n): TSESTree.Identifier | undefined {\n let current: TSESTree.Node | undefined = node;\n while (\n current.type === AST_NODE_TYPES.MemberExpression ||\n current.type === AST_NODE_TYPES.TSNonNullExpression ||\n current.type === AST_NODE_TYPES.ChainExpression\n ) {\n if (current.type === AST_NODE_TYPES.MemberExpression) {\n current = current.object;\n continue;\n }\n if (current.type === AST_NODE_TYPES.TSNonNullExpression) {\n current = current.expression;\n continue;\n }\n\n current = current.expression;\n }\n return current.type === AST_NODE_TYPES.Identifier ? current : undefined;\n}\n"],"names":["getRootIdentifier","node","current","type","AST_NODE_TYPES","MemberExpression","TSNonNullExpression","ChainExpression","object","expression","Identifier","undefined"],"mappings":";;;;AAGO,SAASA,kBACdC,IAAmB,EAAA;AAEnB,IAAA,IAAIC,OAAAA,GAAqCD,IAAAA;AACzC,IAAA,MACEC,QAAQC,IAAI,KAAKC,oBAAAA,CAAeC,gBAAgB,IAChDH,OAAAA,CAAQC,IAAI,KAAKC,oBAAAA,CAAeE,mBAAmB,IACnDJ,OAAAA,CAAQC,IAAI,KAAKC,oBAAAA,CAAeG,eAAe,CAC/C;AACA,QAAA,IAAIL,OAAAA,CAAQC,IAAI,KAAKC,oBAAAA,CAAeC,gBAAgB,EAAE;AACpDH,YAAAA,OAAAA,GAAUA,QAAQM,MAAM;AACxB,YAAA;AACF,QAAA;AACA,QAAA,IAAIN,OAAAA,CAAQC,IAAI,KAAKC,oBAAAA,CAAeE,mBAAmB,EAAE;AACvDJ,YAAAA,OAAAA,GAAUA,QAAQO,UAAU;AAC5B,YAAA;AACF,QAAA;AAEAP,QAAAA,OAAAA,GAAUA,QAAQO,UAAU;AAC9B,IAAA;AACA,IAAA,OAAOP,QAAQC,IAAI,KAAKC,oBAAAA,CAAeM,UAAU,GAAGR,OAAAA,GAAUS,SAAAA;AAChE;;;;"}
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import type { RuleModule } from '@typescript-eslint/utils/ts-eslint';\nimport type { ESLint, Linter } from 'eslint';\nimport { rules } from './rules';\n\ntype RuleKey = keyof typeof rules;\n\nexport interface Plugin extends Omit<ESLint.Plugin, 'rules'> {\n rules: Record<RuleKey, RuleModule<any, any, any>>;\n configs: {\n recommended: ESLint.ConfigData;\n 'flat/recommended': Array<Linter.Config>;\n };\n}\n\nexport const plugin: Plugin = {\n meta: {\n name: '@openapi-qraft/eslint-plugin-query',\n },\n configs: {} as Plugin['configs'],\n rules,\n};\n\n// Assign configs here so we can reference `plugin`\nObject.assign(plugin.configs, {\n recommended: {\n plugins: ['@openapi-qraft/query'],\n rules: {\n '@openapi-qraft/query/no-rest-destructuring': 'warn',\n '@openapi-qraft/query/no-unstable-deps': 'error',\n },\n },\n 'flat/recommended': [\n {\n name: 'openapi-qraft/query/flat/recommended',\n plugins: {\n '@openapi-qraft/query': plugin,\n },\n rules: {\n '@openapi-qraft/query/no-rest-destructuring': 'warn',\n '@openapi-qraft/query/no-unstable-deps': 'error',\n },\n },\n ],\n});\n\n// Reexport rules & configs for the Legacy config\nexport { rules };\nexport const configs = plugin.configs;\n\n/**\n * @alias\n * @type {Plugin}\n **/\nexport default plugin;\n"],"names":["plugin","meta","name","configs","rules","Object","assign","recommended","plugins"],"mappings":";;MAcaA,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import type { RuleModule } from '@typescript-eslint/utils/ts-eslint';\nimport type { ESLint, Linter } from 'eslint';\nimport { rules } from './rules';\n\ntype RuleKey = keyof typeof rules;\n\nexport interface Plugin extends Omit<ESLint.Plugin, 'rules'> {\n rules: Record<RuleKey, RuleModule<any, any, any>>;\n configs: {\n recommended: ESLint.ConfigData;\n 'flat/recommended': Array<Linter.Config>;\n };\n}\n\nexport const plugin: Plugin = {\n meta: {\n name: '@openapi-qraft/eslint-plugin-query',\n },\n configs: {} as Plugin['configs'],\n rules,\n};\n\n// Assign configs here so we can reference `plugin`\nObject.assign(plugin.configs, {\n recommended: {\n plugins: ['@openapi-qraft/query'],\n rules: {\n '@openapi-qraft/query/no-rest-destructuring': 'warn',\n '@openapi-qraft/query/no-unstable-deps': 'error',\n },\n },\n 'flat/recommended': [\n {\n name: 'openapi-qraft/query/flat/recommended',\n plugins: {\n '@openapi-qraft/query': plugin,\n },\n rules: {\n '@openapi-qraft/query/no-rest-destructuring': 'warn',\n '@openapi-qraft/query/no-unstable-deps': 'error',\n },\n },\n ],\n});\n\n// Reexport rules & configs for the Legacy config\nexport { rules };\nexport const configs = plugin.configs;\n\n/**\n * @alias\n * @type {Plugin}\n **/\nexport default plugin;\n"],"names":["plugin","meta","name","configs","rules","Object","assign","recommended","plugins"],"mappings":";;MAcaA,MAAAA,GAAiB;IAC5BC,IAAAA,EAAM;QACJC,IAAAA,EAAM;AACR,KAAA;AACAC,IAAAA,OAAAA,EAAS,EAAC;AACVC,IAAAA;AACF;AAEA;AACAC,MAAAA,CAAOC,MAAM,CAACN,MAAAA,CAAOG,OAAO,EAAE;IAC5BI,WAAAA,EAAa;QACXC,OAAAA,EAAS;AAAC,YAAA;AAAuB,SAAA;QACjCJ,KAAAA,EAAO;YACL,4CAAA,EAA8C,MAAA;YAC9C,uCAAA,EAAyC;AAC3C;AACF,KAAA;IACA,kBAAA,EAAoB;AAClB,QAAA;YACEF,IAAAA,EAAM,sCAAA;YACNM,OAAAA,EAAS;gBACP,sBAAA,EAAwBR;AAC1B,aAAA;YACAI,KAAAA,EAAO;gBACL,4CAAA,EAA8C,MAAA;gBAC9C,uCAAA,EAAyC;AAC3C;AACF;AACD;AACH,CAAA,CAAA;AAIO,MAAMD,OAAAA,GAAUH,MAAAA,CAAOG;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';
|
|
2
2
|
import { createClientNameRegex } from '../../utils/create-client-name-regex.js';
|
|
3
3
|
import { getDocsUrl } from '../../utils/get-docs-url.js';
|
|
4
4
|
import { getRootIdentifier } from '../../utils/get-root-identifier.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-rest-destructuring.rule.js","sources":["../../../../src/rules/no-rest-destructuring/no-rest-destructuring.rule.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport type { ExtraRuleDocs } from '../../types';\nimport { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';\nimport { createClientNameRegex } from '../../utils/create-client-name-regex';\nimport { getDocsUrl } from '../../utils/get-docs-url';\nimport { getRootIdentifier } from '../../utils/get-root-identifier';\nimport { NoRestDestructuringUtils } from './no-rest-destructuring.utils';\n\nexport const name = 'no-rest-destructuring';\n\nconst createRule = ESLintUtils.RuleCreator<ExtraRuleDocs>(getDocsUrl);\n\nconst queryHooks = [\n 'useQuery',\n 'useQueries',\n 'useInfiniteQuery',\n 'useSuspenseQuery',\n 'useSuspenseQueries',\n 'useSuspenseInfiniteQuery',\n];\n\nexport const rule = createRule({\n name,\n meta: {\n type: 'problem',\n docs: {\n description: 'Disallows rest destructuring in queries',\n recommended: 'warn',\n },\n messages: {\n objectRestDestructure: `Object rest destructuring on a query will observe all changes to the query, leading to excessive re-renders.`,\n },\n schema: [\n {\n type: 'object',\n properties: {\n clientNamePattern: { type: 'string' },\n },\n additionalProperties: false,\n },\n ],\n },\n defaultOptions: [{}],\n\n create: (context) => {\n const option =\n (context.options[0] as { clientNamePattern?: string } | undefined) ?? {};\n\n const clientRegex = createClientNameRegex(option.clientNamePattern);\n\n const queryResultVariables = new Set<string>();\n\n return {\n CallExpression: (node) => {\n if (node.parent.type !== AST_NODE_TYPES.VariableDeclarator) return;\n\n const callee = node.callee;\n if (callee.type !== AST_NODE_TYPES.MemberExpression) return;\n const hookName = getHookNameIfTargetFromClient(clientRegex, callee);\n if (!hookName) return;\n const returnValue = node.parent.id;\n\n if (hookName !== 'useQueries' && hookName !== 'useSuspenseQueries') {\n if (NoRestDestructuringUtils.isObjectRestDestructuring(returnValue)) {\n return context.report({\n node: node.parent,\n messageId: 'objectRestDestructure',\n });\n }\n\n if (returnValue.type === AST_NODE_TYPES.Identifier) {\n queryResultVariables.add(returnValue.name);\n }\n\n return;\n }\n\n if (returnValue.type !== AST_NODE_TYPES.ArrayPattern) {\n if (returnValue.type === AST_NODE_TYPES.Identifier) {\n queryResultVariables.add(returnValue.name);\n }\n return;\n }\n\n returnValue.elements.forEach((queryResult) => {\n if (queryResult === null) {\n return;\n }\n if (NoRestDestructuringUtils.isObjectRestDestructuring(queryResult)) {\n context.report({\n node: queryResult,\n messageId: 'objectRestDestructure',\n });\n }\n });\n },\n\n VariableDeclarator: (node) => {\n if (\n node.init?.type === AST_NODE_TYPES.Identifier &&\n queryResultVariables.has(node.init.name) &&\n NoRestDestructuringUtils.isObjectRestDestructuring(node.id)\n ) {\n context.report({\n node,\n messageId: 'objectRestDestructure',\n });\n }\n },\n\n SpreadElement: (node) => {\n if (\n node.argument.type === AST_NODE_TYPES.Identifier &&\n queryResultVariables.has(node.argument.name)\n ) {\n context.report({\n node,\n messageId: 'objectRestDestructure',\n });\n }\n },\n };\n },\n});\n\nfunction getHookNameIfTargetFromClient(\n clientRegex: RegExp,\n callee: TSESTree.MemberExpression\n): string | undefined {\n if (callee.property.type !== AST_NODE_TYPES.Identifier) return;\n const name = callee.property.name;\n if (!queryHooks.includes(name)) return;\n const root = getRootIdentifier(callee.object);\n return root && clientRegex.test(root.name) ? name : undefined;\n}\n"],"names":["name","createRule","ESLintUtils","RuleCreator","getDocsUrl","queryHooks","rule","meta","type","docs","description","recommended","messages","objectRestDestructure","schema","properties","clientNamePattern","additionalProperties","defaultOptions","create","context","option","options","clientRegex","createClientNameRegex","queryResultVariables","Set","CallExpression","node","parent","AST_NODE_TYPES","VariableDeclarator","callee","MemberExpression","hookName","getHookNameIfTargetFromClient","returnValue","id","NoRestDestructuringUtils","isObjectRestDestructuring","report","messageId","Identifier","add","ArrayPattern","elements","forEach","queryResult","init","has","SpreadElement","argument","property","includes","root","getRootIdentifier","object","test","undefined"],"mappings":";;;;;;AAQO,MAAMA,OAAO
|
|
1
|
+
{"version":3,"file":"no-rest-destructuring.rule.js","sources":["../../../../src/rules/no-rest-destructuring/no-rest-destructuring.rule.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport type { ExtraRuleDocs } from '../../types';\nimport { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';\nimport { createClientNameRegex } from '../../utils/create-client-name-regex';\nimport { getDocsUrl } from '../../utils/get-docs-url';\nimport { getRootIdentifier } from '../../utils/get-root-identifier';\nimport { NoRestDestructuringUtils } from './no-rest-destructuring.utils';\n\nexport const name = 'no-rest-destructuring';\n\nconst createRule = ESLintUtils.RuleCreator<ExtraRuleDocs>(getDocsUrl);\n\nconst queryHooks = [\n 'useQuery',\n 'useQueries',\n 'useInfiniteQuery',\n 'useSuspenseQuery',\n 'useSuspenseQueries',\n 'useSuspenseInfiniteQuery',\n];\n\nexport const rule = createRule({\n name,\n meta: {\n type: 'problem',\n docs: {\n description: 'Disallows rest destructuring in queries',\n recommended: 'warn',\n },\n messages: {\n objectRestDestructure: `Object rest destructuring on a query will observe all changes to the query, leading to excessive re-renders.`,\n },\n schema: [\n {\n type: 'object',\n properties: {\n clientNamePattern: { type: 'string' },\n },\n additionalProperties: false,\n },\n ],\n },\n defaultOptions: [{}],\n\n create: (context) => {\n const option =\n (context.options[0] as { clientNamePattern?: string } | undefined) ?? {};\n\n const clientRegex = createClientNameRegex(option.clientNamePattern);\n\n const queryResultVariables = new Set<string>();\n\n return {\n CallExpression: (node) => {\n if (node.parent.type !== AST_NODE_TYPES.VariableDeclarator) return;\n\n const callee = node.callee;\n if (callee.type !== AST_NODE_TYPES.MemberExpression) return;\n const hookName = getHookNameIfTargetFromClient(clientRegex, callee);\n if (!hookName) return;\n const returnValue = node.parent.id;\n\n if (hookName !== 'useQueries' && hookName !== 'useSuspenseQueries') {\n if (NoRestDestructuringUtils.isObjectRestDestructuring(returnValue)) {\n return context.report({\n node: node.parent,\n messageId: 'objectRestDestructure',\n });\n }\n\n if (returnValue.type === AST_NODE_TYPES.Identifier) {\n queryResultVariables.add(returnValue.name);\n }\n\n return;\n }\n\n if (returnValue.type !== AST_NODE_TYPES.ArrayPattern) {\n if (returnValue.type === AST_NODE_TYPES.Identifier) {\n queryResultVariables.add(returnValue.name);\n }\n return;\n }\n\n returnValue.elements.forEach((queryResult) => {\n if (queryResult === null) {\n return;\n }\n if (NoRestDestructuringUtils.isObjectRestDestructuring(queryResult)) {\n context.report({\n node: queryResult,\n messageId: 'objectRestDestructure',\n });\n }\n });\n },\n\n VariableDeclarator: (node) => {\n if (\n node.init?.type === AST_NODE_TYPES.Identifier &&\n queryResultVariables.has(node.init.name) &&\n NoRestDestructuringUtils.isObjectRestDestructuring(node.id)\n ) {\n context.report({\n node,\n messageId: 'objectRestDestructure',\n });\n }\n },\n\n SpreadElement: (node) => {\n if (\n node.argument.type === AST_NODE_TYPES.Identifier &&\n queryResultVariables.has(node.argument.name)\n ) {\n context.report({\n node,\n messageId: 'objectRestDestructure',\n });\n }\n },\n };\n },\n});\n\nfunction getHookNameIfTargetFromClient(\n clientRegex: RegExp,\n callee: TSESTree.MemberExpression\n): string | undefined {\n if (callee.property.type !== AST_NODE_TYPES.Identifier) return;\n const name = callee.property.name;\n if (!queryHooks.includes(name)) return;\n const root = getRootIdentifier(callee.object);\n return root && clientRegex.test(root.name) ? name : undefined;\n}\n"],"names":["name","createRule","ESLintUtils","RuleCreator","getDocsUrl","queryHooks","rule","meta","type","docs","description","recommended","messages","objectRestDestructure","schema","properties","clientNamePattern","additionalProperties","defaultOptions","create","context","option","options","clientRegex","createClientNameRegex","queryResultVariables","Set","CallExpression","node","parent","AST_NODE_TYPES","VariableDeclarator","callee","MemberExpression","hookName","getHookNameIfTargetFromClient","returnValue","id","NoRestDestructuringUtils","isObjectRestDestructuring","report","messageId","Identifier","add","ArrayPattern","elements","forEach","queryResult","init","has","SpreadElement","argument","property","includes","root","getRootIdentifier","object","test","undefined"],"mappings":";;;;;;AAQO,MAAMA,OAAO;AAEpB,MAAMC,UAAAA,GAAaC,WAAAA,CAAYC,WAAW,CAAgBC,UAAAA,CAAAA;AAE1D,MAAMC,UAAAA,GAAa;AACjB,IAAA,UAAA;AACA,IAAA,YAAA;AACA,IAAA,kBAAA;AACA,IAAA,kBAAA;AACA,IAAA,oBAAA;AACA,IAAA;AACD,CAAA;AAEM,MAAMC,OAAOL,UAAAA,CAAW;AAC7BD,IAAAA,IAAAA;IACAO,IAAAA,EAAM;QACJC,IAAAA,EAAM,SAAA;QACNC,IAAAA,EAAM;YACJC,WAAAA,EAAa,yCAAA;YACbC,WAAAA,EAAa;AACf,SAAA;QACAC,QAAAA,EAAU;YACRC,qBAAAA,EAAuB,CAAC,4GAA4G;AACtI,SAAA;QACAC,MAAAA,EAAQ;AACN,YAAA;gBACEN,IAAAA,EAAM,QAAA;gBACNO,UAAAA,EAAY;oBACVC,iBAAAA,EAAmB;wBAAER,IAAAA,EAAM;AAAS;AACtC,iBAAA;gBACAS,oBAAAA,EAAsB;AACxB;AACD;AACH,KAAA;IACAC,cAAAA,EAAgB;QAAC;AAAG,KAAA;AAEpBC,IAAAA,MAAAA,EAAQ,CAACC,OAAAA,GAAAA;AACP,QAAA,MAAMC,SACJ,OAACD,CAAQE,OAAO,CAAC,CAAA,CAAE,IAAmD,EAAC;QAEzE,MAAMC,WAAAA,GAAcC,qBAAAA,CAAsBH,MAAAA,CAAOL,iBAAiB,CAAA;AAElE,QAAA,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sB,cAAAA,CAAeY,UAAU,EAAE;AACxD,IAAA,MAAM1C,IAAAA,GAAOgC,MAAAA,CAAOoB,QAAQ,CAACpD,IAAI;AACjC,IAAA,IAAI,CAACK,UAAAA,CAAWgD,QAAQ,CAACrD,IAAAA,CAAAA,EAAO;IAChC,MAAMsD,IAAAA,GAAOC,iBAAAA,CAAkBvB,MAAAA,CAAOwB,MAAM,CAAA;AAC5C,IAAA,OAAOF,QAAQ/B,WAAAA,CAAYkC,IAAI,CAACH,IAAAA,CAAKtD,IAAI,IAAIA,IAAAA,GAAO0D,SAAAA;AACtD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-rest-destructuring.utils.js","sources":["../../../../src/rules/no-rest-destructuring/no-rest-destructuring.utils.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport { AST_NODE_TYPES } from '@typescript-eslint/utils';\n\nexport const NoRestDestructuringUtils = {\n isObjectRestDestructuring(node: TSESTree.Node): boolean {\n if (node.type !== AST_NODE_TYPES.ObjectPattern) {\n return false;\n }\n return node.properties.some((p) => p.type === AST_NODE_TYPES.RestElement);\n },\n};\n"],"names":["NoRestDestructuringUtils","isObjectRestDestructuring","node","type","AST_NODE_TYPES","ObjectPattern","properties","some","p","RestElement"],"mappings":";;MAGaA,
|
|
1
|
+
{"version":3,"file":"no-rest-destructuring.utils.js","sources":["../../../../src/rules/no-rest-destructuring/no-rest-destructuring.utils.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport { AST_NODE_TYPES } from '@typescript-eslint/utils';\n\nexport const NoRestDestructuringUtils = {\n isObjectRestDestructuring(node: TSESTree.Node): boolean {\n if (node.type !== AST_NODE_TYPES.ObjectPattern) {\n return false;\n }\n return node.properties.some((p) => p.type === AST_NODE_TYPES.RestElement);\n },\n};\n"],"names":["NoRestDestructuringUtils","isObjectRestDestructuring","node","type","AST_NODE_TYPES","ObjectPattern","properties","some","p","RestElement"],"mappings":";;MAGaA,wBAAAA,GAA2B;AACtCC,IAAAA,yBAAAA,CAAAA,CAA0BC,IAAmB,EAAA;AAC3C,QAAA,IAAIA,IAAAA,CAAKC,IAAI,KAAKC,cAAAA,CAAeC,aAAa,EAAE;YAC9C,OAAO,KAAA;AACT,QAAA;QACA,OAAOH,IAAAA,CAAKI,UAAU,CAACC,IAAI,CAAC,CAACC,CAAAA,GAAMA,CAAAA,CAAEL,IAAI,KAAKC,cAAAA,CAAeK,WAAW,CAAA;AAC1E,IAAA;AACF;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';
|
|
2
2
|
import { createClientNameRegex } from '../../utils/create-client-name-regex.js';
|
|
3
3
|
import { getDocsUrl } from '../../utils/get-docs-url.js';
|
|
4
4
|
import { getRootIdentifier } from '../../utils/get-root-identifier.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-unstable-deps.rule.js","sources":["../../../../src/rules/no-unstable-deps/no-unstable-deps.rule.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport type { ExtraRuleDocs } from '../../types';\nimport { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';\nimport { createClientNameRegex } from '../../utils/create-client-name-regex';\nimport { getDocsUrl } from '../../utils/get-docs-url';\nimport { getRootIdentifier } from '../../utils/get-root-identifier';\n\nexport const name = 'no-unstable-deps';\n\nexport const reactHookNames = ['useEffect', 'useCallback', 'useMemo'];\nexport const useQueryHookNames = [\n 'useQuery',\n 'useSuspenseQuery',\n 'useQueries',\n 'useSuspenseQueries',\n 'useInfiniteQuery',\n 'useSuspenseInfiniteQuery',\n];\nconst allHookNames = ['useMutation', ...useQueryHookNames];\nconst createRule = ESLintUtils.RuleCreator<ExtraRuleDocs>(getDocsUrl);\n\nexport const rule = createRule({\n name,\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Disallow putting the result of query hooks directly in a React hook dependency array',\n recommended: 'error',\n },\n messages: {\n noUnstableDeps: `The result of {{queryHook}} is not referentially stable, so don't pass it directly into the dependencies array of {{reactHook}}. Instead, destructure the return value of {{queryHook}} and pass the destructured values into the dependency array of {{reactHook}}.`,\n },\n schema: [\n {\n type: 'object',\n properties: {\n clientNamePattern: { type: 'string' },\n },\n additionalProperties: false,\n },\n ],\n },\n defaultOptions: [{}],\n\n create: (context) => {\n const option =\n (context.options[0] as { clientNamePattern?: string } | undefined) ?? {};\n const clientRegex = createClientNameRegex(option.clientNamePattern);\n\n const trackedVariables: Record<string, string> = {};\n const hookAliasMap: Record<string, string> = {};\n\n function getReactHook(node: TSESTree.CallExpression): string | undefined {\n if (node.callee.type === 'Identifier') {\n const calleeName = node.callee.name;\n if (reactHookNames.includes(calleeName) || calleeName in hookAliasMap) {\n // Return the actually used identifier (could be alias)\n return calleeName;\n }\n } else if (\n node.callee.type === 'MemberExpression' &&\n node.callee.object.type === 'Identifier' &&\n node.callee.object.name === 'React' &&\n node.callee.property.type === 'Identifier' &&\n reactHookNames.includes(node.callee.property.name)\n ) {\n return node.callee.property.name;\n }\n return undefined;\n }\n\n return {\n ImportDeclaration(node: TSESTree.ImportDeclaration) {\n if (\n node.specifiers.length > 0 &&\n node.importKind === 'value' &&\n node.source.value === 'React'\n ) {\n node.specifiers.forEach((specifier) => {\n if (\n specifier.type === AST_NODE_TYPES.ImportSpecifier &&\n specifier.imported.type === AST_NODE_TYPES.Identifier &&\n reactHookNames.includes(specifier.imported.name)\n ) {\n hookAliasMap[specifier.local.name] = specifier.imported.name;\n }\n });\n }\n },\n\n VariableDeclarator(node) {\n if (node.init?.type !== AST_NODE_TYPES.CallExpression) return;\n const hook = isQueryHookFromClient(clientRegex, node.init);\n if (!hook) return;\n if (node.id.type === AST_NODE_TYPES.Identifier) {\n trackedVariables[node.id.name] = hook;\n }\n },\n CallExpression: (node) => {\n const reactHook = getReactHook(node);\n if (!reactHook) return;\n if (node.arguments.length <= 1) return;\n if (node.arguments[1]?.type !== AST_NODE_TYPES.ArrayExpression) return;\n\n const depsArray = node.arguments[1].elements;\n depsArray.forEach((dep) => {\n if (dep?.type !== AST_NODE_TYPES.Identifier) return;\n const queryHook = trackedVariables[dep.name];\n if (!queryHook) return;\n context.report({\n node: dep,\n messageId: 'noUnstableDeps',\n data: {\n queryHook,\n reactHook,\n },\n });\n });\n },\n };\n },\n});\n\nfunction isQueryHookFromClient(\n clientRegex: RegExp,\n call: TSESTree.CallExpression\n): string | null {\n if (call.callee.type !== AST_NODE_TYPES.MemberExpression) return null;\n const member = call.callee;\n if (member.property.type !== AST_NODE_TYPES.Identifier) return null;\n const hook = member.property.name;\n if (!allHookNames.includes(hook)) return null;\n const root = getRootIdentifier(member.object);\n if (!root) return null;\n return clientRegex.test(root.name) ? hook : null;\n}\n"],"names":["name","reactHookNames","useQueryHookNames","allHookNames","createRule","ESLintUtils","RuleCreator","getDocsUrl","rule","meta","type","docs","description","recommended","messages","noUnstableDeps","schema","properties","clientNamePattern","additionalProperties","defaultOptions","create","context","option","options","clientRegex","createClientNameRegex","trackedVariables","hookAliasMap","getReactHook","node","callee","calleeName","includes","object","property","undefined","ImportDeclaration","specifiers","length","importKind","source","value","forEach","specifier","AST_NODE_TYPES","ImportSpecifier","imported","Identifier","local","VariableDeclarator","init","CallExpression","hook","isQueryHookFromClient","id","reactHook","arguments","ArrayExpression","depsArray","elements","dep","queryHook","report","messageId","data","call","MemberExpression","member","root","getRootIdentifier","test"],"mappings":";;;;;AAOO,MAAMA,OAAO,mBAAmB;MAE1BC,cAAiB,GAAA;AAAC,IAAA,WAAA;AAAa,IAAA,aAAA;AAAe,IAAA,SAAA;EAAW;MACzDC,iBAAoB,GAAA;AAC/B,IAAA,UAAA;AACA,IAAA,kBAAA;AACA,IAAA,YAAA;AACA,IAAA,oBAAA;AACA,IAAA,kBAAA;AACA,IAAA,0BAAA;EACA;AACF,MAAMC,YAAe,GAAA;AAAC,IAAA,aAAA;AAAkBD,IAA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AA;wBACXC,IAAM,EAAA;AACJH,4BAAAA,SAAAA;AACAN,4BAAAA,SAAAA;AACF,yBAAA;AACF,qBAAA,CAAA,CAAA;AACF,iBAAA,CAAA,CAAA;AACF,aAAA;AACF,SAAA,CAAA;AACF,KAAA;AACF,CAAG,EAAA;AAEH,SAASF,qBAAAA,CACP7B,WAAmB,EACnByC,IAA6B,EAAA;IAE7B,IAAIA,IAAAA,CAAKnC,MAAM,CAACrB,IAAI,KAAKmC,cAAesB,CAAAA,gBAAgB,EAAE,OAAO,IAAA,CAAA;IACjE,MAAMC,MAAAA,GAASF,KAAKnC,MAAM,CAAA;IAC1B,IAAIqC,MAAAA,CAAOjC,QAAQ,CAACzB,IAAI,KAAKmC,cAAeG,CAAAA,UAAU,EAAE,OAAO,IAAA,CAAA;AAC/D,IAAA,MAAMK,IAAOe,GAAAA,MAAAA,CAAOjC,QAAQ,CAACnC,IAAI,CAAA;AACjC,IAAA,IAAI,CAACG,YAAAA,CAAa8B,QAAQ,CAACoB,OAAO,OAAO,IAAA,CAAA;IACzC,MAAMgB,IAAAA,GAAOC,iBAAkBF,CAAAA,MAAAA,CAAOlC,MAAM,CAAA,CAAA;IAC5C,IAAI,CAACmC,MAAM,OAAO,IAAA,CAAA;AAClB,IAAA,OAAO5C,YAAY8C,IAAI,CAACF,IAAKrE,CAAAA,IAAI,IAAIqD,IAAO,GAAA,IAAA,CAAA;AAC9C;;;;"}
|
|
1
|
+
{"version":3,"file":"no-unstable-deps.rule.js","sources":["../../../../src/rules/no-unstable-deps/no-unstable-deps.rule.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport type { ExtraRuleDocs } from '../../types';\nimport { AST_NODE_TYPES, ESLintUtils } from '@typescript-eslint/utils';\nimport { createClientNameRegex } from '../../utils/create-client-name-regex';\nimport { getDocsUrl } from '../../utils/get-docs-url';\nimport { getRootIdentifier } from '../../utils/get-root-identifier';\n\nexport const name = 'no-unstable-deps';\n\nexport const reactHookNames = ['useEffect', 'useCallback', 'useMemo'];\nexport const useQueryHookNames = [\n 'useQuery',\n 'useSuspenseQuery',\n 'useQueries',\n 'useSuspenseQueries',\n 'useInfiniteQuery',\n 'useSuspenseInfiniteQuery',\n];\nconst allHookNames = ['useMutation', ...useQueryHookNames];\nconst createRule = ESLintUtils.RuleCreator<ExtraRuleDocs>(getDocsUrl);\n\nexport const rule = createRule({\n name,\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Disallow putting the result of query hooks directly in a React hook dependency array',\n recommended: 'error',\n },\n messages: {\n noUnstableDeps: `The result of {{queryHook}} is not referentially stable, so don't pass it directly into the dependencies array of {{reactHook}}. Instead, destructure the return value of {{queryHook}} and pass the destructured values into the dependency array of {{reactHook}}.`,\n },\n schema: [\n {\n type: 'object',\n properties: {\n clientNamePattern: { type: 'string' },\n },\n additionalProperties: false,\n },\n ],\n },\n defaultOptions: [{}],\n\n create: (context) => {\n const option =\n (context.options[0] as { clientNamePattern?: string } | undefined) ?? {};\n const clientRegex = createClientNameRegex(option.clientNamePattern);\n\n const trackedVariables: Record<string, string> = {};\n const hookAliasMap: Record<string, string> = {};\n\n function getReactHook(node: TSESTree.CallExpression): string | undefined {\n if (node.callee.type === 'Identifier') {\n const calleeName = node.callee.name;\n if (reactHookNames.includes(calleeName) || calleeName in hookAliasMap) {\n // Return the actually used identifier (could be alias)\n return calleeName;\n }\n } else if (\n node.callee.type === 'MemberExpression' &&\n node.callee.object.type === 'Identifier' &&\n node.callee.object.name === 'React' &&\n node.callee.property.type === 'Identifier' &&\n reactHookNames.includes(node.callee.property.name)\n ) {\n return node.callee.property.name;\n }\n return undefined;\n }\n\n return {\n ImportDeclaration(node: TSESTree.ImportDeclaration) {\n if (\n node.specifiers.length > 0 &&\n node.importKind === 'value' &&\n node.source.value === 'React'\n ) {\n node.specifiers.forEach((specifier) => {\n if (\n specifier.type === AST_NODE_TYPES.ImportSpecifier &&\n specifier.imported.type === AST_NODE_TYPES.Identifier &&\n reactHookNames.includes(specifier.imported.name)\n ) {\n hookAliasMap[specifier.local.name] = specifier.imported.name;\n }\n });\n }\n },\n\n VariableDeclarator(node) {\n if (node.init?.type !== AST_NODE_TYPES.CallExpression) return;\n const hook = isQueryHookFromClient(clientRegex, node.init);\n if (!hook) return;\n if (node.id.type === AST_NODE_TYPES.Identifier) {\n trackedVariables[node.id.name] = hook;\n }\n },\n CallExpression: (node) => {\n const reactHook = getReactHook(node);\n if (!reactHook) return;\n if (node.arguments.length <= 1) return;\n if (node.arguments[1]?.type !== AST_NODE_TYPES.ArrayExpression) return;\n\n const depsArray = node.arguments[1].elements;\n depsArray.forEach((dep) => {\n if (dep?.type !== AST_NODE_TYPES.Identifier) return;\n const queryHook = trackedVariables[dep.name];\n if (!queryHook) return;\n context.report({\n node: dep,\n messageId: 'noUnstableDeps',\n data: {\n queryHook,\n reactHook,\n },\n });\n });\n },\n };\n },\n});\n\nfunction isQueryHookFromClient(\n clientRegex: RegExp,\n call: TSESTree.CallExpression\n): string | null {\n if (call.callee.type !== AST_NODE_TYPES.MemberExpression) return null;\n const member = call.callee;\n if (member.property.type !== AST_NODE_TYPES.Identifier) return null;\n const hook = member.property.name;\n if (!allHookNames.includes(hook)) return null;\n const root = getRootIdentifier(member.object);\n if (!root) return null;\n return clientRegex.test(root.name) ? hook : null;\n}\n"],"names":["name","reactHookNames","useQueryHookNames","allHookNames","createRule","ESLintUtils","RuleCreator","getDocsUrl","rule","meta","type","docs","description","recommended","messages","noUnstableDeps","schema","properties","clientNamePattern","additionalProperties","defaultOptions","create","context","option","options","clientRegex","createClientNameRegex","trackedVariables","hookAliasMap","getReactHook","node","callee","calleeName","includes","object","property","undefined","ImportDeclaration","specifiers","length","importKind","source","value","forEach","specifier","AST_NODE_TYPES","ImportSpecifier","imported","Identifier","local","VariableDeclarator","init","CallExpression","hook","isQueryHookFromClient","id","reactHook","arguments","ArrayExpression","depsArray","elements","dep","queryHook","report","messageId","data","call","MemberExpression","member","root","getRootIdentifier","test"],"mappings":";;;;;AAO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A,EAAW;AAChBxC,oBAAAA,OAAAA,CAAQyC,MAAM,CAAC;wBACbjC,IAAAA,EAAM+B,GAAAA;wBACNG,SAAAA,EAAW,gBAAA;wBACXC,IAAAA,EAAM;AACJH,4BAAAA,SAAAA;AACAN,4BAAAA;AACF;AACF,qBAAA,CAAA;AACF,gBAAA,CAAA,CAAA;AACF,YAAA;AACF,SAAA;AACF,IAAA;AACF,CAAA;AAEA,SAASF,qBAAAA,CACP7B,WAAmB,EACnByC,IAA6B,EAAA;IAE7B,IAAIA,IAAAA,CAAKnC,MAAM,CAACrB,IAAI,KAAKmC,cAAAA,CAAesB,gBAAgB,EAAE,OAAO,IAAA;IACjE,MAAMC,MAAAA,GAASF,KAAKnC,MAAM;IAC1B,IAAIqC,MAAAA,CAAOjC,QAAQ,CAACzB,IAAI,KAAKmC,cAAAA,CAAeG,UAAU,EAAE,OAAO,IAAA;AAC/D,IAAA,MAAMK,IAAAA,GAAOe,MAAAA,CAAOjC,QAAQ,CAACnC,IAAI;AACjC,IAAA,IAAI,CAACG,YAAAA,CAAa8B,QAAQ,CAACoB,OAAO,OAAO,IAAA;IACzC,MAAMgB,IAAAA,GAAOC,iBAAAA,CAAkBF,MAAAA,CAAOlC,MAAM,CAAA;IAC5C,IAAI,CAACmC,MAAM,OAAO,IAAA;AAClB,IAAA,OAAO5C,YAAY8C,IAAI,CAACF,IAAAA,CAAKrE,IAAI,IAAIqD,IAAAA,GAAO,IAAA;AAC9C;;;;"}
|
package/dist/esm/rules.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { rule as rule$1, name as name$1 } from './rules/no-rest-destructuring/no-rest-destructuring.rule.js';
|
|
2
|
+
import { rule, name } from './rules/no-unstable-deps/no-unstable-deps.rule.js';
|
|
3
3
|
|
|
4
4
|
const rules = {
|
|
5
|
-
[name]: rule,
|
|
6
|
-
[name
|
|
5
|
+
[name$1]: rule$1,
|
|
6
|
+
[name]: rule
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export { rules };
|
package/dist/esm/rules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.js","sources":["../../src/rules.ts"],"sourcesContent":["import type { ESLintUtils } from '@typescript-eslint/utils';\nimport type { ExtraRuleDocs } from './types';\nimport * as noRestDestructuring from './rules/no-rest-destructuring/no-rest-destructuring.rule';\nimport * as noUnstableDeps from './rules/no-unstable-deps/no-unstable-deps.rule';\n\nexport const rules: Record<\n string,\n ESLintUtils.RuleModule<\n string,\n ReadonlyArray<unknown>,\n ExtraRuleDocs,\n ESLintUtils.RuleListener\n >\n> = {\n [noRestDestructuring.name]: noRestDestructuring.rule,\n [noUnstableDeps.name]: noUnstableDeps.rule,\n};\n"],"names":["rules","noRestDestructuring","noUnstableDeps"],"mappings":";;;MAKaA,
|
|
1
|
+
{"version":3,"file":"rules.js","sources":["../../src/rules.ts"],"sourcesContent":["import type { ESLintUtils } from '@typescript-eslint/utils';\nimport type { ExtraRuleDocs } from './types';\nimport * as noRestDestructuring from './rules/no-rest-destructuring/no-rest-destructuring.rule';\nimport * as noUnstableDeps from './rules/no-unstable-deps/no-unstable-deps.rule';\n\nexport const rules: Record<\n string,\n ESLintUtils.RuleModule<\n string,\n ReadonlyArray<unknown>,\n ExtraRuleDocs,\n ESLintUtils.RuleListener\n >\n> = {\n [noRestDestructuring.name]: noRestDestructuring.rule,\n [noUnstableDeps.name]: noUnstableDeps.rule,\n};\n"],"names":["rules","noRestDestructuring","noUnstableDeps"],"mappings":";;;MAKaA,KAAAA,GAQT;AACF,IAAA,CAACC,MAAwB,GAAGA,MAAwB;AACpD,IAAA,CAACC,IAAmB,GAAGA;AACzB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-client-name-regex.js","sources":["../../../src/utils/create-client-name-regex.ts"],"sourcesContent":["export function createClientNameRegex(clientNamePattern: string | undefined) {\n clientNamePattern = clientNamePattern?.trim();\n\n if (clientNamePattern) {\n // Check if pattern is in regex format: /pattern/flags\n const regexMatch = clientNamePattern.match(/^\\/(.*)\\/([gimuy]*)$/);\n\n if (regexMatch) {\n const regexPattern = regexMatch[1].trim();\n const flags = regexMatch[2];\n\n // Validate that regex pattern is not empty or whitespace-only\n if (regexPattern === '') {\n throw new Error(\n 'clientNamePattern cannot be empty or contain only whitespace'\n );\n }\n\n return new RegExp(regexPattern, flags);\n }\n\n // Fallback to treating as plain string pattern\n return new RegExp(clientNamePattern);\n } else if (clientNamePattern === '') {\n throw new Error(\n 'clientNamePattern cannot be empty or contain only whitespace'\n );\n }\n\n // Default if no pattern provided\n return /qraft|api/i;\n}\n"],"names":["createClientNameRegex","clientNamePattern","trim","regexMatch","match","regexPattern","flags","Error","RegExp"],"mappings":"AAAO,SAASA,sBAAsBC,iBAAqC,EAAA;AACzEA,IAAAA,iBAAAA,GAAoBA,
|
|
1
|
+
{"version":3,"file":"create-client-name-regex.js","sources":["../../../src/utils/create-client-name-regex.ts"],"sourcesContent":["export function createClientNameRegex(clientNamePattern: string | undefined) {\n clientNamePattern = clientNamePattern?.trim();\n\n if (clientNamePattern) {\n // Check if pattern is in regex format: /pattern/flags\n const regexMatch = clientNamePattern.match(/^\\/(.*)\\/([gimuy]*)$/);\n\n if (regexMatch) {\n const regexPattern = regexMatch[1].trim();\n const flags = regexMatch[2];\n\n // Validate that regex pattern is not empty or whitespace-only\n if (regexPattern === '') {\n throw new Error(\n 'clientNamePattern cannot be empty or contain only whitespace'\n );\n }\n\n return new RegExp(regexPattern, flags);\n }\n\n // Fallback to treating as plain string pattern\n return new RegExp(clientNamePattern);\n } else if (clientNamePattern === '') {\n throw new Error(\n 'clientNamePattern cannot be empty or contain only whitespace'\n );\n }\n\n // Default if no pattern provided\n return /qraft|api/i;\n}\n"],"names":["createClientNameRegex","clientNamePattern","trim","regexMatch","match","regexPattern","flags","Error","RegExp"],"mappings":"AAAO,SAASA,sBAAsBC,iBAAqC,EAAA;AACzEA,IAAAA,iBAAAA,GAAoBA,iBAAAA,EAAmBC,IAAAA,EAAAA;AAEvC,IAAA,IAAID,iBAAAA,EAAmB;;QAErB,MAAME,UAAAA,GAAaF,iBAAAA,CAAkBG,KAAK,CAAC,sBAAA,CAAA;AAE3C,QAAA,IAAID,UAAAA,EAAY;AACd,YAAA,MAAME,YAAAA,GAAeF,UAAU,CAAC,CAAA,CAAE,CAACD,IAAI,EAAA;YACvC,MAAMI,KAAAA,GAAQH,UAAU,CAAC,CAAA,CAAE;;AAG3B,YAAA,IAAIE,iBAAiB,EAAA,EAAI;AACvB,gBAAA,MAAM,IAAIE,KAAAA,CACR,8DAAA,CAAA;AAEJ,YAAA;YAEA,OAAO,IAAIC,OAAOH,YAAAA,EAAcC,KAAAA,CAAAA;AAClC,QAAA;;AAGA,QAAA,OAAO,IAAIE,MAAAA,CAAOP,iBAAAA,CAAAA;IACpB,CAAA,MAAO,IAAIA,sBAAsB,EAAA,EAAI;AACnC,QAAA,MAAM,IAAIM,KAAAA,CACR,8DAAA,CAAA;AAEJ,IAAA;;IAGA,OAAO,YAAA;AACT;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-docs-url.js","sources":["../../../src/utils/get-docs-url.ts"],"sourcesContent":["export const getDocsUrl = (ruleName: string): string =>\n `https://openapi-qraft.github.io/openapi-qraft/docs/eslint/${ruleName}`;\n"],"names":["getDocsUrl","ruleName"],"mappings":"AAAO,MAAMA,aAAa,CAACC,QAAAA,GACzB,CAAC,0DAA0D,EAAEA
|
|
1
|
+
{"version":3,"file":"get-docs-url.js","sources":["../../../src/utils/get-docs-url.ts"],"sourcesContent":["export const getDocsUrl = (ruleName: string): string =>\n `https://openapi-qraft.github.io/openapi-qraft/docs/eslint/${ruleName}`;\n"],"names":["getDocsUrl","ruleName"],"mappings":"AAAO,MAAMA,aAAa,CAACC,QAAAA,GACzB,CAAC,0DAA0D,EAAEA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-root-identifier.js","sources":["../../../src/utils/get-root-identifier.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport { AST_NODE_TYPES } from '@typescript-eslint/utils';\n\nexport function getRootIdentifier(\n node: TSESTree.Node\n): TSESTree.Identifier | undefined {\n let current: TSESTree.Node | undefined = node;\n while (\n current.type === AST_NODE_TYPES.MemberExpression ||\n current.type === AST_NODE_TYPES.TSNonNullExpression ||\n current.type === AST_NODE_TYPES.ChainExpression\n ) {\n if (current.type === AST_NODE_TYPES.MemberExpression) {\n current = current.object;\n continue;\n }\n if (current.type === AST_NODE_TYPES.TSNonNullExpression) {\n current = current.expression;\n continue;\n }\n\n current = current.expression;\n }\n return current.type === AST_NODE_TYPES.Identifier ? current : undefined;\n}\n"],"names":["getRootIdentifier","node","current","type","AST_NODE_TYPES","MemberExpression","TSNonNullExpression","ChainExpression","object","expression","Identifier","undefined"],"mappings":";;AAGO,SAASA,kBACdC,IAAmB,EAAA;AAEnB,IAAA,IAAIC,
|
|
1
|
+
{"version":3,"file":"get-root-identifier.js","sources":["../../../src/utils/get-root-identifier.ts"],"sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport { AST_NODE_TYPES } from '@typescript-eslint/utils';\n\nexport function getRootIdentifier(\n node: TSESTree.Node\n): TSESTree.Identifier | undefined {\n let current: TSESTree.Node | undefined = node;\n while (\n current.type === AST_NODE_TYPES.MemberExpression ||\n current.type === AST_NODE_TYPES.TSNonNullExpression ||\n current.type === AST_NODE_TYPES.ChainExpression\n ) {\n if (current.type === AST_NODE_TYPES.MemberExpression) {\n current = current.object;\n continue;\n }\n if (current.type === AST_NODE_TYPES.TSNonNullExpression) {\n current = current.expression;\n continue;\n }\n\n current = current.expression;\n }\n return current.type === AST_NODE_TYPES.Identifier ? current : undefined;\n}\n"],"names":["getRootIdentifier","node","current","type","AST_NODE_TYPES","MemberExpression","TSNonNullExpression","ChainExpression","object","expression","Identifier","undefined"],"mappings":";;AAGO,SAASA,kBACdC,IAAmB,EAAA;AAEnB,IAAA,IAAIC,OAAAA,GAAqCD,IAAAA;AACzC,IAAA,MACEC,QAAQC,IAAI,KAAKC,cAAAA,CAAeC,gBAAgB,IAChDH,OAAAA,CAAQC,IAAI,KAAKC,cAAAA,CAAeE,mBAAmB,IACnDJ,OAAAA,CAAQC,IAAI,KAAKC,cAAAA,CAAeG,eAAe,CAC/C;AACA,QAAA,IAAIL,OAAAA,CAAQC,IAAI,KAAKC,cAAAA,CAAeC,gBAAgB,EAAE;AACpDH,YAAAA,OAAAA,GAAUA,QAAQM,MAAM;AACxB,YAAA;AACF,QAAA;AACA,QAAA,IAAIN,OAAAA,CAAQC,IAAI,KAAKC,cAAAA,CAAeE,mBAAmB,EAAE;AACvDJ,YAAAA,OAAAA,GAAUA,QAAQO,UAAU;AAC5B,YAAA;AACF,QAAA;AAEAP,QAAAA,OAAAA,GAAUA,QAAQO,UAAU;AAC9B,IAAA;AACA,IAAA,OAAOP,QAAQC,IAAI,KAAKC,cAAAA,CAAeM,UAAU,GAAGR,OAAAA,GAAUS,SAAAA;AAChE;;;;"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ExtraRuleDocs } from '../../types';
|
|
2
2
|
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
3
3
|
export declare const name = "no-rest-destructuring";
|
|
4
|
-
export declare const rule: ESLintUtils.RuleModule<"objectRestDestructure", [{}], ExtraRuleDocs, ESLintUtils.RuleListener
|
|
4
|
+
export declare const rule: ESLintUtils.RuleModule<"objectRestDestructure", [{}], ExtraRuleDocs, ESLintUtils.RuleListener> & {
|
|
5
|
+
name: string;
|
|
6
|
+
};
|
|
5
7
|
//# sourceMappingURL=no-rest-destructuring.rule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-rest-destructuring.rule.d.ts","sourceRoot":"","sources":["../../../../src/rules/no-rest-destructuring/no-rest-destructuring.rule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAkB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAMvE,eAAO,MAAM,IAAI,0BAA0B,CAAC;AAa5C,eAAO,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"no-rest-destructuring.rule.d.ts","sourceRoot":"","sources":["../../../../src/rules/no-rest-destructuring/no-rest-destructuring.rule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAkB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAMvE,eAAO,MAAM,IAAI,0BAA0B,CAAC;AAa5C,eAAO,MAAM,IAAI;;CAsGf,CAAC"}
|
|
@@ -3,5 +3,7 @@ import { ESLintUtils } from '@typescript-eslint/utils';
|
|
|
3
3
|
export declare const name = "no-unstable-deps";
|
|
4
4
|
export declare const reactHookNames: string[];
|
|
5
5
|
export declare const useQueryHookNames: string[];
|
|
6
|
-
export declare const rule: ESLintUtils.RuleModule<"noUnstableDeps", [{}], ExtraRuleDocs, ESLintUtils.RuleListener
|
|
6
|
+
export declare const rule: ESLintUtils.RuleModule<"noUnstableDeps", [{}], ExtraRuleDocs, ESLintUtils.RuleListener> & {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
7
9
|
//# sourceMappingURL=no-unstable-deps.rule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-unstable-deps.rule.d.ts","sourceRoot":"","sources":["../../../../src/rules/no-unstable-deps/no-unstable-deps.rule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAkB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAKvE,eAAO,MAAM,IAAI,qBAAqB,CAAC;AAEvC,eAAO,MAAM,cAAc,UAA0C,CAAC;AACtE,eAAO,MAAM,iBAAiB,UAO7B,CAAC;AAIF,eAAO,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"no-unstable-deps.rule.d.ts","sourceRoot":"","sources":["../../../../src/rules/no-unstable-deps/no-unstable-deps.rule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAkB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAKvE,eAAO,MAAM,IAAI,qBAAqB,CAAC;AAEvC,eAAO,MAAM,cAAc,UAA0C,CAAC;AACtE,eAAO,MAAM,iBAAiB,UAO7B,CAAC;AAIF,eAAO,MAAM,IAAI;;CAqGf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-docs-url.d.ts","sourceRoot":"","sources":["../../../src/utils/get-docs-url.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"get-docs-url.d.ts","sourceRoot":"","sources":["../../../src/utils/get-docs-url.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,GAAI,UAAU,MAAM,KAAG,MAC2B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openapi-qraft/eslint-plugin-query",
|
|
3
|
-
"version": "2.15.0-beta.
|
|
3
|
+
"version": "2.15.0-beta.7",
|
|
4
4
|
"description": "ESLint plugin for OpenAPI Qraft",
|
|
5
5
|
"homepage": "https://openapi-qraft.github.io/openapi-qraft/docs/eslint/eslint-plugin-query",
|
|
6
6
|
"packageManager": "yarn@4.0.2",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "yarn clean && NODE_ENV=production rollup --config rollup.config.mjs && tsc --project tsconfig.build.json --emitDeclarationOnly",
|
|
18
18
|
"typecheck": "tsc --noEmit",
|
|
19
|
-
"lint": "eslint",
|
|
19
|
+
"lint": "eslint --max-warnings 0",
|
|
20
20
|
"test": "vitest run --coverage",
|
|
21
21
|
"clean": "rimraf dist/"
|
|
22
22
|
},
|
|
@@ -46,20 +46,20 @@
|
|
|
46
46
|
"!src/__tests__"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@typescript-eslint/utils": "^8.
|
|
49
|
+
"@typescript-eslint/utils": "^8.58.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@openapi-qraft/eslint-config": "1.0.
|
|
53
|
-
"@openapi-qraft/rollup-config": "1.
|
|
54
|
-
"@types/node": "^20.
|
|
55
|
-
"@typescript-eslint/rule-tester": "^8.
|
|
56
|
-
"@typescript-eslint/typescript-estree": "^8.
|
|
57
|
-
"@vitest/coverage-v8": "^
|
|
58
|
-
"eslint": "^
|
|
59
|
-
"rimraf": "^6.1.
|
|
60
|
-
"rollup": "~4.
|
|
61
|
-
"typescript": "^5.
|
|
62
|
-
"vitest": "^
|
|
52
|
+
"@openapi-qraft/eslint-config": "1.1.0-beta.0",
|
|
53
|
+
"@openapi-qraft/rollup-config": "1.2.0-beta.0",
|
|
54
|
+
"@types/node": "^20.19.37",
|
|
55
|
+
"@typescript-eslint/rule-tester": "^8.58.0",
|
|
56
|
+
"@typescript-eslint/typescript-estree": "^8.58.0",
|
|
57
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
58
|
+
"eslint": "^10.1.0",
|
|
59
|
+
"rimraf": "^6.1.3",
|
|
60
|
+
"rollup": "~4.60.1",
|
|
61
|
+
"typescript": "^5.9.3",
|
|
62
|
+
"vitest": "^4.1.2"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"eslint": "^8.57.0 || ^9.0.0"
|