Fixing linter and test errors

This commit is contained in:
Richard Knoll 2016-05-25 17:07:36 -07:00
parent 084b94c4c1
commit db856431e8
5 changed files with 20 additions and 32 deletions

View File

@ -713,6 +713,16 @@ namespace ts {
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array"));
}
}
else {
// By default, exclude common package folders
excludeSpecs = ["node_modules", "bower_components", "jspm_packages"];
}
// Always exclude the output directory unless explicitly included
const outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"];
if (outDir) {
excludeSpecs.push(outDir);
}
if (fileNames === undefined && includeSpecs === undefined) {
includeSpecs = ["**/*"];
@ -885,7 +895,6 @@ namespace ts {
*/
function matchFileNames(fileNames: string[], include: string[], exclude: string[], basePath: string, options: CompilerOptions, host: ParseConfigHost, errors: Diagnostic[]): ExpandResult {
basePath = normalizePath(basePath);
basePath = removeTrailingDirectorySeparator(basePath);
// The exclude spec list is converted into a regular expression, which allows us to quickly
// test whether a file or directory should be excluded before recursively traversing the
@ -941,6 +950,10 @@ namespace ts {
continue;
}
if (IgnoreFileNamePattern.test(file)) {
continue;
}
// We may have included a wildcard path with a lower priority
// extension due to the user-defined order of entries in the
// "include" array. If there is a lower priority extension in the

View File

@ -1067,7 +1067,7 @@ namespace ts {
return basePaths;
}
export function ensureScriptKind(fileName: string, scriptKind?: ScriptKind): ScriptKind {
// Using scriptKind as a condition handles both:
// - 'scriptKind' is unspecified and thus it is `undefined`

View File

@ -367,7 +367,7 @@ namespace ts {
const files: string[] = [];
const directories: string[] = [];
for (const entry of entries) {
// This is necessary because on some file system node fails to exclude
// This is necessary because on some file system node fails to exclude
// "." and "..". See https://github.com/nodejs/node/issues/4002
if (entry === "." || entry === "..") {
continue;
@ -391,10 +391,6 @@ namespace ts {
function readDirectory(path: string, extensions?: string[], excludes?: string[], includes?: string[]): string[] {
return matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), getAccessibleFileSystemEntries);
}
function getCanonicalPath(path: string): string {
return useCaseSensitiveFileNames ? path : path.toLowerCase();
}
const enum FileSystemEntryKind {
File,

View File

@ -81,7 +81,7 @@ namespace ts {
*/
readDirectory(rootDir: string, extension: string, exclude?: string, include?: string, depth?: number): string;
useCaseSensitiveFileNames?(): boolean;
trace(s: string): void;
trace(s: string): void;
}
///
@ -432,10 +432,10 @@ namespace ts {
public directoryExists: (directoryName: string) => boolean;
public realpath: (path: string) => string;
public useCaseSensitiveFileNames: boolean;
public useCaseSensitiveFileNames: boolean;
constructor(private shimHost: CoreServicesShimHost) {
this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false;
this.useCaseSensitiveFileNames = this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false;
if ("directoryExists" in this.shimHost) {
this.directoryExists = directoryName => this.shimHost.directoryExists(directoryName);
}
@ -453,7 +453,7 @@ namespace ts {
JSON.stringify(extensions),
JSON.stringify(exclude),
JSON.stringify(include),
depth
depth
));
}
catch (e) {

View File

@ -50,27 +50,6 @@ namespace ts {
const host: ParseConfigHost = new MockParseConfigHost(basePath, true, allFileList);
const parsed = ts.parseJsonConfigFileContent(json, host, basePath, /*existingOptions*/ undefined, configFileName);
assert.isTrue(arrayIsEqualTo(parsed.fileNames.sort(), expectedFileList.sort()));
function mockReadDirectory(rootDir: string, extension: string, exclude: string[]): string[] {
const result: string[] = [];
const fullExcludeDirectories = ts.map(exclude, directory => combinePaths(rootDir, directory));
for (const file of allFileList) {
let shouldExclude = false;
for (const fullExcludeDirectorie of fullExcludeDirectories) {
if (file.indexOf(fullExcludeDirectorie) >= 0) {
shouldExclude = true;
break;
}
}
if (shouldExclude) {
continue;
}
if (fileExtensionIs(file, extension)) {
result.push(file);
}
}
return result;
}
}
it("returns empty config for file with only whitespaces", () => {