mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:19:30 -06:00
Upgrade typescript-eslint version (#39242)
* Upgrade typescript-eslint version * Update TS version used by typescript-eslint
This commit is contained in:
parent
a3ee09ddc9
commit
cc7cb9eadb
@ -18,11 +18,20 @@
|
||||
"@typescript-eslint/array-type": "error",
|
||||
|
||||
"camelcase": "off",
|
||||
"@typescript-eslint/camelcase": ["error", { "properties": "never", "allow": ["^[A-Za-z][a-zA-Za-z]+_[A-Za-z]+$"] }],
|
||||
"@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": "^[A-Za-z]+_[A-Za-z]+$", "match": false } },
|
||||
{ "selector": "memberLike", "format": ["camelCase"], "leadingUnderscore": "allow", "filter": { "regex": "^[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 }
|
||||
],
|
||||
|
||||
"@typescript-eslint/class-name-casing": "error",
|
||||
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
|
||||
"@typescript-eslint/interface-name-prefix": "error",
|
||||
"@typescript-eslint/no-inferrable-types": "error",
|
||||
"@typescript-eslint/no-misused-new": "error",
|
||||
"@typescript-eslint/no-this-alias": "error",
|
||||
|
||||
@ -54,9 +54,9 @@
|
||||
"@types/through2": "latest",
|
||||
"@types/travis-fold": "latest",
|
||||
"@types/xml2js": "^0.4.0",
|
||||
"@typescript-eslint/eslint-plugin": "2.27.0",
|
||||
"@typescript-eslint/experimental-utils": "2.27.0",
|
||||
"@typescript-eslint/parser": "2.27.0",
|
||||
"@typescript-eslint/eslint-plugin": "^3.4.0",
|
||||
"@typescript-eslint/experimental-utils": "^3.4.0",
|
||||
"@typescript-eslint/parser": "^3.4.0",
|
||||
"async": "latest",
|
||||
"azure-devops-node-api": "^10.1.0",
|
||||
"browser-resolve": "^1.11.2",
|
||||
@ -97,7 +97,7 @@
|
||||
"source-map-support": "latest",
|
||||
"through2": "latest",
|
||||
"travis-fold": "latest",
|
||||
"typescript": "^3.9.3",
|
||||
"typescript": "^4.0.0-dev.20200624",
|
||||
"vinyl": "latest",
|
||||
"vinyl-sourcemaps-apply": "latest",
|
||||
"xml2js": "^0.4.19"
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
namespace Harness {
|
||||
// eslint-disable-next-line @typescript-eslint/interface-name-prefix
|
||||
export interface IO {
|
||||
newLine(): string;
|
||||
getCurrentDirectory(): string;
|
||||
|
||||
@ -5,7 +5,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
// for backwards-compatibility
|
||||
// eslint-disable-next-line @typescript-eslint/interface-name-prefix
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
export interface ITypingsInstaller {
|
||||
isKnownTypesPackageName(name: string): boolean;
|
||||
installPackage(options: InstallPackageOptionsWithProject): Promise<ApplyCodeActionCommandResult>;
|
||||
|
||||
@ -116,7 +116,7 @@ namespace ts {
|
||||
* snapshot is observably immutable. i.e. the same calls with the same parameters will return
|
||||
* the same values.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/interface-name-prefix
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
export interface IScriptSnapshot {
|
||||
/** Gets a portion of the script snapshot specified by [start, end). */
|
||||
getText(start: number, end: number): string;
|
||||
|
||||
@ -1113,7 +1113,7 @@ import b = require("./moduleB");
|
||||
|
||||
function test(hasDirectoryExists: boolean) {
|
||||
const file1: File = { name: "/root/folder1/file1.ts" };
|
||||
const file1_1: File = { name: "/root/folder1/file1_1/index.d.ts" }; // eslint-disable-line @typescript-eslint/camelcase
|
||||
const file1_1: File = { name: "/root/folder1/file1_1/index.d.ts" }; // eslint-disable-line @typescript-eslint/naming-convention
|
||||
const file2: File = { name: "/root/generated/folder1/file2.ts" };
|
||||
const file3: File = { name: "/root/generated/folder2/file3.ts" };
|
||||
const host = createModuleResolutionHost(hasDirectoryExists, file1, file1_1, file2, file3);
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
namespace ts {
|
||||
describe("unittests:: tsbuild:: outFile:: on amd modules with --out", () => {
|
||||
let outFileFs: vfs.FileSystem;
|
||||
const enum project { lib, app }
|
||||
const enum Project { lib, app }
|
||||
function relName(path: string) { return path.slice(1); }
|
||||
type Sources = [string, readonly string[]];
|
||||
const enum source { config, ts }
|
||||
const enum Source { config, ts }
|
||||
const sources: [Sources, Sources] = [
|
||||
[
|
||||
"/src/lib/tsconfig.json",
|
||||
@ -51,7 +51,7 @@ namespace ts {
|
||||
incrementalScenarios: [
|
||||
{
|
||||
buildKind: BuildKind.IncrementalDtsUnchanged,
|
||||
modifyFs: fs => appendText(fs, relName(sources[project.lib][source.ts][1]), "console.log(x);")
|
||||
modifyFs: fs => appendText(fs, relName(sources[Project.lib][Source.ts][1]), "console.log(x);")
|
||||
},
|
||||
...(modifyAgainFs ? [{
|
||||
buildKind: BuildKind.IncrementalHeadersChange,
|
||||
@ -71,15 +71,15 @@ namespace ts {
|
||||
verifyOutFileScenario({
|
||||
subScenario: "multiple prologues in all projects",
|
||||
modifyFs: fs => {
|
||||
enableStrict(fs, sources[project.lib][source.config]);
|
||||
addTestPrologue(fs, sources[project.lib][source.ts][0], `"myPrologue"`);
|
||||
addTestPrologue(fs, sources[project.lib][source.ts][2], `"myPrologueFile"`);
|
||||
addTestPrologue(fs, sources[project.lib][source.ts][3], `"myPrologue3"`);
|
||||
enableStrict(fs, sources[project.app][source.config]);
|
||||
addTestPrologue(fs, sources[project.app][source.ts][0], `"myPrologue"`);
|
||||
addTestPrologue(fs, sources[project.app][source.ts][1], `"myPrologue2";`);
|
||||
enableStrict(fs, sources[Project.lib][Source.config]);
|
||||
addTestPrologue(fs, sources[Project.lib][Source.ts][0], `"myPrologue"`);
|
||||
addTestPrologue(fs, sources[Project.lib][Source.ts][2], `"myPrologueFile"`);
|
||||
addTestPrologue(fs, sources[Project.lib][Source.ts][3], `"myPrologue3"`);
|
||||
enableStrict(fs, sources[Project.app][Source.config]);
|
||||
addTestPrologue(fs, sources[Project.app][Source.ts][0], `"myPrologue"`);
|
||||
addTestPrologue(fs, sources[Project.app][Source.ts][1], `"myPrologue2";`);
|
||||
},
|
||||
modifyAgainFs: fs => addTestPrologue(fs, relName(sources[project.lib][source.ts][1]), `"myPrologue5"`)
|
||||
modifyAgainFs: fs => addTestPrologue(fs, relName(sources[Project.lib][Source.ts][1]), `"myPrologue5"`)
|
||||
});
|
||||
});
|
||||
|
||||
@ -125,10 +125,10 @@ namespace ts {
|
||||
describe("stripInternal", () => {
|
||||
function stripInternalScenario(fs: vfs.FileSystem) {
|
||||
const internal = "/*@internal*/";
|
||||
replaceText(fs, sources[project.app][source.config], `"composite": true,`, `"composite": true,
|
||||
replaceText(fs, sources[Project.app][Source.config], `"composite": true,`, `"composite": true,
|
||||
"stripInternal": true,`);
|
||||
replaceText(fs, sources[project.lib][source.ts][0], "const", `${internal} const`);
|
||||
appendText(fs, sources[project.lib][source.ts][1], `
|
||||
replaceText(fs, sources[Project.lib][Source.ts][0], "const", `${internal} const`);
|
||||
appendText(fs, sources[Project.lib][Source.ts][1], `
|
||||
export class normalC {
|
||||
${internal} constructor() { }
|
||||
${internal} prop: string;
|
||||
@ -160,16 +160,16 @@ ${internal} export enum internalEnum { a, b, c }`);
|
||||
verifyOutFileScenario({
|
||||
subScenario: "stripInternal",
|
||||
modifyFs: stripInternalScenario,
|
||||
modifyAgainFs: fs => replaceText(fs, sources[project.lib][source.ts][1], `export const`, `/*@internal*/ export const`),
|
||||
modifyAgainFs: fs => replaceText(fs, sources[Project.lib][Source.ts][1], `export const`, `/*@internal*/ export const`),
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the module resolution finds original source file", () => {
|
||||
function modifyFs(fs: vfs.FileSystem) {
|
||||
// Make lib to output to parent dir
|
||||
replaceText(fs, sources[project.lib][source.config], `"outFile": "module.js"`, `"outFile": "../module.js", "rootDir": "../"`);
|
||||
replaceText(fs, sources[Project.lib][Source.config], `"outFile": "module.js"`, `"outFile": "../module.js", "rootDir": "../"`);
|
||||
// Change reference to file1 module to resolve to lib/file1
|
||||
replaceText(fs, sources[project.app][source.ts][0], "file1", "lib/file1");
|
||||
replaceText(fs, sources[Project.app][Source.ts][0], "file1", "lib/file1");
|
||||
}
|
||||
|
||||
verifyTsc({
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
namespace ts {
|
||||
describe("unittests:: tsbuild:: outFile::", () => {
|
||||
let outFileFs: vfs.FileSystem;
|
||||
const enum ext { js, jsmap, dts, dtsmap, buildinfo }
|
||||
const enum project { first, second, third }
|
||||
const enum Ext { js, jsmap, dts, dtsmap, buildinfo }
|
||||
const enum Project { first, second, third }
|
||||
type OutputFile = [string, string, string, string, string];
|
||||
function relName(path: string) { return path.slice(1); }
|
||||
const outputFiles: [OutputFile, OutputFile, OutputFile] = [
|
||||
@ -30,8 +30,8 @@ namespace ts {
|
||||
];
|
||||
const relOutputFiles = outputFiles.map(v => v.map(relName)) as [OutputFile, OutputFile, OutputFile];
|
||||
type Sources = [string, readonly string[]];
|
||||
const enum source { config, ts }
|
||||
const enum part { one, two, three }
|
||||
const enum Source { config, ts }
|
||||
const enum Part { one, two, three }
|
||||
const sources: [Sources, Sources, Sources] = [
|
||||
[
|
||||
"/src/first/tsconfig.json",
|
||||
@ -57,13 +57,13 @@ namespace ts {
|
||||
];
|
||||
const relSources = sources.map(([config, sources]) => [relName(config), sources.map(relName)]) as any as [Sources, Sources, Sources];
|
||||
let initialExpectedDiagnostics: readonly fakes.ExpectedDiagnostic[] = [
|
||||
getExpectedDiagnosticForProjectsInBuild(relSources[project.first][source.config], relSources[project.second][source.config], relSources[project.third][source.config]),
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relSources[project.first][source.config], relOutputFiles[project.first][ext.js]],
|
||||
[Diagnostics.Building_project_0, sources[project.first][source.config]],
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relSources[project.second][source.config], relOutputFiles[project.second][ext.js]],
|
||||
[Diagnostics.Building_project_0, sources[project.second][source.config]],
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relSources[project.third][source.config], relOutputFiles[project.third][ext.js]],
|
||||
[Diagnostics.Building_project_0, sources[project.third][source.config]]
|
||||
getExpectedDiagnosticForProjectsInBuild(relSources[Project.first][Source.config], relSources[Project.second][Source.config], relSources[Project.third][Source.config]),
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relSources[Project.first][Source.config], relOutputFiles[Project.first][Ext.js]],
|
||||
[Diagnostics.Building_project_0, sources[Project.first][Source.config]],
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relSources[Project.second][Source.config], relOutputFiles[Project.second][Ext.js]],
|
||||
[Diagnostics.Building_project_0, sources[Project.second][Source.config]],
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, relSources[Project.third][Source.config], relOutputFiles[Project.third][Ext.js]],
|
||||
[Diagnostics.Building_project_0, sources[Project.third][Source.config]]
|
||||
];
|
||||
before(() => {
|
||||
outFileFs = loadProjectFromDisk("tests/projects/outfile-concat");
|
||||
@ -98,13 +98,13 @@ namespace ts {
|
||||
if (!ignoreDtsChanged) {
|
||||
incrementalScenarios.push({
|
||||
buildKind: BuildKind.IncrementalDtsChange,
|
||||
modifyFs: fs => replaceText(fs, relSources[project.first][source.ts][part.one], "Hello", "Hola"),
|
||||
modifyFs: fs => replaceText(fs, relSources[Project.first][Source.ts][Part.one], "Hello", "Hola"),
|
||||
});
|
||||
}
|
||||
if (!ignoreDtsUnchanged) {
|
||||
incrementalScenarios.push({
|
||||
buildKind: BuildKind.IncrementalDtsUnchanged,
|
||||
modifyFs: fs => appendText(fs, relSources[project.first][source.ts][part.one], "console.log(s);"),
|
||||
modifyFs: fs => appendText(fs, relSources[Project.first][Source.ts][Part.one], "console.log(s);"),
|
||||
});
|
||||
}
|
||||
if (modifyAgainFs) {
|
||||
@ -136,7 +136,7 @@ namespace ts {
|
||||
// Verify baseline with build info + dts unChanged
|
||||
verifyOutFileScenario({
|
||||
subScenario: "when final project is not composite but uses project references",
|
||||
modifyFs: fs => replaceText(fs, sources[project.third][source.config], `"composite": true,`, ""),
|
||||
modifyFs: fs => replaceText(fs, sources[Project.third][Source.config], `"composite": true,`, ""),
|
||||
ignoreDtsChanged: true,
|
||||
baselineOnly: true
|
||||
});
|
||||
@ -144,7 +144,7 @@ namespace ts {
|
||||
// Verify baseline with build info
|
||||
verifyOutFileScenario({
|
||||
subScenario: "when final project is not composite but incremental",
|
||||
modifyFs: fs => replaceText(fs, sources[project.third][source.config], `"composite": true,`, `"incremental": true,`),
|
||||
modifyFs: fs => replaceText(fs, sources[Project.third][Source.config], `"composite": true,`, `"incremental": true,`),
|
||||
ignoreDtsChanged: true,
|
||||
ignoreDtsUnchanged: true,
|
||||
baselineOnly: true
|
||||
@ -153,7 +153,7 @@ namespace ts {
|
||||
// Verify baseline with build info
|
||||
verifyOutFileScenario({
|
||||
subScenario: "when final project specifies tsBuildInfoFile",
|
||||
modifyFs: fs => replaceText(fs, sources[project.third][source.config], `"composite": true,`, `"composite": true,
|
||||
modifyFs: fs => replaceText(fs, sources[Project.third][Source.config], `"composite": true,`, `"composite": true,
|
||||
"tsBuildInfoFile": "./thirdjs/output/third.tsbuildinfo",`),
|
||||
ignoreDtsChanged: true,
|
||||
ignoreDtsUnchanged: true,
|
||||
@ -182,7 +182,7 @@ namespace ts {
|
||||
subScenario: "verify buildInfo absence results in new build",
|
||||
fs: getOutFileFsAfterBuild,
|
||||
commandLineArgs: ["--b", "/src/third", "--verbose"],
|
||||
modifyFs: fs => fs.unlinkSync(outputFiles[project.first][ext.buildinfo]),
|
||||
modifyFs: fs => fs.unlinkSync(outputFiles[Project.first][Ext.buildinfo]),
|
||||
});
|
||||
|
||||
verifyTsc({
|
||||
@ -190,7 +190,7 @@ namespace ts {
|
||||
subScenario: "tsbuildinfo is not generated when incremental is set to false",
|
||||
fs: () => outFileFs,
|
||||
commandLineArgs: ["--b", "/src/third", "--verbose"],
|
||||
modifyFs: fs => replaceText(fs, sources[project.third][source.config], `"composite": true,`, ""),
|
||||
modifyFs: fs => replaceText(fs, sources[Project.third][Source.config], `"composite": true,`, ""),
|
||||
});
|
||||
|
||||
it("rebuilds completely when version in tsbuildinfo doesnt match ts version", () => {
|
||||
@ -206,20 +206,20 @@ namespace ts {
|
||||
tick();
|
||||
builder.build();
|
||||
host.assertDiagnosticMessages(
|
||||
getExpectedDiagnosticForProjectsInBuild(relSources[project.first][source.config], relSources[project.second][source.config], relSources[project.third][source.config]),
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relSources[project.first][source.config], fakes.version, version],
|
||||
[Diagnostics.Building_project_0, sources[project.first][source.config]],
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relSources[project.second][source.config], fakes.version, version],
|
||||
[Diagnostics.Building_project_0, sources[project.second][source.config]],
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relSources[project.third][source.config], fakes.version, version],
|
||||
[Diagnostics.Building_project_0, sources[project.third][source.config]],
|
||||
getExpectedDiagnosticForProjectsInBuild(relSources[Project.first][Source.config], relSources[Project.second][Source.config], relSources[Project.third][Source.config]),
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relSources[Project.first][Source.config], fakes.version, version],
|
||||
[Diagnostics.Building_project_0, sources[Project.first][Source.config]],
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relSources[Project.second][Source.config], fakes.version, version],
|
||||
[Diagnostics.Building_project_0, sources[Project.second][Source.config]],
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relSources[Project.third][Source.config], fakes.version, version],
|
||||
[Diagnostics.Building_project_0, sources[Project.third][Source.config]],
|
||||
);
|
||||
});
|
||||
|
||||
it("rebuilds completely when command line incremental flag changes between non dts changes", () => {
|
||||
const { fs, tick } = getFsWithTime(outFileFs);
|
||||
// Make non composite third project
|
||||
replaceText(fs, sources[project.third][source.config], `"composite": true,`, "");
|
||||
replaceText(fs, sources[Project.third][Source.config], `"composite": true,`, "");
|
||||
|
||||
// Build with command line incremental
|
||||
const host = fakes.SolutionBuilderHost.create(fs);
|
||||
@ -230,31 +230,31 @@ namespace ts {
|
||||
tick();
|
||||
|
||||
// Make non incremental build with change in file that doesnt affect dts
|
||||
appendText(fs, relSources[project.first][source.ts][part.one], "console.log(s);");
|
||||
appendText(fs, relSources[Project.first][Source.ts][Part.one], "console.log(s);");
|
||||
builder = createSolutionBuilder(host, { verbose: true });
|
||||
builder.build();
|
||||
host.assertDiagnosticMessages(getExpectedDiagnosticForProjectsInBuild(relSources[project.first][source.config], relSources[project.second][source.config], relSources[project.third][source.config]),
|
||||
[Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[project.first][source.config], relOutputFiles[project.first][ext.js], relSources[project.first][source.ts][part.one]],
|
||||
[Diagnostics.Building_project_0, sources[project.first][source.config]],
|
||||
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relSources[project.second][source.config], relSources[project.second][source.ts][part.one], relOutputFiles[project.second][ext.js]],
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed, relSources[project.third][source.config], "src/first"],
|
||||
[Diagnostics.Building_project_0, sources[project.third][source.config]]
|
||||
host.assertDiagnosticMessages(getExpectedDiagnosticForProjectsInBuild(relSources[Project.first][Source.config], relSources[Project.second][Source.config], relSources[Project.third][Source.config]),
|
||||
[Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[Project.first][Source.config], relOutputFiles[Project.first][Ext.js], relSources[Project.first][Source.ts][Part.one]],
|
||||
[Diagnostics.Building_project_0, sources[Project.first][Source.config]],
|
||||
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relSources[Project.second][Source.config], relSources[Project.second][Source.ts][Part.one], relOutputFiles[Project.second][Ext.js]],
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed, relSources[Project.third][Source.config], "src/first"],
|
||||
[Diagnostics.Building_project_0, sources[Project.third][Source.config]]
|
||||
);
|
||||
host.clearDiagnostics();
|
||||
tick();
|
||||
|
||||
// Make incremental build with change in file that doesnt affect dts
|
||||
appendText(fs, relSources[project.first][source.ts][part.one], "console.log(s);");
|
||||
appendText(fs, relSources[Project.first][Source.ts][Part.one], "console.log(s);");
|
||||
builder = createSolutionBuilder(host, { verbose: true, incremental: true });
|
||||
builder.build();
|
||||
// Builds completely because tsbuildinfo is old.
|
||||
host.assertDiagnosticMessages(
|
||||
getExpectedDiagnosticForProjectsInBuild(relSources[project.first][source.config], relSources[project.second][source.config], relSources[project.third][source.config]),
|
||||
[Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[project.first][source.config], relOutputFiles[project.first][ext.js], relSources[project.first][source.ts][part.one]],
|
||||
[Diagnostics.Building_project_0, sources[project.first][source.config]],
|
||||
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relSources[project.second][source.config], relSources[project.second][source.ts][part.one], relOutputFiles[project.second][ext.js]],
|
||||
[Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[project.third][source.config], relOutputFiles[project.third][ext.buildinfo], "src/first"],
|
||||
[Diagnostics.Building_project_0, sources[project.third][source.config]]
|
||||
getExpectedDiagnosticForProjectsInBuild(relSources[Project.first][Source.config], relSources[Project.second][Source.config], relSources[Project.third][Source.config]),
|
||||
[Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[Project.first][Source.config], relOutputFiles[Project.first][Ext.js], relSources[Project.first][Source.ts][Part.one]],
|
||||
[Diagnostics.Building_project_0, sources[Project.first][Source.config]],
|
||||
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relSources[Project.second][Source.config], relSources[Project.second][Source.ts][Part.one], relOutputFiles[Project.second][Ext.js]],
|
||||
[Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[Project.third][Source.config], relOutputFiles[Project.third][Ext.buildinfo], "src/first"],
|
||||
[Diagnostics.Building_project_0, sources[Project.third][Source.config]]
|
||||
);
|
||||
host.clearDiagnostics();
|
||||
});
|
||||
@ -263,12 +263,12 @@ namespace ts {
|
||||
const fs = outFileFs.shadow();
|
||||
const host = fakes.SolutionBuilderHost.create(fs);
|
||||
const builder = createSolutionBuilder(host, { verbose: false });
|
||||
const result = builder.build(sources[project.second][source.config]);
|
||||
const result = builder.build(sources[Project.second][Source.config]);
|
||||
host.assertDiagnosticMessages(/*empty*/);
|
||||
// First and Third is not built
|
||||
verifyOutputsAbsent(fs, [...outputFiles[project.first], ...outputFiles[project.third]]);
|
||||
verifyOutputsAbsent(fs, [...outputFiles[Project.first], ...outputFiles[Project.third]]);
|
||||
// second is built
|
||||
verifyOutputsPresent(fs, outputFiles[project.second]);
|
||||
verifyOutputsPresent(fs, outputFiles[Project.second]);
|
||||
assert.equal(result, ExitStatus.Success);
|
||||
});
|
||||
|
||||
@ -277,12 +277,12 @@ namespace ts {
|
||||
const host = fakes.SolutionBuilderHost.create(fs);
|
||||
const builder = createSolutionBuilder(host, { verbose: false });
|
||||
builder.build();
|
||||
const result = builder.clean(sources[project.second][source.config]);
|
||||
const result = builder.clean(sources[Project.second][Source.config]);
|
||||
host.assertDiagnosticMessages(/*empty*/);
|
||||
// First and Third output for present
|
||||
verifyOutputsPresent(fs, [...outputFiles[project.first], ...outputFiles[project.third]]);
|
||||
verifyOutputsPresent(fs, [...outputFiles[Project.first], ...outputFiles[Project.third]]);
|
||||
// second is cleaned
|
||||
verifyOutputsAbsent(fs, outputFiles[project.second]);
|
||||
verifyOutputsAbsent(fs, outputFiles[Project.second]);
|
||||
assert.equal(result, ExitStatus.Success);
|
||||
});
|
||||
|
||||
@ -293,17 +293,17 @@ namespace ts {
|
||||
verifyOutFileScenario({
|
||||
subScenario: "strict in all projects",
|
||||
modifyFs: fs => {
|
||||
enableStrict(fs, sources[project.first][source.config]);
|
||||
enableStrict(fs, sources[project.second][source.config]);
|
||||
enableStrict(fs, sources[project.third][source.config]);
|
||||
enableStrict(fs, sources[Project.first][Source.config]);
|
||||
enableStrict(fs, sources[Project.second][Source.config]);
|
||||
enableStrict(fs, sources[Project.third][Source.config]);
|
||||
},
|
||||
modifyAgainFs: fs => addTestPrologue(fs, relSources[project.first][source.ts][part.one], `"myPrologue"`)
|
||||
modifyAgainFs: fs => addTestPrologue(fs, relSources[Project.first][Source.ts][Part.one], `"myPrologue"`)
|
||||
});
|
||||
|
||||
// Verify ignore dtsChanged
|
||||
verifyOutFileScenario({
|
||||
subScenario: "strict in one dependency",
|
||||
modifyFs: fs => enableStrict(fs, sources[project.second][source.config]),
|
||||
modifyFs: fs => enableStrict(fs, sources[Project.second][Source.config]),
|
||||
modifyAgainFs: fs => addTestPrologue(fs, "src/first/first_PART1.ts", `"myPrologue"`),
|
||||
ignoreDtsChanged: true,
|
||||
baselineOnly: true
|
||||
@ -313,28 +313,28 @@ namespace ts {
|
||||
verifyOutFileScenario({
|
||||
subScenario: "multiple prologues in all projects",
|
||||
modifyFs: fs => {
|
||||
enableStrict(fs, sources[project.first][source.config]);
|
||||
addTestPrologue(fs, sources[project.first][source.ts][part.one], `"myPrologue"`);
|
||||
enableStrict(fs, sources[project.second][source.config]);
|
||||
addTestPrologue(fs, sources[project.second][source.ts][part.one], `"myPrologue"`);
|
||||
addTestPrologue(fs, sources[project.second][source.ts][part.two], `"myPrologue2";`);
|
||||
enableStrict(fs, sources[project.third][source.config]);
|
||||
addTestPrologue(fs, sources[project.third][source.ts][part.one], `"myPrologue";`);
|
||||
addTestPrologue(fs, sources[project.third][source.ts][part.one], `"myPrologue3";`);
|
||||
enableStrict(fs, sources[Project.first][Source.config]);
|
||||
addTestPrologue(fs, sources[Project.first][Source.ts][Part.one], `"myPrologue"`);
|
||||
enableStrict(fs, sources[Project.second][Source.config]);
|
||||
addTestPrologue(fs, sources[Project.second][Source.ts][Part.one], `"myPrologue"`);
|
||||
addTestPrologue(fs, sources[Project.second][Source.ts][Part.two], `"myPrologue2";`);
|
||||
enableStrict(fs, sources[Project.third][Source.config]);
|
||||
addTestPrologue(fs, sources[Project.third][Source.ts][Part.one], `"myPrologue";`);
|
||||
addTestPrologue(fs, sources[Project.third][Source.ts][Part.one], `"myPrologue3";`);
|
||||
},
|
||||
modifyAgainFs: fs => addTestPrologue(fs, relSources[project.first][source.ts][part.one], `"myPrologue5"`)
|
||||
modifyAgainFs: fs => addTestPrologue(fs, relSources[Project.first][Source.ts][Part.one], `"myPrologue5"`)
|
||||
});
|
||||
|
||||
// Verify ignore dtsChanged
|
||||
verifyOutFileScenario({
|
||||
subScenario: "multiple prologues in different projects",
|
||||
modifyFs: fs => {
|
||||
enableStrict(fs, sources[project.first][source.config]);
|
||||
addTestPrologue(fs, sources[project.second][source.ts][part.one], `"myPrologue"`);
|
||||
addTestPrologue(fs, sources[project.second][source.ts][part.two], `"myPrologue2";`);
|
||||
enableStrict(fs, sources[project.third][source.config]);
|
||||
enableStrict(fs, sources[Project.first][Source.config]);
|
||||
addTestPrologue(fs, sources[Project.second][Source.ts][Part.one], `"myPrologue"`);
|
||||
addTestPrologue(fs, sources[Project.second][Source.ts][Part.two], `"myPrologue2";`);
|
||||
enableStrict(fs, sources[Project.third][Source.config]);
|
||||
},
|
||||
modifyAgainFs: fs => addTestPrologue(fs, sources[project.first][source.ts][part.one], `"myPrologue5"`),
|
||||
modifyAgainFs: fs => addTestPrologue(fs, sources[Project.first][Source.ts][Part.one], `"myPrologue5"`),
|
||||
ignoreDtsChanged: true,
|
||||
baselineOnly: true
|
||||
});
|
||||
@ -446,13 +446,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
function diableRemoveCommentsInAll(fs: vfs.FileSystem) {
|
||||
disableRemoveComments(fs, sources[project.first][source.config]);
|
||||
disableRemoveComments(fs, sources[project.second][source.config]);
|
||||
disableRemoveComments(fs, sources[project.third][source.config]);
|
||||
disableRemoveComments(fs, sources[Project.first][Source.config]);
|
||||
disableRemoveComments(fs, sources[Project.second][Source.config]);
|
||||
disableRemoveComments(fs, sources[Project.third][Source.config]);
|
||||
}
|
||||
|
||||
function stripInternalOfThird(fs: vfs.FileSystem) {
|
||||
replaceText(fs, sources[project.third][source.config], `"declaration": true,`, `"declaration": true,
|
||||
replaceText(fs, sources[Project.third][Source.config], `"declaration": true,`, `"declaration": true,
|
||||
"stripInternal": true,`);
|
||||
}
|
||||
|
||||
@ -462,8 +462,8 @@ namespace ts {
|
||||
diableRemoveCommentsInAll(fs);
|
||||
}
|
||||
stripInternalOfThird(fs);
|
||||
replaceText(fs, sources[project.first][source.ts][part.one], "interface", `${internal} interface`);
|
||||
appendText(fs, sources[project.second][source.ts][part.one], `
|
||||
replaceText(fs, sources[Project.first][Source.ts][Part.one], "interface", `${internal} interface`);
|
||||
appendText(fs, sources[Project.second][Source.ts][Part.one], `
|
||||
class normalC {
|
||||
${internal} constructor() { }
|
||||
${internal} prop: string;
|
||||
@ -495,14 +495,14 @@ ${internal} enum internalEnum { a, b, c }`);
|
||||
verifyOutFileScenario({
|
||||
subScenario: "stripInternal",
|
||||
modifyFs: stripInternalScenario,
|
||||
modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"),
|
||||
modifyAgainFs: fs => replaceText(fs, sources[Project.first][Source.ts][Part.one], `/*@internal*/ interface`, "interface"),
|
||||
});
|
||||
|
||||
// Verify ignore dtsChanged
|
||||
verifyOutFileScenario({
|
||||
subScenario: "stripInternal with comments emit enabled",
|
||||
modifyFs: fs => stripInternalScenario(fs, /*removeCommentsDisabled*/ true),
|
||||
modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"),
|
||||
modifyAgainFs: fs => replaceText(fs, sources[Project.first][Source.ts][Part.one], `/*@internal*/ interface`, "interface"),
|
||||
ignoreDtsChanged: true,
|
||||
baselineOnly: true
|
||||
});
|
||||
@ -511,7 +511,7 @@ ${internal} enum internalEnum { a, b, c }`);
|
||||
verifyOutFileScenario({
|
||||
subScenario: "stripInternal jsdoc style comment",
|
||||
modifyFs: fs => stripInternalScenario(fs, /*removeCommentsDisabled*/ false, /*jsDocStyle*/ true),
|
||||
modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/**@internal*/ interface`, "interface"),
|
||||
modifyAgainFs: fs => replaceText(fs, sources[Project.first][Source.ts][Part.one], `/**@internal*/ interface`, "interface"),
|
||||
ignoreDtsChanged: true,
|
||||
baselineOnly: true
|
||||
});
|
||||
@ -526,9 +526,9 @@ ${internal} enum internalEnum { a, b, c }`);
|
||||
|
||||
describe("with three levels of project dependency", () => {
|
||||
function makeOneTwoThreeDependOrder(fs: vfs.FileSystem) {
|
||||
replaceText(fs, sources[project.second][source.config], "[", `[
|
||||
replaceText(fs, sources[Project.second][Source.config], "[", `[
|
||||
{ "path": "../first", "prepend": true }`);
|
||||
replaceText(fs, sources[project.third][source.config], `{ "path": "../first", "prepend": true },`, "");
|
||||
replaceText(fs, sources[Project.third][Source.config], `{ "path": "../first", "prepend": true },`, "");
|
||||
}
|
||||
|
||||
function stripInternalWithDependentOrder(fs: vfs.FileSystem, removeCommentsDisabled?: boolean, jsDocStyle?: boolean) {
|
||||
@ -540,14 +540,14 @@ ${internal} enum internalEnum { a, b, c }`);
|
||||
verifyOutFileScenario({
|
||||
subScenario: "stripInternal when one-two-three are prepended in order",
|
||||
modifyFs: stripInternalWithDependentOrder,
|
||||
modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"),
|
||||
modifyAgainFs: fs => replaceText(fs, sources[Project.first][Source.ts][Part.one], `/*@internal*/ interface`, "interface"),
|
||||
});
|
||||
|
||||
// Verify ignore dtsChanged
|
||||
verifyOutFileScenario({
|
||||
subScenario: "stripInternal with comments emit enabled when one-two-three are prepended in order",
|
||||
modifyFs: fs => stripInternalWithDependentOrder(fs, /*removeCommentsDisabled*/ true),
|
||||
modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"),
|
||||
modifyAgainFs: fs => replaceText(fs, sources[Project.first][Source.ts][Part.one], `/*@internal*/ interface`, "interface"),
|
||||
ignoreDtsChanged: true,
|
||||
baselineOnly: true
|
||||
});
|
||||
@ -556,7 +556,7 @@ ${internal} enum internalEnum { a, b, c }`);
|
||||
verifyOutFileScenario({
|
||||
subScenario: "stripInternal jsdoc style comment when one-two-three are prepended in order",
|
||||
modifyFs: fs => stripInternalWithDependentOrder(fs, /*removeCommentsDisabled*/ false, /*jsDocStyle*/ true),
|
||||
modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/**@internal*/ interface`, "interface"),
|
||||
modifyAgainFs: fs => replaceText(fs, sources[Project.first][Source.ts][Part.one], `/**@internal*/ interface`, "interface"),
|
||||
ignoreDtsChanged: true,
|
||||
baselineOnly: true
|
||||
});
|
||||
@ -575,7 +575,7 @@ ${internal} enum internalEnum { a, b, c }`);
|
||||
subScenario: "stripInternal baseline when internal is inside another internal",
|
||||
modifyFs: fs => {
|
||||
stripInternalOfThird(fs);
|
||||
prependText(fs, sources[project.first][source.ts][part.one], `namespace ts {
|
||||
prependText(fs, sources[Project.first][Source.ts][Part.one], `namespace ts {
|
||||
/* @internal */
|
||||
/**
|
||||
* Subset of properties from SourceFile that are used in multiple utility functions
|
||||
@ -614,7 +614,7 @@ ${internal} enum internalEnum { a, b, c }`);
|
||||
subScenario: "stripInternal when few members of enum are internal",
|
||||
modifyFs: fs => {
|
||||
stripInternalOfThird(fs);
|
||||
prependText(fs, sources[project.first][source.ts][part.one], `enum TokenFlags {
|
||||
prependText(fs, sources[Project.first][Source.ts][Part.one], `enum TokenFlags {
|
||||
None = 0,
|
||||
/* @internal */
|
||||
PrecedingLineBreak = 1 << 0,
|
||||
@ -649,9 +649,9 @@ ${internal} enum internalEnum { a, b, c }`);
|
||||
ignoreDtsChanged: true,
|
||||
ignoreDtsUnchanged: true,
|
||||
modifyFs: fs => {
|
||||
fs.writeFileSync(sources[project.first][source.ts][part.one], "/* @internal */ const A = 1;");
|
||||
fs.writeFileSync(sources[project.third][source.ts][part.one], "const B = 2;");
|
||||
fs.writeFileSync(sources[project.first][source.config], JSON.stringify({
|
||||
fs.writeFileSync(sources[Project.first][Source.ts][Part.one], "/* @internal */ const A = 1;");
|
||||
fs.writeFileSync(sources[Project.third][Source.ts][Part.one], "const B = 2;");
|
||||
fs.writeFileSync(sources[Project.first][Source.config], JSON.stringify({
|
||||
compilerOptions: {
|
||||
composite: true,
|
||||
declaration: true,
|
||||
@ -660,9 +660,9 @@ ${internal} enum internalEnum { a, b, c }`);
|
||||
sourceMap: true,
|
||||
outFile: "./bin/first-output.js"
|
||||
},
|
||||
files: [sources[project.first][source.ts][part.one]]
|
||||
files: [sources[Project.first][Source.ts][Part.one]]
|
||||
}));
|
||||
fs.writeFileSync(sources[project.third][source.config], JSON.stringify({
|
||||
fs.writeFileSync(sources[Project.third][Source.config], JSON.stringify({
|
||||
compilerOptions: {
|
||||
composite: true,
|
||||
declaration: true,
|
||||
@ -672,7 +672,7 @@ ${internal} enum internalEnum { a, b, c }`);
|
||||
outFile: "./thirdjs/output/third-output.js"
|
||||
},
|
||||
references: [{ path: "../first", prepend: true }],
|
||||
files: [sources[project.third][source.ts][part.one]]
|
||||
files: [sources[Project.third][Source.ts][Part.one]]
|
||||
}));
|
||||
}
|
||||
});
|
||||
@ -680,7 +680,7 @@ ${internal} enum internalEnum { a, b, c }`);
|
||||
|
||||
describe("empty source files", () => {
|
||||
function makeThirdEmptySourceFile(fs: vfs.FileSystem) {
|
||||
fs.writeFileSync(sources[project.third][source.ts][part.one], "", "utf8");
|
||||
fs.writeFileSync(sources[Project.third][Source.ts][Part.one], "", "utf8");
|
||||
}
|
||||
|
||||
// Verify ignore dtsChanged
|
||||
@ -696,9 +696,9 @@ ${internal} enum internalEnum { a, b, c }`);
|
||||
subScenario: "declarationMap and sourceMap disabled",
|
||||
modifyFs: fs => {
|
||||
makeThirdEmptySourceFile(fs);
|
||||
replaceText(fs, sources[project.third][source.config], `"composite": true,`, "");
|
||||
replaceText(fs, sources[project.third][source.config], `"sourceMap": true,`, "");
|
||||
replaceText(fs, sources[project.third][source.config], `"declarationMap": true,`, "");
|
||||
replaceText(fs, sources[Project.third][Source.config], `"composite": true,`, "");
|
||||
replaceText(fs, sources[Project.third][Source.config], `"sourceMap": true,`, "");
|
||||
replaceText(fs, sources[Project.third][Source.config], `"declarationMap": true,`, "");
|
||||
},
|
||||
ignoreDtsChanged: true,
|
||||
ignoreDtsUnchanged: true,
|
||||
@ -714,18 +714,18 @@ ${internal} enum internalEnum { a, b, c }`);
|
||||
commandLineArgs: ["--b", "/src/third", "--verbose"],
|
||||
modifyFs: fs => {
|
||||
// No prepend
|
||||
replaceText(fs, sources[project.third][source.config], `{ "path": "../first", "prepend": true }`, `{ "path": "../first" }`);
|
||||
replaceText(fs, sources[project.third][source.config], `{ "path": "../second", "prepend": true }`, `{ "path": "../second" }`);
|
||||
replaceText(fs, sources[Project.third][Source.config], `{ "path": "../first", "prepend": true }`, `{ "path": "../first" }`);
|
||||
replaceText(fs, sources[Project.third][Source.config], `{ "path": "../second", "prepend": true }`, `{ "path": "../second" }`);
|
||||
|
||||
// Non Modules
|
||||
replaceText(fs, sources[project.first][source.config], `"composite": true,`, `"composite": true, "module": "none",`);
|
||||
replaceText(fs, sources[project.second][source.config], `"composite": true,`, `"composite": true, "module": "none",`);
|
||||
replaceText(fs, sources[project.third][source.config], `"composite": true,`, `"composite": true, "module": "none",`);
|
||||
replaceText(fs, sources[Project.first][Source.config], `"composite": true,`, `"composite": true, "module": "none",`);
|
||||
replaceText(fs, sources[Project.second][Source.config], `"composite": true,`, `"composite": true, "module": "none",`);
|
||||
replaceText(fs, sources[Project.third][Source.config], `"composite": true,`, `"composite": true, "module": "none",`);
|
||||
|
||||
// Own file emit
|
||||
replaceText(fs, sources[project.first][source.config], `"outFile": "./bin/first-output.js",`, "");
|
||||
replaceText(fs, sources[project.second][source.config], `"outFile": "../2/second-output.js",`, "");
|
||||
replaceText(fs, sources[project.third][source.config], `"outFile": "./thirdjs/output/third-output.js",`, "");
|
||||
replaceText(fs, sources[Project.first][Source.config], `"outFile": "./bin/first-output.js",`, "");
|
||||
replaceText(fs, sources[Project.second][Source.config], `"outFile": "../2/second-output.js",`, "");
|
||||
replaceText(fs, sources[Project.third][Source.config], `"outFile": "./thirdjs/output/third-output.js",`, "");
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user