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

0 commit comments

Comments
 (0)