cognitive-complexity-ts 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -33,7 +33,7 @@ function getColumnAndLine(node) {
|
|
|
33
33
|
exports.getColumnAndLine = getColumnAndLine;
|
|
34
34
|
function getIdentifier(node) {
|
|
35
35
|
for (const child of node.getChildren()) {
|
|
36
|
-
if (ts.
|
|
36
|
+
if (ts.isIdentifierOrPrivateIdentifier(child) || ts.isComputedPropertyName(child)) {
|
|
37
37
|
return child.getText();
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -65,7 +65,7 @@ exports.isBinaryTypeOperator = isBinaryTypeOperator;
|
|
|
65
65
|
function isBreakOrContinueToLabel(node) {
|
|
66
66
|
if (ts.isBreakOrContinueStatement(node)) {
|
|
67
67
|
for (const child of node.getChildren()) {
|
|
68
|
-
if (ts.
|
|
68
|
+
if (ts.isIdentifierOrPrivateIdentifier(child)) {
|
|
69
69
|
return true;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
@@ -140,7 +140,7 @@ exports.getExpressionToAccessObjectMember = getExpressionToAccessObjectMember;
|
|
|
140
140
|
*/
|
|
141
141
|
function getAccessorIdentifierName(node) {
|
|
142
142
|
for (const child of node.getChildren()) {
|
|
143
|
-
if (ts.
|
|
143
|
+
if (ts.isIdentifierOrPrivateIdentifier(child)) {
|
|
144
144
|
return [child.getText(), true];
|
|
145
145
|
}
|
|
146
146
|
if (ts.isComputedPropertyName(child)) {
|
|
@@ -150,7 +150,7 @@ function getAccessorIdentifierName(node) {
|
|
|
150
150
|
throw new node_util_1.UnreachableNodeState(node, "The accessor was expected to have an identifier or computed property name.");
|
|
151
151
|
}
|
|
152
152
|
function getIdentifierDespiteBrackets(node) {
|
|
153
|
-
if (ts.
|
|
153
|
+
if (ts.isIdentifierOrPrivateIdentifier(node) || ts.isElementAccessExpression(node)) {
|
|
154
154
|
return node.getText();
|
|
155
155
|
}
|
|
156
156
|
if (ts.isParenthesizedExpression(node)) {
|
|
@@ -188,7 +188,7 @@ function getFunctionNodeName(func) {
|
|
|
188
188
|
}
|
|
189
189
|
if (ts.isFunctionExpression(func)) {
|
|
190
190
|
const maybeIdentifier = func.getChildren()[1];
|
|
191
|
-
if (ts.
|
|
191
|
+
if (ts.isIdentifierOrPrivateIdentifier(maybeIdentifier)) {
|
|
192
192
|
return maybeIdentifier.getText();
|
|
193
193
|
}
|
|
194
194
|
else {
|
|
@@ -219,7 +219,7 @@ function getModuleDeclarationName(node) {
|
|
|
219
219
|
*/
|
|
220
220
|
function getMethodDeclarationName(node) {
|
|
221
221
|
for (const child of node.getChildren()) {
|
|
222
|
-
if (ts.
|
|
222
|
+
if (ts.isIdentifierOrPrivateIdentifier(child)) {
|
|
223
223
|
return [child.getText(), true];
|
|
224
224
|
}
|
|
225
225
|
if (ts.isComputedPropertyName(child)) {
|
|
@@ -236,7 +236,7 @@ function getTypeAliasName(node) {
|
|
|
236
236
|
}
|
|
237
237
|
function maybeGetFirstIdentifierName(node) {
|
|
238
238
|
const name = node.getChildren()
|
|
239
|
-
.find(child => ts.
|
|
239
|
+
.find(child => ts.isIdentifierOrPrivateIdentifier(child));
|
|
240
240
|
return name === null || name === void 0 ? void 0 : name.getText();
|
|
241
241
|
}
|
|
242
242
|
//# sourceMappingURL=node-naming.js.map
|