|
1 | 1 | import { stripIndent } from 'common-tags'
|
2 |
| -import { fromFixture } from 'eslint-etc' |
3 |
| -import rule, { ruleName, messageId } from '../../src/rules/no-typed-store' |
| 2 | +import rule, { |
| 3 | + messageId, |
| 4 | + noTypedStoreSuggest, |
| 5 | + ruleName, |
| 6 | +} from '../../src/rules/no-typed-store' |
4 | 7 | import { ruleTester } from '../utils'
|
5 | 8 |
|
6 | 9 | ruleTester().run(ruleName, rule, {
|
7 | 10 | valid: [
|
8 | 11 | stripIndent`
|
9 | 12 | export class Ok {
|
10 |
| - constructor(store: Store) |
| 13 | + constructor(store: Store) {} |
11 | 14 | }`,
|
12 | 15 | ],
|
13 | 16 | invalid: [
|
14 |
| - fromFixture( |
15 |
| - stripIndent` |
16 |
| - export class NotOk { |
17 |
| - constructor(store: Store<PersonsState>){} |
18 |
| - ~~~~~~~~~~~~~~~~~~~ [${messageId}] |
19 |
| - }`, |
20 |
| - ), |
21 |
| - fromFixture( |
22 |
| - stripIndent` |
23 |
| - export class NotOk2 { |
24 |
| - constructor(cdr: ChangeDetectionRef, private store: Store<CustomersState>){} |
25 |
| - ~~~~~~~~~~~~~~~~~~~~~ [${messageId}] |
26 |
| - }`, |
27 |
| - ), |
28 |
| - fromFixture( |
29 |
| - stripIndent` |
| 17 | + { |
| 18 | + code: stripIndent` |
| 19 | + export class NotOk1 { |
| 20 | + constructor(store: Store<PersonsState>) {} |
| 21 | + }`, |
| 22 | + errors: [ |
| 23 | + { |
| 24 | + column: 27, |
| 25 | + endColumn: 41, |
| 26 | + line: 2, |
| 27 | + messageId, |
| 28 | + suggestions: [ |
| 29 | + { |
| 30 | + messageId: noTypedStoreSuggest, |
| 31 | + output: stripIndent` |
| 32 | + export class NotOk1 { |
| 33 | + constructor(store: Store) {} |
| 34 | + }`, |
| 35 | + }, |
| 36 | + ], |
| 37 | + }, |
| 38 | + ], |
| 39 | + }, |
| 40 | + { |
| 41 | + code: stripIndent` |
| 42 | + export class NotOk2 { |
| 43 | + constructor(cdr: ChangeDetectionRef, private store: Store<CustomersState>) {} |
| 44 | + }`, |
| 45 | + errors: [ |
| 46 | + { |
| 47 | + column: 60, |
| 48 | + endColumn: 76, |
| 49 | + line: 2, |
| 50 | + messageId, |
| 51 | + suggestions: [ |
| 52 | + { |
| 53 | + messageId: noTypedStoreSuggest, |
| 54 | + output: stripIndent` |
| 55 | + export class NotOk2 { |
| 56 | + constructor(cdr: ChangeDetectionRef, private store: Store) {} |
| 57 | + }`, |
| 58 | + }, |
| 59 | + ], |
| 60 | + }, |
| 61 | + ], |
| 62 | + }, |
| 63 | + { |
| 64 | + code: stripIndent` |
30 | 65 | export class NotOk3 {
|
31 |
| - constructor(private store: Store<any>, private personsService: PersonsService){} |
32 |
| - ~~~~~~~~~~ [${messageId}] |
| 66 | + constructor(private store: Store<any>, private personsService: PersonsService) {} |
33 | 67 | }`,
|
34 |
| - ), |
35 |
| - fromFixture( |
36 |
| - stripIndent` |
| 68 | + errors: [ |
| 69 | + { |
| 70 | + column: 35, |
| 71 | + endColumn: 40, |
| 72 | + line: 2, |
| 73 | + messageId, |
| 74 | + suggestions: [ |
| 75 | + { |
| 76 | + messageId: noTypedStoreSuggest, |
| 77 | + output: stripIndent` |
| 78 | + export class NotOk3 { |
| 79 | + constructor(private store: Store, private personsService: PersonsService) {} |
| 80 | + }`, |
| 81 | + }, |
| 82 | + ], |
| 83 | + }, |
| 84 | + ], |
| 85 | + }, |
| 86 | + { |
| 87 | + code: stripIndent` |
37 | 88 | export class NotOk4 {
|
38 |
| - constructor(store: Store<{}>) |
39 |
| - ~~~~~~~~~ [${messageId}] |
| 89 | + constructor(store: Store<{}>) {} |
40 | 90 | }`,
|
41 |
| - ), |
42 |
| - fromFixture( |
43 |
| - stripIndent` |
| 91 | + errors: [ |
| 92 | + { |
| 93 | + column: 27, |
| 94 | + endColumn: 31, |
| 95 | + line: 2, |
| 96 | + messageId, |
| 97 | + suggestions: [ |
| 98 | + { |
| 99 | + messageId: noTypedStoreSuggest, |
| 100 | + output: stripIndent` |
| 101 | + export class NotOk4 { |
| 102 | + constructor(store: Store) {} |
| 103 | + }`, |
| 104 | + }, |
| 105 | + ], |
| 106 | + }, |
| 107 | + ], |
| 108 | + }, |
| 109 | + { |
| 110 | + code: stripIndent` |
44 | 111 | export class NotOk5 {
|
45 |
| - constructor(store: Store<object>) |
46 |
| - ~~~~~~~~~~~~~ [${messageId}] |
47 |
| - }`, |
48 |
| - ), |
| 112 | + constructor(store: Store<object>) {} |
| 113 | + }`, |
| 114 | + errors: [ |
| 115 | + { |
| 116 | + column: 27, |
| 117 | + endColumn: 35, |
| 118 | + line: 2, |
| 119 | + messageId, |
| 120 | + suggestions: [ |
| 121 | + { |
| 122 | + messageId: noTypedStoreSuggest, |
| 123 | + output: stripIndent` |
| 124 | + export class NotOk5 { |
| 125 | + constructor(store: Store) {} |
| 126 | + }`, |
| 127 | + }, |
| 128 | + ], |
| 129 | + }, |
| 130 | + ], |
| 131 | + }, |
49 | 132 | ],
|
50 | 133 | })
|
0 commit comments