Skip to content
This repository was archived by the owner on Mar 25, 2021. It is now read-only.

Commit b322f77

Browse files
ajafffadidahiya
authored andcommitted
no-namespace: ignore global augmentation (#3163)
[bugfix] `no-namespace` ignores global augmentation Fixes #3157
1 parent 1c184db commit b322f77

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/rules/noNamespaceRule.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { hasModifier } from "tsutils";
18+
import { hasModifier, isNodeFlagSet } from "tsutils";
1919
import * as ts from "typescript";
2020

2121
import * as Lint from "../index";
@@ -72,6 +72,7 @@ function walk(ctx: Lint.WalkContext<Options>) {
7272
for (const node of ctx.sourceFile.statements) {
7373
if (node.kind === ts.SyntaxKind.ModuleDeclaration) {
7474
if ((node as ts.ModuleDeclaration).name.kind !== ts.SyntaxKind.StringLiteral &&
75+
!isNodeFlagSet(node, ts.NodeFlags.GlobalAugmentation) &&
7576
(!ctx.options.allowDeclarations || !hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword))) {
7677
ctx.addFailureAtNode(node, Rule.FAILURE_STRING);
7778
}

test/rules/no-namespace/default/test.ts.lint

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ declare namespace Foo {
1919

2020
declare module 'foo' {
2121
}
22+
23+
declare global {
24+
interface Foo {}
25+
}

0 commit comments

Comments
 (0)