β¬ οΈ Back to Table of Contents
π no-namespace¶
π Analysis Summary¶
| Metric | Count |
|---|---|
| π§ Functions | 2 |
| π¦ Imports | 4 |
| π Type Aliases | 2 |
π Table of Contents¶
π οΈ File Location:¶
π packages/eslint-plugin/src/rules/no-namespace.ts
π€ Default Export¶
| Property | Value |
|---|---|
name |
'no-namespace' |
meta.type |
'suggestion' |
meta.docs.description |
'Disallow TypeScript namespaces' |
meta.docs.recommended |
'recommended' |
meta.messages.moduleSyntaxIsPreferred |
'ES2015 module syntax is preferred over namespaces.' |
meta.schema |
[ { type: 'object', additionalProperties: false, properties: { allowDeclarations: { type: 'boolean', description: 'Wh... |
defaultOptions |
[ { allowDeclarations: false, allowDefinitionFiles: true, }, ] |
Entry point: create β documented under Functions.
π¦ Imports¶
| Name | Source |
|---|---|
TSESTree |
@typescript-eslint/utils |
AST_NODE_TYPES |
@typescript-eslint/utils |
createRule |
../util |
isDefinitionFile |
../util |
Functions¶
create(context: any, [{ allowDeclarations, allowDefiβ¦: any): { "TSModuleDeclaration[global!=true][id.type!='Literal']"(n⦶
Parameters:
contextany[{ allowDeclarations, allowDefinitionFiles }]any
Returns: { "TSModuleDeclaration[global!=true][id.type!='Literal']"(node: TSESTree.TSModuleDeclaration): void; }
Calls:
isDeclarationisDefinitionFile (from ../util)context.report
Code
create(context, [{ allowDeclarations, allowDefinitionFiles }]) {
function isDeclaration(node: TSESTree.Node): boolean {
if (node.type === AST_NODE_TYPES.TSModuleDeclaration && node.declare) {
return true;
}
return node.parent != null && isDeclaration(node.parent);
}
return {
"TSModuleDeclaration[global!=true][id.type!='Literal']"(
node: TSESTree.TSModuleDeclaration,
): void {
if (
node.parent.type === AST_NODE_TYPES.TSModuleDeclaration ||
(allowDefinitionFiles && isDefinitionFile(context.filename)) ||
(allowDeclarations && isDeclaration(node))
) {
return;
}
context.report({
node,
messageId: 'moduleSyntaxIsPreferred',
});
},
};
}
Internal helpers¶
Declared inside another function in this file.
isDeclaration(node: TSESTree.Node): boolean¶
Parameters:
nodeTSESTree.Node
Returns: boolean
Calls:
isDeclaration
Code
Type Aliases¶
Options¶
MessageIds¶
Generated by Syntax Scribe