Skip to content

Commit db85643

Browse files
committed
Fixing linter and test errors
1 parent 084b94c commit db85643

5 files changed

Lines changed: 20 additions & 32 deletions

File tree

src/compiler/commandLineParser.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,16 @@ namespace ts {
713713
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array"));
714714
}
715715
}
716+
else {
717+
// By default, exclude common package folders
718+
excludeSpecs = ["node_modules", "bower_components", "jspm_packages"];
719+
}
720+
721+
// Always exclude the output directory unless explicitly included
722+
const outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"];
723+
if (outDir) {
724+
excludeSpecs.push(outDir);
725+
}
716726

717727
if (fileNames === undefined && includeSpecs === undefined) {
718728
includeSpecs = ["**/*"];
@@ -885,7 +895,6 @@ namespace ts {
885895
*/
886896
function matchFileNames(fileNames: string[], include: string[], exclude: string[], basePath: string, options: CompilerOptions, host: ParseConfigHost, errors: Diagnostic[]): ExpandResult {
887897
basePath = normalizePath(basePath);
888-
basePath = removeTrailingDirectorySeparator(basePath);
889898

890899
// The exclude spec list is converted into a regular expression, which allows us to quickly
891900
// test whether a file or directory should be excluded before recursively traversing the
@@ -941,6 +950,10 @@ namespace ts {
941950
continue;
942951
}
943952

953+
if (IgnoreFileNamePattern.test(file)) {
954+
continue;
955+
}
956+
944957
// We may have included a wildcard path with a lower priority
945958
// extension due to the user-defined order of entries in the
946959
// "include" array. If there is a lower priority extension in the

src/compiler/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ namespace ts {
10671067

10681068
return basePaths;
10691069
}
1070-
1070+
10711071
export function ensureScriptKind(fileName: string, scriptKind?: ScriptKind): ScriptKind {
10721072
// Using scriptKind as a condition handles both:
10731073
// - 'scriptKind' is unspecified and thus it is `undefined`

src/compiler/sys.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ namespace ts {
367367
const files: string[] = [];
368368
const directories: string[] = [];
369369
for (const entry of entries) {
370-
// This is necessary because on some file system node fails to exclude
370+
// This is necessary because on some file system node fails to exclude
371371
// "." and "..". See https://github.com/nodejs/node/issues/4002
372372
if (entry === "." || entry === "..") {
373373
continue;
@@ -391,10 +391,6 @@ namespace ts {
391391
function readDirectory(path: string, extensions?: string[], excludes?: string[], includes?: string[]): string[] {
392392
return matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), getAccessibleFileSystemEntries);
393393
}
394-
395-
function getCanonicalPath(path: string): string {
396-
return useCaseSensitiveFileNames ? path : path.toLowerCase();
397-
}
398394

399395
const enum FileSystemEntryKind {
400396
File,

src/services/shims.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ namespace ts {
8181
*/
8282
readDirectory(rootDir: string, extension: string, exclude?: string, include?: string, depth?: number): string;
8383
useCaseSensitiveFileNames?(): boolean;
84-
trace(s: string): void;
84+
trace(s: string): void;
8585
}
8686

8787
///
@@ -432,10 +432,10 @@ namespace ts {
432432

433433
public directoryExists: (directoryName: string) => boolean;
434434
public realpath: (path: string) => string;
435-
public useCaseSensitiveFileNames: boolean;
435+
public useCaseSensitiveFileNames: boolean;
436436

437437
constructor(private shimHost: CoreServicesShimHost) {
438-
this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false;
438+
this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false;
439439
if ("directoryExists" in this.shimHost) {
440440
this.directoryExists = directoryName => this.shimHost.directoryExists(directoryName);
441441
}
@@ -453,7 +453,7 @@ namespace ts {
453453
JSON.stringify(extensions),
454454
JSON.stringify(exclude),
455455
JSON.stringify(include),
456-
depth
456+
depth
457457
));
458458
}
459459
catch (e) {

tests/cases/unittests/tsconfigParsing.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,6 @@ namespace ts {
5050
const host: ParseConfigHost = new MockParseConfigHost(basePath, true, allFileList);
5151
const parsed = ts.parseJsonConfigFileContent(json, host, basePath, /*existingOptions*/ undefined, configFileName);
5252
assert.isTrue(arrayIsEqualTo(parsed.fileNames.sort(), expectedFileList.sort()));
53-
54-
function mockReadDirectory(rootDir: string, extension: string, exclude: string[]): string[] {
55-
const result: string[] = [];
56-
const fullExcludeDirectories = ts.map(exclude, directory => combinePaths(rootDir, directory));
57-
for (const file of allFileList) {
58-
let shouldExclude = false;
59-
for (const fullExcludeDirectorie of fullExcludeDirectories) {
60-
if (file.indexOf(fullExcludeDirectorie) >= 0) {
61-
shouldExclude = true;
62-
break;
63-
}
64-
}
65-
if (shouldExclude) {
66-
continue;
67-
}
68-
if (fileExtensionIs(file, extension)) {
69-
result.push(file);
70-
}
71-
}
72-
return result;
73-
}
7453
}
7554

7655
it("returns empty config for file with only whitespaces", () => {

0 commit comments

Comments
 (0)