Skip to content

Commit fa0b032

Browse files
authored
test(eslint-plugin): add missing test cases for rules (typescript-eslint#296)
1 parent 9f1d314 commit fa0b032

File tree

3 files changed

+35
-10
lines changed

3 files changed

+35
-10
lines changed

packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ export default util.createRule({
9090
const tsQualifier = esTreeNodeToTSNodeMap.get(qualifier);
9191
const tsName = esTreeNodeToTSNodeMap.get(name);
9292

93-
if (!(tsQualifier && tsName)) return false; // TODO: throw error?
94-
9593
const namespaceSymbol = checker.getSymbolAtLocation(tsQualifier);
9694

9795
if (
@@ -145,16 +143,11 @@ export default util.createRule({
145143
}
146144

147145
function enterDeclaration(node: TSESTree.Node): void {
148-
const tsDeclaration = esTreeNodeToTSNodeMap.get(node);
149-
if (tsDeclaration) {
150-
namespacesInScope.push(tsDeclaration);
151-
}
146+
namespacesInScope.push(esTreeNodeToTSNodeMap.get(node));
152147
}
153148

154-
function exitDeclaration(node: TSESTree.Node) {
155-
if (esTreeNodeToTSNodeMap.has(node)) {
156-
namespacesInScope.pop();
157-
}
149+
function exitDeclaration() {
150+
namespacesInScope.pop();
158151
}
159152

160153
function resetCurrentNamespaceExpression(node: TSESTree.Node): void {

packages/eslint-plugin/tests/rules/array-type.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ ruleTester.run('array-type', rule, {
4040
code: 'let a: Array<{ foo: Array<Bar> }> = []',
4141
options: ['generic']
4242
},
43+
{
44+
code: `let fooVar: Array;`,
45+
options: ['generic']
46+
},
4347
{
4448
code: `function foo (a: Array<Bar>): Array<Bar> {}`,
4549
options: ['generic']
@@ -622,6 +626,30 @@ let yyyy: Arr<Arr<string>[][]> = [[[["2"]]]];`,
622626
}
623627
]
624628
},
629+
{
630+
code: `let fooVar: Array[];`,
631+
options: ['array'],
632+
errors: [
633+
{
634+
messageId: 'errorStringArray',
635+
data: { type: 'any' },
636+
line: 1,
637+
column: 13
638+
}
639+
]
640+
},
641+
{
642+
code: `let fooVar: Array[];`,
643+
options: ['array-simple'],
644+
errors: [
645+
{
646+
messageId: 'errorStringArraySimple',
647+
data: { type: 'any' },
648+
line: 1,
649+
column: 13
650+
}
651+
]
652+
},
625653
{
626654
code: `let x: Array<number> = [1] as number[];`,
627655
output: `let x: Array<number> = [1] as Array<number>;`,

packages/eslint-plugin/tests/rules/type-annotation-spacing.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ type Foo = {
8484
greet: (name: string) => string;
8585
}
8686
`,
87+
`
88+
const isString = (): x is string => {
89+
}
90+
`,
8791
{
8892
code: 'let foo: string;',
8993
options: [{ after: true }]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy