@bastidood/eslint-config-tanstack-query 0.0.0-stage → 0.6.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Basti Ortiz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,39 @@
1
- # Temporary Holding Version
1
+ # `@bastidood/eslint-config-tanstack-query`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ TanStack Query entries for `@bastidood/eslint-config`, including the rules of `@tanstack/eslint-plugin-query`.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ pnpm add --save-dev @bastidood/eslint-config @bastidood/eslint-config-svelte @bastidood/eslint-config-tanstack-query eslint svelte typescript
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ ```ts
14
+ // eslint.config.ts
15
+ import { compose } from '@bastidood/eslint-config';
16
+ import { SVELTE } from '@bastidood/eslint-config-svelte';
17
+ import { TANSTACK_SVELTE_QUERY } from '@bastidood/eslint-config-tanstack-query/svelte';
18
+ import { CORE } from '@bastidood/eslint-config/core';
19
+ import { TANSTACK_QUERY } from '@bastidood/eslint-config/tanstack/query';
20
+ import { defineConfig } from 'eslint/config';
21
+
22
+ export default defineConfig(
23
+ { files: ['**/*.ts'] },
24
+ compose(CORE, SVELTE, TANSTACK_QUERY, TANSTACK_SVELTE_QUERY),
25
+ );
26
+ ```
27
+
28
+ List `TANSTACK_SVELTE_QUERY` after `SVELTE`, whose parser its template selectors need.
29
+
30
+ ## Entry Points
31
+
32
+ | Entry point | Contents |
33
+ | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
34
+ | `@bastidood/eslint-config-tanstack-query/svelte` | Enables `exhaustive-deps`, `infinite-query-property-order`, and `no-void-query-fn` from `@tanstack/eslint-plugin-query`; bans `useQueryClient`, destructuring query results, inline `queryFn` in `createQuery`, and `use:enhance` with `onsubmit` |
35
+
36
+ ## Limitations
37
+
38
+ - Rules are not configurable.
39
+ - `exhaustive-deps` does not check the top-level script of `.svelte` components.
@@ -0,0 +1,3 @@
1
+ import { Entry } from "@bastidood/eslint-config";
2
+ /** TanStack Svelte Query rules. Compose after `SVELTE`, whose parser the template selectors need. */
3
+ export declare const TANSTACK_SVELTE_QUERY: Entry;
@@ -0,0 +1,35 @@
1
+ import tanstackQueryPlugin from "@tanstack/eslint-plugin-query";
2
+ /** TanStack Svelte Query rules. Compose after `SVELTE`, whose parser the template selectors need. */
3
+ const TANSTACK_SVELTE_QUERY = {
4
+ configs: [{
5
+ name: "@bastidood/eslint-config-tanstack-query/svelte",
6
+ plugins: { "@tanstack/query": tanstackQueryPlugin },
7
+ rules: {
8
+ "@tanstack/query/exhaustive-deps": "error",
9
+ "@tanstack/query/infinite-query-property-order": "error",
10
+ "@tanstack/query/no-void-query-fn": "error"
11
+ }
12
+ }],
13
+ restrictions: {
14
+ importPaths: [{
15
+ name: "@tanstack/svelte-query",
16
+ importNames: ["useQueryClient"],
17
+ message: "Obtain the `QueryClient` from the query or mutation callback context instead of capturing `useQueryClient` in a closure. Suppress this only to call `prefetchQuery` on hover or `ensureQueryData` in an event handler, and name that use in the suppression reason."
18
+ }],
19
+ syntax: [
20
+ {
21
+ selector: "VariableDeclarator[id.type=\"ObjectPattern\"][init.callee.name=/^create(?:Query|InfiniteQuery|Mutation|Queries)$/]",
22
+ message: "Read fields from the result object, such as `query.data`. The result is a reactive proxy, so destructuring copies its current values and stops updates."
23
+ },
24
+ {
25
+ selector: "CallExpression[callee.name=/^create(?:Infinite)?Query$/] > :function > ObjectExpression > Property[key.name=\"queryFn\"], CallExpression[callee.name=/^create(?:Infinite)?Query$/] > :function > BlockStatement ReturnStatement > ObjectExpression > Property[key.name=\"queryFn\"]",
26
+ message: "Define `queryKey` and `queryFn` together in a `queryOptions()` factory and pass its result, such as `createQuery(() => jobQueries.detail(id))`."
27
+ },
28
+ {
29
+ selector: "SvelteDirective[kind=\"Action\"][key.name.name=\"enhance\"] ~ SvelteAttribute[key.name=\"onsubmit\"], SvelteAttribute[key.name=\"onsubmit\"] ~ SvelteDirective[kind=\"Action\"][key.name.name=\"enhance\"]",
30
+ message: "Choose one submission lifecycle for this form: `use:enhance` with a SvelteKit form action, or an `onsubmit` handler that calls a TanStack mutation. With both, one submit runs both."
31
+ }
32
+ ]
33
+ }
34
+ };
35
+ export { TANSTACK_SVELTE_QUERY };
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@bastidood/eslint-config-tanstack-query",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.6.1",
4
+ "description": "TanStack Query rules for @bastidood/eslint-config, including @tanstack/eslint-plugin-query.",
5
+ "license": "MIT",
6
+ "homepage": "https://github.com/BastiDood/slopstopper",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/BastiDood/slopstopper.git",
10
+ "directory": "configs/eslint-tanstack-query"
11
+ },
12
+ "type": "module",
13
+ "exports": {
14
+ "./svelte": "./dist/svelte.mjs"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "dependencies": {
23
+ "@tanstack/eslint-plugin-query": "^5.106.1"
24
+ },
25
+ "devDependencies": {
26
+ "@bastidood/eslint-config": "0.6.1",
27
+ "@bastidood/tsconfig": "0.1.1",
28
+ "@typescript/native": "npm:typescript@^7.0.2",
29
+ "eslint": "^10.14.0",
30
+ "tsdown": "0.23.5",
31
+ "typescript": "npm:@typescript/typescript6@^6.0.2"
32
+ },
33
+ "peerDependencies": {
34
+ "@bastidood/eslint-config": "^0.6.1",
35
+ "@bastidood/eslint-config-svelte": "^0.6.1",
36
+ "eslint": "^10.0.0",
37
+ "typescript": ">=4.8.4 <6.1.0"
38
+ },
39
+ "scripts": {
40
+ "check": "tsc"
41
+ }
6
42
  }