Skip to content

Commit 47bd8c8

Browse files
Use 'eslint-plugin-simple-import-sort' to sort imports (#3446)
1 parent 085d1ee commit 47bd8c8

File tree

126 files changed

+788
-762
lines changed

Some content is hidden

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

126 files changed

+788
-762
lines changed

.eslintrc.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ plugins:
99
- internal-rules
1010
- node
1111
- import
12+
- simple-import-sort
1213
settings:
1314
node:
1415
tryExtensions: ['.js', '.json', '.node', '.ts', '.d.ts']
@@ -140,6 +141,38 @@ rules:
140141
import/group-exports: off
141142
import/dynamic-import-chunkname: off
142143

144+
##############################################################################
145+
# `eslint-plugin-simple-import-sort` rule list based on `v2.25.x`
146+
# https://github.com/lydell/eslint-plugin-simple-import-sort
147+
##############################################################################
148+
simple-import-sort/imports:
149+
- error
150+
- groups:
151+
# Packages.
152+
# Things that start with a letter (or digit or underscore), or `@` followed by a letter.
153+
- ["^@?\\w"]
154+
155+
# General utilities
156+
- ["^(\\./|(\\.\\./)+)__testUtils__/"]
157+
- ["^(\\./|(\\.\\./)+)jsutils/"]
158+
159+
# Top-level directories
160+
- ["^(\\./|(\\.\\./)+)error/"]
161+
- ["^(\\./|(\\.\\./)+)language/"]
162+
- ["^(\\./|(\\.\\./)+)type/"]
163+
- ["^(\\./|(\\.\\./)+)validation/"]
164+
- ["^(\\./|(\\.\\./)+)execution/"]
165+
- ["^(\\./|(\\.\\./)+)utilities/"]
166+
167+
# Relative imports.
168+
# Anything that starts with a dot.
169+
- ["^(\\.\\./){4,}"]
170+
- ["^(\\.\\./){3}"]
171+
- ["^(\\.\\./){2}"]
172+
- ["^(\\.\\./){1}"]
173+
- ["^\\./"]
174+
simple-import-sort/exports: off # TODO
175+
143176
##############################################################################
144177
# ESLint builtin rules list based on `v8.5.x`
145178
##############################################################################

package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"eslint-plugin-import": "2.25.3",
6868
"eslint-plugin-internal-rules": "file:./resources/eslint-internal-rules",
6969
"eslint-plugin-node": "11.1.0",
70+
"eslint-plugin-simple-import-sort": "7.0.0",
7071
"eslint-plugin-tsdoc": "0.2.14",
7172
"mocha": "9.1.3",
7273
"prettier": "2.5.1",

src/__testUtils__/expectJSON.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect } from 'chai';
22

3-
import { mapValue } from '../jsutils/mapValue';
43
import { isObjectLike } from '../jsutils/isObjectLike';
4+
import { mapValue } from '../jsutils/mapValue';
55

66
/**
77
* Deeply transforms an arbitrary value to a JSON-safe value by calling toJSON

src/__tests__/starWarsSchema.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { GraphQLSchema } from '../type/schema';
2-
import { GraphQLString } from '../type/scalars';
31
import {
4-
GraphQLList,
5-
GraphQLNonNull,
62
GraphQLEnumType,
73
GraphQLInterfaceType,
4+
GraphQLList,
5+
GraphQLNonNull,
86
GraphQLObjectType,
97
} from '../type/definition';
8+
import { GraphQLString } from '../type/scalars';
9+
import { GraphQLSchema } from '../type/schema';
1010

11-
import { getFriends, getHero, getHuman, getDroid } from './starWarsData';
11+
import { getDroid, getFriends, getHero, getHuman } from './starWarsData';
1212

1313
/**
1414
* This is designed to be an end-to-end test, demonstrating

src/error/GraphQLError.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { isObjectLike } from '../jsutils/isObjectLike';
22
import type { Maybe } from '../jsutils/Maybe';
33

44
import type { ASTNode, Location } from '../language/ast';
5-
import type { Source } from '../language/source';
65
import type { SourceLocation } from '../language/location';
76
import { getLocation } from '../language/location';
87
import { printLocation, printSourceLocation } from '../language/printLocation';
8+
import type { Source } from '../language/source';
99

1010
/**
1111
* Custom extensions

src/error/__tests__/GraphQLError-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Kind } from '../../language/kinds';
99
import { parse } from '../../language/parser';
1010
import { Source } from '../../language/source';
1111

12-
import { GraphQLError, printError, formatError } from '../GraphQLError';
12+
import { formatError, GraphQLError, printError } from '../GraphQLError';
1313

1414
const source = new Source(dedent`
1515
{

src/execution/__tests__/abstract-test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ import { expectJSON } from '../../__testUtils__/expectJSON';
55

66
import { parse } from '../../language/parser';
77

8-
import { GraphQLSchema } from '../../type/schema';
9-
import { GraphQLString, GraphQLBoolean } from '../../type/scalars';
108
import {
119
assertInterfaceType,
10+
GraphQLInterfaceType,
1211
GraphQLList,
1312
GraphQLObjectType,
14-
GraphQLInterfaceType,
1513
GraphQLUnionType,
1614
} from '../../type/definition';
15+
import { GraphQLBoolean, GraphQLString } from '../../type/scalars';
16+
import { GraphQLSchema } from '../../type/schema';
1717

1818
import { buildSchema } from '../../utilities/buildASTSchema';
1919

20-
import { executeSync, execute } from '../execute';
20+
import { execute, executeSync } from '../execute';
2121

2222
async function executeQuery(args: {
2323
schema: GraphQLSchema;

src/execution/__tests__/directives-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { describe, it } from 'mocha';
33

44
import { parse } from '../../language/parser';
55

6-
import { GraphQLSchema } from '../../type/schema';
7-
import { GraphQLString } from '../../type/scalars';
86
import { GraphQLObjectType } from '../../type/definition';
7+
import { GraphQLString } from '../../type/scalars';
8+
import { GraphQLSchema } from '../../type/schema';
99

1010
import { executeSync } from '../execute';
1111

src/execution/__tests__/executor-test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ import { invariant } from '../../jsutils/invariant';
99
import { Kind } from '../../language/kinds';
1010
import { parse } from '../../language/parser';
1111

12-
import { GraphQLSchema } from '../../type/schema';
13-
import { GraphQLInt, GraphQLBoolean, GraphQLString } from '../../type/scalars';
1412
import {
13+
GraphQLInterfaceType,
1514
GraphQLList,
1615
GraphQLNonNull,
17-
GraphQLScalarType,
18-
GraphQLInterfaceType,
1916
GraphQLObjectType,
17+
GraphQLScalarType,
2018
GraphQLUnionType,
2119
} from '../../type/definition';
20+
import { GraphQLBoolean, GraphQLInt, GraphQLString } from '../../type/scalars';
21+
import { GraphQLSchema } from '../../type/schema';
2222

2323
import { execute, executeSync } from '../execute';
2424

src/execution/__tests__/mutations-test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ import { expect } from 'chai';
22
import { describe, it } from 'mocha';
33

44
import { expectJSON } from '../../__testUtils__/expectJSON';
5-
65
import { resolveOnNextTick } from '../../__testUtils__/resolveOnNextTick';
76

87
import { parse } from '../../language/parser';
98

9+
import { GraphQLObjectType } from '../../type/definition';
1010
import { GraphQLInt } from '../../type/scalars';
1111
import { GraphQLSchema } from '../../type/schema';
12-
import { GraphQLObjectType } from '../../type/definition';
1312

1413
import { execute, executeSync } from '../execute';
1514

src/execution/__tests__/nonnull-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { expectJSON } from '../../__testUtils__/expectJSON';
55

66
import { parse } from '../../language/parser';
77

8-
import { GraphQLSchema } from '../../type/schema';
9-
import { GraphQLString } from '../../type/scalars';
108
import { GraphQLNonNull, GraphQLObjectType } from '../../type/definition';
9+
import { GraphQLString } from '../../type/scalars';
10+
import { GraphQLSchema } from '../../type/schema';
1111

1212
import { buildSchema } from '../../utilities/buildASTSchema';
1313

src/execution/__tests__/resolve-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { describe, it } from 'mocha';
44
import { parse } from '../../language/parser';
55

66
import type { GraphQLFieldConfig } from '../../type/definition';
7-
import { GraphQLSchema } from '../../type/schema';
8-
import { GraphQLInt, GraphQLString } from '../../type/scalars';
97
import { GraphQLObjectType } from '../../type/definition';
8+
import { GraphQLInt, GraphQLString } from '../../type/scalars';
9+
import { GraphQLSchema } from '../../type/schema';
1010

1111
import { executeSync } from '../execute';
1212

src/execution/__tests__/schema-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ import { describe, it } from 'mocha';
33

44
import { parse } from '../../language/parser';
55

6-
import { GraphQLSchema } from '../../type/schema';
76
import {
87
GraphQLList,
98
GraphQLNonNull,
109
GraphQLObjectType,
1110
} from '../../type/definition';
1211
import {
12+
GraphQLBoolean,
1313
GraphQLID,
1414
GraphQLInt,
1515
GraphQLString,
16-
GraphQLBoolean,
1716
} from '../../type/scalars';
17+
import { GraphQLSchema } from '../../type/schema';
1818

1919
import { executeSync } from '../execute';
2020

src/execution/__tests__/subscribe-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import { isAsyncIterable } from '../../jsutils/isAsyncIterable';
99

1010
import { parse } from '../../language/parser';
1111

12-
import { GraphQLSchema } from '../../type/schema';
1312
import { GraphQLList, GraphQLObjectType } from '../../type/definition';
14-
import { GraphQLInt, GraphQLString, GraphQLBoolean } from '../../type/scalars';
13+
import { GraphQLBoolean, GraphQLInt, GraphQLString } from '../../type/scalars';
14+
import { GraphQLSchema } from '../../type/schema';
1515

1616
import { createSourceEventStream, subscribe } from '../subscribe';
1717

src/execution/__tests__/sync-test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import { expectJSON } from '../../__testUtils__/expectJSON';
55

66
import { parse } from '../../language/parser';
77

8-
import { validate } from '../../validation/validate';
9-
10-
import { GraphQLSchema } from '../../type/schema';
11-
import { GraphQLString } from '../../type/scalars';
128
import { GraphQLObjectType } from '../../type/definition';
9+
import { GraphQLString } from '../../type/scalars';
10+
import { GraphQLSchema } from '../../type/schema';
11+
12+
import { validate } from '../../validation/validate';
1313

1414
import { graphqlSync } from '../../graphql';
1515

src/execution/__tests__/union-interface-test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { describe, it } from 'mocha';
33

44
import { parse } from '../../language/parser';
55

6-
import { GraphQLSchema } from '../../type/schema';
7-
import { GraphQLString, GraphQLBoolean } from '../../type/scalars';
86
import {
7+
GraphQLInterfaceType,
98
GraphQLList,
10-
GraphQLUnionType,
119
GraphQLObjectType,
12-
GraphQLInterfaceType,
10+
GraphQLUnionType,
1311
} from '../../type/definition';
12+
import { GraphQLBoolean, GraphQLString } from '../../type/scalars';
13+
import { GraphQLSchema } from '../../type/schema';
1414

1515
import { executeSync } from '../execute';
1616

src/execution/__tests__/variables-test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ import { Kind } from '../../language/kinds';
1010
import { parse } from '../../language/parser';
1111

1212
import type {
13-
GraphQLFieldConfig,
1413
GraphQLArgumentConfig,
14+
GraphQLFieldConfig,
1515
} from '../../type/definition';
16-
import { GraphQLSchema } from '../../type/schema';
17-
import { GraphQLString } from '../../type/scalars';
1816
import {
17+
GraphQLEnumType,
18+
GraphQLInputObjectType,
1919
GraphQLList,
2020
GraphQLNonNull,
21-
GraphQLScalarType,
2221
GraphQLObjectType,
23-
GraphQLInputObjectType,
24-
GraphQLEnumType,
22+
GraphQLScalarType,
2523
} from '../../type/definition';
24+
import { GraphQLString } from '../../type/scalars';
25+
import { GraphQLSchema } from '../../type/schema';
2626

2727
import { executeSync } from '../execute';
2828
import { getVariableValues } from '../values';

src/execution/collectFields.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import type { ObjMap } from '../jsutils/ObjMap';
22

33
import type {
4-
SelectionSetNode,
54
FieldNode,
5+
FragmentDefinitionNode,
66
FragmentSpreadNode,
77
InlineFragmentNode,
8-
FragmentDefinitionNode,
8+
SelectionSetNode,
99
} from '../language/ast';
1010
import { Kind } from '../language/kinds';
1111

12-
import type { GraphQLSchema } from '../type/schema';
1312
import type { GraphQLObjectType } from '../type/definition';
13+
import { isAbstractType } from '../type/definition';
1414
import {
1515
GraphQLIncludeDirective,
1616
GraphQLSkipDirective,
1717
} from '../type/directives';
18-
import { isAbstractType } from '../type/definition';
18+
import type { GraphQLSchema } from '../type/schema';
1919

2020
import { typeFromAST } from '../utilities/typeFromAST';
2121

0 commit comments

Comments
 (0)