跳到主要内容

@typescript-eslint/no-namespace

禁止使用 TypeScript语法中的命名空间。

命名空间是一种过时的语法,推荐使用import/export。

该规则仅支持对.js/.ts文件进行检查。

规则配置

// code-linter.json5
{
"rules": {
"@typescript-eslint/no-namespace": "error"
}
}

选项

详情请参考@typescript-eslint/no-namespace选项

正例

// foo为模块名
declare module 'foo' {}
// anything inside a d.ts file

反例

module foo {}
namespace foo {}

declare module foo {}
declare namespace foo {}

规则集

plugin:@typescript-eslint/all

Code Linter代码检查规则的配置指导请参考Code Linter代码检查