Skip to content

Commit

Permalink
[generated] Run dprint
Browse files Browse the repository at this point in the history
[git-generate]
test -f ./node_modules/.bin/dprint || npm ci
npx dprint fmt
  • Loading branch information
jakebailey committed Nov 16, 2022
1 parent d8e52d5 commit c1c700b
Show file tree
Hide file tree
Showing 439 changed files with 86,213 additions and 22,547 deletions.
74 changes: 64 additions & 10 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,53 @@

"@typescript-eslint/naming-convention": [
"error",
{ "selector": "typeLike", "format": ["PascalCase"], "filter": { "regex": "^(__String|[A-Za-z]+_[A-Za-z]+)$", "match": false } },
{ "selector": "interface", "format": ["PascalCase"], "custom": { "regex": "^I[A-Z]", "match": false }, "filter": { "regex": "^I(Arguments|TextWriter|O([A-Z][a-z]+[A-Za-z]*)?)$", "match": false } },
{ "selector": "variable", "format": ["camelCase", "PascalCase", "UPPER_CASE"], "leadingUnderscore": "allow", "filter": { "regex": "^(_{1,2}filename|_{1,2}dirname|_+|[A-Za-z]+_[A-Za-z]+)$", "match": false } },
{ "selector": "function", "format": ["camelCase", "PascalCase"], "leadingUnderscore": "allow", "filter": { "regex": "^[A-Za-z]+_[A-Za-z]+$", "match": false } },
{ "selector": "parameter", "format": ["camelCase"], "leadingUnderscore": "allow", "filter": { "regex": "^(_+|[A-Za-z]+_[A-Z][a-z]+)$", "match": false } },
{ "selector": "method", "format": ["camelCase", "PascalCase"], "leadingUnderscore": "allow", "filter": { "regex": "^([0-9]+|[A-Za-z]+_[A-Za-z]+)$", "match": false } },
{ "selector": "memberLike", "format": ["camelCase"], "leadingUnderscore": "allow", "filter": { "regex": "^([0-9]+|[A-Za-z]+_[A-Za-z]+)$", "match": false } },
{ "selector": "enumMember", "format": ["camelCase", "PascalCase"], "leadingUnderscore": "allow", "filter": { "regex": "^[A-Za-z]+_[A-Za-z]+$", "match": false } },
{
"selector": "typeLike",
"format": ["PascalCase"],
"filter": { "regex": "^(__String|[A-Za-z]+_[A-Za-z]+)$", "match": false }
},
{
"selector": "interface",
"format": ["PascalCase"],
"custom": { "regex": "^I[A-Z]", "match": false },
"filter": { "regex": "^I(Arguments|TextWriter|O([A-Z][a-z]+[A-Za-z]*)?)$", "match": false }
},
{
"selector": "variable",
"format": ["camelCase", "PascalCase", "UPPER_CASE"],
"leadingUnderscore": "allow",
"filter": { "regex": "^(_{1,2}filename|_{1,2}dirname|_+|[A-Za-z]+_[A-Za-z]+)$", "match": false }
},
{
"selector": "function",
"format": ["camelCase", "PascalCase"],
"leadingUnderscore": "allow",
"filter": { "regex": "^[A-Za-z]+_[A-Za-z]+$", "match": false }
},
{
"selector": "parameter",
"format": ["camelCase"],
"leadingUnderscore": "allow",
"filter": { "regex": "^(_+|[A-Za-z]+_[A-Z][a-z]+)$", "match": false }
},
{
"selector": "method",
"format": ["camelCase", "PascalCase"],
"leadingUnderscore": "allow",
"filter": { "regex": "^([0-9]+|[A-Za-z]+_[A-Za-z]+)$", "match": false }
},
{
"selector": "memberLike",
"format": ["camelCase"],
"leadingUnderscore": "allow",
"filter": { "regex": "^([0-9]+|[A-Za-z]+_[A-Za-z]+)$", "match": false }
},
{
"selector": "enumMember",
"format": ["camelCase", "PascalCase"],
"leadingUnderscore": "allow",
"filter": { "regex": "^[A-Za-z]+_[A-Za-z]+$", "match": false }
},
{ "selector": "property", "format": null }
],

Expand Down Expand Up @@ -87,7 +126,15 @@
"no-new-func": "error",
"no-new-wrappers": "error",
"no-return-await": "error",
"no-restricted-globals": ["error", { "name": "setTimeout" }, { "name": "clearTimeout" }, { "name": "setInterval" }, { "name": "clearInterval" }, { "name": "setImmediate" }, { "name": "clearImmediate" }],
"no-restricted-globals": [
"error",
{ "name": "setTimeout" },
{ "name": "clearTimeout" },
{ "name": "setInterval" },
{ "name": "clearInterval" },
{ "name": "setImmediate" },
{ "name": "clearImmediate" }
],
"no-sparse-arrays": "error",
"no-template-curly-in-string": "error",
"no-throw-literal": "error",
Expand Down Expand Up @@ -121,7 +168,14 @@
"files": ["*.mjs", "*.mts"],
"rules": {
// These globals don't exist outside of CJS files.
"no-restricted-globals": ["error", { "name": "__filename" }, { "name": "__dirname" }, { "name": "require" }, { "name": "module" }, { "name": "exports" }]
"no-restricted-globals": [
"error",
{ "name": "__filename" },
{ "name": "__dirname" },
{ "name": "require" },
{ "name": "module" },
{ "name": "exports" }
]
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"[typescript][javascript][json][jsonc]": {
// "editor.formatOnSave": true,
"editor.defaultFormatter": "dprint.dprint"
}
},

// To ignore commits listed in .git-blame-ignore-revs in GitLens:
// "gitlens.advanced.blame.customArguments": [
Expand Down
132 changes: 111 additions & 21 deletions Herebyfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,24 @@ import { task } from "hereby";
import _glob from "glob";
import util from "util";
import chalk from "chalk";
import { exec, readJson, getDiffTool, getDirSize, memoize, needsUpdate, Debouncer, Deferred } from "./scripts/build/utils.mjs";
import { runConsoleTests, refBaseline, localBaseline, refRwcBaseline, localRwcBaseline, cleanTestDirs } from "./scripts/build/tests.mjs";
import {
exec,
readJson,
getDiffTool,
getDirSize,
memoize,
needsUpdate,
Debouncer,
Deferred,
} from "./scripts/build/utils.mjs";
import {
runConsoleTests,
refBaseline,
localBaseline,
refRwcBaseline,
localRwcBaseline,
cleanTestDirs,
} from "./scripts/build/tests.mjs";
import { buildProject as realBuildProject, cleanProject, watchProject } from "./scripts/build/projects.mjs";
import { localizationDirectories } from "./scripts/build/localization.mjs";
import cmdLineOptions from "./scripts/build/options.mjs";
Expand Down Expand Up @@ -40,7 +56,10 @@ const buildProjectWithEmit = async (...args) => {

if (currentlyBuilding === 0) {
oldTsconfigBase = fs.readFileSync(tsconfigBasePath, "utf-8");
fs.writeFileSync(tsconfigBasePath, oldTsconfigBase.replace(`"emitDeclarationOnly": true,`, `"emitDeclarationOnly": false, // DO NOT COMMIT`));
fs.writeFileSync(
tsconfigBasePath,
oldTsconfigBase.replace(`"emitDeclarationOnly": true,`, `"emitDeclarationOnly": false, // DO NOT COMMIT`),
);
}

currentlyBuilding++;
Expand Down Expand Up @@ -138,7 +157,12 @@ const localize = task({
dependencies: [generateDiagnostics],
run: async () => {
if (needsUpdate(diagnosticMessagesGeneratedJson, generatedLCGFile)) {
await exec(process.execPath, ["scripts/generateLocalizedDiagnosticMessages.mjs", "src/loc/lcl", "built/local", diagnosticMessagesGeneratedJson], { ignoreExitCode: true });
await exec(process.execPath, [
"scripts/generateLocalizedDiagnosticMessages.mjs",
"src/loc/lcl",
"built/local",
diagnosticMessagesGeneratedJson,
], { ignoreExitCode: true });
}
},
});
Expand Down Expand Up @@ -224,7 +248,9 @@ function createBundler(entrypoint, outfile, taskOptions = {}) {
//
// See: https://github.com/evanw/esbuild/issues/1958
return {
errors: [{ text: 'Attempted to bundle from node_modules; ensure "external" is set correctly.' }],
errors: [{
text: 'Attempted to bundle from node_modules; ensure "external" is set correctly.',
}],
};
});
},
Expand Down Expand Up @@ -266,7 +292,8 @@ function createBundler(entrypoint, outfile, taskOptions = {}) {

return {
build: async () => esbuild.build(await getOptions()),
watch: async () => esbuild.build({ ...await getOptions(), watch: taskOptions.watchMode ?? true, logLevel: "info" }),
watch: async () =>
esbuild.build({ ...await getOptions(), watch: taskOptions.watchMode ?? true, logLevel: "info" }),
};
}

Expand Down Expand Up @@ -317,7 +344,10 @@ function entrypointBuildTask(options) {
const outDir = path.dirname(options.output);
await fs.promises.mkdir(outDir, { recursive: true });
const moduleSpecifier = path.relative(outDir, options.builtEntrypoint);
await fs.promises.writeFile(options.output, `module.exports = require("./${moduleSpecifier.replace(/[\\/]/g, "/")}")`);
await fs.promises.writeFile(
options.output,
`module.exports = require("./${moduleSpecifier.replace(/[\\/]/g, "/")}")`,
);
},
});

Expand All @@ -330,13 +360,19 @@ function entrypointBuildTask(options) {
const watch = task({
name: `watch-${options.name}`,
hiddenFromTaskList: true, // This is best effort.
dependencies: (options.buildDeps ?? []).concat(options.mainDeps ?? []).concat(cmdLineOptions.bundle ? [] : [shim]),
dependencies: (options.buildDeps ?? []).concat(options.mainDeps ?? []).concat(
cmdLineOptions.bundle ? [] : [shim],
),
run: () => {
// These watch functions return promises that resolve once watch mode has started,
// allowing them to operate as regular tasks, while creating unresolved promises
// in the background that keep the process running after all tasks have exited.
if (!printedWatchWarning) {
console.error(chalk.yellowBright("Warning: watch mode is incomplete and may not work as expected. Use at your own risk."));
console.error(
chalk.yellowBright(
"Warning: watch mode is incomplete and may not work as expected. Use at your own risk.",
),
);
printedWatchWarning = true;
}

Expand Down Expand Up @@ -380,7 +416,12 @@ export const dtsServices = task({
description: "Bundles typescript.d.ts",
dependencies: [buildServices],
run: async () => {
if (needsUpdate("./built/local/typescript/tsconfig.tsbuildinfo", ["./built/local/typescript.d.ts", "./built/local/typescript.internal.d.ts"])) {
if (
needsUpdate("./built/local/typescript/tsconfig.tsbuildinfo", [
"./built/local/typescript.d.ts",
"./built/local/typescript.internal.d.ts",
])
) {
await runDtsBundler("./built/local/typescript/typescript.d.ts", "./built/local/typescript.d.ts");
}
},
Expand Down Expand Up @@ -439,8 +480,16 @@ export const dtsLssl = task({
description: "Bundles tsserverlibrary.d.ts",
dependencies: [buildLssl],
run: async () => {
if (needsUpdate("./built/local/tsserverlibrary/tsconfig.tsbuildinfo", ["./built/local/tsserverlibrary.d.ts", "./built/local/tsserverlibrary.internal.d.ts"])) {
await runDtsBundler("./built/local/tsserverlibrary/tsserverlibrary.d.ts", "./built/local/tsserverlibrary.d.ts");
if (
needsUpdate("./built/local/tsserverlibrary/tsconfig.tsbuildinfo", [
"./built/local/tsserverlibrary.d.ts",
"./built/local/tsserverlibrary.internal.d.ts",
])
) {
await runDtsBundler(
"./built/local/tsserverlibrary/tsserverlibrary.d.ts",
"./built/local/tsserverlibrary.d.ts",
);
}
},
});
Expand Down Expand Up @@ -573,7 +622,13 @@ export const watchOtherOutputs = task({
name: "watch-other-outputs",
description: "Builds miscelaneous scripts and documents distributed with the LKG",
hiddenFromTaskList: true,
dependencies: [watchCancellationToken, watchTypingsInstaller, watchWatchGuard, generateTypesMap, copyBuiltLocalDiagnosticMessages],
dependencies: [
watchCancellationToken,
watchTypingsInstaller,
watchWatchGuard,
generateTypesMap,
copyBuiltLocalDiagnosticMessages,
],
});

const buildLocal = task({
Expand All @@ -584,7 +639,9 @@ const buildLocal = task({
export const local = task({
name: "local",
description: "Builds the full compiler and services",
dependencies: [localize, tsc, tsserver, services, lssl, otherOutputs, dts].concat(cmdLineOptions.typecheck ? [buildLocal] : []),
dependencies: [localize, tsc, tsserver, services, lssl, otherOutputs, dts].concat(
cmdLineOptions.typecheck ? [buildLocal] : [],
),
});
export default local;

Expand Down Expand Up @@ -656,7 +713,10 @@ export const runTestsAndWatch = task({
if (!token.signaled) {
running = true;
try {
await runConsoleTests(testRunner, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, { token, watching: true });
await runConsoleTests(testRunner, "mocha-fivemat-progress-reporter", /*runInParallel*/ false, {
token,
watching: true,
});
}
catch {
// ignore
Expand Down Expand Up @@ -815,7 +875,10 @@ export const updateSublime = task({
dependencies: [tsserver],
run: async () => {
for (const file of ["built/local/tsserver.js", "built/local/tsserver.js.map"]) {
await fs.promises.copyFile(file, path.resolve("../TypeScript-Sublime-Plugin/tsserver/", path.basename(file)));
await fs.promises.copyFile(
file,
path.resolve("../TypeScript-Sublime-Plugin/tsserver/", path.basename(file)),
);
}
},
});
Expand Down Expand Up @@ -851,7 +914,10 @@ export const produceLKG = task({
.concat(localizationTargets)
.filter(f => !fs.existsSync(f));
if (missingFiles.length > 0) {
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"));
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"),
);
}
const sizeBefore = getDirSize("lib");
await exec(process.execPath, ["scripts/produceLKG.mjs"]);
Expand All @@ -872,7 +938,13 @@ export const generateSpec = task({
name: "generate-spec",
description: "Generates a Markdown version of the Language Specification",
hiddenFromTaskList: true,
run: () => exec("cscript", ["//nologo", "scripts/word2md.mjs", path.resolve("doc/TypeScript Language Specification - ARCHIVED.docx"), path.resolve("doc/spec-ARCHIVED.md")]),
run: () =>
exec("cscript", [
"//nologo",
"scripts/word2md.mjs",
path.resolve("doc/TypeScript Language Specification - ARCHIVED.docx"),
path.resolve("doc/spec-ARCHIVED.md"),
]),
});

export const cleanBuilt = task({
Expand All @@ -890,19 +962,37 @@ export const clean = task({
export const configureNightly = task({
name: "configure-nightly",
description: "Runs scripts/configurePrerelease.mjs to prepare a build for nightly publishing",
run: () => exec(process.execPath, ["scripts/configurePrerelease.mjs", "dev", "package.json", "src/compiler/corePublic.ts"]),
run: () =>
exec(process.execPath, [
"scripts/configurePrerelease.mjs",
"dev",
"package.json",
"src/compiler/corePublic.ts",
]),
});

export const configureInsiders = task({
name: "configure-insiders",
description: "Runs scripts/configurePrerelease.mjs to prepare a build for insiders publishing",
run: () => exec(process.execPath, ["scripts/configurePrerelease.mjs", "insiders", "package.json", "src/compiler/corePublic.ts"]),
run: () =>
exec(process.execPath, [
"scripts/configurePrerelease.mjs",
"insiders",
"package.json",
"src/compiler/corePublic.ts",
]),
});

export const configureExperimental = task({
name: "configure-experimental",
description: "Runs scripts/configurePrerelease.mjs to prepare a build for experimental publishing",
run: () => exec(process.execPath, ["scripts/configurePrerelease.mjs", "experimental", "package.json", "src/compiler/corePublic.ts"]),
run: () =>
exec(process.execPath, [
"scripts/configurePrerelease.mjs",
"experimental",
"package.json",
"src/compiler/corePublic.ts",
]),
});

export const help = task({
Expand Down
16 changes: 15 additions & 1 deletion scripts/build/localization.mjs
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
export const localizationDirectories = ["cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-br", "ru", "tr", "zh-cn", "zh-tw"].map(f => f.toLowerCase());
export const localizationDirectories = [
"cs",
"de",
"es",
"fr",
"it",
"ja",
"ko",
"pl",
"pt-br",
"ru",
"tr",
"zh-cn",
"zh-tw",
].map(f => f.toLowerCase());
Loading

0 comments on commit c1c700b

Please sign in to comment.