noNamespace
¥Summary
-
规则生效日期:
v1.0.0¥Rule available since:
v1.0.0 -
¥Diagnostic Category:
lint/style/noNamespace -
此规则没有修复方案。
¥This rule doesn’t have a fix.
-
此规则的默认严重级别为 warning。
¥The default severity of this rule is warning.
-
来源:
¥Sources:
¥How to configure
{ "linter": { "rules": { "style": { "noNamespace": "error" } } }}¥Description
禁止使用 TypeScript 的 namespace。
¥Disallow the use of TypeScript’s namespaces.
命名空间是在 TypeScript 中组织代码的一种旧方法。它们不再推荐,应该由 ES6 模块(import/export 语法)替换。
¥Namespaces are an old way to organize your code in TypeScript.
They are not recommended anymore and should be replaced by ES6 modules
(the import/export syntax).
¥Examples
¥Invalid
module foo {}code-block.ts:1:1 lint/style/noNamespace ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ TypeScript’s namespaces are an outdated way to organize code.
> 1 │ module foo {}
│ ^^^^^^^^^^^^^
2 │
ℹ Prefer the ES6 modules (import/export) over namespaces.
declare module foo {}code-block.ts:1:9 lint/style/noNamespace ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ TypeScript’s namespaces are an outdated way to organize code.
> 1 │ declare module foo {}
│ ^^^^^^^^^^^^^
2 │
ℹ Prefer the ES6 modules (import/export) over namespaces.
namespace foo {}code-block.ts:1:1 lint/style/noNamespace ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ TypeScript’s namespaces are an outdated way to organize code.
> 1 │ namespace foo {}
│ ^^^^^^^^^^^^^^^^
2 │
ℹ Prefer the ES6 modules (import/export) over namespaces.
declare namespace foo {}code-block.ts:1:9 lint/style/noNamespace ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ TypeScript’s namespaces are an outdated way to organize code.
> 1 │ declare namespace foo {}
│ ^^^^^^^^^^^^^^^^
2 │
ℹ Prefer the ES6 modules (import/export) over namespaces.
¥Valid
import foo from 'foo';export { bar };declare global {}declare module 'foo' {}¥Related links
Biome v2.1 中文网 - 粤ICP备13048890号