⬅️ Back to Table of Contents
📊 Analysis Summary
Metric |
Count |
🔧 Functions |
2 |
📦 Imports |
5 |
📊 Variables & Constants |
4 |
📐 Interfaces |
1 |
📑 Type Aliases |
4 |
📚 Table of Contents
🛠️ File Location:
📂 packages/eslint-plugin/src/rules/related-getter-setter-pairs.ts
📦 Imports
Name |
Source |
TSESTree |
@typescript-eslint/utils |
AST_NODE_TYPES |
@typescript-eslint/utils |
createRule |
../util |
getNameFromMember |
../util |
getParserServices |
../util |
Variables & Constants
Name |
Type |
Kind |
Value |
Exported |
methodPairsStack |
Map<string, MethodPair>[] |
const |
[] |
✗ |
methodPairs |
Map<string, MethodPair> |
const |
methodPairsStack[methodPairsStack.length - 1] |
✗ |
methodPairs |
Map<string, MethodPair> |
const |
methodPairsStack[methodPairsStack.length - 1] |
✗ |
getter |
any |
const |
pair.get |
✗ |
Functions
addPropertyNode(member: GetMethod | SetMethod, inner: TSESTree.Node, kind: 'get' | 'set'): void
Code
function addPropertyNode(
member: GetMethod | SetMethod,
inner: TSESTree.Node,
kind: 'get' | 'set',
): void {
const methodPairs = methodPairsStack[methodPairsStack.length - 1];
const { name } = getNameFromMember(member, context.sourceCode);
methodPairs.set(name, {
...methodPairs.get(name),
[kind]: inner,
});
}
- Parameters:
member: GetMethod | SetMethod
inner: TSESTree.Node
kind: 'get' | 'set'
- Return Type:
void
- Calls:
getNameFromMember (from ../util)
methodPairs.set
methodPairs.get
getMethodFromNode(node: GetMethodRaw | SetMethod): any
Code
function getMethodFromNode(node: GetMethodRaw | SetMethod) {
return node.type === AST_NODE_TYPES.TSMethodSignature ? node : node.value;
}
- Parameters:
node: GetMethodRaw | SetMethod
- Return Type:
any
Interfaces
MethodPair
Interface Code
interface MethodPair {
get?: GetMethod;
set?: SetMethod;
}
Properties
Name |
Type |
Optional |
Description |
get |
GetMethod |
✓ |
|
set |
SetMethod |
✓ |
|
Type Aliases
Method
type Method = TSESTree.MethodDefinition | TSESTree.TSMethodSignature;
GetMethod
type GetMethod = {
kind: 'get';
returnType: TSESTree.TSTypeAnnotation;
} & Method;
GetMethodRaw
type GetMethodRaw = {
returnType: TSESTree.TSTypeAnnotation | undefined;
} & GetMethod;
SetMethod
type SetMethod = { kind: 'set'; params: [TSESTree.Node] } & Method;