Skip to content

Commit

Permalink
Use 'eslint-plugin-simple-import-sort' to sort imports (#3446)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored Jan 3, 2022
1 parent 085d1ee commit 47bd8c8
Show file tree
Hide file tree
Showing 126 changed files with 788 additions and 762 deletions.
33 changes: 33 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins:
- internal-rules
- node
- import
- simple-import-sort
settings:
node:
tryExtensions: ['.js', '.json', '.node', '.ts', '.d.ts']
Expand Down Expand Up @@ -140,6 +141,38 @@ rules:
import/group-exports: off
import/dynamic-import-chunkname: off

##############################################################################
# `eslint-plugin-simple-import-sort` rule list based on `v2.25.x`
# https://github.com/lydell/eslint-plugin-simple-import-sort
##############################################################################
simple-import-sort/imports:
- error
- groups:
# Packages.
# Things that start with a letter (or digit or underscore), or `@` followed by a letter.
- ["^@?\\w"]

# General utilities
- ["^(\\./|(\\.\\./)+)__testUtils__/"]
- ["^(\\./|(\\.\\./)+)jsutils/"]

# Top-level directories
- ["^(\\./|(\\.\\./)+)error/"]
- ["^(\\./|(\\.\\./)+)language/"]
- ["^(\\./|(\\.\\./)+)type/"]
- ["^(\\./|(\\.\\./)+)validation/"]
- ["^(\\./|(\\.\\./)+)execution/"]
- ["^(\\./|(\\.\\./)+)utilities/"]

# Relative imports.
# Anything that starts with a dot.
- ["^(\\.\\./){4,}"]
- ["^(\\.\\./){3}"]
- ["^(\\.\\./){2}"]
- ["^(\\.\\./){1}"]
- ["^\\./"]
simple-import-sort/exports: off # TODO

##############################################################################
# ESLint builtin rules list based on `v8.5.x`
##############################################################################
Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"eslint-plugin-import": "2.25.3",
"eslint-plugin-internal-rules": "file:./resources/eslint-internal-rules",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-simple-import-sort": "7.0.0",
"eslint-plugin-tsdoc": "0.2.14",
"mocha": "9.1.3",
"prettier": "2.5.1",
Expand Down
2 changes: 1 addition & 1 deletion src/__testUtils__/expectJSON.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';

import { mapValue } from '../jsutils/mapValue';
import { isObjectLike } from '../jsutils/isObjectLike';
import { mapValue } from '../jsutils/mapValue';

/**
* Deeply transforms an arbitrary value to a JSON-safe value by calling toJSON
Expand Down
10 changes: 5 additions & 5 deletions src/__tests__/starWarsSchema.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { GraphQLSchema } from '../type/schema';
import { GraphQLString } from '../type/scalars';
import {
GraphQLList,
GraphQLNonNull,
GraphQLEnumType,
GraphQLInterfaceType,
GraphQLList,
GraphQLNonNull,
GraphQLObjectType,
} from '../type/definition';
import { GraphQLString } from '../type/scalars';
import { GraphQLSchema } from '../type/schema';

import { getFriends, getHero, getHuman, getDroid } from './starWarsData';
import { getDroid, getFriends, getHero, getHuman } from './starWarsData';

/**
* This is designed to be an end-to-end test, demonstrating
Expand Down
2 changes: 1 addition & 1 deletion src/error/GraphQLError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { isObjectLike } from '../jsutils/isObjectLike';
import type { Maybe } from '../jsutils/Maybe';

import type { ASTNode, Location } from '../language/ast';
import type { Source } from '../language/source';
import type { SourceLocation } from '../language/location';
import { getLocation } from '../language/location';
import { printLocation, printSourceLocation } from '../language/printLocation';
import type { Source } from '../language/source';

/**
* Custom extensions
Expand Down
2 changes: 1 addition & 1 deletion src/error/__tests__/GraphQLError-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Kind } from '../../language/kinds';
import { parse } from '../../language/parser';
import { Source } from '../../language/source';

import { GraphQLError, printError, formatError } from '../GraphQLError';
import { formatError, GraphQLError, printError } from '../GraphQLError';

const source = new Source(dedent`
{
Expand Down
8 changes: 4 additions & 4 deletions src/execution/__tests__/abstract-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import { expectJSON } from '../../__testUtils__/expectJSON';

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

import { GraphQLSchema } from '../../type/schema';
import { GraphQLString, GraphQLBoolean } from '../../type/scalars';
import {
assertInterfaceType,
GraphQLInterfaceType,
GraphQLList,
GraphQLObjectType,
GraphQLInterfaceType,
GraphQLUnionType,
} from '../../type/definition';
import { GraphQLBoolean, GraphQLString } from '../../type/scalars';
import { GraphQLSchema } from '../../type/schema';

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

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

async function executeQuery(args: {
schema: GraphQLSchema;
Expand Down
4 changes: 2 additions & 2 deletions src/execution/__tests__/directives-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { describe, it } from 'mocha';

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

import { GraphQLSchema } from '../../type/schema';
import { GraphQLString } from '../../type/scalars';
import { GraphQLObjectType } from '../../type/definition';
import { GraphQLString } from '../../type/scalars';
import { GraphQLSchema } from '../../type/schema';

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

Expand Down
8 changes: 4 additions & 4 deletions src/execution/__tests__/executor-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import { invariant } from '../../jsutils/invariant';
import { Kind } from '../../language/kinds';
import { parse } from '../../language/parser';

import { GraphQLSchema } from '../../type/schema';
import { GraphQLInt, GraphQLBoolean, GraphQLString } from '../../type/scalars';
import {
GraphQLInterfaceType,
GraphQLList,
GraphQLNonNull,
GraphQLScalarType,
GraphQLInterfaceType,
GraphQLObjectType,
GraphQLScalarType,
GraphQLUnionType,
} from '../../type/definition';
import { GraphQLBoolean, GraphQLInt, GraphQLString } from '../../type/scalars';
import { GraphQLSchema } from '../../type/schema';

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

Expand Down
3 changes: 1 addition & 2 deletions src/execution/__tests__/mutations-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import { expect } from 'chai';
import { describe, it } from 'mocha';

import { expectJSON } from '../../__testUtils__/expectJSON';

import { resolveOnNextTick } from '../../__testUtils__/resolveOnNextTick';

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

import { GraphQLObjectType } from '../../type/definition';
import { GraphQLInt } from '../../type/scalars';
import { GraphQLSchema } from '../../type/schema';
import { GraphQLObjectType } from '../../type/definition';

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

Expand Down
4 changes: 2 additions & 2 deletions src/execution/__tests__/nonnull-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { expectJSON } from '../../__testUtils__/expectJSON';

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

import { GraphQLSchema } from '../../type/schema';
import { GraphQLString } from '../../type/scalars';
import { GraphQLNonNull, GraphQLObjectType } from '../../type/definition';
import { GraphQLString } from '../../type/scalars';
import { GraphQLSchema } from '../../type/schema';

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

Expand Down
4 changes: 2 additions & 2 deletions src/execution/__tests__/resolve-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { describe, it } from 'mocha';
import { parse } from '../../language/parser';

import type { GraphQLFieldConfig } from '../../type/definition';
import { GraphQLSchema } from '../../type/schema';
import { GraphQLInt, GraphQLString } from '../../type/scalars';
import { GraphQLObjectType } from '../../type/definition';
import { GraphQLInt, GraphQLString } from '../../type/scalars';
import { GraphQLSchema } from '../../type/schema';

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

Expand Down
4 changes: 2 additions & 2 deletions src/execution/__tests__/schema-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import { describe, it } from 'mocha';

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

import { GraphQLSchema } from '../../type/schema';
import {
GraphQLList,
GraphQLNonNull,
GraphQLObjectType,
} from '../../type/definition';
import {
GraphQLBoolean,
GraphQLID,
GraphQLInt,
GraphQLString,
GraphQLBoolean,
} from '../../type/scalars';
import { GraphQLSchema } from '../../type/schema';

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

Expand Down
4 changes: 2 additions & 2 deletions src/execution/__tests__/subscribe-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { isAsyncIterable } from '../../jsutils/isAsyncIterable';

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

import { GraphQLSchema } from '../../type/schema';
import { GraphQLList, GraphQLObjectType } from '../../type/definition';
import { GraphQLInt, GraphQLString, GraphQLBoolean } from '../../type/scalars';
import { GraphQLBoolean, GraphQLInt, GraphQLString } from '../../type/scalars';
import { GraphQLSchema } from '../../type/schema';

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

Expand Down
8 changes: 4 additions & 4 deletions src/execution/__tests__/sync-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { expectJSON } from '../../__testUtils__/expectJSON';

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

import { validate } from '../../validation/validate';

import { GraphQLSchema } from '../../type/schema';
import { GraphQLString } from '../../type/scalars';
import { GraphQLObjectType } from '../../type/definition';
import { GraphQLString } from '../../type/scalars';
import { GraphQLSchema } from '../../type/schema';

import { validate } from '../../validation/validate';

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

Expand Down
8 changes: 4 additions & 4 deletions src/execution/__tests__/union-interface-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { describe, it } from 'mocha';

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

import { GraphQLSchema } from '../../type/schema';
import { GraphQLString, GraphQLBoolean } from '../../type/scalars';
import {
GraphQLInterfaceType,
GraphQLList,
GraphQLUnionType,
GraphQLObjectType,
GraphQLInterfaceType,
GraphQLUnionType,
} from '../../type/definition';
import { GraphQLBoolean, GraphQLString } from '../../type/scalars';
import { GraphQLSchema } from '../../type/schema';

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

Expand Down
12 changes: 6 additions & 6 deletions src/execution/__tests__/variables-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import { Kind } from '../../language/kinds';
import { parse } from '../../language/parser';

import type {
GraphQLFieldConfig,
GraphQLArgumentConfig,
GraphQLFieldConfig,
} from '../../type/definition';
import { GraphQLSchema } from '../../type/schema';
import { GraphQLString } from '../../type/scalars';
import {
GraphQLEnumType,
GraphQLInputObjectType,
GraphQLList,
GraphQLNonNull,
GraphQLScalarType,
GraphQLObjectType,
GraphQLInputObjectType,
GraphQLEnumType,
GraphQLScalarType,
} from '../../type/definition';
import { GraphQLString } from '../../type/scalars';
import { GraphQLSchema } from '../../type/schema';

import { executeSync } from '../execute';
import { getVariableValues } from '../values';
Expand Down
8 changes: 4 additions & 4 deletions src/execution/collectFields.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import type { ObjMap } from '../jsutils/ObjMap';

import type {
SelectionSetNode,
FieldNode,
FragmentDefinitionNode,
FragmentSpreadNode,
InlineFragmentNode,
FragmentDefinitionNode,
SelectionSetNode,
} from '../language/ast';
import { Kind } from '../language/kinds';

import type { GraphQLSchema } from '../type/schema';
import type { GraphQLObjectType } from '../type/definition';
import { isAbstractType } from '../type/definition';
import {
GraphQLIncludeDirective,
GraphQLSkipDirective,
} from '../type/directives';
import { isAbstractType } from '../type/definition';
import type { GraphQLSchema } from '../type/schema';

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

Expand Down
Loading

0 comments on commit 47bd8c8

Please sign in to comment.