⬅️ Back to Table of Contents
📄 no-confusing-non-null-assertion.ts
📊 Analysis Summary
Metric |
Count |
🔧 Functions |
27 |
📦 Imports |
7 |
📊 Variables & Constants |
3 |
📑 Type Aliases |
2 |
📚 Table of Contents
🛠️ File Location:
📂 packages/eslint-plugin/src/rules/no-confusing-non-null-assertion.ts
📦 Imports
Name |
Source |
TSESLint |
@typescript-eslint/utils |
TSESTree |
@typescript-eslint/utils |
ReportDescriptor |
@typescript-eslint/utils/ts-eslint |
RuleFix |
@typescript-eslint/utils/ts-eslint |
AST_NODE_TYPES |
@typescript-eslint/utils |
AST_TOKEN_TYPES |
@typescript-eslint/utils |
createRule |
../util |
Variables & Constants
Name |
Type |
Kind |
Value |
Exported |
confusingOperators |
Set<"in" | "=" | "==" | "===" | "instanceof"> |
const |
`new Set([ |
|
'=', |
|
|
|
|
'==', |
|
|
|
|
'===', |
|
|
|
|
'in', |
|
|
|
|
'instanceof', |
|
|
|
|
] as const)` |
✗ |
|
|
|
operator |
any |
const |
node.operator |
✗ |
suggestions |
TSESLint.SuggestionReportDescriptor<MessageId>[] |
let/var |
*not shown* |
✗ |
Functions
isConfusingOperator(operator: string): operator is ConfusingOperator
Code
function isConfusingOperator(operator: string): operator is ConfusingOperator {
return confusingOperators.has(operator as ConfusingOperator);
}
- Parameters:
operator: string
- Return Type:
operator is ConfusingOperator
- Calls:
confusingOperators.has
confusingOperatorToMessageData(operator: ConfusingOperator): Pick<ReportDescriptor<MessageId>, 'data' | 'messageId'>
Code
function confusingOperatorToMessageData(
operator: ConfusingOperator,
): Pick<ReportDescriptor<MessageId>, 'data' | 'messageId'> {
switch (operator) {
case '=':
return {
messageId: 'confusingAssign',
};
case '==':
case '===':
return {
messageId: 'confusingEqual',
};
case 'in':
case 'instanceof':
return {
messageId: 'confusingOperator',
data: { operator },
};
// istanbul ignore next
default:
operator satisfies never;
throw new Error(`Unexpected operator ${operator as string}`);
}
}
- Parameters:
operator: ConfusingOperator
- Return Type:
Pick<ReportDescriptor<MessageId>, 'data' | 'messageId'>
- Internal Comments:
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
fix(fixer: any): RuleFix
Code
(fixer): RuleFix => fixer.remove(leftHandFinalToken)
- Parameters:
fixer: any
- Return Type:
RuleFix
- Calls:
fixer.remove
wrapUpLeftFixer(node: TSESTree.AssignmentExpression | TSESTree.BinaryExpression): TSESLint.ReportFixFunction
Code
function wrapUpLeftFixer(
node: TSESTree.AssignmentExpression | TSESTree.BinaryExpression,
): TSESLint.ReportFixFunction {
return (fixer): TSESLint.RuleFix[] => [
fixer.insertTextBefore(node.left, '('),
fixer.insertTextAfter(node.left, ')'),
];
}
- Parameters:
node: TSESTree.AssignmentExpression | TSESTree.BinaryExpression
- Return Type:
TSESLint.ReportFixFunction
- Calls:
fixer.insertTextBefore
fixer.insertTextAfter
Type Aliases
MessageId
type MessageId = | 'confusingAssign'
| 'confusingEqual'
| 'confusingOperator'
| 'notNeedInAssign'
| 'notNeedInEqualTest'
| 'notNeedInOperator'
| 'wrapUpLeft';
ConfusingOperator
type ConfusingOperator = typeof confusingOperators extends Set<infer T> ? T : never;