Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Sep 25, 2020. It is now read-only.

Commit 01caad2

Browse files
armano2bradzacher
authored andcommitted
test(eslint-plugin): add missing test cases for rules (typescript-eslint#1402)
1 parent 3f2f3e8 commit 01caad2

18 files changed

+416
-303
lines changed

packages/eslint-plugin/src/rules/class-name-casing.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,13 @@ export default util.createRule<Options, MessageIds>({
6767
* @param decl The declaration
6868
* @param id The name of the declaration
6969
*/
70-
function report(decl: TSESTree.Node, id: TSESTree.Identifier): void {
70+
function report(
71+
decl:
72+
| TSESTree.ClassDeclaration
73+
| TSESTree.TSInterfaceDeclaration
74+
| TSESTree.ClassExpression,
75+
id: TSESTree.Identifier,
76+
): void {
7177
let friendlyName;
7278

7379
switch (decl.type) {
@@ -78,8 +84,6 @@ export default util.createRule<Options, MessageIds>({
7884
case AST_NODE_TYPES.TSInterfaceDeclaration:
7985
friendlyName = 'Interface';
8086
break;
81-
default:
82-
friendlyName = decl.type;
8387
}
8488

8589
context.report({

packages/eslint-plugin/src/rules/explicit-member-accessibility.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export default util.createRule<Options, MessageIds>({
183183

184184
/**
185185
* Checks that the parameter property has the desired accessibility modifiers set.
186-
* @param {TSESTree.TSParameterProperty} node The node representing a Parameter Property
186+
* @param node The node representing a Parameter Property
187187
*/
188188
function checkParameterPropertyAccessibilityModifier(
189189
node: TSESTree.TSParameterProperty,

packages/eslint-plugin/src/rules/no-array-constructor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default util.createRule({
1515
},
1616
fixable: 'code',
1717
messages: {
18-
useLiteral: 'The array literal notation [] is preferrable.',
18+
useLiteral: 'The array literal notation [] is preferable.',
1919
},
2020
schema: [],
2121
},

packages/eslint-plugin/src/rules/no-empty-interface.ts

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,33 +49,25 @@ export default util.createRule<Options, MessageIds>({
4949
return;
5050
}
5151

52-
if (!node.extends || node.extends.length === 0) {
52+
const extend = node.extends;
53+
if (!extend || extend.length === 0) {
5354
context.report({
5455
node: node.id,
5556
messageId: 'noEmpty',
5657
});
57-
} else if (node.extends.length === 1) {
58+
} else if (extend.length === 1) {
5859
// interface extends exactly 1 interface --> Report depending on rule setting
59-
if (allowSingleExtends) {
60-
return;
61-
} else {
60+
if (!allowSingleExtends) {
6261
context.report({
6362
node: node.id,
6463
messageId: 'noEmptyWithSuper',
65-
fix(fixer) {
66-
if (node.extends && node.extends.length) {
67-
return [
68-
fixer.replaceText(
69-
node,
70-
`type ${sourceCode.getText(
71-
node.id,
72-
)} = ${sourceCode.getText(node.extends[0])}`,
73-
),
74-
];
75-
}
76-
77-
return null;
78-
},
64+
fix: fixer =>
65+
fixer.replaceText(
66+
node,
67+
`type ${sourceCode.getText(node.id)} = ${sourceCode.getText(
68+
extend[0],
69+
)}`,
70+
),
7971
});
8072
}
8173
}

packages/eslint-plugin/src/rules/no-misused-new.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default util.createRule({
2222
defaultOptions: [],
2323
create(context) {
2424
/**
25-
* @param {ASTNode} node type to be inspected.
25+
* @param node type to be inspected.
2626
* @returns name of simple type or null
2727
*/
2828
function getTypeReferenceName(
@@ -48,8 +48,8 @@ export default util.createRule({
4848
}
4949

5050
/**
51-
* @param {ASTNode} parent parent node.
52-
* @param {ASTNode} returnType type to be compared
51+
* @param parent parent node.
52+
* @param returnType type to be compared
5353
*/
5454
function isMatchingParentType(
5555
parent: undefined | TSESTree.Node,

packages/eslint-plugin/src/rules/no-type-alias.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ export default util.createRule<Options, MessageIds>({
218218

219219
/**
220220
* Validates the node looking for aliases, callbacks and literals.
221-
* @param node the node to be validated.
222-
* @param compositionType the type of composition this alias is part of (null if not
221+
* @param type the type of composition this alias is part of (null if not
223222
* part of a composition)
224223
* @param isTopLevel a flag indicating this is the top level node.
225224
*/

packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export default util.createRule<Options, MessageIds>({
245245
node: TSESTree.TSTypeAssertion | TSESTree.TSAsExpression,
246246
): void {
247247
if (
248-
options?.typesToIgnore?.includes(
248+
options.typesToIgnore?.includes(
249249
sourceCode.getText(node.typeAnnotation),
250250
)
251251
) {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// used by no-throw-literal test case to validate custom error
2+
export class Error {}

0 commit comments

Comments
 (0)