Skip to content

namespaceDeclarations

Reports using legacy namespace declarations.

✅ This rule is included in the ts logical and logicalStrict presets.

Namespaces are a legacy feature of TypeScript that can lead to confusion and are not compatible with ECMAScript modules. Modern codebases generally use export and import statements to define and use ECMAScript modules instead.

namespace
namespace Values
Values
{
export const
const Values.value: 123
value
= 123;
}
namespace
namespace Fruits
Fruits
{
export const
const Fruits.apple: "🍎"
apple
= "🍎";
}

Whether to allow namespaces declared with the declare keyword.

const ts: Plugin<RuleAbout, "all" | "javascript" | "typescript", [Rule<{
readonly description: "Reports getter and setter accessors for the same property that are not adjacent.";
readonly id: "accessorPairGroups";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "notGrouped", AnyOptionalSchema>, Rule<{
readonly description: "Reports mismatched types between getter and setter accessor pairs.";
readonly id: "accessorPairTypes";
readonly presets: [...];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "mismatchedTypes", AnyOptionalSchema>, ... 290 more ..., Rule<...>]>
ts
.
Plugin<RuleAbout, "all" | "javascript" | "typescript", [Rule<{ readonly description: "Reports getter and setter accessors for the same property that are not adjacent."; readonly id: "accessorPairGroups"; readonly presets: [...]; } & { ...; }, object, object, "notGrouped", AnyOptionalSchema>, ... 291 more ..., Rule<...>]>.rules: (rulesOptions: PluginRulesOptions<[Rule<{
readonly description: "Reports getter and setter accessors for the same property that are not adjacent.";
readonly id: "accessorPairGroups";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "notGrouped", AnyOptionalSchema>, Rule<{
readonly description: "Reports mismatched types between getter and setter accessor pairs.";
readonly id: "accessorPairTypes";
readonly presets: [...];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "mismatchedTypes", AnyOptionalSchema>, ... 290 more ..., Rule<...>]>) => [...]

Defines rules to configure or disable on files in a config.

rules
({
namespaceDeclarations?: boolean | {
allowDeclarations?: boolean | undefined;
allowDefinitionFiles?: boolean | undefined;
} | undefined
namespaceDeclarations
: {
allowDeclarations?: boolean | undefined
allowDeclarations
: true,
},
});
namespace
namespace Values
Values
{
export const
const Values.value: 123
value
= 123;
}
const ts: Plugin<RuleAbout, "all" | "javascript" | "typescript", [Rule<{
readonly description: "Reports getter and setter accessors for the same property that are not adjacent.";
readonly id: "accessorPairGroups";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "notGrouped", AnyOptionalSchema>, Rule<{
readonly description: "Reports mismatched types between getter and setter accessor pairs.";
readonly id: "accessorPairTypes";
readonly presets: [...];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "mismatchedTypes", AnyOptionalSchema>, ... 290 more ..., Rule<...>]>
ts
.
Plugin<RuleAbout, "all" | "javascript" | "typescript", [Rule<{ readonly description: "Reports getter and setter accessors for the same property that are not adjacent."; readonly id: "accessorPairGroups"; readonly presets: [...]; } & { ...; }, object, object, "notGrouped", AnyOptionalSchema>, ... 291 more ..., Rule<...>]>.rules: (rulesOptions: PluginRulesOptions<[Rule<{
readonly description: "Reports getter and setter accessors for the same property that are not adjacent.";
readonly id: "accessorPairGroups";
readonly presets: ["stylistic", "stylisticStrict"];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "notGrouped", AnyOptionalSchema>, Rule<{
readonly description: "Reports mismatched types between getter and setter accessor pairs.";
readonly id: "accessorPairTypes";
readonly presets: [...];
} & {
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict" | "untyped")[];
url: string;
}, object, object, "mismatchedTypes", AnyOptionalSchema>, ... 290 more ..., Rule<...>]>) => [...]

Defines rules to configure or disable on files in a config.

rules
({
namespaceDeclarations?: boolean | {
allowDeclarations?: boolean | undefined;
allowDefinitionFiles?: boolean | undefined;
} | undefined
namespaceDeclarations
: {
allowDefinitionFiles?: boolean | undefined
allowDefinitionFiles
: true,
},
});

Whether to allow namespaces in .d.ts and other definition files.

index.ts
declare namespace
namespace Values
Values
{
const
const Values.value: number
value
: number;
}

If your project uses TypeScript’s CommonJS export syntax (export = ...), you may need to use namespaces in order to export types from your module. You can learn more about this at:

If your project uses this syntax, either because it was architected before modern modules and namespaces, or because a module option such as verbatimModuleSyntax requires it, it may be difficult to migrate off of namespaces. In that case you may not be able to use this rule for parts of your project.

You might consider using Flint disable comments and/or configuration file disables for those specific situations instead of completely disabling this rule.

Made with ❤️‍🔥 around the world by the Flint team and contributors.