Skip to content

Commit 9c721e5

Browse files
refactor: Sort imports with eslint (#5634)
1 parent 8f19f73 commit 9c721e5

File tree

129 files changed

+460
-437
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+460
-437
lines changed

.eslintrc.cjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const config = {
55
extends: [
66
'plugin:@typescript-eslint/eslint-recommended',
77
'plugin:@typescript-eslint/recommended',
8+
'plugin:import/recommended',
89
'plugin:import/typescript',
910
'prettier',
1011
],
@@ -41,15 +42,38 @@ const config = {
4142
'@typescript-eslint/no-explicit-any': 'off',
4243
'@typescript-eslint/no-non-null-assertion': 'off',
4344
'@typescript-eslint/no-unnecessary-condition': 'error',
45+
'@typescript-eslint/no-unused-vars': 'off',
4446
'@typescript-eslint/no-inferrable-types': [
4547
'error',
4648
{ ignoreParameters: true },
4749
],
50+
'import/default': 'off',
51+
'import/export': 'off',
52+
'import/namespace': 'off',
53+
'import/newline-after-import': 'error',
4854
'import/no-cycle': 'error',
55+
'import/no-duplicates': 'off',
56+
'import/no-named-as-default-member': 'off',
4957
'import/no-unresolved': ['error', { ignore: ['^@tanstack/'] }],
5058
'import/no-unused-modules': ['off', { unusedExports: true }],
59+
'import/order': [
60+
'error',
61+
{
62+
groups: [
63+
'builtin',
64+
'external',
65+
'internal',
66+
'parent',
67+
'sibling',
68+
'index',
69+
'object',
70+
'type',
71+
],
72+
},
73+
],
5174
'no-redeclare': 'off',
5275
'no-shadow': 'error',
76+
'sort-imports': ['error', { ignoreDeclarationSort: true }],
5377
},
5478
overrides: [
5579
{

packages/eslint-plugin-query/src/configs/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { TSESLint } from '@typescript-eslint/utils'
21
import { rules } from '../rules'
2+
import type { TSESLint } from '@typescript-eslint/utils'
33

44
function generateRecommendedConfig(
55
allRules: Record<string, TSESLint.RuleModule<any, any>>,

packages/eslint-plugin-query/src/rules/exhaustive-deps/exhaustive-deps.rule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type { TSESLint } from '@typescript-eslint/utils'
21
import { AST_NODE_TYPES } from '@typescript-eslint/utils'
32
import { ASTUtils } from '../../utils/ast-utils'
43
import { createRule } from '../../utils/create-rule'
54
import { uniqueBy } from '../../utils/unique-by'
65
import { ExhaustiveDepsUtils } from './exhaustive-deps.utils'
6+
import type { TSESLint } from '@typescript-eslint/utils'
77

88
const QUERY_KEY = 'queryKey'
99
const QUERY_FN = 'queryFn'

packages/eslint-plugin-query/src/rules/exhaustive-deps/exhaustive-deps.utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { TSESLint } from '@typescript-eslint/utils'
21
import { AST_NODE_TYPES } from '@typescript-eslint/utils'
32
import { ASTUtils } from '../../utils/ast-utils'
3+
import type { TSESLint } from '@typescript-eslint/utils'
44

55
export const ExhaustiveDepsUtils = {
66
isRelevantReference(params: {

packages/eslint-plugin-query/src/rules/prefer-query-object-syntax/prefer-query-object-syntax.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { rule, name } from './prefer-query-object-syntax'
2-
import { normalizeIndent } from '../../utils/test-utils'
31
import { ESLintUtils } from '@typescript-eslint/utils'
2+
import { normalizeIndent } from '../../utils/test-utils'
3+
import { name, rule } from './prefer-query-object-syntax'
44

55
const ruleTester = new ESLintUtils.RuleTester({
66
parser: '@typescript-eslint/parser',

packages/eslint-plugin-query/src/rules/prefer-query-object-syntax/prefer-query-object-syntax.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type { TSESLint, TSESTree } from '@typescript-eslint/utils'
21
import { AST_NODE_TYPES } from '@typescript-eslint/utils'
32
import { createRule } from '../../utils/create-rule'
43
import { ASTUtils } from '../../utils/ast-utils'
54
import { objectKeys } from '../../utils/object-utils'
5+
import type { TSESLint, TSESTree } from '@typescript-eslint/utils'
66

77
const QUERY_CALLS = {
88
useQuery: { key: 'queryKey', fn: 'queryFn', type: 'query' },

packages/eslint-plugin-query/src/utils/ast-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { AST_NODE_TYPES } from '@typescript-eslint/utils'
2+
import { uniqueBy } from './unique-by'
13
import type { TSESLint, TSESTree } from '@typescript-eslint/utils'
24
import type TSESLintScopeManager from '@typescript-eslint/scope-manager'
3-
import { AST_NODE_TYPES } from '@typescript-eslint/utils'
45
import type { RuleContext } from '@typescript-eslint/utils/dist/ts-eslint'
5-
import { uniqueBy } from './unique-by'
66

77
export const ASTUtils = {
88
isNodeOfOneOf<T extends AST_NODE_TYPES>(

packages/eslint-plugin-query/src/utils/create-rule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ESLintUtils } from '@typescript-eslint/utils'
2-
import type { EnhancedCreate } from './detect-react-query-imports'
32
import { detectTanstackQueryImports } from './detect-react-query-imports'
3+
import type { EnhancedCreate } from './detect-react-query-imports'
44

55
const getDocsUrl = (ruleName: string): string =>
66
`https://tanstack.com/query/v4/docs/eslint/${ruleName}`

packages/query-async-storage-persister/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { asyncThrottle } from './asyncThrottle'
12
import type {
23
PersistedClient,
34
Persister,
45
Promisable,
56
} from '@tanstack/query-persist-client-core'
6-
import { asyncThrottle } from './asyncThrottle'
77

88
interface AsyncStorage {
99
getItem: (key: string) => Promise<string | null>

packages/query-core/src/infiniteQueryObserver.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
import { QueryObserver } from './queryObserver'
2+
import {
3+
hasNextPage,
4+
hasPreviousPage,
5+
infiniteQueryBehavior,
6+
} from './infiniteQueryBehavior'
17
import type {
28
DefaultedInfiniteQueryObserverOptions,
39
FetchNextPageOptions,
@@ -9,12 +15,6 @@ import type {
915
} from './types'
1016
import type { QueryClient } from './queryClient'
1117
import type { NotifyOptions, ObserverFetchOptions } from './queryObserver'
12-
import { QueryObserver } from './queryObserver'
13-
import {
14-
hasNextPage,
15-
hasPreviousPage,
16-
infiniteQueryBehavior,
17-
} from './infiniteQueryBehavior'
1818
import type { Query } from './query'
1919

2020
type InfiniteQueryObserverListener<TData, TError> = (

0 commit comments

Comments
 (0)