Skip to content

Commit 2a8436c

Browse files
authored
Use eslint-plugin-simple-import-sort (#52090)
1 parent 0d251ba commit 2a8436c

File tree

145 files changed

+515
-475
lines changed

Some content is hidden

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

145 files changed

+515
-475
lines changed

.eslintrc.json

+11-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"es6": true
1212
},
1313
"plugins": [
14-
"@typescript-eslint", "no-null", "import", "eslint-plugin-local"
14+
"@typescript-eslint", "no-null", "import", "eslint-plugin-local", "simple-import-sort"
1515
],
1616
"ignorePatterns": [
1717
"**/node_modules/**",
@@ -25,11 +25,8 @@
2525
"/coverage/**"
2626
],
2727
"rules": {
28-
"sort-imports": ["error", {
29-
"ignoreCase": true,
30-
"ignoreDeclarationSort": true,
31-
"allowSeparatedGroups": true
32-
}],
28+
"simple-import-sort/imports": "error",
29+
"simple-import-sort/exports": "error",
3330

3431
"@typescript-eslint/adjacent-overload-signatures": "error",
3532
"@typescript-eslint/array-type": "error",
@@ -180,6 +177,14 @@
180177
{ "name": "exports" }
181178
]
182179
}
180+
},
181+
{
182+
// These files contain imports in a specific order that are generally unsafe to modify.
183+
"files": ["**/_namespaces/**"],
184+
"rules": {
185+
"simple-import-sort/imports": "off",
186+
"simple-import-sort/exports": "off"
187+
}
183188
}
184189
]
185190
}

.vscode/settings.template.json

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
// ".git-blame-ignore-revs"
1414
// ]
1515

16+
// Match eslint-plugin-simple-import-sort in organize/auto-imports.
17+
"typescript.unstable": {
18+
"organizeImportsCollation": "unicode",
19+
"organizeImportsCaseFirst": "upper",
20+
"organizeImportsIgnoreCase": false,
21+
"organizeImportsNumericCollation": true
22+
},
23+
1624
// These options search the repo recursively and slow down
1725
// the build task menu. We define our own in tasks.json.
1826
"typescript.tsc.autoDetect": "off",

Herebyfile.mjs

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
// @ts-check
2-
import path from "path";
3-
import fs from "fs";
2+
import { CancelToken } from "@esfx/canceltoken";
3+
import chalk from "chalk";
4+
import chokidar from "chokidar";
45
import del from "del";
5-
import { task } from "hereby";
6+
import esbuild from "esbuild";
7+
import { EventEmitter } from "events";
8+
import fs from "fs";
9+
import fsExtra from "fs-extra";
610
import _glob from "glob";
11+
import { task } from "hereby";
12+
import path from "path";
713
import util from "util";
8-
import chalk from "chalk";
9-
import fsExtra from "fs-extra";
10-
import { Debouncer, Deferred, exec, getDiffTool, getDirSize, memoize, needsUpdate, readJson } from "./scripts/build/utils.mjs";
11-
import { localBaseline, localRwcBaseline, refBaseline, refRwcBaseline, runConsoleTests } from "./scripts/build/tests.mjs";
12-
import { buildProject, cleanProject, watchProject } from "./scripts/build/projects.mjs";
14+
1315
import { localizationDirectories } from "./scripts/build/localization.mjs";
1416
import cmdLineOptions from "./scripts/build/options.mjs";
15-
import esbuild from "esbuild";
16-
import chokidar from "chokidar";
17-
import { EventEmitter } from "events";
18-
import { CancelToken } from "@esfx/canceltoken";
17+
import { buildProject, cleanProject, watchProject } from "./scripts/build/projects.mjs";
18+
import { localBaseline, localRwcBaseline, refBaseline, refRwcBaseline, runConsoleTests } from "./scripts/build/tests.mjs";
19+
import { Debouncer, Deferred, exec, getDiffTool, getDirSize, memoize, needsUpdate, readJson } from "./scripts/build/utils.mjs";
1920

2021
const glob = util.promisify(_glob);
2122

package-lock.json

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"eslint-plugin-import": "^2.26.0",
6767
"eslint-plugin-local": "^1.0.0",
6868
"eslint-plugin-no-null": "^1.0.2",
69+
"eslint-plugin-simple-import-sort": "^10.0.0",
6970
"fast-xml-parser": "^4.0.11",
7071
"fs-extra": "^9.1.0",
7172
"glob": "latest",

scripts/browserIntegrationTest.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import chalk from "chalk";
2-
import { join } from "path";
32
import { readFileSync } from "fs";
3+
import { join } from "path";
44

55
let playwright;
66
try {

scripts/build/findUpDir.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { dirname, join, resolve } from "path";
21
import { existsSync } from "fs";
2+
import { dirname, join, resolve } from "path";
33
import url from "url";
44

55
const __filename = url.fileURLToPath(new URL(import.meta.url));

scripts/build/projects.mjs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { Debouncer, exec } from "./utils.mjs";
21
import { resolve } from "path";
2+
33
import { findUpRoot } from "./findUpDir.mjs";
44
import cmdLineOptions from "./options.mjs";
5+
import { Debouncer, exec } from "./utils.mjs";
56

67
class ProjectQueue {
78
/**

scripts/build/tests.mjs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
import { CancelError } from "@esfx/canceltoken";
2+
import chalk from "chalk";
13
import del from "del";
24
import fs from "fs";
35
import os from "os";
46
import path from "path";
5-
import chalk from "chalk";
7+
8+
import { findUpFile, findUpRoot } from "./findUpDir.mjs";
69
import cmdLineOptions from "./options.mjs";
710
import { exec } from "./utils.mjs";
8-
import { findUpFile, findUpRoot } from "./findUpDir.mjs";
9-
import { CancelError } from "@esfx/canceltoken";
1011

1112
const mochaJs = path.resolve(findUpRoot(), "node_modules", "mocha", "bin", "_mocha");
1213
export const localBaseline = "tests/baselines/local/";

scripts/build/utils.mjs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/* eslint-disable no-restricted-globals */
22

3-
import fs from "fs";
4-
import path from "path";
3+
import { CancelError } from "@esfx/canceltoken";
4+
import assert from "assert";
55
import chalk from "chalk";
6-
import which from "which";
76
import { spawn } from "child_process";
8-
import assert from "assert";
7+
import fs from "fs";
98
import JSONC from "jsonc-parser";
10-
import { CancelError } from "@esfx/canceltoken";
9+
import path from "path";
10+
import which from "which";
1111

1212
/**
1313
* Executes the provided command once with the supplied arguments.

scripts/configurePrerelease.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { normalize, relative } from "path";
21
import assert from "assert";
32
import { readFileSync, writeFileSync } from "fs";
3+
import { normalize, relative } from "path";
44
import url from "url";
55

66
const __filename = url.fileURLToPath(new URL(import.meta.url));

scripts/dtsBundler.mjs

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
* bundle as namespaces again, even though the project is modules.
66
*/
77

8+
import assert, { fail } from "assert";
89
import fs from "fs";
9-
import path from "path";
1010
import minimist from "minimist";
11+
import path from "path";
1112
import url from "url";
13+
1214
import ts from "../lib/typescript.js";
13-
import assert, { fail } from "assert";
1415

1516
const __filename = url.fileURLToPath(new URL(import.meta.url));
1617
const __dirname = path.dirname(__filename);

scripts/find-unused-diganostic-messages.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// This file requires a modern version of node 14+, and grep to be available.
22

33
// node scripts/find-unused-diagnostic-messages.mjs
4+
import { execSync } from "child_process";
45
import { readFileSync } from "fs";
56
import { EOL } from "os";
6-
import { execSync } from "child_process";
77

88
const diags = readFileSync("src/compiler/diagnosticInformationMap.generated.ts", "utf8");
99
const startOfDiags = diags.split("export const Diagnostics")[1];

scripts/generateLocalizedDiagnosticMessages.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { XMLParser } from "fast-xml-parser";
12
import fs from "fs";
23
import path from "path";
3-
import { XMLParser } from "fast-xml-parser";
44

55
/** @typedef {{
66
LCX: {

scripts/importDefinitelyTypedTests.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import * as childProcess from "child_process";
12
import * as fs from "fs";
2-
import * as path from "path";
33
import * as os from "os";
4-
import * as childProcess from "child_process";
4+
import * as path from "path";
55
import url from "url";
66

77
const __filename = url.fileURLToPath(new URL(import.meta.url));

scripts/link-hooks.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from "fs";
22
import path from "path";
33
import url from "url";
4+
45
import { findUpRoot } from "./build/findUpDir.mjs";
56

67
const __filename = url.fileURLToPath(new URL(import.meta.url));

scripts/open-cherry-pick-pr.mjs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { Octokit } from "@octokit/rest";
2-
import { runSequence } from "./run-sequence.mjs";
32
import fs from "fs";
43
import path from "path";
54
import url from "url";
65

6+
import { runSequence } from "./run-sequence.mjs";
7+
78
const __filename = url.fileURLToPath(new URL(import.meta.url));
89
const __dirname = path.dirname(__filename);
910

scripts/open-user-pr.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Octokit } from "@octokit/rest";
2+
23
import { runSequence } from "./run-sequence.mjs";
34

45
const userName = process.env.GH_USERNAME || "typescript-bot";

scripts/perf-result-post.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Octokit } from "@octokit/rest";
2-
import fs from "fs";
2+
import assert from "assert";
33
import ado from "azure-devops-node-api";
4+
import fs from "fs";
45
import fetch from "node-fetch";
5-
import assert from "assert";
66

77

88
async function main() {

scripts/processDiagnosticMessages.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import path from "path";
21
import fs from "fs";
2+
import path from "path";
33

44
/** @typedef {{
55
category: string;

scripts/produceLKG.mjs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import del from "del";
12
import fs from "fs-extra";
2-
import path from "path";
33
import glob from "glob";
4+
import path from "path";
45
import url from "url";
5-
import del from "del";
6+
67
import { localizationDirectories } from "./build/localization.mjs";
78

89
const __filename = url.fileURLToPath(new URL(import.meta.url));

scripts/update-experimental-branches.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Octokit } from "@octokit/rest";
2+
23
import { runSequence } from "./run-sequence.mjs";
34

45
// The first is used by bot-based kickoffs, the second by automatic triggers

src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1062,8 +1062,8 @@ import {
10621062
WithStatement,
10631063
YieldExpression,
10641064
} from "./_namespaces/ts";
1065-
import * as performance from "./_namespaces/ts.performance";
10661065
import * as moduleSpecifiers from "./_namespaces/ts.moduleSpecifiers";
1066+
import * as performance from "./_namespaces/ts.performance";
10671067

10681068
const ambientModuleSymbolRegex = /^".+"$/;
10691069
const anon = "(anonymous)" as __String & string;

src/compiler/moduleNameResolver.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ import {
103103
tryExtractTSExtension,
104104
tryGetExtensionFromPath,
105105
tryParsePatterns,
106-
version,
107106
Version,
107+
version,
108108
versionMajorMinor,
109109
VersionRange,
110110
} from "./_namespaces/ts";

src/compiler/transformer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ import {
5555
transformECMAScriptModule,
5656
Transformer,
5757
TransformerFactory,
58+
transformES5,
5859
transformES2015,
5960
transformES2016,
6061
transformES2017,
6162
transformES2018,
6263
transformES2019,
6364
transformES2020,
6465
transformES2021,
65-
transformES5,
6666
transformESDecorators,
6767
transformESNext,
6868
transformGenerators,

src/compiler/utilities.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ import {
199199
HasExpressionInitializer,
200200
hasExtension,
201201
HasFlowNode,
202-
hasInitializer,
203202
HasInitializer,
203+
hasInitializer,
204204
HasJSDoc,
205205
hasJSDocNodes,
206206
HasModifiers,

src/deprecatedCompat/deprecate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import {
33
DeprecationOptions,
44
formatStringFromArgs,
55
noop,
6-
version,
76
Version,
7+
version,
88
} from "./_namespaces/ts";
99

1010
export let enableDeprecationWarnings = true;

src/executeCommandLine/executeCommandLine.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as performance from "../compiler/_namespaces/ts.performance";
12
import * as ts from "./_namespaces/ts";
23
import {
34
arrayFrom,
@@ -19,8 +20,8 @@ import {
1920
createDiagnosticReporter,
2021
createGetCanonicalFileName,
2122
createIncrementalCompilerHost,
22-
createProgram,
2323
CreateProgram,
24+
createProgram,
2425
CreateProgramOptions,
2526
createSolutionBuilder,
2627
createSolutionBuilderHost,
@@ -87,7 +88,6 @@ import {
8788
WatchCompilerHost,
8889
WatchOptions,
8990
} from "./_namespaces/ts";
90-
import * as performance from "../compiler/_namespaces/ts.performance";
9191

9292
interface Statistic {
9393
name: string;

0 commit comments

Comments
 (0)