⬅️ Back to Table of Contents
📄 max-params.ts
📊 Analysis Summary
Metric |
Count |
🔧 Functions |
2 |
📦 Imports |
6 |
📑 Type Aliases |
4 |
📚 Table of Contents
🛠️ File Location:
📂 packages/eslint-plugin/src/rules/max-params.ts
📦 Imports
Name |
Source |
TSESTree |
@typescript-eslint/utils |
AST_NODE_TYPES |
@typescript-eslint/utils |
InferMessageIdsTypeFromRule |
../util |
InferOptionsTypeFromRule |
../util |
createRule |
../util |
getESLintCoreRule |
../util/getESLintCoreRule |
Functions
removeVoidThisParam(node: T): T
Code
<T extends FunctionLike>(node: T): T => {
if (
node.params.length === 0 ||
node.params[0].type !== AST_NODE_TYPES.Identifier ||
node.params[0].name !== 'this' ||
node.params[0].typeAnnotation?.typeAnnotation.type !==
AST_NODE_TYPES.TSVoidKeyword
) {
return node;
}
return {
...node,
params: node.params.slice(1),
};
}
- Parameters:
node: T
- Return Type:
T
- Calls:
node.params.slice
wrapListener(listener: FunctionRuleListener<T>): FunctionRuleListener<T>
Code
<T extends FunctionLike>(
listener: FunctionRuleListener<T>,
): FunctionRuleListener<T> => {
return (node: T): void => {
listener(removeVoidThisParam(node));
};
}
- Parameters:
listener: FunctionRuleListener<T>
- Return Type:
FunctionRuleListener<T>
- Calls:
listener
removeVoidThisParam
Type Aliases
FunctionLike
type FunctionLike = | TSESTree.ArrowFunctionExpression
| TSESTree.FunctionDeclaration
| TSESTree.FunctionExpression
| TSESTree.TSDeclareFunction
| TSESTree.TSFunctionType;
FunctionRuleListener<T extends FunctionLike extends FunctionLike>
type FunctionRuleListener<T extends FunctionLike extends FunctionLike> = (node: T) => void;
Options
type Options = InferOptionsTypeFromRule<typeof baseRule>;
MessageIds
type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;