Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit c50b78a

Browse files
committed
Migrate typescript-eslint-parser to 21.0.1
1 parent e550d5e commit c50b78a

9 files changed

+212
-406
lines changed

lib/rules/class-name-casing.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ module.exports = {
5454
case "ClassExpression":
5555
friendlyName = "Class";
5656
break;
57+
case "TSAbstractClassDeclaration":
58+
friendlyName = "Abstract class";
59+
break;
5760
case "TSInterfaceDeclaration":
5861
friendlyName = "Interface";
5962
break;
@@ -72,7 +75,9 @@ module.exports = {
7275
//----------------------------------------------------------------------
7376

7477
return {
75-
"ClassDeclaration, TSInterfaceDeclaration"(node) {
78+
"ClassDeclaration, TSInterfaceDeclaration, TSAbstractClassDeclaration, ClassExpression"(
79+
node
80+
) {
7681
// class expressions (i.e. export default class {}) are OK
7782
if (node.id && !isPascalCase(node.id.name)) {
7883
report(node);
@@ -82,9 +87,7 @@ module.exports = {
8287
if (node.init && node.init.type === "ClassExpression") {
8388
const id = node.id;
8489

85-
if (node.init.id && !isPascalCase(node.init.id.name)) {
86-
report(node.init);
87-
} else if (id && !isPascalCase(id.name)) {
90+
if (!node.init.id && id && !isPascalCase(id.name)) {
8891
report(node.init, id);
8992
}
9093
}

lib/rules/no-explicit-any.js

+3-73
Original file line numberDiff line numberDiff line change
@@ -18,89 +18,19 @@ module.exports = {
1818
extraDescription: [util.tslintRule("no-any")],
1919
category: "TypeScript",
2020
url:
21-
"https://github.com/nzakas/eslint-plugin-typescript/blob/master/docs/rules/no-explicit-any.md",
21+
"https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/no-explicit-any.md",
2222
},
2323
schema: [],
2424
},
2525

2626
create(context) {
27-
//----------------------------------------------------------------------
28-
// Helpers
29-
//----------------------------------------------------------------------
30-
31-
/**
32-
* Checks if the node has a type annotation of type any.
33-
* @param {ASTNode} node The node being validated.
34-
* @returns {void}
35-
* @private
36-
*/
37-
function checkGenericNodeForAnnotation(node) {
38-
if (node.type === "TSAnyKeyword") {
27+
return {
28+
TSAnyKeyword(node) {
3929
context.report({
4030
node,
4131
message: "Unexpected any. Specify a different type.",
4232
});
43-
} else if (node.type === "TSArrayType") {
44-
checkGenericNodeForAnnotation(node.elementType);
45-
} else if (
46-
node.type === "TSUnionType" ||
47-
node.type === "TSIntersectionType"
48-
) {
49-
node.types.forEach(type => {
50-
checkGenericNodeForAnnotation(type);
51-
});
52-
} else if (node.type === "TSTypeReference") {
53-
if (node.typeParameters) {
54-
// handles generics
55-
node.typeParameters.params.forEach(param => {
56-
checkGenericNodeForAnnotation(param);
57-
});
58-
} else if (node.typeName) {
59-
// handles non generics
60-
checkGenericNodeForAnnotation(node.typeName);
61-
}
62-
} else if (node.type === "GenericTypeAnnotation") {
63-
if (node.typeParameters) {
64-
node.typeParameters.params.forEach(param => {
65-
checkGenericNodeForAnnotation(param);
66-
});
67-
} else {
68-
checkGenericNodeForAnnotation(node.id);
69-
}
70-
}
71-
}
72-
73-
/**
74-
* Checks if a function node used the any type
75-
* @param {ASTNode} node The node representing a function.
76-
* @returns {void}
77-
* @private
78-
*/
79-
function checkFunctionReturnTypeForAnnotation(node) {
80-
if (node.returnType) {
81-
checkGenericNodeForAnnotation(node.returnType.typeAnnotation);
82-
}
83-
}
84-
85-
//----------------------------------------------------------------------
86-
// Public
87-
//----------------------------------------------------------------------
88-
return {
89-
Identifier(node) {
90-
if (node.typeAnnotation) {
91-
checkGenericNodeForAnnotation(
92-
node.typeAnnotation.typeAnnotation
93-
);
94-
}
95-
},
96-
TSTypeAnnotation(node) {
97-
if (node.typeAnnotation) {
98-
checkGenericNodeForAnnotation(node.typeAnnotation);
99-
}
10033
},
101-
FunctionDeclaration: checkFunctionReturnTypeForAnnotation,
102-
FunctionExpression: checkFunctionReturnTypeForAnnotation,
103-
ArrowFunctionExpression: checkFunctionReturnTypeForAnnotation,
10434
};
10535
},
10636
};

0 commit comments

Comments
 (0)