ā¬ ļø Back to Table of Contents
š no-unsafe-function-type¶
š Analysis Summary¶
| Metric | Count |
|---|---|
| š§ Functions | 2 |
| š¦ Imports | 4 |
š Table of Contents¶
š ļø File Location:¶
š packages/eslint-plugin/src/rules/no-unsafe-function-type.ts
š¤ Default Export¶
| Property | Value |
|---|---|
name |
'no-unsafe-function-type' |
meta.type |
'problem' |
meta.docs.description |
'Disallow using the unsafe built-in Function type' |
meta.docs.recommended |
'recommended' |
meta.messages.bannedFunctionType |
[ 'The Function type accepts any function-like value.', 'Prefer explicitly defining any function parameters and ret... |
meta.schema |
[] |
defaultOptions |
[] |
Entry point: create ā documented under Functions.
š¦ Imports¶
| Name | Source |
|---|---|
TSESTree |
@typescript-eslint/utils |
AST_NODE_TYPES |
@typescript-eslint/utils |
createRule |
../util |
isReferenceToGlobalFunction |
../util |
Functions¶
create(context: any): { TSClassImplements(node: any): void; TSInterfaceHeritage(n⦶
Parameters:
contextany
Returns: { TSClassImplements(node: any): void; TSInterfaceHeritage(node: any): void; TSTypeReference(node: any): void; }
Calls:
isReferenceToGlobalFunction (from ../util)context.reportcheckBannedTypes
Code
create(context) {
function checkBannedTypes(node: TSESTree.Node): void {
if (
node.type === AST_NODE_TYPES.Identifier &&
node.name === 'Function' &&
isReferenceToGlobalFunction('Function', node, context.sourceCode)
) {
context.report({
node,
messageId: 'bannedFunctionType',
});
}
}
return {
TSClassImplements(node): void {
checkBannedTypes(node.expression);
},
TSInterfaceHeritage(node): void {
checkBannedTypes(node.expression);
},
TSTypeReference(node): void {
checkBannedTypes(node.typeName);
},
};
}
Internal helpers¶
Declared inside another function in this file.
checkBannedTypes(node: TSESTree.Node): void¶
Parameters:
nodeTSESTree.Node
Returns: void
Calls:
isReferenceToGlobalFunction (from ../util)context.report
Code
Generated by Syntax Scribe