From 136f4cfc0f6c9846401da3751696d1ac9c77bb5d Mon Sep 17 00:00:00 2001 From: Alexander T Date: Thu, 27 Jun 2019 12:29:32 +0300 Subject: [PATCH] no-redeclare --- .eslintrc | 2 +- scripts/failed-tests.d.ts | 3 ++- src/compiler/builder.ts | 1 + src/compiler/builderState.ts | 6 ++++-- src/compiler/core.ts | 2 ++ src/compiler/factory.ts | 1 + src/compiler/performance.ts | 1 + src/compiler/tsbuild.ts | 1 + src/compiler/utilities.ts | 7 ++++++- src/compiler/visitor.ts | 1 + src/compiler/watch.ts | 1 + src/harness/harness.ts | 1 + src/server/utilities.ts | 2 ++ src/services/findAllReferences.ts | 1 + src/services/utilities.ts | 1 + 15 files changed, 26 insertions(+), 5 deletions(-) diff --git a/.eslintrc b/.eslintrc index f6451e8206b..064dc326864 100644 --- a/.eslintrc +++ b/.eslintrc @@ -99,7 +99,7 @@ "no-multiple-empty-lines": "off", "no-new-func": "error", "no-new-wrappers": "error", - "no-redeclare": "off", + "no-redeclare": "error", "no-return-await": "error", "no-restricted-globals": ["error", { "name": "setTimeout" }, diff --git a/scripts/failed-tests.d.ts b/scripts/failed-tests.d.ts index e82c0b178e8..c17e0a5a39a 100644 --- a/scripts/failed-tests.d.ts +++ b/scripts/failed-tests.d.ts @@ -12,6 +12,7 @@ declare class FailedTestsReporter extends Mocha.reporters.Base { done(failures: number, fn?: (failures: number) => void): void; } +// eslint-disable-next-line no-redeclare declare namespace FailedTestsReporter { interface ReporterOptions { file?: string; @@ -19,4 +20,4 @@ declare namespace FailedTestsReporter { reporter?: string | Mocha.ReporterConstructor; reporterOptions?: any; } -} \ No newline at end of file +} diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index 066db100983..b238492100a 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -1055,6 +1055,7 @@ namespace ts { } } +// eslint-disable-next-line no-redeclare namespace ts { export type AffectedFileResult = { result: T; affected: SourceFile | Program; } | undefined; diff --git a/src/compiler/builderState.ts b/src/compiler/builderState.ts index 58b189d9e81..72c73500d3d 100644 --- a/src/compiler/builderState.ts +++ b/src/compiler/builderState.ts @@ -12,7 +12,8 @@ namespace ts { } } -/*@internal*/ +/* @internal */ +// eslint-disable-next-line no-redeclare namespace ts { export function getFileEmitOutput(program: Program, sourceFile: SourceFile, emitOnlyDtsFiles: boolean, cancellationToken?: CancellationToken, customTransformers?: CustomTransformers): EmitOutput { @@ -80,7 +81,8 @@ namespace ts { } } -/*@internal*/ +/* @internal */ +// eslint-disable-next-line no-redeclare namespace ts.BuilderState { /** * Information about the source file: Its version and optional signature from last emit diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 4529ce2fd83..e868647f07a 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -6,6 +6,7 @@ namespace ts { export const version = `${versionMajorMinor}.0-dev`; } +// eslint-disable-next-line no-redeclare namespace ts { /** * Type of objects whose values are all of the same type. @@ -68,6 +69,7 @@ namespace ts { } /* @internal */ +// eslint-disable-next-line no-redeclare namespace ts { export const emptyArray: never[] = [] as never[]; diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index cc2e5aaef4c..0107e6fea57 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -3423,6 +3423,7 @@ namespace ts { } /* @internal */ +// eslint-disable-next-line no-redeclare namespace ts { export const nullTransformationContext: TransformationContext = { enableEmitNotification: noop, diff --git a/src/compiler/performance.ts b/src/compiler/performance.ts index 3471ecd0591..8e809082655 100644 --- a/src/compiler/performance.ts +++ b/src/compiler/performance.ts @@ -7,6 +7,7 @@ namespace ts { /*@internal*/ /** Performance measurements for the compiler. */ +// eslint-disable-next-line no-redeclare namespace ts.performance { declare const onProfilerEvent: { (markName: string): void; profiler: boolean; }; diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 868eac2cf06..e94e8d38adb 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -150,6 +150,7 @@ namespace ts { } } +// eslint-disable-next-line no-redeclare namespace ts { const minimumDate = new Date(-8640000000000000); const maximumDate = new Date(8640000000000000); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index d90a025b6bc..c9ecad33d53 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -12,6 +12,7 @@ namespace ts { } /* @internal */ +// eslint-disable-next-line no-redeclare namespace ts { export const resolvingEmptyArray: never[] = [] as never[]; export const emptyMap = createMap() as ReadonlyMap & ReadonlyPragmaMap; @@ -4615,6 +4616,7 @@ namespace ts { } } +// eslint-disable-next-line no-redeclare namespace ts { export function getDefaultLibFileName(options: CompilerOptions): string { switch (options.target) { @@ -5391,6 +5393,7 @@ namespace ts { } // Simple node tests of the form `node.kind === SyntaxKind.Foo`. +// eslint-disable-next-line no-redeclare namespace ts { // Literals export function isNumericLiteral(node: Node): node is NumericLiteral { @@ -6129,6 +6132,7 @@ namespace ts { // // All node tests in the following list should *not* reference parent pointers so that // they may be used with transformations. +// eslint-disable-next-line no-redeclare namespace ts { /* @internal */ export function isSyntaxList(n: Node): n is SyntaxList { @@ -6971,8 +6975,8 @@ namespace ts { } } - /* @internal */ +// eslint-disable-next-line no-redeclare namespace ts { export function isNamedImportsOrExports(node: Node): node is NamedImportsOrExports { return node.kind === SyntaxKind.NamedImports || node.kind === SyntaxKind.NamedExports; @@ -7588,6 +7592,7 @@ namespace ts { } /* @internal */ +// eslint-disable-next-line no-redeclare namespace ts { export function getPathComponentsRelativeTo(from: string, to: string, stringEqualityComparer: (a: string, b: string) => boolean, getCanonicalFileName: GetCanonicalFileName) { const fromComponents = reducePathComponents(getPathComponents(from)); diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index c06fcd4f655..29801ea10bd 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -935,6 +935,7 @@ namespace ts { } /* @internal */ +// eslint-disable-next-line no-redeclare namespace ts { function reduceNode(node: Node | undefined, f: (memo: T, node: Node) => T, initial: T) { return node ? f(initial, node) : initial; diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index aae90bf34b4..148dd806bae 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -438,6 +438,7 @@ namespace ts { } } +// eslint-disable-next-line no-redeclare namespace ts { export function readBuilderProgram(compilerOptions: CompilerOptions, readFile: (path: string) => string | undefined) { if (compilerOptions.out || compilerOptions.outFile) return undefined; diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 84c4555c080..6219e98187e 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -608,6 +608,7 @@ if (Harness.IO.tryEnableSourceMapsForHost && /^development$/i.test(Harness.IO.ge Harness.IO.tryEnableSourceMapsForHost(); } +// eslint-disable-next-line no-redeclare namespace Harness { export const libFolder = "built/local/"; const tcServicesFileName = ts.combinePaths(libFolder, "typescriptServices.js"); diff --git a/src/server/utilities.ts b/src/server/utilities.ts index 91880ccfdbe..9c85236d920 100644 --- a/src/server/utilities.ts +++ b/src/server/utilities.ts @@ -122,6 +122,7 @@ namespace ts.server { } /* @internal */ +// eslint-disable-next-line no-redeclare namespace ts.server { export class ThrottledOperations { private readonly pendingTimeouts: Map = createMap(); @@ -219,6 +220,7 @@ namespace ts.server { } /* @internal */ +// eslint-disable-next-line no-redeclare namespace ts { // Additional tsserver specific watch information export const enum WatchType { diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 711a690f33c..e213db9dbd9 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -530,6 +530,7 @@ namespace ts.FindAllReferences { /** Encapsulates the core find-all-references algorithm. */ /* @internal */ +// eslint-disable-next-line no-redeclare namespace ts.FindAllReferences.Core { /** Core find-all-references algorithm. Handles special cases before delegating to `getReferencedSymbolsForSymbol`. */ export function getReferencedSymbolsForNode(position: number, node: Node, program: Program, sourceFiles: ReadonlyArray, cancellationToken: CancellationToken, options: Options = {}, sourceFilesSet: ReadonlyMap = arrayToSet(sourceFiles, f => f.fileName)): ReadonlyArray | undefined { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index ec6e9777e25..c08fb2b8860 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1438,6 +1438,7 @@ namespace ts { // Display-part writer helpers /* @internal */ +// eslint-disable-next-line no-redeclare namespace ts { export function isFirstDeclarationOfSymbolParameter(symbol: Symbol) { return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === SyntaxKind.Parameter;