Skip to content

Commit fddcda1

Browse files
committed
Merge branch 'main' into remove-typescriptservices
2 parents 8a2a92c + e14a229 commit fddcda1

File tree

734 files changed

+44283
-44299
lines changed

Some content is hidden

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

734 files changed

+44283
-44299
lines changed

.dockerignore

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,8 @@ build.json
1717
*.config
1818
scripts/debug.bat
1919
scripts/run.bat
20-
scripts/word2md.js
21-
scripts/buildProtocol.js
22-
scripts/ior.js
23-
scripts/configurePrerelease.js
24-
scripts/open-user-pr.js
25-
scripts/open-cherry-pick-pr.js
26-
scripts/processDiagnosticMessages.d.ts
27-
scripts/processDiagnosticMessages.js
28-
scripts/produceLKG.js
29-
scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js
30-
scripts/generateLocalizedDiagnosticMessages.js
31-
scripts/configureLanguageServiceBuild.js
32-
scripts/*.js.map
33-
scripts/typings/
20+
scripts/**/*.js
21+
scripts/**/*.js.map
3422
coverage/
3523
internal/
3624
**/.DS_Store

.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
/lib/**
55
/src/lib/*.generated.d.ts
66
# Ignore all compiled script outputs
7-
/scripts/*.js
7+
/scripts/**/*.js
8+
/scripts/**/*.d.*
89
# But, not the ones that are hand-written.
910
# TODO: remove once scripts are pure JS
1011
!/scripts/browserIntegrationTest.js

.eslintplugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const fs = require("fs");
22
const path = require("path");
33

44
const rulesDir = path.join(__dirname, "scripts", "eslint", "rules");
5-
const ext = ".js";
5+
const ext = ".cjs";
66
const ruleFiles = fs.readdirSync(rulesDir).filter((p) => p.endsWith(ext));
77

88
module.exports = {

.eslintrc.json

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@
1212
"plugins": [
1313
"@typescript-eslint", "jsdoc", "no-null", "import", "eslint-plugin-local"
1414
],
15-
"overrides": [
16-
// By default, the ESLint CLI only looks at .js files. But, it will also look at
17-
// any files which are referenced in an override config. Most users of typescript-eslint
18-
// get this behavior by default by extending a recommended typescript-eslint config, which
19-
// just so happens to override some core ESLint rules. We don't extend from any config, so
20-
// explicitly reference TS files here so the CLI picks them up.
21-
//
22-
// ESLint in VS Code will lint any opened file (so long as it's not eslintignore'd), so
23-
// that will work regardless of the below.
24-
{ "files": ["*.ts", "*.mts", "*.cts", "*.mjs", "*.cjs"] }
25-
],
2615
"rules": {
2716
"@typescript-eslint/adjacent-overload-signatures": "error",
2817
"@typescript-eslint/array-type": "error",
@@ -151,5 +140,31 @@
151140
"no-prototype-builtins": "error",
152141
"no-self-assign": "error",
153142
"no-dupe-else-if": "error"
154-
}
143+
},
144+
"overrides": [
145+
// By default, the ESLint CLI only looks at .js files. But, it will also look at
146+
// any files which are referenced in an override config. Most users of typescript-eslint
147+
// get this behavior by default by extending a recommended typescript-eslint config, which
148+
// just so happens to override some core ESLint rules. We don't extend from any config, so
149+
// explicitly reference TS files here so the CLI picks them up.
150+
//
151+
// ESLint in VS Code will lint any opened file (so long as it's not eslintignore'd), so
152+
// that will work regardless of the below.
153+
//
154+
// The same applies to mjs files; ESLint appears to not scan those either.
155+
{ "files": ["*.ts", "*.mts", "*.cts", "*.mjs", "*.cjs"] },
156+
{
157+
"files": ["*.mjs", "*.mts"],
158+
"rules": {
159+
// These globals don't exist outside of CJS files.
160+
"no-restricted-globals": ["error",
161+
{ "name": "__filename" },
162+
{ "name": "__dirname" },
163+
{ "name": "require" },
164+
{ "name": "module" },
165+
{ "name": "exports" }
166+
]
167+
}
168+
}
169+
]
155170
}

.github/workflows/ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,20 @@ jobs:
6767

6868
- name: Validate the browser can import TypeScript
6969
run: gulp test-browser-integration
70+
71+
misc:
72+
runs-on: ubuntu-latest
73+
74+
steps:
75+
- uses: actions/checkout@v3
76+
- uses: actions/setup-node@v3
77+
with:
78+
node-version: "*"
79+
check-latest: true
80+
- run: npm ci
81+
82+
- name: Build scripts
83+
run: gulp scripts
84+
85+
- name: ESLint tests
86+
run: gulp run-eslint-rules-tests

.gitignore

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,8 @@ tests/cases/**/*.js.map
4040
scripts/eslint/built/
4141
scripts/debug.bat
4242
scripts/run.bat
43-
scripts/word2md.js
44-
scripts/buildProtocol.js
45-
scripts/ior.js
46-
scripts/configurePrerelease.js
47-
scripts/configureLanguageServiceBuild.js
48-
scripts/open-user-pr.js
49-
scripts/open-cherry-pick-pr.js
50-
scripts/processDiagnosticMessages.d.ts
51-
scripts/processDiagnosticMessages.js
52-
scripts/produceLKG.js
53-
scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js
54-
scripts/generateLocalizedDiagnosticMessages.js
55-
scripts/request-pr-review.js
56-
scripts/errorCheck.js
57-
scripts/*.js.map
58-
scripts/typings/
43+
scripts/**/*.js
44+
scripts/**/*.js.map
5945
coverage/
6046
internal/
6147
**/.DS_Store

Gulpfile.js renamed to Gulpfile.mjs

Lines changed: 39 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
// @ts-check
2-
const path = require("path");
3-
const fs = require("fs");
4-
const log = require("fancy-log");
5-
const newer = require("gulp-newer");
6-
const sourcemaps = require("gulp-sourcemaps");
7-
const del = require("del");
8-
const rename = require("gulp-rename");
9-
const concat = require("gulp-concat");
10-
const merge2 = require("merge2");
11-
const { src, dest, task, parallel, series, watch } = require("gulp");
12-
const { append, transform } = require("gulp-insert");
13-
const { prependFile } = require("./scripts/build/prepend");
14-
const { exec, readJson, needsUpdate, getDiffTool, getDirSize, rm } = require("./scripts/build/utils");
15-
const { runConsoleTests, refBaseline, localBaseline, refRwcBaseline, localRwcBaseline } = require("./scripts/build/tests");
16-
const { buildProject, cleanProject, watchProject } = require("./scripts/build/projects");
17-
const cmdLineOptions = require("./scripts/build/options");
2+
import path from "path";
3+
import fs from "fs";
4+
import log from "fancy-log";
5+
import newer from "gulp-newer";
6+
import sourcemaps from "gulp-sourcemaps";
7+
import del from "del";
8+
import rename from "gulp-rename";
9+
import concat from "gulp-concat";
10+
import merge2 from "merge2";
11+
import gulp from "gulp";
12+
import { append, transform } from "gulp-insert";
13+
import { prependFile } from "./scripts/build/prepend.mjs";
14+
import { exec, readJson, needsUpdate, getDiffTool, getDirSize, rm } from "./scripts/build/utils.mjs";
15+
import { runConsoleTests, refBaseline, localBaseline, refRwcBaseline, localRwcBaseline } from "./scripts/build/tests.mjs";
16+
import { buildProject, cleanProject, watchProject } from "./scripts/build/projects.mjs";
17+
import cmdLineOptions from "./scripts/build/options.mjs";
18+
19+
const { src, dest, task, parallel, series, watch } = gulp;
1820

1921
const copyright = "CopyrightNotice.txt";
2022
const cleanTasks = [];
@@ -23,9 +25,6 @@ const buildScripts = () => buildProject("scripts");
2325
task("scripts", buildScripts);
2426
task("scripts").description = "Builds files in the 'scripts' folder.";
2527

26-
const cleanScripts = () => cleanProject("scripts");
27-
cleanTasks.push(cleanScripts);
28-
2928
/** @type {{ libs: string[]; paths: Record<string, string | undefined>; }} */
3029
const libraries = readJson("./src/lib/libs.json");
3130
const libs = libraries.libs.map(lib => {
@@ -56,10 +55,10 @@ const diagnosticMessagesJson = "src/compiler/diagnosticMessages.json";
5655
const diagnosticMessagesGeneratedJson = "src/compiler/diagnosticMessages.generated.json";
5756
const generateDiagnostics = async () => {
5857
if (needsUpdate(diagnosticMessagesJson, [diagnosticMessagesGeneratedJson, diagnosticInformationMapTs])) {
59-
await exec(process.execPath, ["scripts/processDiagnosticMessages.js", diagnosticMessagesJson]);
58+
await exec(process.execPath, ["scripts/processDiagnosticMessages.mjs", diagnosticMessagesJson]);
6059
}
6160
};
62-
task("generate-diagnostics", series(buildScripts, generateDiagnostics));
61+
task("generate-diagnostics", generateDiagnostics);
6362
task("generate-diagnostics").description = "Generates a diagnostic file in TypeScript based on an input JSON file";
6463

6564
const cleanDiagnostics = () => del([diagnosticInformationMapTs, diagnosticMessagesGeneratedJson]);
@@ -88,7 +87,7 @@ const localizationTargets = ["cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt
8887

8988
const localize = async () => {
9089
if (needsUpdate(diagnosticMessagesGeneratedJson, generatedLCGFile)) {
91-
return exec(process.execPath, ["scripts/generateLocalizedDiagnosticMessages.js", "src/loc/lcl", "built/local", diagnosticMessagesGeneratedJson], { ignoreExitCode: true });
90+
return exec(process.execPath, ["scripts/generateLocalizedDiagnosticMessages.mjs", "src/loc/lcl", "built/local", diagnosticMessagesGeneratedJson], { ignoreExitCode: true });
9291
}
9392
};
9493

@@ -97,7 +96,7 @@ const cleanDebugTools = () => cleanProject("src/debug");
9796
cleanTasks.push(cleanDebugTools);
9897

9998
// Pre-build steps when targeting the LKG compiler
100-
const lkgPreBuild = parallel(generateLibs, series(buildScripts, generateDiagnostics, buildDebugTools));
99+
const lkgPreBuild = parallel(generateLibs, series(generateDiagnostics, buildDebugTools));
101100

102101
const buildTsc = () => buildProject("src/tsc");
103102
task("tsc", series(lkgPreBuild, buildTsc));
@@ -113,7 +112,7 @@ task("watch-tsc", series(lkgPreBuild, parallel(watchLib, watchDiagnostics, watch
113112
task("watch-tsc").description = "Watch for changes and rebuild the command-line compiler only.";
114113

115114
// Pre-build steps when targeting the built/local compiler.
116-
const localPreBuild = parallel(generateLibs, series(buildScripts, generateDiagnostics, buildDebugTools, buildTsc));
115+
const localPreBuild = parallel(generateLibs, series(generateDiagnostics, buildDebugTools, buildTsc));
117116

118117
// Pre-build steps to use based on supplied options.
119118
const preBuild = cmdLineOptions.lkg ? lkgPreBuild : localPreBuild;
@@ -309,17 +308,8 @@ task("clean-tests").description = "Cleans the outputs for the test infrastructur
309308

310309
const watchTests = () => watchProject("src/testRunner", cmdLineOptions);
311310

312-
const buildEslintRules = () => buildProject("scripts/eslint");
313-
task("build-eslint-rules", buildEslintRules);
314-
task("build-eslint-rules").description = "Compiles eslint rules to js";
315-
316-
const cleanEslintRules = () => cleanProject("scripts/eslint");
317-
cleanTasks.push(cleanEslintRules);
318-
task("clean-eslint-rules", cleanEslintRules);
319-
task("clean-eslint-rules").description = "Cleans the outputs for the eslint rules";
320-
321-
const runEslintRulesTests = () => runConsoleTests("scripts/eslint/built/tests", "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ false);
322-
task("run-eslint-rules-tests", series(buildEslintRules, runEslintRulesTests));
311+
const runEslintRulesTests = () => runConsoleTests("scripts/eslint/tests", "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ false);
312+
task("run-eslint-rules-tests", runEslintRulesTests);
323313
task("run-eslint-rules-tests").description = "Runs the eslint rule tests";
324314

325315
/** @type { (folder: string) => { (): Promise<any>; displayName?: string } } */
@@ -433,8 +423,8 @@ task("runtests-parallel").flags = {
433423
};
434424

435425

436-
task("test-browser-integration", () => exec(process.execPath, ["scripts/browserIntegrationTest.js"]));
437-
task("test-browser-integration").description = "Runs scripts/browserIntegrationTest.ts which tests that typescript.js loads in a browser";
426+
task("test-browser-integration", () => exec(process.execPath, ["scripts/browserIntegrationTest.mjs"]));
427+
task("test-browser-integration").description = "Runs scripts/browserIntegrationTest.mjs which tests that typescript.js loads in a browser";
438428

439429

440430
task("diff", () => exec(getDiffTool(), [refBaseline, localBaseline], { ignoreExitCode: true, waitForExit: false }));
@@ -467,13 +457,9 @@ const updateSublime = () => src(["built/local/tsserver.js", "built/local/tsserve
467457
task("update-sublime", updateSublime);
468458
task("update-sublime").description = "Updates the sublime plugin's tsserver";
469459

470-
const buildImportDefinitelyTypedTests = () => buildProject("scripts/importDefinitelyTypedTests");
471-
const cleanImportDefinitelyTypedTests = () => cleanProject("scripts/importDefinitelyTypedTests");
472-
cleanTasks.push(cleanImportDefinitelyTypedTests);
473-
474460
// TODO(rbuckton): Should the path to DefinitelyTyped be configurable via an environment variable?
475-
const importDefinitelyTypedTests = () => exec(process.execPath, ["scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js", "./", "../DefinitelyTyped"]);
476-
task("importDefinitelyTypedTests", series(buildImportDefinitelyTypedTests, importDefinitelyTypedTests));
461+
const importDefinitelyTypedTests = () => exec(process.execPath, ["scripts/importDefinitelyTypedTests.mjs", "./", "../DefinitelyTyped"]);
462+
task("importDefinitelyTypedTests", importDefinitelyTypedTests);
477463
task("importDefinitelyTypedTests").description = "Runs the importDefinitelyTypedTests script to copy DT's tests to the TS-internal RWC tests";
478464

479465
const buildReleaseTsc = () => buildProject("src/tsc/tsconfig.release.json");
@@ -501,7 +487,7 @@ const produceLKG = async () => {
501487
throw new Error("Cannot replace the LKG unless all built targets are present in directory 'built/local/'. The following files are missing:\n" + missingFiles.join("\n"));
502488
}
503489
const sizeBefore = getDirSize("lib");
504-
await exec(process.execPath, ["scripts/produceLKG.js"]);
490+
await exec(process.execPath, ["scripts/produceLKG.mjs"]);
505491
const sizeAfter = getDirSize("lib");
506492
if (sizeAfter > (sizeBefore * 1.10)) {
507493
throw new Error("The lib folder increased by 10% or more. This likely indicates a bug.");
@@ -515,24 +501,24 @@ task("LKG").flags = {
515501
};
516502
task("lkg", series("LKG"));
517503

518-
const generateSpec = () => exec("cscript", ["//nologo", "scripts/word2md.js", path.resolve("doc/TypeScript Language Specification - ARCHIVED.docx"), path.resolve("doc/spec-ARCHIVED.md")]);
519-
task("generate-spec", series(buildScripts, generateSpec));
504+
const generateSpec = () => exec("cscript", ["//nologo", "scripts/word2md.mjs", path.resolve("doc/TypeScript Language Specification - ARCHIVED.docx"), path.resolve("doc/spec-ARCHIVED.md")]);
505+
task("generate-spec", generateSpec);
520506
task("generate-spec").description = "Generates a Markdown version of the Language Specification";
521507

522508
task("clean", series(parallel(cleanTasks), cleanBuilt));
523509
task("clean").description = "Cleans build outputs";
524510

525-
const configureNightly = () => exec(process.execPath, ["scripts/configurePrerelease.js", "dev", "package.json", "src/compiler/corePublic.ts"]);
511+
const configureNightly = () => exec(process.execPath, ["scripts/configurePrerelease.mjs", "dev", "package.json", "src/compiler/corePublic.ts"]);
526512
task("configure-nightly", series(buildScripts, configureNightly));
527513
task("configure-nightly").description = "Runs scripts/configurePrerelease.ts to prepare a build for nightly publishing";
528514

529-
const configureInsiders = () => exec(process.execPath, ["scripts/configurePrerelease.js", "insiders", "package.json", "src/compiler/corePublic.ts"]);
530-
task("configure-insiders", series(buildScripts, configureInsiders));
531-
task("configure-insiders").description = "Runs scripts/configurePrerelease.ts to prepare a build for insiders publishing";
515+
const configureInsiders = () => exec(process.execPath, ["scripts/configurePrerelease.mjs", "insiders", "package.json", "src/compiler/corePublic.ts"]);
516+
task("configure-insiders", configureInsiders);
517+
task("configure-insiders").description = "Runs scripts/configurePrerelease.mjs to prepare a build for insiders publishing";
532518

533-
const configureExperimental = () => exec(process.execPath, ["scripts/configurePrerelease.js", "experimental", "package.json", "src/compiler/corePublic.ts"]);
534-
task("configure-experimental", series(buildScripts, configureExperimental));
535-
task("configure-experimental").description = "Runs scripts/configurePrerelease.ts to prepare a build for experimental publishing";
519+
const configureExperimental = () => exec(process.execPath, ["scripts/configurePrerelease.mjs", "experimental", "package.json", "src/compiler/corePublic.ts"]);
520+
task("configure-experimental", configureExperimental);
521+
task("configure-experimental").description = "Runs scripts/configurePrerelease.mjs to prepare a build for experimental publishing";
536522

537523
const publishNightly = () => exec("npm", ["publish", "--tag", "next"]);
538524
task("publish-nightly", series(task("clean"), task("LKG"), task("clean"), task("runtests-parallel"), publishNightly));

0 commit comments

Comments
 (0)