,
45 | property: (
46 | name: string,
47 | value?: P
48 | ) => ExpectChain
& ((name: string) => ExpectChain),
49 |
50 | length: (value: number) => ExpectChain | ExpectChain,
51 | lengthOf: (value: number) => ExpectChain,
52 |
53 | match: (regex: RegExp) => ExpectChain,
54 | string: (string: string) => ExpectChain,
55 |
56 | key: (key: string) => ExpectChain,
57 | keys: (
58 | key: string | Array,
59 | ...keys: Array
60 | ) => ExpectChain,
61 |
62 | throw: (
63 | err?: Class | Error | RegExp | string,
64 | errMsgMatcher?: RegExp | string,
65 | msg?: string
66 | ) => ExpectChain,
67 |
68 | respondTo: (method: string) => ExpectChain,
69 | itself: ExpectChain,
70 |
71 | satisfy: (method: (value: T) => boolean) => ExpectChain,
72 |
73 | closeTo: (expected: T & number, delta: number) => ExpectChain,
74 |
75 | members: (set: mixed) => ExpectChain,
76 | oneOf: (list: Array) => ExpectChain,
77 |
78 | change: (obj: mixed, key: string) => ExpectChain,
79 | increase: (obj: mixed, key: string) => ExpectChain,
80 | decrease: (obj: mixed, key: string) => ExpectChain,
81 |
82 | // dirty-chai
83 | ok: () => ExpectChain,
84 | true: () => ExpectChain,
85 | false: () => ExpectChain,
86 | null: () => ExpectChain,
87 | undefined: () => ExpectChain,
88 | exist: () => ExpectChain,
89 | empty: () => ExpectChain,
90 |
91 | extensible: () => ExpectChain,
92 | sealed: () => ExpectChain,
93 | frozen: () => ExpectChain,
94 |
95 | // chai-immutable
96 | size: (n: number) => ExpectChain,
97 |
98 | // sinon-chai
99 | called: () => ExpectChain,
100 | callCount: (n: number) => ExpectChain,
101 | calledOnce: () => ExpectChain,
102 | calledTwice: () => ExpectChain,
103 | calledThrice: () => ExpectChain,
104 | calledBefore: (spy: mixed) => ExpectChain,
105 | calledAfter: (spy: mixed) => ExpectChain,
106 | calledWith: (...args: Array) => ExpectChain,
107 | calledWithMatch: (...args: Array) => ExpectChain,
108 | calledWithExactly: (...args: Array) => ExpectChain,
109 |
110 | // chai-as-promised
111 | eventually: ExpectChain,
112 | resolvedWith: (value: mixed) => Promise & ExpectChain,
113 | resolved: () => Promise & ExpectChain,
114 | rejectedWith: (value: mixed) => Promise & ExpectChain,
115 | rejected: () => Promise & ExpectChain,
116 | notify: (callback: () => mixed) => ExpectChain,
117 | fulfilled: () => Promise & ExpectChain,
118 |
119 | // chai-subset
120 | containSubset: (obj: Object | Object[]) => ExpectChain
121 | };
122 |
123 | declare function expect(actual: T): ExpectChain;
124 |
125 | declare function use(plugin: (chai: Object, utils: Object) => void): void;
126 |
127 | declare class assert {
128 | static (expression: mixed, message?: string): void,
129 | static fail(
130 | actual: mixed,
131 | expected: mixed,
132 | message?: string,
133 | operator?: string
134 | ): void,
135 |
136 | static isOk(object: mixed, message?: string): void,
137 | static isNotOk(object: mixed, message?: string): void,
138 |
139 | static equal(actual: mixed, expected: mixed, message?: string): void,
140 | static notEqual(actual: mixed, expected: mixed, message?: string): void,
141 |
142 | static strictEqual(act: mixed, exp: mixed, msg?: string): void,
143 | static notStrictEqual(act: mixed, exp: mixed, msg?: string): void,
144 |
145 | static deepEqual(act: mixed, exp: mixed, msg?: string): void,
146 | static notDeepEqual(act: mixed, exp: mixed, msg?: string): void,
147 |
148 | static ok(val: mixed, msg?: string): void,
149 | static isTrue(val: mixed, msg?: string): void,
150 | static isNotTrue(val: mixed, msg?: string): void,
151 | static isFalse(val: mixed, msg?: string): void,
152 | static isNotFalse(val: mixed, msg?: string): void,
153 |
154 | static isNull(val: mixed, msg?: string): void,
155 | static isNotNull(val: mixed, msg?: string): void,
156 |
157 | static isUndefined(val: mixed, msg?: string): void,
158 | static isDefined(val: mixed, msg?: string): void,
159 |
160 | static isNaN(val: mixed, msg?: string): void,
161 | static isNotNaN(val: mixed, msg?: string): void,
162 |
163 | static isAbove(val: number, abv: number, msg?: string): void,
164 | static isBelow(val: number, blw: number, msg?: string): void,
165 |
166 | static isAtMost(val: number, atmst: number, msg?: string): void,
167 | static isAtLeast(val: number, atlst: number, msg?: string): void,
168 |
169 | static isFunction(val: mixed, msg?: string): void,
170 | static isNotFunction(val: mixed, msg?: string): void,
171 |
172 | static isObject(val: mixed, msg?: string): void,
173 | static isNotObject(val: mixed, msg?: string): void,
174 |
175 | static isArray(val: mixed, msg?: string): void,
176 | static isNotArray(val: mixed, msg?: string): void,
177 |
178 | static isString(val: mixed, msg?: string): void,
179 | static isNotString(val: mixed, msg?: string): void,
180 |
181 | static isNumber(val: mixed, msg?: string): void,
182 | static isNotNumber(val: mixed, msg?: string): void,
183 |
184 | static isBoolean(val: mixed, msg?: string): void,
185 | static isNotBoolean(val: mixed, msg?: string): void,
186 |
187 | static typeOf(val: mixed, type: string, msg?: string): void,
188 | static notTypeOf(val: mixed, type: string, msg?: string): void,
189 |
190 | static instanceOf(val: mixed, constructor: Function, msg?: string): void,
191 | static notInstanceOf(val: mixed, constructor: Function, msg?: string): void,
192 |
193 | static include(exp: string, inc: mixed, msg?: string): void,
194 | static include(exp: Array, inc: T, msg?: string): void,
195 |
196 | static notInclude(exp: string, inc: mixed, msg?: string): void,
197 | static notInclude(exp: Array, inc: T, msg?: string): void,
198 |
199 | static match(exp: mixed, re: RegExp, msg?: string): void,
200 | static notMatch(exp: mixed, re: RegExp, msg?: string): void,
201 |
202 | static property(obj: Object, prop: string, msg?: string): void,
203 | static notProperty(obj: Object, prop: string, msg?: string): void,
204 | static deepProperty(obj: Object, prop: string, msg?: string): void,
205 | static notDeepProperty(obj: Object, prop: string, msg?: string): void,
206 |
207 | static propertyVal(
208 | obj: Object,
209 | prop: string,
210 | val: mixed,
211 | msg?: string
212 | ): void,
213 | static propertyNotVal(
214 | obj: Object,
215 | prop: string,
216 | val: mixed,
217 | msg?: string
218 | ): void,
219 |
220 | static deepPropertyVal(
221 | obj: Object,
222 | prop: string,
223 | val: mixed,
224 | msg?: string
225 | ): void,
226 | static deepPropertyNotVal(
227 | obj: Object,
228 | prop: string,
229 | val: mixed,
230 | msg?: string
231 | ): void,
232 |
233 | static lengthOf(exp: mixed, len: number, msg?: string): void,
234 |
235 | static throws(
236 | func: () => any,
237 | err?: Class | Error | RegExp | string,
238 | errorMsgMatcher?: string | RegExp,
239 | msg?: string
240 | ): void,
241 | static doesNotThrow(
242 | func: () => any,
243 | err?: Class | Error | RegExp | string,
244 | errorMsgMatcher?: string | RegExp,
245 | msg?: string
246 | ): void
247 | }
248 |
249 | declare var config: {
250 | includeStack: boolean,
251 | showDiff: boolean,
252 | truncateThreshold: number
253 | };
254 | }
255 |
--------------------------------------------------------------------------------
/flow-typed/npm/cross-env_vx.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: 5761b13ae4eeba63c9dcca6e7ab147b6
2 | // flow-typed version: <>/cross-env_v^5.0.5/flow_v0.55.0
3 |
4 | /**
5 | * This is an autogenerated libdef stub for:
6 | *
7 | * 'cross-env'
8 | *
9 | * Fill this stub out by replacing all the `any` types.
10 | *
11 | * Once filled out, we encourage you to share your work with the
12 | * community by sending a pull request to:
13 | * https://github.com/flowtype/flow-typed
14 | */
15 |
16 | declare module 'cross-env' {
17 | declare module.exports: any;
18 | }
19 |
20 | /**
21 | * We include stubs for each file inside this npm package in case you need to
22 | * require those files directly. Feel free to delete any files that aren't
23 | * needed.
24 | */
25 | declare module 'cross-env/dist/bin/cross-env-shell' {
26 | declare module.exports: any;
27 | }
28 |
29 | declare module 'cross-env/dist/bin/cross-env' {
30 | declare module.exports: any;
31 | }
32 |
33 | declare module 'cross-env/dist/command' {
34 | declare module.exports: any;
35 | }
36 |
37 | declare module 'cross-env/dist/index' {
38 | declare module.exports: any;
39 | }
40 |
41 | declare module 'cross-env/dist/variable' {
42 | declare module.exports: any;
43 | }
44 |
45 | // Filename aliases
46 | declare module 'cross-env/dist/bin/cross-env-shell.js' {
47 | declare module.exports: $Exports<'cross-env/dist/bin/cross-env-shell'>;
48 | }
49 | declare module 'cross-env/dist/bin/cross-env.js' {
50 | declare module.exports: $Exports<'cross-env/dist/bin/cross-env'>;
51 | }
52 | declare module 'cross-env/dist/command.js' {
53 | declare module.exports: $Exports<'cross-env/dist/command'>;
54 | }
55 | declare module 'cross-env/dist/index.js' {
56 | declare module.exports: $Exports<'cross-env/dist/index'>;
57 | }
58 | declare module 'cross-env/dist/variable.js' {
59 | declare module.exports: $Exports<'cross-env/dist/variable'>;
60 | }
61 |
--------------------------------------------------------------------------------
/flow-typed/npm/cross-spawn_vx.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: e82f4545224c83a24063f8e7ed24d60d
2 | // flow-typed version: <>/cross-spawn_v^5.1.0/flow_v0.55.0
3 |
4 | /**
5 | * This is an autogenerated libdef stub for:
6 | *
7 | * 'cross-spawn'
8 | *
9 | * Fill this stub out by replacing all the `any` types.
10 | *
11 | * Once filled out, we encourage you to share your work with the
12 | * community by sending a pull request to:
13 | * https://github.com/flowtype/flow-typed
14 | */
15 |
16 | declare module 'cross-spawn' {
17 | declare module.exports: any;
18 | }
19 |
20 | /**
21 | * We include stubs for each file inside this npm package in case you need to
22 | * require those files directly. Feel free to delete any files that aren't
23 | * needed.
24 | */
25 | declare module 'cross-spawn/lib/enoent' {
26 | declare module.exports: any;
27 | }
28 |
29 | declare module 'cross-spawn/lib/parse' {
30 | declare module.exports: any;
31 | }
32 |
33 | declare module 'cross-spawn/lib/util/escapeArgument' {
34 | declare module.exports: any;
35 | }
36 |
37 | declare module 'cross-spawn/lib/util/escapeCommand' {
38 | declare module.exports: any;
39 | }
40 |
41 | declare module 'cross-spawn/lib/util/hasEmptyArgumentBug' {
42 | declare module.exports: any;
43 | }
44 |
45 | declare module 'cross-spawn/lib/util/readShebang' {
46 | declare module.exports: any;
47 | }
48 |
49 | declare module 'cross-spawn/lib/util/resolveCommand' {
50 | declare module.exports: any;
51 | }
52 |
53 | // Filename aliases
54 | declare module 'cross-spawn/index' {
55 | declare module.exports: $Exports<'cross-spawn'>;
56 | }
57 | declare module 'cross-spawn/index.js' {
58 | declare module.exports: $Exports<'cross-spawn'>;
59 | }
60 | declare module 'cross-spawn/lib/enoent.js' {
61 | declare module.exports: $Exports<'cross-spawn/lib/enoent'>;
62 | }
63 | declare module 'cross-spawn/lib/parse.js' {
64 | declare module.exports: $Exports<'cross-spawn/lib/parse'>;
65 | }
66 | declare module 'cross-spawn/lib/util/escapeArgument.js' {
67 | declare module.exports: $Exports<'cross-spawn/lib/util/escapeArgument'>;
68 | }
69 | declare module 'cross-spawn/lib/util/escapeCommand.js' {
70 | declare module.exports: $Exports<'cross-spawn/lib/util/escapeCommand'>;
71 | }
72 | declare module 'cross-spawn/lib/util/hasEmptyArgumentBug.js' {
73 | declare module.exports: $Exports<'cross-spawn/lib/util/hasEmptyArgumentBug'>;
74 | }
75 | declare module 'cross-spawn/lib/util/readShebang.js' {
76 | declare module.exports: $Exports<'cross-spawn/lib/util/readShebang'>;
77 | }
78 | declare module 'cross-spawn/lib/util/resolveCommand.js' {
79 | declare module.exports: $Exports<'cross-spawn/lib/util/resolveCommand'>;
80 | }
81 |
--------------------------------------------------------------------------------
/flow-typed/npm/eslint-config-bliss_vx.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: e672ed43c2ec37273eb40f61a5b763b4
2 | // flow-typed version: <>/eslint-config-bliss_v^1.0.13/flow_v0.55.0
3 |
4 | /**
5 | * This is an autogenerated libdef stub for:
6 | *
7 | * 'eslint-config-bliss'
8 | *
9 | * Fill this stub out by replacing all the `any` types.
10 | *
11 | * Once filled out, we encourage you to share your work with the
12 | * community by sending a pull request to:
13 | * https://github.com/flowtype/flow-typed
14 | */
15 |
16 | declare module 'eslint-config-bliss' {
17 | declare module.exports: any;
18 | }
19 |
--------------------------------------------------------------------------------
/flow-typed/npm/eslint-config-prettier_vx.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: d0678cafc582a50d9b252566f0bd84bf
2 | // flow-typed version: <>/eslint-config-prettier_v^2.6.0/flow_v0.55.0
3 |
4 | /**
5 | * This is an autogenerated libdef stub for:
6 | *
7 | * 'eslint-config-prettier'
8 | *
9 | * Fill this stub out by replacing all the `any` types.
10 | *
11 | * Once filled out, we encourage you to share your work with the
12 | * community by sending a pull request to:
13 | * https://github.com/flowtype/flow-typed
14 | */
15 |
16 | declare module 'eslint-config-prettier' {
17 | declare module.exports: any;
18 | }
19 |
20 | /**
21 | * We include stubs for each file inside this npm package in case you need to
22 | * require those files directly. Feel free to delete any files that aren't
23 | * needed.
24 | */
25 | declare module 'eslint-config-prettier/bin/cli' {
26 | declare module.exports: any;
27 | }
28 |
29 | declare module 'eslint-config-prettier/bin/validators' {
30 | declare module.exports: any;
31 | }
32 |
33 | declare module 'eslint-config-prettier/flowtype' {
34 | declare module.exports: any;
35 | }
36 |
37 | declare module 'eslint-config-prettier/react' {
38 | declare module.exports: any;
39 | }
40 |
41 | declare module 'eslint-config-prettier/standard' {
42 | declare module.exports: any;
43 | }
44 |
45 | // Filename aliases
46 | declare module 'eslint-config-prettier/bin/cli.js' {
47 | declare module.exports: $Exports<'eslint-config-prettier/bin/cli'>;
48 | }
49 | declare module 'eslint-config-prettier/bin/validators.js' {
50 | declare module.exports: $Exports<'eslint-config-prettier/bin/validators'>;
51 | }
52 | declare module 'eslint-config-prettier/flowtype.js' {
53 | declare module.exports: $Exports<'eslint-config-prettier/flowtype'>;
54 | }
55 | declare module 'eslint-config-prettier/index' {
56 | declare module.exports: $Exports<'eslint-config-prettier'>;
57 | }
58 | declare module 'eslint-config-prettier/index.js' {
59 | declare module.exports: $Exports<'eslint-config-prettier'>;
60 | }
61 | declare module 'eslint-config-prettier/react.js' {
62 | declare module.exports: $Exports<'eslint-config-prettier/react'>;
63 | }
64 | declare module 'eslint-config-prettier/standard.js' {
65 | declare module.exports: $Exports<'eslint-config-prettier/standard'>;
66 | }
67 |
--------------------------------------------------------------------------------
/flow-typed/npm/eslint-formatter-pretty_vx.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: 99dd6e4d352a6ff8ac8f0331237d3d0b
2 | // flow-typed version: <>/eslint-formatter-pretty_v^1.3.0/flow_v0.55.0
3 |
4 | /**
5 | * This is an autogenerated libdef stub for:
6 | *
7 | * 'eslint-formatter-pretty'
8 | *
9 | * Fill this stub out by replacing all the `any` types.
10 | *
11 | * Once filled out, we encourage you to share your work with the
12 | * community by sending a pull request to:
13 | * https://github.com/flowtype/flow-typed
14 | */
15 |
16 | declare module 'eslint-formatter-pretty' {
17 | declare module.exports: any;
18 | }
19 |
20 | /**
21 | * We include stubs for each file inside this npm package in case you need to
22 | * require those files directly. Feel free to delete any files that aren't
23 | * needed.
24 | */
25 |
26 |
27 | // Filename aliases
28 | declare module 'eslint-formatter-pretty/index' {
29 | declare module.exports: $Exports<'eslint-formatter-pretty'>;
30 | }
31 | declare module 'eslint-formatter-pretty/index.js' {
32 | declare module.exports: $Exports<'eslint-formatter-pretty'>;
33 | }
34 |
--------------------------------------------------------------------------------
/flow-typed/npm/eslint-nibble-ignore_vx.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: 3a0139c4b686428d360cb6afbf18764d
2 | // flow-typed version: <>/eslint-nibble-ignore_v^3.0.0/flow_v0.55.0
3 |
4 | /**
5 | * This is an autogenerated libdef stub for:
6 | *
7 | * 'eslint-nibble-ignore'
8 | *
9 | * Fill this stub out by replacing all the `any` types.
10 | *
11 | * Once filled out, we encourage you to share your work with the
12 | * community by sending a pull request to:
13 | * https://github.com/flowtype/flow-typed
14 | */
15 |
16 | declare module 'eslint-nibble-ignore' {
17 | declare module.exports: any;
18 | }
19 |
20 | /**
21 | * We include stubs for each file inside this npm package in case you need to
22 | * require those files directly. Feel free to delete any files that aren't
23 | * needed.
24 | */
25 | declare module 'eslint-nibble-ignore/bin/eslint-nibble' {
26 | declare module.exports: any;
27 | }
28 |
29 | declare module 'eslint-nibble-ignore/lib/cli' {
30 | declare module.exports: any;
31 | }
32 |
33 | declare module 'eslint-nibble-ignore/lib/config/formatters' {
34 | declare module.exports: any;
35 | }
36 |
37 | declare module 'eslint-nibble-ignore/lib/config/options' {
38 | declare module.exports: any;
39 | }
40 |
41 | declare module 'eslint-nibble-ignore/lib/nibbler' {
42 | declare module.exports: any;
43 | }
44 |
45 | // Filename aliases
46 | declare module 'eslint-nibble-ignore/bin/eslint-nibble.js' {
47 | declare module.exports: $Exports<'eslint-nibble-ignore/bin/eslint-nibble'>;
48 | }
49 | declare module 'eslint-nibble-ignore/index' {
50 | declare module.exports: $Exports<'eslint-nibble-ignore'>;
51 | }
52 | declare module 'eslint-nibble-ignore/index.js' {
53 | declare module.exports: $Exports<'eslint-nibble-ignore'>;
54 | }
55 | declare module 'eslint-nibble-ignore/lib/cli.js' {
56 | declare module.exports: $Exports<'eslint-nibble-ignore/lib/cli'>;
57 | }
58 | declare module 'eslint-nibble-ignore/lib/config/formatters.js' {
59 | declare module.exports: $Exports<'eslint-nibble-ignore/lib/config/formatters'>;
60 | }
61 | declare module 'eslint-nibble-ignore/lib/config/options.js' {
62 | declare module.exports: $Exports<'eslint-nibble-ignore/lib/config/options'>;
63 | }
64 | declare module 'eslint-nibble-ignore/lib/nibbler.js' {
65 | declare module.exports: $Exports<'eslint-nibble-ignore/lib/nibbler'>;
66 | }
67 |
--------------------------------------------------------------------------------
/flow-typed/npm/eslint-plugin-import_vx.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: 5d724bb54b7f755d333168a8f6684d9c
2 | // flow-typed version: <>/eslint-plugin-import_v^2.7.0/flow_v0.55.0
3 |
4 | /**
5 | * This is an autogenerated libdef stub for:
6 | *
7 | * 'eslint-plugin-import'
8 | *
9 | * Fill this stub out by replacing all the `any` types.
10 | *
11 | * Once filled out, we encourage you to share your work with the
12 | * community by sending a pull request to:
13 | * https://github.com/flowtype/flow-typed
14 | */
15 |
16 | declare module 'eslint-plugin-import' {
17 | declare module.exports: any;
18 | }
19 |
20 | /**
21 | * We include stubs for each file inside this npm package in case you need to
22 | * require those files directly. Feel free to delete any files that aren't
23 | * needed.
24 | */
25 | declare module 'eslint-plugin-import/config/electron' {
26 | declare module.exports: any;
27 | }
28 |
29 | declare module 'eslint-plugin-import/config/errors' {
30 | declare module.exports: any;
31 | }
32 |
33 | declare module 'eslint-plugin-import/config/react-native' {
34 | declare module.exports: any;
35 | }
36 |
37 | declare module 'eslint-plugin-import/config/react' {
38 | declare module.exports: any;
39 | }
40 |
41 | declare module 'eslint-plugin-import/config/recommended' {
42 | declare module.exports: any;
43 | }
44 |
45 | declare module 'eslint-plugin-import/config/stage-0' {
46 | declare module.exports: any;
47 | }
48 |
49 | declare module 'eslint-plugin-import/config/warnings' {
50 | declare module.exports: any;
51 | }
52 |
53 | declare module 'eslint-plugin-import/lib/core/importType' {
54 | declare module.exports: any;
55 | }
56 |
57 | declare module 'eslint-plugin-import/lib/core/staticRequire' {
58 | declare module.exports: any;
59 | }
60 |
61 | declare module 'eslint-plugin-import/lib/ExportMap' {
62 | declare module.exports: any;
63 | }
64 |
65 | declare module 'eslint-plugin-import/lib/importDeclaration' {
66 | declare module.exports: any;
67 | }
68 |
69 | declare module 'eslint-plugin-import/lib/index' {
70 | declare module.exports: any;
71 | }
72 |
73 | declare module 'eslint-plugin-import/lib/rules/default' {
74 | declare module.exports: any;
75 | }
76 |
77 | declare module 'eslint-plugin-import/lib/rules/export' {
78 | declare module.exports: any;
79 | }
80 |
81 | declare module 'eslint-plugin-import/lib/rules/extensions' {
82 | declare module.exports: any;
83 | }
84 |
85 | declare module 'eslint-plugin-import/lib/rules/first' {
86 | declare module.exports: any;
87 | }
88 |
89 | declare module 'eslint-plugin-import/lib/rules/imports-first' {
90 | declare module.exports: any;
91 | }
92 |
93 | declare module 'eslint-plugin-import/lib/rules/max-dependencies' {
94 | declare module.exports: any;
95 | }
96 |
97 | declare module 'eslint-plugin-import/lib/rules/named' {
98 | declare module.exports: any;
99 | }
100 |
101 | declare module 'eslint-plugin-import/lib/rules/namespace' {
102 | declare module.exports: any;
103 | }
104 |
105 | declare module 'eslint-plugin-import/lib/rules/newline-after-import' {
106 | declare module.exports: any;
107 | }
108 |
109 | declare module 'eslint-plugin-import/lib/rules/no-absolute-path' {
110 | declare module.exports: any;
111 | }
112 |
113 | declare module 'eslint-plugin-import/lib/rules/no-amd' {
114 | declare module.exports: any;
115 | }
116 |
117 | declare module 'eslint-plugin-import/lib/rules/no-anonymous-default-export' {
118 | declare module.exports: any;
119 | }
120 |
121 | declare module 'eslint-plugin-import/lib/rules/no-commonjs' {
122 | declare module.exports: any;
123 | }
124 |
125 | declare module 'eslint-plugin-import/lib/rules/no-deprecated' {
126 | declare module.exports: any;
127 | }
128 |
129 | declare module 'eslint-plugin-import/lib/rules/no-duplicates' {
130 | declare module.exports: any;
131 | }
132 |
133 | declare module 'eslint-plugin-import/lib/rules/no-dynamic-require' {
134 | declare module.exports: any;
135 | }
136 |
137 | declare module 'eslint-plugin-import/lib/rules/no-extraneous-dependencies' {
138 | declare module.exports: any;
139 | }
140 |
141 | declare module 'eslint-plugin-import/lib/rules/no-internal-modules' {
142 | declare module.exports: any;
143 | }
144 |
145 | declare module 'eslint-plugin-import/lib/rules/no-mutable-exports' {
146 | declare module.exports: any;
147 | }
148 |
149 | declare module 'eslint-plugin-import/lib/rules/no-named-as-default-member' {
150 | declare module.exports: any;
151 | }
152 |
153 | declare module 'eslint-plugin-import/lib/rules/no-named-as-default' {
154 | declare module.exports: any;
155 | }
156 |
157 | declare module 'eslint-plugin-import/lib/rules/no-named-default' {
158 | declare module.exports: any;
159 | }
160 |
161 | declare module 'eslint-plugin-import/lib/rules/no-namespace' {
162 | declare module.exports: any;
163 | }
164 |
165 | declare module 'eslint-plugin-import/lib/rules/no-nodejs-modules' {
166 | declare module.exports: any;
167 | }
168 |
169 | declare module 'eslint-plugin-import/lib/rules/no-restricted-paths' {
170 | declare module.exports: any;
171 | }
172 |
173 | declare module 'eslint-plugin-import/lib/rules/no-unassigned-import' {
174 | declare module.exports: any;
175 | }
176 |
177 | declare module 'eslint-plugin-import/lib/rules/no-unresolved' {
178 | declare module.exports: any;
179 | }
180 |
181 | declare module 'eslint-plugin-import/lib/rules/no-webpack-loader-syntax' {
182 | declare module.exports: any;
183 | }
184 |
185 | declare module 'eslint-plugin-import/lib/rules/order' {
186 | declare module.exports: any;
187 | }
188 |
189 | declare module 'eslint-plugin-import/lib/rules/prefer-default-export' {
190 | declare module.exports: any;
191 | }
192 |
193 | declare module 'eslint-plugin-import/lib/rules/unambiguous' {
194 | declare module.exports: any;
195 | }
196 |
197 | declare module 'eslint-plugin-import/memo-parser/index' {
198 | declare module.exports: any;
199 | }
200 |
201 | // Filename aliases
202 | declare module 'eslint-plugin-import/config/electron.js' {
203 | declare module.exports: $Exports<'eslint-plugin-import/config/electron'>;
204 | }
205 | declare module 'eslint-plugin-import/config/errors.js' {
206 | declare module.exports: $Exports<'eslint-plugin-import/config/errors'>;
207 | }
208 | declare module 'eslint-plugin-import/config/react-native.js' {
209 | declare module.exports: $Exports<'eslint-plugin-import/config/react-native'>;
210 | }
211 | declare module 'eslint-plugin-import/config/react.js' {
212 | declare module.exports: $Exports<'eslint-plugin-import/config/react'>;
213 | }
214 | declare module 'eslint-plugin-import/config/recommended.js' {
215 | declare module.exports: $Exports<'eslint-plugin-import/config/recommended'>;
216 | }
217 | declare module 'eslint-plugin-import/config/stage-0.js' {
218 | declare module.exports: $Exports<'eslint-plugin-import/config/stage-0'>;
219 | }
220 | declare module 'eslint-plugin-import/config/warnings.js' {
221 | declare module.exports: $Exports<'eslint-plugin-import/config/warnings'>;
222 | }
223 | declare module 'eslint-plugin-import/lib/core/importType.js' {
224 | declare module.exports: $Exports<'eslint-plugin-import/lib/core/importType'>;
225 | }
226 | declare module 'eslint-plugin-import/lib/core/staticRequire.js' {
227 | declare module.exports: $Exports<'eslint-plugin-import/lib/core/staticRequire'>;
228 | }
229 | declare module 'eslint-plugin-import/lib/ExportMap.js' {
230 | declare module.exports: $Exports<'eslint-plugin-import/lib/ExportMap'>;
231 | }
232 | declare module 'eslint-plugin-import/lib/importDeclaration.js' {
233 | declare module.exports: $Exports<'eslint-plugin-import/lib/importDeclaration'>;
234 | }
235 | declare module 'eslint-plugin-import/lib/index.js' {
236 | declare module.exports: $Exports<'eslint-plugin-import/lib/index'>;
237 | }
238 | declare module 'eslint-plugin-import/lib/rules/default.js' {
239 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/default'>;
240 | }
241 | declare module 'eslint-plugin-import/lib/rules/export.js' {
242 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/export'>;
243 | }
244 | declare module 'eslint-plugin-import/lib/rules/extensions.js' {
245 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/extensions'>;
246 | }
247 | declare module 'eslint-plugin-import/lib/rules/first.js' {
248 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/first'>;
249 | }
250 | declare module 'eslint-plugin-import/lib/rules/imports-first.js' {
251 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/imports-first'>;
252 | }
253 | declare module 'eslint-plugin-import/lib/rules/max-dependencies.js' {
254 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/max-dependencies'>;
255 | }
256 | declare module 'eslint-plugin-import/lib/rules/named.js' {
257 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/named'>;
258 | }
259 | declare module 'eslint-plugin-import/lib/rules/namespace.js' {
260 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/namespace'>;
261 | }
262 | declare module 'eslint-plugin-import/lib/rules/newline-after-import.js' {
263 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/newline-after-import'>;
264 | }
265 | declare module 'eslint-plugin-import/lib/rules/no-absolute-path.js' {
266 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-absolute-path'>;
267 | }
268 | declare module 'eslint-plugin-import/lib/rules/no-amd.js' {
269 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-amd'>;
270 | }
271 | declare module 'eslint-plugin-import/lib/rules/no-anonymous-default-export.js' {
272 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-anonymous-default-export'>;
273 | }
274 | declare module 'eslint-plugin-import/lib/rules/no-commonjs.js' {
275 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-commonjs'>;
276 | }
277 | declare module 'eslint-plugin-import/lib/rules/no-deprecated.js' {
278 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-deprecated'>;
279 | }
280 | declare module 'eslint-plugin-import/lib/rules/no-duplicates.js' {
281 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-duplicates'>;
282 | }
283 | declare module 'eslint-plugin-import/lib/rules/no-dynamic-require.js' {
284 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-dynamic-require'>;
285 | }
286 | declare module 'eslint-plugin-import/lib/rules/no-extraneous-dependencies.js' {
287 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-extraneous-dependencies'>;
288 | }
289 | declare module 'eslint-plugin-import/lib/rules/no-internal-modules.js' {
290 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-internal-modules'>;
291 | }
292 | declare module 'eslint-plugin-import/lib/rules/no-mutable-exports.js' {
293 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-mutable-exports'>;
294 | }
295 | declare module 'eslint-plugin-import/lib/rules/no-named-as-default-member.js' {
296 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-named-as-default-member'>;
297 | }
298 | declare module 'eslint-plugin-import/lib/rules/no-named-as-default.js' {
299 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-named-as-default'>;
300 | }
301 | declare module 'eslint-plugin-import/lib/rules/no-named-default.js' {
302 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-named-default'>;
303 | }
304 | declare module 'eslint-plugin-import/lib/rules/no-namespace.js' {
305 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-namespace'>;
306 | }
307 | declare module 'eslint-plugin-import/lib/rules/no-nodejs-modules.js' {
308 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-nodejs-modules'>;
309 | }
310 | declare module 'eslint-plugin-import/lib/rules/no-restricted-paths.js' {
311 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-restricted-paths'>;
312 | }
313 | declare module 'eslint-plugin-import/lib/rules/no-unassigned-import.js' {
314 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-unassigned-import'>;
315 | }
316 | declare module 'eslint-plugin-import/lib/rules/no-unresolved.js' {
317 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-unresolved'>;
318 | }
319 | declare module 'eslint-plugin-import/lib/rules/no-webpack-loader-syntax.js' {
320 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-webpack-loader-syntax'>;
321 | }
322 | declare module 'eslint-plugin-import/lib/rules/order.js' {
323 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/order'>;
324 | }
325 | declare module 'eslint-plugin-import/lib/rules/prefer-default-export.js' {
326 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/prefer-default-export'>;
327 | }
328 | declare module 'eslint-plugin-import/lib/rules/unambiguous.js' {
329 | declare module.exports: $Exports<'eslint-plugin-import/lib/rules/unambiguous'>;
330 | }
331 | declare module 'eslint-plugin-import/memo-parser/index.js' {
332 | declare module.exports: $Exports<'eslint-plugin-import/memo-parser/index'>;
333 | }
334 |
--------------------------------------------------------------------------------
/flow-typed/npm/eslint-plugin-prettier_vx.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: f1a51233b3cf47086ba5f249e8fd0345
2 | // flow-typed version: <>/eslint-plugin-prettier_v^2.3.1/flow_v0.55.0
3 |
4 | /**
5 | * This is an autogenerated libdef stub for:
6 | *
7 | * 'eslint-plugin-prettier'
8 | *
9 | * Fill this stub out by replacing all the `any` types.
10 | *
11 | * Once filled out, we encourage you to share your work with the
12 | * community by sending a pull request to:
13 | * https://github.com/flowtype/flow-typed
14 | */
15 |
16 | declare module 'eslint-plugin-prettier' {
17 | declare module.exports: any;
18 | }
19 |
20 | /**
21 | * We include stubs for each file inside this npm package in case you need to
22 | * require those files directly. Feel free to delete any files that aren't
23 | * needed.
24 | */
25 | declare module 'eslint-plugin-prettier/eslint-plugin-prettier' {
26 | declare module.exports: any;
27 | }
28 |
29 | // Filename aliases
30 | declare module 'eslint-plugin-prettier/eslint-plugin-prettier.js' {
31 | declare module.exports: $Exports<'eslint-plugin-prettier/eslint-plugin-prettier'>;
32 | }
33 |
--------------------------------------------------------------------------------
/flow-typed/npm/flow-bin_v0.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: 6a5610678d4b01e13bbfbbc62bdaf583
2 | // flow-typed version: 3817bc6980/flow-bin_v0.x.x/flow_>=v0.25.x
3 |
4 | declare module "flow-bin" {
5 | declare module.exports: string;
6 | }
7 |
--------------------------------------------------------------------------------
/flow-typed/npm/jest-cli_vx.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: e61cbf3293e974600c9df77616868175
2 | // flow-typed version: <>/jest-cli_v^21.1.0/flow_v0.55.0
3 |
4 | /**
5 | * This is an autogenerated libdef stub for:
6 | *
7 | * 'jest-cli'
8 | *
9 | * Fill this stub out by replacing all the `any` types.
10 | *
11 | * Once filled out, we encourage you to share your work with the
12 | * community by sending a pull request to:
13 | * https://github.com/flowtype/flow-typed
14 | */
15 |
16 | declare module 'jest-cli' {
17 | declare module.exports: any;
18 | }
19 |
20 | /**
21 | * We include stubs for each file inside this npm package in case you need to
22 | * require those files directly. Feel free to delete any files that aren't
23 | * needed.
24 | */
25 | declare module 'jest-cli/bin/jest' {
26 | declare module.exports: any;
27 | }
28 |
29 | declare module 'jest-cli/build/cli/args' {
30 | declare module.exports: any;
31 | }
32 |
33 | declare module 'jest-cli/build/cli/get_jest' {
34 | declare module.exports: any;
35 | }
36 |
37 | declare module 'jest-cli/build/cli/index' {
38 | declare module.exports: any;
39 | }
40 |
41 | declare module 'jest-cli/build/constants' {
42 | declare module.exports: any;
43 | }
44 |
45 | declare module 'jest-cli/build/generate_empty_coverage' {
46 | declare module.exports: any;
47 | }
48 |
49 | declare module 'jest-cli/build/get_changed_files_promise' {
50 | declare module.exports: any;
51 | }
52 |
53 | declare module 'jest-cli/build/get_no_test_found_message' {
54 | declare module.exports: any;
55 | }
56 |
57 | declare module 'jest-cli/build/get_no_test_found_related_to_changed_files' {
58 | declare module.exports: any;
59 | }
60 |
61 | declare module 'jest-cli/build/get_no_test_found_verbose' {
62 | declare module.exports: any;
63 | }
64 |
65 | declare module 'jest-cli/build/get_no_test_found' {
66 | declare module.exports: any;
67 | }
68 |
69 | declare module 'jest-cli/build/jest' {
70 | declare module.exports: any;
71 | }
72 |
73 | declare module 'jest-cli/build/lib/colorize' {
74 | declare module.exports: any;
75 | }
76 |
77 | declare module 'jest-cli/build/lib/create_context' {
78 | declare module.exports: any;
79 | }
80 |
81 | declare module 'jest-cli/build/lib/format_test_name_by_pattern' {
82 | declare module.exports: any;
83 | }
84 |
85 | declare module 'jest-cli/build/lib/handle_deprecation_warnings' {
86 | declare module.exports: any;
87 | }
88 |
89 | declare module 'jest-cli/build/lib/highlight' {
90 | declare module.exports: any;
91 | }
92 |
93 | declare module 'jest-cli/build/lib/is_valid_path' {
94 | declare module.exports: any;
95 | }
96 |
97 | declare module 'jest-cli/build/lib/log_debug_messages' {
98 | declare module.exports: any;
99 | }
100 |
101 | declare module 'jest-cli/build/lib/pattern_mode_helpers' {
102 | declare module.exports: any;
103 | }
104 |
105 | declare module 'jest-cli/build/lib/Prompt' {
106 | declare module.exports: any;
107 | }
108 |
109 | declare module 'jest-cli/build/lib/scroll_list' {
110 | declare module.exports: any;
111 | }
112 |
113 | declare module 'jest-cli/build/lib/terminal_utils' {
114 | declare module.exports: any;
115 | }
116 |
117 | declare module 'jest-cli/build/lib/update_global_config' {
118 | declare module.exports: any;
119 | }
120 |
121 | declare module 'jest-cli/build/pattern_prompt' {
122 | declare module.exports: any;
123 | }
124 |
125 | declare module 'jest-cli/build/pluralize' {
126 | declare module.exports: any;
127 | }
128 |
129 | declare module 'jest-cli/build/pre_run_message' {
130 | declare module.exports: any;
131 | }
132 |
133 | declare module 'jest-cli/build/reporter_dispatcher' {
134 | declare module.exports: any;
135 | }
136 |
137 | declare module 'jest-cli/build/reporters/base_reporter' {
138 | declare module.exports: any;
139 | }
140 |
141 | declare module 'jest-cli/build/reporters/coverage_reporter' {
142 | declare module.exports: any;
143 | }
144 |
145 | declare module 'jest-cli/build/reporters/coverage_worker' {
146 | declare module.exports: any;
147 | }
148 |
149 | declare module 'jest-cli/build/reporters/default_reporter' {
150 | declare module.exports: any;
151 | }
152 |
153 | declare module 'jest-cli/build/reporters/get_result_header' {
154 | declare module.exports: any;
155 | }
156 |
157 | declare module 'jest-cli/build/reporters/get_snapshot_status' {
158 | declare module.exports: any;
159 | }
160 |
161 | declare module 'jest-cli/build/reporters/get_snapshot_summary' {
162 | declare module.exports: any;
163 | }
164 |
165 | declare module 'jest-cli/build/reporters/notify_reporter' {
166 | declare module.exports: any;
167 | }
168 |
169 | declare module 'jest-cli/build/reporters/Status' {
170 | declare module.exports: any;
171 | }
172 |
173 | declare module 'jest-cli/build/reporters/summary_reporter' {
174 | declare module.exports: any;
175 | }
176 |
177 | declare module 'jest-cli/build/reporters/utils' {
178 | declare module.exports: any;
179 | }
180 |
181 | declare module 'jest-cli/build/reporters/verbose_reporter' {
182 | declare module.exports: any;
183 | }
184 |
185 | declare module 'jest-cli/build/run_jest' {
186 | declare module.exports: any;
187 | }
188 |
189 | declare module 'jest-cli/build/search_source' {
190 | declare module.exports: any;
191 | }
192 |
193 | declare module 'jest-cli/build/test_name_pattern_prompt' {
194 | declare module.exports: any;
195 | }
196 |
197 | declare module 'jest-cli/build/test_path_pattern_prompt' {
198 | declare module.exports: any;
199 | }
200 |
201 | declare module 'jest-cli/build/test_path_pattern_to_regexp' {
202 | declare module.exports: any;
203 | }
204 |
205 | declare module 'jest-cli/build/test_result_helpers' {
206 | declare module.exports: any;
207 | }
208 |
209 | declare module 'jest-cli/build/test_scheduler' {
210 | declare module.exports: any;
211 | }
212 |
213 | declare module 'jest-cli/build/test_sequencer' {
214 | declare module.exports: any;
215 | }
216 |
217 | declare module 'jest-cli/build/test_watcher' {
218 | declare module.exports: any;
219 | }
220 |
221 | declare module 'jest-cli/build/watch' {
222 | declare module.exports: any;
223 | }
224 |
225 | // Filename aliases
226 | declare module 'jest-cli/bin/jest.js' {
227 | declare module.exports: $Exports<'jest-cli/bin/jest'>;
228 | }
229 | declare module 'jest-cli/build/cli/args.js' {
230 | declare module.exports: $Exports<'jest-cli/build/cli/args'>;
231 | }
232 | declare module 'jest-cli/build/cli/get_jest.js' {
233 | declare module.exports: $Exports<'jest-cli/build/cli/get_jest'>;
234 | }
235 | declare module 'jest-cli/build/cli/index.js' {
236 | declare module.exports: $Exports<'jest-cli/build/cli/index'>;
237 | }
238 | declare module 'jest-cli/build/constants.js' {
239 | declare module.exports: $Exports<'jest-cli/build/constants'>;
240 | }
241 | declare module 'jest-cli/build/generate_empty_coverage.js' {
242 | declare module.exports: $Exports<'jest-cli/build/generate_empty_coverage'>;
243 | }
244 | declare module 'jest-cli/build/get_changed_files_promise.js' {
245 | declare module.exports: $Exports<'jest-cli/build/get_changed_files_promise'>;
246 | }
247 | declare module 'jest-cli/build/get_no_test_found_message.js' {
248 | declare module.exports: $Exports<'jest-cli/build/get_no_test_found_message'>;
249 | }
250 | declare module 'jest-cli/build/get_no_test_found_related_to_changed_files.js' {
251 | declare module.exports: $Exports<'jest-cli/build/get_no_test_found_related_to_changed_files'>;
252 | }
253 | declare module 'jest-cli/build/get_no_test_found_verbose.js' {
254 | declare module.exports: $Exports<'jest-cli/build/get_no_test_found_verbose'>;
255 | }
256 | declare module 'jest-cli/build/get_no_test_found.js' {
257 | declare module.exports: $Exports<'jest-cli/build/get_no_test_found'>;
258 | }
259 | declare module 'jest-cli/build/jest.js' {
260 | declare module.exports: $Exports<'jest-cli/build/jest'>;
261 | }
262 | declare module 'jest-cli/build/lib/colorize.js' {
263 | declare module.exports: $Exports<'jest-cli/build/lib/colorize'>;
264 | }
265 | declare module 'jest-cli/build/lib/create_context.js' {
266 | declare module.exports: $Exports<'jest-cli/build/lib/create_context'>;
267 | }
268 | declare module 'jest-cli/build/lib/format_test_name_by_pattern.js' {
269 | declare module.exports: $Exports<'jest-cli/build/lib/format_test_name_by_pattern'>;
270 | }
271 | declare module 'jest-cli/build/lib/handle_deprecation_warnings.js' {
272 | declare module.exports: $Exports<'jest-cli/build/lib/handle_deprecation_warnings'>;
273 | }
274 | declare module 'jest-cli/build/lib/highlight.js' {
275 | declare module.exports: $Exports<'jest-cli/build/lib/highlight'>;
276 | }
277 | declare module 'jest-cli/build/lib/is_valid_path.js' {
278 | declare module.exports: $Exports<'jest-cli/build/lib/is_valid_path'>;
279 | }
280 | declare module 'jest-cli/build/lib/log_debug_messages.js' {
281 | declare module.exports: $Exports<'jest-cli/build/lib/log_debug_messages'>;
282 | }
283 | declare module 'jest-cli/build/lib/pattern_mode_helpers.js' {
284 | declare module.exports: $Exports<'jest-cli/build/lib/pattern_mode_helpers'>;
285 | }
286 | declare module 'jest-cli/build/lib/Prompt.js' {
287 | declare module.exports: $Exports<'jest-cli/build/lib/Prompt'>;
288 | }
289 | declare module 'jest-cli/build/lib/scroll_list.js' {
290 | declare module.exports: $Exports<'jest-cli/build/lib/scroll_list'>;
291 | }
292 | declare module 'jest-cli/build/lib/terminal_utils.js' {
293 | declare module.exports: $Exports<'jest-cli/build/lib/terminal_utils'>;
294 | }
295 | declare module 'jest-cli/build/lib/update_global_config.js' {
296 | declare module.exports: $Exports<'jest-cli/build/lib/update_global_config'>;
297 | }
298 | declare module 'jest-cli/build/pattern_prompt.js' {
299 | declare module.exports: $Exports<'jest-cli/build/pattern_prompt'>;
300 | }
301 | declare module 'jest-cli/build/pluralize.js' {
302 | declare module.exports: $Exports<'jest-cli/build/pluralize'>;
303 | }
304 | declare module 'jest-cli/build/pre_run_message.js' {
305 | declare module.exports: $Exports<'jest-cli/build/pre_run_message'>;
306 | }
307 | declare module 'jest-cli/build/reporter_dispatcher.js' {
308 | declare module.exports: $Exports<'jest-cli/build/reporter_dispatcher'>;
309 | }
310 | declare module 'jest-cli/build/reporters/base_reporter.js' {
311 | declare module.exports: $Exports<'jest-cli/build/reporters/base_reporter'>;
312 | }
313 | declare module 'jest-cli/build/reporters/coverage_reporter.js' {
314 | declare module.exports: $Exports<'jest-cli/build/reporters/coverage_reporter'>;
315 | }
316 | declare module 'jest-cli/build/reporters/coverage_worker.js' {
317 | declare module.exports: $Exports<'jest-cli/build/reporters/coverage_worker'>;
318 | }
319 | declare module 'jest-cli/build/reporters/default_reporter.js' {
320 | declare module.exports: $Exports<'jest-cli/build/reporters/default_reporter'>;
321 | }
322 | declare module 'jest-cli/build/reporters/get_result_header.js' {
323 | declare module.exports: $Exports<'jest-cli/build/reporters/get_result_header'>;
324 | }
325 | declare module 'jest-cli/build/reporters/get_snapshot_status.js' {
326 | declare module.exports: $Exports<'jest-cli/build/reporters/get_snapshot_status'>;
327 | }
328 | declare module 'jest-cli/build/reporters/get_snapshot_summary.js' {
329 | declare module.exports: $Exports<'jest-cli/build/reporters/get_snapshot_summary'>;
330 | }
331 | declare module 'jest-cli/build/reporters/notify_reporter.js' {
332 | declare module.exports: $Exports<'jest-cli/build/reporters/notify_reporter'>;
333 | }
334 | declare module 'jest-cli/build/reporters/Status.js' {
335 | declare module.exports: $Exports<'jest-cli/build/reporters/Status'>;
336 | }
337 | declare module 'jest-cli/build/reporters/summary_reporter.js' {
338 | declare module.exports: $Exports<'jest-cli/build/reporters/summary_reporter'>;
339 | }
340 | declare module 'jest-cli/build/reporters/utils.js' {
341 | declare module.exports: $Exports<'jest-cli/build/reporters/utils'>;
342 | }
343 | declare module 'jest-cli/build/reporters/verbose_reporter.js' {
344 | declare module.exports: $Exports<'jest-cli/build/reporters/verbose_reporter'>;
345 | }
346 | declare module 'jest-cli/build/run_jest.js' {
347 | declare module.exports: $Exports<'jest-cli/build/run_jest'>;
348 | }
349 | declare module 'jest-cli/build/search_source.js' {
350 | declare module.exports: $Exports<'jest-cli/build/search_source'>;
351 | }
352 | declare module 'jest-cli/build/test_name_pattern_prompt.js' {
353 | declare module.exports: $Exports<'jest-cli/build/test_name_pattern_prompt'>;
354 | }
355 | declare module 'jest-cli/build/test_path_pattern_prompt.js' {
356 | declare module.exports: $Exports<'jest-cli/build/test_path_pattern_prompt'>;
357 | }
358 | declare module 'jest-cli/build/test_path_pattern_to_regexp.js' {
359 | declare module.exports: $Exports<'jest-cli/build/test_path_pattern_to_regexp'>;
360 | }
361 | declare module 'jest-cli/build/test_result_helpers.js' {
362 | declare module.exports: $Exports<'jest-cli/build/test_result_helpers'>;
363 | }
364 | declare module 'jest-cli/build/test_scheduler.js' {
365 | declare module.exports: $Exports<'jest-cli/build/test_scheduler'>;
366 | }
367 | declare module 'jest-cli/build/test_sequencer.js' {
368 | declare module.exports: $Exports<'jest-cli/build/test_sequencer'>;
369 | }
370 | declare module 'jest-cli/build/test_watcher.js' {
371 | declare module.exports: $Exports<'jest-cli/build/test_watcher'>;
372 | }
373 | declare module 'jest-cli/build/watch.js' {
374 | declare module.exports: $Exports<'jest-cli/build/watch'>;
375 | }
376 |
--------------------------------------------------------------------------------
/flow-typed/npm/regenerator-runtime_vx.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: eb616fd791a59a8fec4ac6a42bc978df
2 | // flow-typed version: <>/regenerator-runtime_v^0.11.0/flow_v0.55.0
3 |
4 | /**
5 | * This is an autogenerated libdef stub for:
6 | *
7 | * 'regenerator-runtime'
8 | *
9 | * Fill this stub out by replacing all the `any` types.
10 | *
11 | * Once filled out, we encourage you to share your work with the
12 | * community by sending a pull request to:
13 | * https://github.com/flowtype/flow-typed
14 | */
15 |
16 | declare module 'regenerator-runtime' {
17 | declare module.exports: any;
18 | }
19 |
20 | /**
21 | * We include stubs for each file inside this npm package in case you need to
22 | * require those files directly. Feel free to delete any files that aren't
23 | * needed.
24 | */
25 | declare module 'regenerator-runtime/path' {
26 | declare module.exports: any;
27 | }
28 |
29 | declare module 'regenerator-runtime/runtime-module' {
30 | declare module.exports: any;
31 | }
32 |
33 | declare module 'regenerator-runtime/runtime' {
34 | declare module.exports: any;
35 | }
36 |
37 | // Filename aliases
38 | declare module 'regenerator-runtime/path.js' {
39 | declare module.exports: $Exports<'regenerator-runtime/path'>;
40 | }
41 | declare module 'regenerator-runtime/runtime-module.js' {
42 | declare module.exports: $Exports<'regenerator-runtime/runtime-module'>;
43 | }
44 | declare module 'regenerator-runtime/runtime.js' {
45 | declare module.exports: $Exports<'regenerator-runtime/runtime'>;
46 | }
47 |
--------------------------------------------------------------------------------
/flow-typed/npm/slash_vx.x.x.js:
--------------------------------------------------------------------------------
1 | // flow-typed signature: 7d9efd774ed301bffb5241731b17f3a1
2 | // flow-typed version: <>/slash_v^1.0.0/flow_v0.55.0
3 |
4 | /**
5 | * This is an autogenerated libdef stub for:
6 | *
7 | * 'slash'
8 | *
9 | * Fill this stub out by replacing all the `any` types.
10 | *
11 | * Once filled out, we encourage you to share your work with the
12 | * community by sending a pull request to:
13 | * https://github.com/flowtype/flow-typed
14 | */
15 |
16 | declare module 'slash' {
17 | declare module.exports: any;
18 | }
19 |
20 | /**
21 | * We include stubs for each file inside this npm package in case you need to
22 | * require those files directly. Feel free to delete any files that aren't
23 | * needed.
24 | */
25 |
26 |
27 | // Filename aliases
28 | declare module 'slash/index' {
29 | declare module.exports: $Exports<'slash'>;
30 | }
31 | declare module 'slash/index.js' {
32 | declare module.exports: $Exports<'slash'>;
33 | }
34 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | module.exports = require('./dist/index').default;
3 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eslint-plugin-flowtype-errors",
3 | "version": "4.5.0",
4 | "description": "Retrieve Flow errors as ESLint errors.",
5 | "author": "Amila Welihinda",
6 | "bugs": "https://github.com/amilajack/eslint-plugin-flowtype-errors/issues",
7 | "homepage": "https://github.com/amilajack/eslint-plugin-flowtype-errors#readme",
8 | "main": "index.js",
9 | "scripts": {
10 | "build": "cross-env NODE_ENV=production babel src --out-dir dist",
11 | "lint": "eslint --cache .",
12 | "prettier": "prettier --single-quote --write \"./src/*.js\"",
13 | "preversion": "npm run build",
14 | "spec": "npm run build && jest",
15 | "test": "flow && npm run lint && npm run spec"
16 | },
17 | "repository": "https://github.com/amilajack/eslint-plugin-flowtype-errors",
18 | "jest": {
19 | "testEnvironment": "node"
20 | },
21 | "keywords": [
22 | "eslint",
23 | "flow",
24 | "plugin",
25 | "errors"
26 | ],
27 | "files": [
28 | "index.js",
29 | "dist"
30 | ],
31 | "dependencies": {
32 | "@babel/runtime": "^7.16.0",
33 | "core-js": "3.8.1",
34 | "find-up": "^5.0.0",
35 | "slash": "^3.0.0"
36 | },
37 | "devDependencies": {
38 | "@babel/cli": "^7.16.0",
39 | "@babel/core": "^7.16.0",
40 | "@babel/plugin-proposal-class-properties": "^7.16.0",
41 | "@babel/preset-env": "^7.16.0",
42 | "@babel/preset-flow": "^7.16.0",
43 | "@babel/register": "^7.16.0",
44 | "babel-core": "^7.0.0-bridge.0",
45 | "babel-eslint": "^10.1.0",
46 | "babel-jest": "^26.6.3",
47 | "chai": "^4.3.4",
48 | "cross-env": "^7.0.3",
49 | "cross-spawn": "^7.0.3",
50 | "eslint": "7.32.0",
51 | "eslint-config-airbnb-base": "^14.2.1",
52 | "eslint-config-prettier": "^7.2.0",
53 | "eslint-plugin-flowtype": "^5.10.0",
54 | "eslint-plugin-html": "^6.2.0",
55 | "eslint-plugin-import": "^2.25.2",
56 | "eslint-plugin-prettier": "^3.4.1",
57 | "eslint-plugin-vue": "^7.20.0",
58 | "execa": "^5.1.1",
59 | "flow-bin": "0.139.0",
60 | "husky": "^4.3.8",
61 | "jest-cli": "^26.6.3",
62 | "lint-staged": "^10.5.4",
63 | "prettier": "^2.2.1"
64 | },
65 | "lint-staged": {
66 | "*.js": [
67 | "eslint",
68 | "prettier --write"
69 | ]
70 | },
71 | "peerDependencies": {
72 | "eslint": ">=5.16.0",
73 | "flow-bin": ">=0.93.0"
74 | },
75 | "engines": {
76 | "node": ">=4.x",
77 | "npm": ">=5.x"
78 | },
79 | "babel": {
80 | "presets": [
81 | [
82 | "@babel/preset-env",
83 | {
84 | "targets": {
85 | "node": 10
86 | },
87 | "useBuiltIns": "usage",
88 | "corejs": 3
89 | }
90 | ],
91 | "@babel/preset-flow"
92 | ]
93 | },
94 | "eslintConfig": {
95 | "extends": [
96 | "airbnb-base",
97 | "prettier",
98 | "prettier/flowtype"
99 | ],
100 | "parser": "babel-eslint",
101 | "env": {
102 | "node": true,
103 | "es6": true
104 | },
105 | "plugins": [
106 | "flowtype",
107 | "prettier"
108 | ],
109 | "rules": {
110 | "consistent-return": "off",
111 | "flowtype/define-flow-type": "error",
112 | "fp/no-arguments": "off",
113 | "fp/no-class": "off",
114 | "fp/no-delete": "off",
115 | "fp/no-events": "off",
116 | "fp/no-get-set": "off",
117 | "fp/no-let": "off",
118 | "fp/no-loops": "off",
119 | "fp/no-mutating-assign": "off",
120 | "fp/no-mutating-methods": "off",
121 | "fp/no-mutation": "off",
122 | "fp/no-nil": "off",
123 | "fp/no-proxy": "off",
124 | "fp/no-rest-parameters": "off",
125 | "fp/no-this": "off",
126 | "fp/no-throw": "off",
127 | "fp/no-unused-expression": "off",
128 | "fp/no-valueof-field": "off",
129 | "prefer-destructuring": "off"
130 | }
131 | },
132 | "renovate": {
133 | "extends": [
134 | "bliss"
135 | ]
136 | },
137 | "husky": {
138 | "hooks": {
139 | "pre-commit": "npm test"
140 | }
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/src/collect.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 | /**
3 | * Run Flow and collect errors in JSON format
4 | *
5 | * Reference the following links for possible bug fixes and optimizations
6 | * https://github.com/facebook/nuclide/blob/master/pkg/nuclide-flow-rpc/lib/FlowRoot.js
7 | * https://github.com/ptmt/tryflow/blob/gh-pages/js/worker.js
8 | */
9 | import pathModule from 'path';
10 | import childProcess from 'child_process';
11 | import slash from 'slash';
12 |
13 | let flowBin;
14 |
15 | try {
16 | if (!process.env.FLOW_BIN) {
17 | flowBin = require('flow-bin'); // eslint-disable-line global-require
18 | }
19 | } catch (e) {
20 | /* eslint-disable */
21 | console.log();
22 | console.log('Oops! Something went wrong! :(');
23 | console.log();
24 | console.log(
25 | 'eslint-plugin-flowtype-errors could not find the package "flow-bin". This can happen for a couple different reasons.'
26 | );
27 | console.log();
28 | console.log(
29 | '1. If ESLint is installed globally, then make sure "flow-bin" is also installed globally.'
30 | );
31 | console.log();
32 | console.log(
33 | '2. If ESLint is installed locally, then it\'s likely that "flow-bin" is not installed correctly. Try reinstalling by running the following:'
34 | );
35 | console.log();
36 | console.log(' npm i -D flow-bin@latest');
37 | console.log();
38 | process.exit(1);
39 | /* eslint-enable */
40 | }
41 |
42 | export const FlowSeverity = {
43 | Error: 'error',
44 | Warning: 'warning',
45 | };
46 |
47 | type Pos = {
48 | line: number,
49 | column: number,
50 | };
51 |
52 | type Loc = {
53 | start: Pos,
54 | end: Pos,
55 | };
56 |
57 | type FlowPos = {
58 | line: number,
59 | column: number,
60 | offset: number,
61 | };
62 |
63 | type FlowLoc = {
64 | source: string | null,
65 | start: FlowPos,
66 | end: FlowPos,
67 | type:
68 | | 'LibFile'
69 | | 'SourceFile'
70 | | 'JsonFile'
71 | | 'ResourceFile'
72 | | 'Builtins'
73 | | null,
74 | };
75 |
76 | type FlowSimpleMessage =
77 | | { kind: 'Text', text: string }
78 | | { kind: 'Code', text: string };
79 |
80 | opaque type FlowReferenceID = string;
81 |
82 | type FlowReferenceMessage = {
83 | kind: 'Reference',
84 | referenceId: FlowReferenceID,
85 | message: Array,
86 | };
87 |
88 | type FlowInlineMessage = FlowSimpleMessage | FlowReferenceMessage;
89 |
90 | type FlowUnorderedListMessage = {
91 | kind: 'UnorderedList',
92 | message: Array,
93 | items: Array, // eslint-disable-line no-use-before-define
94 | };
95 |
96 | type FlowMessage = Array | FlowUnorderedListMessage;
97 |
98 | type FlowReferenceLocs = {
99 | [referenceId: FlowReferenceID]: FlowLoc,
100 | };
101 |
102 | type FlowError = {
103 | kind:
104 | | 'parse'
105 | | 'infer'
106 | | 'internal'
107 | | 'duplicate provider'
108 | | 'recursion limit exceeded'
109 | | 'lint',
110 | level: 'error' | 'warning',
111 | suppressions: Array<{ loc: FlowLoc }>,
112 | primaryLoc: FlowLoc,
113 | rootLoc: FlowLoc | null,
114 | messageMarkup: FlowMessage,
115 | referenceLocs: FlowReferenceLocs,
116 | };
117 |
118 | type ErrorData = {
119 | errorLoc: FlowLoc,
120 | referenceLocs: FlowReferenceLocs,
121 | root: string,
122 | flowVersion: string,
123 | lineOffset: number,
124 | };
125 |
126 | function fatalError(message) {
127 | return [
128 | {
129 | level: FlowSeverity.Error,
130 | loc: { start: { line: 1, column: 1 }, end: { line: 1, column: 1 } },
131 | message,
132 | },
133 | ];
134 | }
135 |
136 | function formatSeePath(
137 | loc: FlowLoc,
138 | root: string,
139 | flowVersion: string
140 | ): string {
141 | if (loc.source === null) {
142 | return '??';
143 | }
144 |
145 | return loc.type === 'LibFile' && !loc.source.startsWith(root)
146 | ? `https://github.com/facebook/flow/blob/v${flowVersion}/lib/${pathModule.basename(
147 | loc.source
148 | )}#L${loc.start.line}`
149 | : `.${slash(loc.source.replace(root, ''))}:${loc.start.line}`;
150 | }
151 |
152 | function formatSimpleMessage(message: FlowSimpleMessage): string {
153 | return message.kind === 'Code' ? `\`${message.text}\`` : message.text;
154 | }
155 |
156 | function formatReferenceMessage(
157 | message: FlowReferenceMessage,
158 | errorData: ErrorData
159 | ): string {
160 | const { errorLoc, referenceLocs, root, flowVersion, lineOffset } = errorData;
161 | const referenceLoc = referenceLocs[message.referenceId];
162 | let messageStr = message.message.map(formatSimpleMessage).join('');
163 |
164 | if (referenceLoc.source !== errorLoc.source) {
165 | messageStr += ` (see ${formatSeePath(referenceLoc, root, flowVersion)})`;
166 | } else if (referenceLoc.start.line !== errorLoc.start.line) {
167 | messageStr += ` (see line ${referenceLoc.start.line + lineOffset})`;
168 | }
169 |
170 | return messageStr;
171 | }
172 |
173 | function formatInlineMessage(
174 | message: FlowInlineMessage,
175 | errorData: ErrorData
176 | ): string {
177 | return message.kind === 'Reference'
178 | ? formatReferenceMessage(message, errorData)
179 | : formatSimpleMessage(message);
180 | }
181 |
182 | function formatInlineMessageArray(
183 | messages: Array,
184 | errorData: ErrorData
185 | ): string {
186 | return messages
187 | .map((message) => formatInlineMessage(message, errorData))
188 | .join('');
189 | }
190 |
191 | function formatMessage(message: FlowMessage, errorData: ErrorData): string {
192 | if (Array.isArray(message)) {
193 | return formatInlineMessageArray(message, errorData);
194 | }
195 |
196 | return [
197 | formatInlineMessageArray(message.message, errorData),
198 | ...message.items.map((itemMessage) =>
199 | formatMessage(itemMessage, errorData)
200 | ),
201 | ].join(' ');
202 | }
203 |
204 | function getFlowBin() {
205 | return process.env.FLOW_BIN || flowBin;
206 | }
207 |
208 | let didExecute = false;
209 |
210 | function onExit(root: string) {
211 | if (!didExecute) {
212 | didExecute = true;
213 | process.on('exit', () =>
214 | childProcess.spawnSync(getFlowBin(), ['stop', root])
215 | );
216 | }
217 | }
218 |
219 | function spawnFlow(
220 | mode: string,
221 | input: string,
222 | root: string,
223 | stopOnExit: boolean,
224 | filepath: string,
225 | extraOptions?: string[] = []
226 | ): string | boolean {
227 | if (!input) {
228 | return true;
229 | }
230 |
231 | /**
232 | * Workaround for Windows bug: https://github.com/facebook/flow/issues/6834
233 | * Starting the Flow server before running `check-contents` prevents Flow from hanging.
234 | */
235 | if (process.platform === 'win32') {
236 | childProcess.spawnSync(getFlowBin(), ['start', root]);
237 | }
238 |
239 | const child = childProcess.spawnSync(
240 | getFlowBin(),
241 | [
242 | mode,
243 | '--json',
244 | `--root=${root}`,
245 | mode === 'coverage' ? `--path=${filepath}` : filepath,
246 | ...extraOptions,
247 | ],
248 | {
249 | cwd: root,
250 | input,
251 | encoding: 'utf-8',
252 | }
253 | );
254 |
255 | const stdout = child.stdout;
256 |
257 | if (!stdout) {
258 | // Flow does not support 32 bit OS's at the moment.
259 | return false;
260 | }
261 |
262 | if (stopOnExit) {
263 | onExit(root);
264 | }
265 |
266 | return stdout.toString();
267 | }
268 |
269 | function determineRuleType(description) {
270 | return description.toLowerCase().includes('missing type annotation')
271 | ? 'missing-annotation'
272 | : 'default';
273 | }
274 |
275 | export type CollectOutputElement = {
276 | level: string,
277 | loc: Loc,
278 | message: string,
279 | };
280 |
281 | type CollectOutput = Array;
282 |
283 | export function collect(
284 | stdin: string,
285 | root: string,
286 | stopOnExit: boolean,
287 | filepath: string,
288 | programOffset: { line: number, column: number }
289 | ): CollectOutput | boolean {
290 | const stdout = spawnFlow(
291 | 'check-contents',
292 | stdin,
293 | root,
294 | stopOnExit,
295 | filepath,
296 | ['--json-version=2']
297 | );
298 |
299 | if (typeof stdout !== 'string') {
300 | return stdout;
301 | }
302 |
303 | let json;
304 |
305 | try {
306 | json = JSON.parse(stdout);
307 | } catch (e) {
308 | return fatalError('Flow returned invalid json');
309 | }
310 |
311 | if (!Array.isArray(json.errors)) {
312 | return json.exit
313 | ? fatalError(
314 | `Flow returned an error: ${json.exit.msg} (code: ${json.exit.code})`
315 | )
316 | : fatalError('Flow returned invalid json');
317 | }
318 |
319 | const output = json.errors.map((error: FlowError) => {
320 | const loc = error.primaryLoc;
321 |
322 | const message = formatMessage(error.messageMarkup, {
323 | errorLoc: loc,
324 | referenceLocs: error.referenceLocs,
325 | root,
326 | flowVersion: json.flowVersion,
327 | lineOffset: programOffset.line,
328 | });
329 |
330 | const newLoc = {
331 | start: {
332 | line: loc.start.line + programOffset.line,
333 | column:
334 | loc.start.line === 0
335 | ? loc.start.column + programOffset.column
336 | : loc.start.column,
337 | offset: loc.start.offset,
338 | },
339 | end: {
340 | line: loc.end.line + programOffset.line,
341 | column:
342 | loc.end.line === 0
343 | ? loc.end.column + programOffset.column
344 | : loc.end.column,
345 | offset: loc.end.offset,
346 | },
347 | };
348 |
349 | return {
350 | ...(process.env.DEBUG_FLOWTYPE_ERRRORS === 'true' ? json : {}),
351 | type: determineRuleType(message),
352 | level: error.level || FlowSeverity.Error,
353 | message,
354 | path: loc.source,
355 | start: newLoc.start.line,
356 | end: newLoc.end.line,
357 | loc: newLoc,
358 | };
359 | });
360 |
361 | return output;
362 | }
363 |
364 | type CoverageOutput = {
365 | coveredCount: number,
366 | uncoveredCount: number,
367 | uncoveredLocs: $ReadOnlyArray<{
368 | ...Loc,
369 | source: string,
370 | }>,
371 | };
372 |
373 | export function coverage(
374 | stdin: string,
375 | root: string,
376 | stopOnExit: boolean,
377 | filepath: string
378 | ): CoverageOutput | boolean {
379 | const stdout = spawnFlow('coverage', stdin, root, stopOnExit, filepath);
380 |
381 | if (typeof stdout !== 'string') {
382 | return stdout;
383 | }
384 |
385 | let expressions;
386 |
387 | try {
388 | expressions = JSON.parse(stdout).expressions;
389 | } catch (e) {
390 | return {
391 | coveredCount: 0,
392 | uncoveredCount: 0,
393 | uncoveredLocs: [],
394 | };
395 | }
396 |
397 | return {
398 | coveredCount: expressions.covered_count,
399 | uncoveredCount: expressions.uncovered_count,
400 | uncoveredLocs: expressions.uncovered_locs,
401 | };
402 | }
403 |
--------------------------------------------------------------------------------
/src/config/recommended.js:
--------------------------------------------------------------------------------
1 | export default {
2 | plugins: ['flowtype-errors'],
3 | rules: {
4 | 'flowtype-errors/show-errors': 'error'
5 | }
6 | };
7 |
--------------------------------------------------------------------------------
/src/format.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This module is responsible for formatting flowtype errors to be more friendly and understandable
3 | * Formatting should be disabled by default
4 | * @TODO
5 | */
6 |
7 | function fomatMessage(description) {
8 | if (description.toLowerCase().includes("' This type")) {
9 | return description.replace('This type', 'type');
10 | }
11 |
12 | return description;
13 | }
14 |
15 | export default function filter(messages) {
16 | return messages.map((e) => ({
17 | ...e,
18 | message: fomatMessage(e.message),
19 | }));
20 | }
21 |
--------------------------------------------------------------------------------
/src/get-program.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | type Pos = {
4 | line: number,
5 | column: number,
6 | };
7 |
8 | export type Loc = {
9 | start: Pos,
10 | end: Pos,
11 | };
12 |
13 | export type Program = { text: string, loc: Loc, offset: Pos };
14 |
15 | export default function getProgram(source: Object, node: Object): ?Program {
16 | // Ignore if body is empty.
17 | if (node.body.length === 0) {
18 | return;
19 | }
20 |
21 | const body0 = node.body[0];
22 | const comments0 = node.comments[0];
23 | let start;
24 | let range;
25 |
26 | // With babel-eslint, program.loc.start.column is always 0,
27 | // workaround it by using the first node of the body to get the offset.
28 |
29 | if (comments0) {
30 | start =
31 | node.range[0] < comments0.range[0]
32 | ? {
33 | line: body0.loc.start.line,
34 | column: body0.loc.start.column,
35 | }
36 | : {
37 | line: comments0.loc.start.line,
38 | column: comments0.loc.start.column,
39 | };
40 | range = [
41 | Math.min(node.range[0], comments0.range[0]),
42 | Math.max(node.range[1], node.comments[node.comments.length - 1].range[1]),
43 | ];
44 | } else {
45 | start = {
46 | line: body0.loc.start.line,
47 | column: body0.loc.start.column,
48 | };
49 | range = node.range;
50 | }
51 |
52 | return {
53 | text: source.text.slice(range[0], range[1]),
54 | loc: {
55 | start,
56 | end: start,
57 | },
58 | offset: {
59 | line: start.line - 1,
60 | column: start.column,
61 | },
62 | };
63 | }
64 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | import path from 'path';
4 | import fs from 'fs';
5 | // $FlowIgnore
6 | import findUp from 'find-up';
7 | import recommended from './config/recommended';
8 | import {
9 | type CollectOutputElement,
10 | FlowSeverity,
11 | collect,
12 | coverage,
13 | } from './collect';
14 | import getProgram, { type Program, type Loc } from './get-program';
15 |
16 | type EslintContext = {
17 | getAllComments: () => { value: string }[],
18 | getFilename: () => string,
19 | getSourceCode: () => Object,
20 | report: ({ loc: Loc, message: string }) => void,
21 | settings: ?{
22 | 'flowtype-errors': ?{
23 | stopOnExit?: any,
24 | },
25 | },
26 | options: any[],
27 | };
28 |
29 | type ReturnRule = { Program: (node: Object) => void }
30 |
31 | type Info = {
32 | flowDir: string,
33 | program: Program,
34 | };
35 |
36 | const DEFAULT_LOC = {
37 | start: {
38 | line: 1,
39 | column: 0,
40 | },
41 | end: {
42 | line: 1,
43 | column: 0,
44 | },
45 | };
46 |
47 | function lookupInfo(
48 | context: EslintContext,
49 | source: Object,
50 | node: Object
51 | ): ?Info {
52 | const flowconfigFile = findUp.sync('.flowconfig', {
53 | cwd: path.dirname(context.getFilename()),
54 | });
55 |
56 | if (flowconfigFile == null) {
57 | const program = getProgram(source, node);
58 | context.report({
59 | loc: program ? program.loc : DEFAULT_LOC,
60 | message: "Could not find '.flowconfig' file",
61 | });
62 | return null;
63 | }
64 |
65 | const flowDir = path.dirname(flowconfigFile);
66 |
67 | const runOnAllFiles = fs
68 | .readFileSync(flowconfigFile, 'utf8')
69 | .includes('all=true');
70 |
71 | const shouldRun =
72 | runOnAllFiles ||
73 | source.getAllComments().some((comment) => /@flow/.test(comment.value));
74 |
75 | const program = shouldRun && getProgram(source, node);
76 |
77 | if (program) {
78 | return {
79 | flowDir,
80 | program,
81 | };
82 | }
83 |
84 | return null;
85 | }
86 |
87 | function stopOnExit(context: EslintContext): boolean {
88 | return !!(
89 | context.settings &&
90 | context.settings['flowtype-errors'] &&
91 | context.settings['flowtype-errors'].stopOnExit
92 | );
93 | }
94 |
95 | function errorFlowCouldNotRun(loc) {
96 | return {
97 | loc,
98 | message: `Flow could not be run. Possible causes include:
99 | * Running on 32-bit OS (https://github.com/facebook/flow/issues/2262)
100 | * Recent glibc version not available (https://github.com/flowtype/flow-bin/issues/49)
101 | * FLOW_BIN environment variable ${
102 | process.env.FLOW_BIN ? 'set incorrectly' : 'not set'
103 | }
104 | .`,
105 | };
106 | }
107 |
108 | function createFilteredErrorRule(filter: (CollectOutputElement) => any): (context: EslintContext) => ReturnRule {
109 | return function showErrors(context: EslintContext): ReturnRule {
110 | return {
111 | Program(node: Object) {
112 | const source = context.getSourceCode();
113 | const info = lookupInfo(context, source, node);
114 |
115 | if (!info) {
116 | return;
117 | }
118 |
119 | const { flowDir, program } = info;
120 |
121 | const collected = collect(
122 | program.text,
123 | flowDir,
124 | stopOnExit(context),
125 | context.getFilename(),
126 | program.offset
127 | );
128 |
129 | if (collected === true) {
130 | return;
131 | }
132 |
133 | if (collected === false) {
134 | context.report(errorFlowCouldNotRun(program.loc));
135 | return;
136 | }
137 |
138 | collected.filter(filter).forEach(({ loc, message }) => {
139 | context.report({
140 | loc: loc
141 | ? {
142 | ...loc,
143 | start: {
144 | ...loc.start,
145 | // Flow's column numbers are 1-based, while ESLint's are 0-based.
146 | column: loc.start.column - 1,
147 | },
148 | }
149 | : loc,
150 | message,
151 | });
152 | });
153 | },
154 | };
155 | };
156 | }
157 |
158 | const MIN_COVERAGE_DIRECTIVE_COMMENT_PATTERN =
159 | /(\s*eslint\s*['"]flowtype-errors\/enforce-min-coverage['"]\s*:\s*\[\s*(?:2|['"]error['"])\s*,\s*)(\d+)(\]\s*)/
160 |
161 | function getMinCoverageDirectiveCommentNodeAndPercent(sourceCode) {
162 | let commentNode
163 | let minPercent
164 | // eslint-disable-next-line no-restricted-syntax
165 | for (const comment of sourceCode.getAllComments()) {
166 | const match = comment.value.match(MIN_COVERAGE_DIRECTIVE_COMMENT_PATTERN)
167 | if (match && match[2]) {
168 | commentNode = comment
169 | minPercent = parseInt(match[2], 10)
170 | break
171 | }
172 | }
173 | return [commentNode, minPercent]
174 | }
175 |
176 | const getCoverage = (context, node) => {
177 | const source = context.getSourceCode();
178 | const info = lookupInfo(context, source, node);
179 |
180 | if (!info) {
181 | return;
182 | }
183 |
184 | const { flowDir, program } = info;
185 |
186 | const coverageInfo = coverage(
187 | program.text,
188 | flowDir,
189 | stopOnExit(context),
190 | context.getFilename()
191 | );
192 |
193 | if (coverageInfo === true) {
194 | return;
195 | }
196 |
197 | if (coverageInfo === false) {
198 | context.report(errorFlowCouldNotRun(program.loc));
199 | return;
200 | }
201 |
202 | return { program, coverageInfo };
203 | };
204 |
205 | export default {
206 | configs: {
207 | recommended,
208 | },
209 | rules: {
210 | uncovered: function showCoverage(context: EslintContext): ReturnRule {
211 | return {
212 | Program(node: Object) {
213 | const res = getCoverage(context, node);
214 | if (!res) {
215 | return;
216 | }
217 |
218 | res.coverageInfo.uncoveredLocs.forEach((loc) => {
219 | context.report({
220 | loc: {
221 | start: {
222 | line: loc.start.line,
223 | // Flow's and eslint's column reporting don't agree
224 | column: loc.start.column - 1,
225 | },
226 | end: loc.end,
227 | },
228 | message: `Uncovered expression! Try adding annotations to inform flow of the type.`,
229 | });
230 | });
231 | },
232 | };
233 | },
234 | 'enforce-min-coverage': function enforceMinCoverage(
235 | context: EslintContext
236 | ): ReturnRule {
237 | return {
238 | Program(node: Object) {
239 | const res = getCoverage(context, node);
240 | if (!res) {
241 | return;
242 | }
243 |
244 | const requiredCoverage = context.options[0];
245 | const { coveredCount, uncoveredCount } = res.coverageInfo;
246 |
247 | /* eslint prefer-template: 0 */
248 | const percentage = Number(
249 | Math.round(
250 | (coveredCount / (coveredCount + uncoveredCount)) * 10000
251 | ) + 'e-2'
252 | );
253 |
254 | if (percentage < requiredCoverage) {
255 | context.report({
256 | loc: res.program.loc,
257 | message: `Expected coverage to be at least ${requiredCoverage}%, but is: ${percentage}%`,
258 | });
259 | }
260 | },
261 | };
262 | },
263 | 'enforce-min-coverage-comments-sync': {
264 | meta: {
265 | fixable: 'code',
266 | },
267 | create: function enforceMinCoverageCommentsSync(
268 | context: EslintContext
269 | ): ReturnRule {
270 | return {
271 | Program(node: Object) {
272 | const res = getCoverage(context, node);
273 | if (!res) {
274 | return;
275 | }
276 |
277 | const sourceCode = context.getSourceCode()
278 | const [minCoverageDirectiveCommentNode, requiredCoverage] = getMinCoverageDirectiveCommentNodeAndPercent(sourceCode)
279 | if (!minCoverageDirectiveCommentNode || !requiredCoverage) {
280 | return;
281 | }
282 |
283 | // Get global requiredCoverage outside the inline module comment.
284 | const enforceMinCoverage = context.options[0];
285 | // If flow coverage is >=updateCommentThreshold% greater than allowed, update the eslint comment.
286 | const updateCommentThreshold = context.options[1];
287 | const { coveredCount, uncoveredCount } = res.coverageInfo;
288 |
289 | /* eslint prefer-template: 0 */
290 | const percentage = Number(
291 | Math.round(
292 | (coveredCount / (coveredCount + uncoveredCount)) * 10000
293 | ) + 'e-2'
294 | );
295 |
296 | if (percentage - requiredCoverage > updateCommentThreshold) {
297 | context.report({
298 | loc: res.program.loc,
299 | message: `Expected coverage comment to be within ${updateCommentThreshold}% of ${requiredCoverage}%, but is: ${percentage}%`,
300 | fix(fixer) {
301 | if (percentage >= enforceMinCoverage) {
302 | // If coverage >= global required amount, remove comment entirely.
303 | return fixer.replaceText(minCoverageDirectiveCommentNode, '')
304 | }
305 |
306 | return fixer.replaceText(minCoverageDirectiveCommentNode, minCoverageDirectiveCommentNode.value.replace(MIN_COVERAGE_DIRECTIVE_COMMENT_PATTERN, `/*$1${Math.floor(percentage)}$3*/`))
307 | }
308 | });
309 | }
310 | },
311 | };
312 | },
313 | },
314 | 'show-errors': (createFilteredErrorRule(
315 | ({ level }) => level !== FlowSeverity.Warning
316 | ) : (context: EslintContext) => ReturnRule),
317 | 'show-warnings': (createFilteredErrorRule(
318 | ({ level }) => level === FlowSeverity.Warning
319 | ) : (context: EslintContext) => ReturnRule),
320 | },
321 | };
322 |
--------------------------------------------------------------------------------
/test/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "jest": true
4 | },
5 | "rules": {
6 | "global-require": "off",
7 | "import/no-dynamic-require": "off",
8 | "no-restricted-syntax": "off"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/test/.flowconfig:
--------------------------------------------------------------------------------
1 | [options]
2 | esproposal.class_static_fields=enable
3 | esproposal.class_instance_fields=enable
4 | esproposal.export_star_as=enable
5 |
--------------------------------------------------------------------------------
/test/1.example.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | /**
3 | * @flow
4 | */
5 | function test(x: string): boolean {
6 | return 'string';
7 | }
8 |
9 | test(x);
10 |
11 | function square(x): number {
12 | return x * x;
13 | }
14 |
15 | function incorrectSquare(x): number {
16 | return x * 'x';
17 | }
18 |
--------------------------------------------------------------------------------
/test/1.expect.js:
--------------------------------------------------------------------------------
1 | export default [
2 | {
3 | end: 6,
4 | loc: {
5 | end: {
6 | column: 17,
7 | line: 6,
8 | offset: 91
9 | },
10 | start: {
11 | column: 10,
12 | line: 6,
13 | offset: 83
14 | }
15 | },
16 | message:
17 | "string: This type is incompatible with the expected return type of 'boolean'. See line 5",
18 | start: 6,
19 | type: 'default'
20 | },
21 | {
22 | end: 9,
23 | loc: {
24 | end: {
25 | column: 6,
26 | line: 9,
27 | offset: 102
28 | },
29 | start: {
30 | column: 6,
31 | line: 9,
32 | offset: 101
33 | }
34 | },
35 | message: 'identifier `x`: Could not resolve name',
36 | start: 9,
37 | type: 'default'
38 | },
39 | {
40 | end: 16,
41 | loc: {
42 | end: {
43 | column: 16,
44 | line: 16,
45 | offset: 208
46 | },
47 | start: {
48 | column: 14,
49 | line: 16,
50 | offset: 205
51 | }
52 | },
53 | message: 'string: The operand of an arithmetic operation must be a number',
54 | start: 16,
55 | type: 'default'
56 | }
57 | ];
58 |
--------------------------------------------------------------------------------
/test/10.example.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | /**
3 | * @flow
4 | */
5 | type Foo = {} & ({ a: Array } | { b: string });
6 |
7 | function foo(a: Foo) {
8 | if ('b' in a) {
9 | a.foo.map(e => e(e))
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/test/2.example.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | /**
3 | * @flow
4 | */
5 | function test(x) {
6 | return x;
7 | }
8 |
9 | export function square(x) {
10 | return x;
11 | }
12 |
13 | test(x);
14 | square();
15 |
--------------------------------------------------------------------------------
/test/2.expect.js:
--------------------------------------------------------------------------------
1 | export default [
2 | {
3 | end: 9,
4 | loc: {
5 | end: {
6 | column: 24,
7 | line: 9,
8 | offset: 96
9 | },
10 | start: {
11 | column: 24,
12 | line: 9,
13 | offset: 95
14 | }
15 | },
16 | message: 'parameter `x`: Missing annotation',
17 | start: 9,
18 | type: 'missing-annotation'
19 | },
20 | {
21 | end: 13,
22 | loc: {
23 | end: {
24 | column: 6,
25 | line: 13,
26 | offset: 121
27 | },
28 | start: {
29 | column: 6,
30 | line: 13,
31 | offset: 120
32 | }
33 | },
34 | message: 'identifier `x`: Could not resolve name',
35 | start: 13,
36 | type: 'default'
37 | }
38 | ];
39 |
--------------------------------------------------------------------------------
/test/3.example.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | /**
3 | * @flow
4 | */
5 | export function square(x: number) {
6 | return x * x;
7 | }
8 |
9 | export function moo(): number {
10 | return 'undefined';
11 | }
12 |
13 | export function who(some: string): number {
14 | return some;
15 | }
16 |
17 | var str: number = 'hello world!';
18 |
19 | moo(str + {});
20 |
--------------------------------------------------------------------------------
/test/3.expect.js:
--------------------------------------------------------------------------------
1 | export default [
2 | {
3 | end: 10,
4 | loc: {
5 | end: {
6 | column: 20,
7 | line: 10,
8 | offset: 145
9 | },
10 | start: {
11 | column: 10,
12 | line: 10,
13 | offset: 134
14 | }
15 | },
16 | message:
17 | "string: This type is incompatible with the expected return type of 'number'. See line 9",
18 | start: 10,
19 | type: 'default'
20 | },
21 | {
22 | end: 14,
23 | loc: {
24 | end: {
25 | column: 13,
26 | line: 14,
27 | offset: 205
28 | },
29 | start: {
30 | column: 10,
31 | line: 14,
32 | offset: 201
33 | }
34 | },
35 | message:
36 | "string: This type is incompatible with the expected return type of 'number'. See line 13",
37 | start: 14,
38 | type: 'default'
39 | },
40 | {
41 | end: 17,
42 | loc: {
43 | end: {
44 | column: 32,
45 | line: 17,
46 | offset: 242
47 | },
48 | start: {
49 | column: 19,
50 | line: 17,
51 | offset: 228
52 | }
53 | },
54 | message: "string: This type is incompatible with 'number'. See line 17",
55 | start: 17,
56 | type: 'default'
57 | },
58 | {
59 | end: 19,
60 | loc: {
61 | end: {
62 | column: 9,
63 | line: 19,
64 | offset: 254
65 | },
66 | start: {
67 | column: 7,
68 | line: 19,
69 | offset: 251
70 | }
71 | },
72 | message: "who: name is already bound 'function who'. See line 13",
73 | start: 19,
74 | type: 'default'
75 | },
76 | {
77 | end: 21,
78 | loc: {
79 | end: {
80 | column: 13,
81 | line: 21,
82 | offset: 275
83 | },
84 | start: {
85 | column: 11,
86 | line: 21,
87 | offset: 272
88 | }
89 | },
90 | message: "function: This type cannot be added to 'number'. See line 21",
91 | start: 21,
92 | type: 'default'
93 | }
94 | ];
95 |
--------------------------------------------------------------------------------
/test/4.example.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | /**
3 | * @flow
4 | */
5 | import React, { Component } from 'react';
6 |
7 | type Props = {
8 | firstName: number,
9 | lastName: string
10 | };
11 |
12 | class Foo extends Component {
13 | props: Props
14 |
15 | render() {
16 | return (
17 |
18 |
19 | Hello {this.props.firstName} {this.props.lastName}
20 |
21 |
22 | );
23 | }
24 | }
25 |
26 | export default class Bar extends Component<{}, {}> {
27 | render() {
28 | return ;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/test/4.expect.js:
--------------------------------------------------------------------------------
1 | export default [
2 | {
3 | end: 12,
4 | loc: {
5 | end: {
6 | column: 3,
7 | line: 12,
8 | offset: 171
9 | },
10 | start: {
11 | column: 10,
12 | line: 9,
13 | offset: 121
14 | }
15 | },
16 | message:
17 | "property `lastName`: Property not found in 'props of React element `Foo`'. See line 25",
18 | start: 9,
19 | type: 'default'
20 | },
21 | {
22 | end: 25,
23 | loc: {
24 | end: {
25 | column: 35,
26 | line: 25,
27 | offset: 399
28 | },
29 | start: {
30 | column: 12,
31 | line: 25,
32 | offset: 375
33 | }
34 | },
35 | message:
36 | "props of React element `Foo`: This type is incompatible with 'object type'. See line 9",
37 | start: 25,
38 | type: 'default'
39 | }
40 | ];
41 |
--------------------------------------------------------------------------------
/test/5.example.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | /**
3 | * @flow
4 | */
5 | export function s(x: number) {
6 | return x * x;
7 | }
8 |
9 | s('4');
10 |
--------------------------------------------------------------------------------
/test/5.expect.js:
--------------------------------------------------------------------------------
1 | export default [
2 | {
3 | end: 9,
4 | loc: {
5 | end: {
6 | column: 5,
7 | line: 9,
8 | offset: 93
9 | },
10 | start: {
11 | column: 3,
12 | line: 9,
13 | offset: 90
14 | }
15 | },
16 | message:
17 | "string: This type is incompatible with the expected param type of 'number'. See line 5",
18 | start: 9,
19 | type: 'default'
20 | }
21 | ];
22 |
--------------------------------------------------------------------------------
/test/6.example.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | /**
3 | * @flow
4 | */
5 | export function foo(bar: { baz: string }) {
6 | console.log(foo);
7 | }
8 |
9 | foo(1234);
10 |
11 | foo({ xyz: 'abc' });
12 |
--------------------------------------------------------------------------------
/test/6.expect.js:
--------------------------------------------------------------------------------
1 | export default [
2 | {
3 | end: 9,
4 | loc: {
5 | end: {
6 | column: 8,
7 | line: 9,
8 | offset: 111
9 | },
10 | start: {
11 | column: 5,
12 | line: 9,
13 | offset: 107
14 | }
15 | },
16 | message:
17 | "number: This type is incompatible with the expected param type of 'object type'. See line 5",
18 | start: 9,
19 | type: 'default'
20 | },
21 | {
22 | end: 11,
23 | loc: {
24 | end: {
25 | column: 17,
26 | line: 11,
27 | offset: 132
28 | },
29 | start: {
30 | column: 1,
31 | line: 11,
32 | offset: 115
33 | }
34 | },
35 | message:
36 | "function call: 'property `baz`'. See line 5. Property not found in 'object literal'. See line 11",
37 | start: 11,
38 | type: 'default'
39 | }
40 | ];
41 |
--------------------------------------------------------------------------------
/test/7.example.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | /**
3 | * @flow
4 | */
5 | import { s } from './5.example.js';
6 |
7 | s('4');
8 |
--------------------------------------------------------------------------------
/test/7.expect.js:
--------------------------------------------------------------------------------
1 | export default [
2 | {
3 | end: 7,
4 | loc: {
5 | end: {
6 | column: 5,
7 | line: 7,
8 | offset: 80
9 | },
10 | start: {
11 | column: 3,
12 | line: 7,
13 | offset: 77
14 | }
15 | },
16 | message:
17 | "string: This type is incompatible with the expected param type of 'number'. See ./5.example.js:5",
18 | start: 7,
19 | type: 'default'
20 | }
21 | ];
22 |
--------------------------------------------------------------------------------
/test/8.example.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | /**
3 | * @flow
4 | */
5 | import { foo } from './6.example.js';
6 |
7 | foo(1234);
8 |
9 | foo({ xyz: 'abc' });
10 |
--------------------------------------------------------------------------------
/test/8.expect.js:
--------------------------------------------------------------------------------
1 | export default [
2 | {
3 | end: 7,
4 | loc: {
5 | end: {
6 | column: 8,
7 | line: 7,
8 | offset: 85
9 | },
10 | start: {
11 | column: 5,
12 | line: 7,
13 | offset: 81
14 | }
15 | },
16 | message:
17 | "number: This type is incompatible with the expected param type of 'object type'. See ./6.example.js:5",
18 | start: 7,
19 | type: 'default'
20 | },
21 | {
22 | end: 9,
23 | loc: {
24 | end: {
25 | column: 17,
26 | line: 9,
27 | offset: 106
28 | },
29 | start: {
30 | column: 1,
31 | line: 9,
32 | offset: 89
33 | }
34 | },
35 | message:
36 | "function call: 'property `baz`'. See ./6.example.js:5. Property not found in 'object literal'. See line 9",
37 | start: 9,
38 | type: 'default'
39 | }
40 | ];
41 |
--------------------------------------------------------------------------------
/test/9.example.import.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | /**
3 | * @flow
4 | */
5 | import * as React from 'react'
6 |
7 | export default function Hello({ name = 'World' }: { name: string }): React.Node {
8 | return Hello, {name}!
;
9 | }
10 |
--------------------------------------------------------------------------------
/test/9.example.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | /**
3 | * @flow
4 | */
5 | import React from 'react';
6 | import ReactDOM from 'react-dom';
7 | import Hello from './9.example.import.js';
8 |
9 | ReactDOM.render(, document.getElementById('app'));
10 |
--------------------------------------------------------------------------------
/test/9.expect.js:
--------------------------------------------------------------------------------
1 | export default [
2 | {
3 | end: 9,
4 | loc: {
5 | end: {
6 | column: 24,
7 | line: 9,
8 | offset: 167
9 | },
10 | start: {
11 | column: 17,
12 | line: 9,
13 | offset: 159
14 | }
15 | },
16 | message:
17 | "React element `Hello`: 'property `name`'. See ./9.example.import.js:7. Property not found in 'props of React element `Hello`'. See line 9",
18 | start: 9,
19 | type: 'default'
20 | }
21 | ];
22 |
--------------------------------------------------------------------------------
/test/__snapshots__/format.spec.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`Check codebases column-offset - eslint should give expected output 1`] = `
4 | "
5 | ./example.js
6 | 7:4 error Cannot resolve name \`test\`. [cannot-resolve-name] flowtype-errors/show-errors
7 | 7:9 error Cannot resolve name \`x\`. [cannot-resolve-name] flowtype-errors/show-errors
8 | 8:6 error Cannot resolve name \`y\`. [cannot-resolve-name] flowtype-errors/show-errors
9 |
10 | ✖ 3 problems (3 errors, 0 warnings)
11 | "
12 | `;
13 |
14 | exports[`Check codebases coverage-fail - eslint should give expected output 1`] = `
15 | "
16 | ./example.js
17 | 1:1 error Expected coverage to be at least 50%, but is: 0% flowtype-errors/enforce-min-coverage
18 |
19 | ✖ 1 problem (1 error, 0 warnings)
20 | "
21 | `;
22 |
23 | exports[`Check codebases coverage-fail2 - eslint should give expected output 1`] = `
24 | "
25 | ./example.js
26 | 1:1 error Expected coverage to be at least 50%, but is: 33.33% flowtype-errors/enforce-min-coverage
27 |
28 | ✖ 1 problem (1 error, 0 warnings)
29 | "
30 | `;
31 |
32 | exports[`Check codebases coverage-ok - eslint should give expected output 1`] = `""`;
33 |
34 | exports[`Check codebases coverage-ok2 - eslint should give expected output 1`] = `""`;
35 |
36 | exports[`Check codebases coverage-sync-remove - eslint should give expected output 1`] = `""`;
37 |
38 | exports[`Check codebases coverage-sync-update - eslint should give expected output 1`] = `""`;
39 |
40 | exports[`Check codebases flow-pragma-1 - eslint should give expected output 1`] = `
41 | "
42 | ./example.js
43 | 4:10 error Cannot return \`'string'\` because string is incompatible with boolean (see line 3). [incompatible-return] flowtype-errors/show-errors
44 | 7:6 error Cannot resolve name \`x\`. [cannot-resolve-name] flowtype-errors/show-errors
45 | 14:14 error Cannot perform arithmetic operation because string is not a number. [unsafe-addition] flowtype-errors/show-errors
46 |
47 | ✖ 3 problems (3 errors, 0 warnings)
48 | "
49 | `;
50 |
51 | exports[`Check codebases flow-pragma-2 - eslint should give expected output 1`] = `
52 | "
53 | ./example.js
54 | 6:10 error Cannot return \`'string'\` because string is incompatible with boolean (see line 5). [incompatible-return] flowtype-errors/show-errors
55 | 9:6 error Cannot resolve name \`x\`. [cannot-resolve-name] flowtype-errors/show-errors
56 | 16:14 error Cannot perform arithmetic operation because string is not a number. [unsafe-addition] flowtype-errors/show-errors
57 |
58 | ✖ 3 problems (3 errors, 0 warnings)
59 | "
60 | `;
61 |
62 | exports[`Check codebases html-support - eslint should give expected output 1`] = `
63 | "
64 | ./a.vue
65 | 5:1 error Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...>?
66 |
67 | 3 |
68 | 4 |
69 | > 5 |
84 | 8 |
85 |
86 | ✖ 2 problems (2 errors, 0 warnings)
87 | "
88 | `;
89 |
90 | exports[`Check codebases libdefs - eslint should give expected output 1`] = `
91 | "
92 | ./example.js
93 | 4:8 error Cannot call \`add\` with \`'2'\` bound to \`b\` because string is incompatible with number (see ./flow-typed/libdef.js:1). [incompatible-call] flowtype-errors/show-errors
94 | 6:21 error Cannot assign \`Date.now()\` to \`str\` because number (see https://github.com/facebook/flow/blob/v0.139.0/lib/core.js#L1497) is incompatible with string. [incompatible-type] flowtype-errors/show-errors
95 |
96 | ✖ 2 problems (2 errors, 0 warnings)
97 | "
98 | `;
99 |
100 | exports[`Check codebases no-flow-pragma - eslint should give expected output 1`] = `""`;
101 |
102 | exports[`Check codebases project-1 - eslint should give expected output 1`] = `
103 | "
104 | ./1.example.js
105 | 5:10 error Cannot return \`'string'\` because string is incompatible with boolean (see line 4). [incompatible-return] flowtype-errors/show-errors
106 | 8:6 error Cannot resolve name \`x\`. [cannot-resolve-name] flowtype-errors/show-errors
107 | 15:14 error Cannot perform arithmetic operation because string is not a number. [unsafe-addition] flowtype-errors/show-errors
108 |
109 | ./2.example.js
110 | 8:24 error Cannot build a typed interface for this module. You should annotate the exports of this module with types. Missing type annotation at array pattern: [signature-verification-failure] flowtype-errors/show-errors
111 | 8:26 error Cannot build a typed interface for this module. You should annotate the exports of this module with types. Missing type annotation at function return: [signature-verification-failure] flowtype-errors/show-errors
112 | 12:6 error Cannot resolve name \`x\`. [cannot-resolve-name] flowtype-errors/show-errors
113 |
114 | ./3.example.js
115 | 18:7 error Parsing error: Identifier 'who' has already been declared.
116 |
117 | 16 | var str: number = 'hello world!';
118 | 17 |
119 | > 18 | const who = {};
120 | | ^
121 | 19 |
122 | 20 | moo(str + who);
123 | 21 |
124 |
125 | ./4.example.js
126 | 26:11 error Cannot build a typed interface for this module. You should annotate the exports of this module with types. Missing type annotation at function return: [signature-verification-failure] flowtype-errors/show-errors
127 | 27:13 error Cannot create \`Foo\` element because property \`lastName\` is missing in props but exists in \`Props\` (see line 11). [prop-missing] flowtype-errors/show-errors
128 | 27:27 error Cannot create \`Foo\` element because string is incompatible with number (see line 7) in property \`firstName\`. [incompatible-type] flowtype-errors/show-errors
129 |
130 | ./5.example.js
131 | 4:29 error Cannot build a typed interface for this module. You should annotate the exports of this module with types. Missing type annotation at function return: [signature-verification-failure] flowtype-errors/show-errors
132 | 8:3 error Cannot call \`s\` with \`'4'\` bound to \`x\` because string is incompatible with number (see line 4). [incompatible-call] flowtype-errors/show-errors
133 |
134 | ./6.example.js
135 | 8:5 error Cannot call \`foo\` with \`1234\` bound to \`bar\` because number is incompatible with object type (see line 4). [incompatible-call] flowtype-errors/show-errors
136 | 10:5 error Cannot call \`foo\` with object literal bound to \`bar\` because property \`baz\` is missing in object literal but exists in object type (see line 4). [prop-missing] flowtype-errors/show-errors
137 |
138 | ./7.example.js
139 | 6:3 error Cannot call \`s\` with \`'4'\` bound to \`x\` because string is incompatible with number (see ./5.example.js:4). [incompatible-call] flowtype-errors/show-errors
140 |
141 | ./8.example.js
142 | 6:5 error Cannot call \`foo\` with \`1234\` bound to \`bar\` because number is incompatible with object type (see ./6.example.js:4). [incompatible-call] flowtype-errors/show-errors
143 | 8:5 error Cannot call \`foo\` with object literal bound to \`bar\` because property \`baz\` is missing in object literal but exists in object type (see ./6.example.js:4). [prop-missing] flowtype-errors/show-errors
144 |
145 | ./9.example.import.js
146 | 6:68 error Cannot build a typed interface for this module. You should annotate the exports of this module with types. Missing type annotation at function return: [signature-verification-failure] flowtype-errors/show-errors
147 |
148 | ./9.example.js
149 | 5:22 error Cannot resolve module \`react-dom\`. [cannot-resolve-module] flowtype-errors/show-errors
150 | 8:18 error Cannot create \`Hello\` element because property \`name\` is missing in props but exists in object type (see ./9.example.import.js:6). [prop-missing] flowtype-errors/show-errors
151 |
152 | ✖ 20 problems (20 errors, 0 warnings)
153 | "
154 | `;
155 |
156 | exports[`Check codebases run-all - eslint should give expected output 1`] = `
157 | "
158 | ./.eslintrc.js
159 | 2:24 error Cannot resolve module \`module\`. [cannot-resolve-module] flowtype-errors/show-errors
160 |
161 | ./example.js
162 | 2:10 error Cannot return \`'string'\` because string is incompatible with boolean (see line 1). [incompatible-return] flowtype-errors/show-errors
163 | 5:6 error Cannot resolve name \`x\`. [cannot-resolve-name] flowtype-errors/show-errors
164 | 12:14 error Cannot perform arithmetic operation because string is not a number. [unsafe-addition] flowtype-errors/show-errors
165 |
166 | ✖ 4 problems (4 errors, 0 warnings)
167 | "
168 | `;
169 |
170 | exports[`Check codebases run-all-flowdir - eslint should give expected output 1`] = `
171 | "
172 | ./subdir/example.js
173 | 2:10 error Cannot return \`'string'\` because string is incompatible with boolean (see line 1). [incompatible-return] flowtype-errors/show-errors
174 | 5:6 error Cannot resolve name \`x\`. [cannot-resolve-name] flowtype-errors/show-errors
175 | 12:14 error Cannot perform arithmetic operation because string is not a number. [unsafe-addition] flowtype-errors/show-errors
176 |
177 | ✖ 3 problems (3 errors, 0 warnings)
178 | "
179 | `;
180 |
181 | exports[`Check codebases uncovered-example - eslint should give expected output 1`] = `
182 | "
183 | ./example.js
184 | 3:7 error Uncovered expression! Try adding annotations to inform flow of the type flowtype-errors/uncovered
185 | 9:1 error Uncovered expression! Try adding annotations to inform flow of the type flowtype-errors/uncovered
186 | 16:26 error Uncovered expression! Try adding annotations to inform flow of the type flowtype-errors/uncovered
187 | 17:14 error Uncovered expression! Try adding annotations to inform flow of the type flowtype-errors/uncovered
188 |
189 | ✖ 4 problems (4 errors, 0 warnings)
190 | "
191 | `;
192 |
193 | exports[`Check codebases warnings-all - eslint should give expected output 1`] = `
194 | "
195 | ./example.js
196 | 9:22 warning Unclear type. Using \`any\`, \`Object\`, or \`Function\` types is not safe! [unclear-type] flowtype-errors/show-warnings
197 |
198 | ✖ 1 problem (0 errors, 1 warning)
199 | "
200 | `;
201 |
202 | exports[`Check codebases warnings-default - eslint should give expected output 1`] = `""`;
203 |
204 | exports[`Check codebases warnings-mixed - eslint should give expected output 1`] = `
205 | "
206 | ./example.js
207 | 10:22 warning Unclear type. Using \`any\`, \`Object\`, or \`Function\` types is not safe! [unclear-type] flowtype-errors/show-warnings
208 | 19:10 error Cannot return \`x.reduce(...) / x.length\` because number is incompatible with string (see line 18). [incompatible-return] flowtype-errors/show-errors
209 |
210 | ✖ 2 problems (1 error, 1 warning)
211 | "
212 | `;
213 |
214 | exports[`Format 1.example.js - should have expected properties 1`] = `
215 | Array [
216 | Object {
217 | "end": 6,
218 | "loc": Object {
219 | "end": Object {
220 | "column": 17,
221 | "line": 6,
222 | "offset": 91,
223 | },
224 | "start": Object {
225 | "column": 10,
226 | "line": 6,
227 | "offset": 83,
228 | },
229 | },
230 | "message": "Cannot return \`'string'\` because string is incompatible with boolean (see line 5). [incompatible-return]",
231 | "start": 6,
232 | "type": "default",
233 | },
234 | Object {
235 | "end": 9,
236 | "loc": Object {
237 | "end": Object {
238 | "column": 6,
239 | "line": 9,
240 | "offset": 102,
241 | },
242 | "start": Object {
243 | "column": 6,
244 | "line": 9,
245 | "offset": 101,
246 | },
247 | },
248 | "message": "Cannot resolve name \`x\`. [cannot-resolve-name]",
249 | "start": 9,
250 | "type": "default",
251 | },
252 | Object {
253 | "end": 16,
254 | "loc": Object {
255 | "end": Object {
256 | "column": 16,
257 | "line": 16,
258 | "offset": 208,
259 | },
260 | "start": Object {
261 | "column": 14,
262 | "line": 16,
263 | "offset": 205,
264 | },
265 | },
266 | "message": "Cannot perform arithmetic operation because string is not a number. [unsafe-addition]",
267 | "start": 16,
268 | "type": "default",
269 | },
270 | ]
271 | `;
272 |
273 | exports[`Format 2.example.js - should have expected properties 1`] = `
274 | Array [
275 | Object {
276 | "end": 9,
277 | "loc": Object {
278 | "end": Object {
279 | "column": 24,
280 | "line": 9,
281 | "offset": 96,
282 | },
283 | "start": Object {
284 | "column": 24,
285 | "line": 9,
286 | "offset": 95,
287 | },
288 | },
289 | "message": "Cannot build a typed interface for this module. You should annotate the exports of this module with types. Missing type annotation at array pattern: [signature-verification-failure]",
290 | "start": 9,
291 | "type": "missing-annotation",
292 | },
293 | Object {
294 | "end": 9,
295 | "loc": Object {
296 | "end": Object {
297 | "column": 25,
298 | "line": 9,
299 | "offset": 97,
300 | },
301 | "start": Object {
302 | "column": 26,
303 | "line": 9,
304 | "offset": 97,
305 | },
306 | },
307 | "message": "Cannot build a typed interface for this module. You should annotate the exports of this module with types. Missing type annotation at function return: [signature-verification-failure]",
308 | "start": 9,
309 | "type": "missing-annotation",
310 | },
311 | Object {
312 | "end": 13,
313 | "loc": Object {
314 | "end": Object {
315 | "column": 6,
316 | "line": 13,
317 | "offset": 121,
318 | },
319 | "start": Object {
320 | "column": 6,
321 | "line": 13,
322 | "offset": 120,
323 | },
324 | },
325 | "message": "Cannot resolve name \`x\`. [cannot-resolve-name]",
326 | "start": 13,
327 | "type": "default",
328 | },
329 | ]
330 | `;
331 |
332 | exports[`Format 3.example.js - should have expected properties 1`] = `
333 | Array [
334 | Object {
335 | "end": 5,
336 | "loc": Object {
337 | "end": Object {
338 | "column": 33,
339 | "line": 5,
340 | "offset": 71,
341 | },
342 | "start": Object {
343 | "column": 34,
344 | "line": 5,
345 | "offset": 71,
346 | },
347 | },
348 | "message": "Cannot build a typed interface for this module. You should annotate the exports of this module with types. Missing type annotation at function return: [signature-verification-failure]",
349 | "start": 5,
350 | "type": "missing-annotation",
351 | },
352 | Object {
353 | "end": 10,
354 | "loc": Object {
355 | "end": Object {
356 | "column": 20,
357 | "line": 10,
358 | "offset": 145,
359 | },
360 | "start": Object {
361 | "column": 10,
362 | "line": 10,
363 | "offset": 134,
364 | },
365 | },
366 | "message": "Cannot return \`'undefined'\` because string is incompatible with number (see line 9). [incompatible-return]",
367 | "start": 10,
368 | "type": "default",
369 | },
370 | Object {
371 | "end": 14,
372 | "loc": Object {
373 | "end": Object {
374 | "column": 13,
375 | "line": 14,
376 | "offset": 207,
377 | },
378 | "start": Object {
379 | "column": 10,
380 | "line": 14,
381 | "offset": 203,
382 | },
383 | },
384 | "message": "Cannot return \`some\` because string (see line 13) is incompatible with number (see line 13). [incompatible-return]",
385 | "start": 14,
386 | "type": "default",
387 | },
388 | Object {
389 | "end": 17,
390 | "loc": Object {
391 | "end": Object {
392 | "column": 32,
393 | "line": 17,
394 | "offset": 244,
395 | },
396 | "start": Object {
397 | "column": 19,
398 | "line": 17,
399 | "offset": 230,
400 | },
401 | },
402 | "message": "Cannot assign \`'hello world!'\` to \`str\` because string is incompatible with number. [incompatible-type]",
403 | "start": 17,
404 | "type": "default",
405 | },
406 | Object {
407 | "end": 19,
408 | "loc": Object {
409 | "end": Object {
410 | "column": 12,
411 | "line": 19,
412 | "offset": 259,
413 | },
414 | "start": Object {
415 | "column": 5,
416 | "line": 19,
417 | "offset": 251,
418 | },
419 | },
420 | "message": "Cannot call \`moo\` because no arguments are expected by function (see line 9). [extra-arg]",
421 | "start": 19,
422 | "type": "default",
423 | },
424 | Object {
425 | "end": 19,
426 | "loc": Object {
427 | "end": Object {
428 | "column": 12,
429 | "line": 19,
430 | "offset": 259,
431 | },
432 | "start": Object {
433 | "column": 11,
434 | "line": 19,
435 | "offset": 257,
436 | },
437 | },
438 | "message": "Cannot add \`str\` and object literal because object literal is incompatible with number (see line 17). [incompatible-type]",
439 | "start": 19,
440 | "type": "default",
441 | },
442 | ]
443 | `;
444 |
445 | exports[`Format 4.example.js - should have expected properties 1`] = `
446 | Array [
447 | Object {
448 | "end": 27,
449 | "loc": Object {
450 | "end": Object {
451 | "column": 10,
452 | "line": 27,
453 | "offset": 413,
454 | },
455 | "start": Object {
456 | "column": 11,
457 | "line": 27,
458 | "offset": 413,
459 | },
460 | },
461 | "message": "Cannot build a typed interface for this module. You should annotate the exports of this module with types. Missing type annotation at function return: [signature-verification-failure]",
462 | "start": 27,
463 | "type": "missing-annotation",
464 | },
465 | Object {
466 | "end": 28,
467 | "loc": Object {
468 | "end": Object {
469 | "column": 15,
470 | "line": 28,
471 | "offset": 431,
472 | },
473 | "start": Object {
474 | "column": 13,
475 | "line": 28,
476 | "offset": 428,
477 | },
478 | },
479 | "message": "Cannot create \`Foo\` element because property \`lastName\` is missing in props but exists in \`Props\` (see line 12). [prop-missing]",
480 | "start": 28,
481 | "type": "default",
482 | },
483 | Object {
484 | "end": 28,
485 | "loc": Object {
486 | "end": Object {
487 | "column": 32,
488 | "line": 28,
489 | "offset": 448,
490 | },
491 | "start": Object {
492 | "column": 27,
493 | "line": 28,
494 | "offset": 442,
495 | },
496 | },
497 | "message": "Cannot create \`Foo\` element because string is incompatible with number (see line 8) in property \`firstName\`. [incompatible-type]",
498 | "start": 28,
499 | "type": "default",
500 | },
501 | ]
502 | `;
503 |
504 | exports[`Format 5.example.js - should have expected properties 1`] = `
505 | Array [
506 | Object {
507 | "end": 5,
508 | "loc": Object {
509 | "end": Object {
510 | "column": 28,
511 | "line": 5,
512 | "offset": 66,
513 | },
514 | "start": Object {
515 | "column": 29,
516 | "line": 5,
517 | "offset": 66,
518 | },
519 | },
520 | "message": "Cannot build a typed interface for this module. You should annotate the exports of this module with types. Missing type annotation at function return: [signature-verification-failure]",
521 | "start": 5,
522 | "type": "missing-annotation",
523 | },
524 | Object {
525 | "end": 9,
526 | "loc": Object {
527 | "end": Object {
528 | "column": 5,
529 | "line": 9,
530 | "offset": 93,
531 | },
532 | "start": Object {
533 | "column": 3,
534 | "line": 9,
535 | "offset": 90,
536 | },
537 | },
538 | "message": "Cannot call \`s\` with \`'4'\` bound to \`x\` because string is incompatible with number (see line 5). [incompatible-call]",
539 | "start": 9,
540 | "type": "default",
541 | },
542 | ]
543 | `;
544 |
545 | exports[`Format 6.example.js - should have expected properties 1`] = `
546 | Array [
547 | Object {
548 | "end": 9,
549 | "loc": Object {
550 | "end": Object {
551 | "column": 8,
552 | "line": 9,
553 | "offset": 113,
554 | },
555 | "start": Object {
556 | "column": 5,
557 | "line": 9,
558 | "offset": 109,
559 | },
560 | },
561 | "message": "Cannot call \`foo\` with \`1234\` bound to \`bar\` because number is incompatible with object type (see line 5). [incompatible-call]",
562 | "start": 9,
563 | "type": "default",
564 | },
565 | Object {
566 | "end": 11,
567 | "loc": Object {
568 | "end": Object {
569 | "column": 18,
570 | "line": 11,
571 | "offset": 135,
572 | },
573 | "start": Object {
574 | "column": 5,
575 | "line": 11,
576 | "offset": 121,
577 | },
578 | },
579 | "message": "Cannot call \`foo\` with object literal bound to \`bar\` because property \`baz\` is missing in object literal but exists in object type (see line 5). [prop-missing]",
580 | "start": 11,
581 | "type": "default",
582 | },
583 | ]
584 | `;
585 |
586 | exports[`Format 7.example.js - should have expected properties 1`] = `
587 | Array [
588 | Object {
589 | "end": 7,
590 | "loc": Object {
591 | "end": Object {
592 | "column": 5,
593 | "line": 7,
594 | "offset": 80,
595 | },
596 | "start": Object {
597 | "column": 3,
598 | "line": 7,
599 | "offset": 77,
600 | },
601 | },
602 | "message": "Cannot call \`s\` with \`'4'\` bound to \`x\` because string is incompatible with number (see ./5.example.js:5). [incompatible-call]",
603 | "start": 7,
604 | "type": "default",
605 | },
606 | ]
607 | `;
608 |
609 | exports[`Format 8.example.js - should have expected properties 1`] = `
610 | Array [
611 | Object {
612 | "end": 7,
613 | "loc": Object {
614 | "end": Object {
615 | "column": 8,
616 | "line": 7,
617 | "offset": 85,
618 | },
619 | "start": Object {
620 | "column": 5,
621 | "line": 7,
622 | "offset": 81,
623 | },
624 | },
625 | "message": "Cannot call \`foo\` with \`1234\` bound to \`bar\` because number is incompatible with object type (see ./6.example.js:5). [incompatible-call]",
626 | "start": 7,
627 | "type": "default",
628 | },
629 | Object {
630 | "end": 9,
631 | "loc": Object {
632 | "end": Object {
633 | "column": 18,
634 | "line": 9,
635 | "offset": 107,
636 | },
637 | "start": Object {
638 | "column": 5,
639 | "line": 9,
640 | "offset": 93,
641 | },
642 | },
643 | "message": "Cannot call \`foo\` with object literal bound to \`bar\` because property \`baz\` is missing in object literal but exists in object type (see ./6.example.js:5). [prop-missing]",
644 | "start": 9,
645 | "type": "default",
646 | },
647 | ]
648 | `;
649 |
650 | exports[`Format 9.example.js - should have expected properties 1`] = `
651 | Array [
652 | Object {
653 | "end": 6,
654 | "loc": Object {
655 | "end": Object {
656 | "column": 32,
657 | "line": 6,
658 | "offset": 97,
659 | },
660 | "start": Object {
661 | "column": 22,
662 | "line": 6,
663 | "offset": 86,
664 | },
665 | },
666 | "message": "Cannot resolve module \`react-dom\`. [cannot-resolve-module]",
667 | "start": 6,
668 | "type": "default",
669 | },
670 | Object {
671 | "end": 9,
672 | "loc": Object {
673 | "end": Object {
674 | "column": 22,
675 | "line": 9,
676 | "offset": 165,
677 | },
678 | "start": Object {
679 | "column": 18,
680 | "line": 9,
681 | "offset": 160,
682 | },
683 | },
684 | "message": "Cannot create \`Hello\` element because property \`name\` is missing in props but exists in object type (see ./9.example.import.js:7). [prop-missing]",
685 | "start": 9,
686 | "type": "default",
687 | },
688 | ]
689 | `;
690 |
691 | exports[`Format 10.example.js - should have expected properties 1`] = `
692 | Array [
693 | Object {
694 | "end": 9,
695 | "loc": Object {
696 | "end": Object {
697 | "column": 9,
698 | "line": 9,
699 | "offset": 145,
700 | },
701 | "start": Object {
702 | "column": 5,
703 | "line": 9,
704 | "offset": 140,
705 | },
706 | },
707 | "message": "Cannot get \`a.foo\` because: [incompatible-use] Either property \`foo\` is missing in object type (see line 5). Or property \`foo\` is missing in object type (see line 5).",
708 | "start": 9,
709 | "type": "default",
710 | },
711 | ]
712 | `;
713 |
--------------------------------------------------------------------------------
/test/codebases/column-offset/.flowconfig:
--------------------------------------------------------------------------------
1 | [options]
2 | esproposal.class_static_fields=enable
3 | esproposal.class_instance_fields=enable
4 | esproposal.export_star_as=enable
5 |
--------------------------------------------------------------------------------
/test/codebases/column-offset/example.js:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | /**
6 | * @flow
7 | */test(x);
8 | test(y);
9 |
--------------------------------------------------------------------------------
/test/codebases/coverage-fail/.flowconfig:
--------------------------------------------------------------------------------
1 | [options]
2 | esproposal.class_static_fields=enable
3 | esproposal.class_instance_fields=enable
4 | esproposal.export_star_as=enable
5 |
--------------------------------------------------------------------------------
/test/codebases/coverage-fail/example.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | let x;
4 |
--------------------------------------------------------------------------------
/test/codebases/coverage-fail2/.flowconfig:
--------------------------------------------------------------------------------
1 | [options]
2 | esproposal.class_static_fields=enable
3 | esproposal.class_instance_fields=enable
4 | esproposal.export_star_as=enable
5 |
--------------------------------------------------------------------------------
/test/codebases/coverage-fail2/example.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | let x: number;
4 | let y;
5 | let z;
6 |
--------------------------------------------------------------------------------
/test/codebases/coverage-ok/.flowconfig:
--------------------------------------------------------------------------------
1 | [options]
2 | esproposal.class_static_fields=enable
3 | esproposal.class_instance_fields=enable
4 | esproposal.export_star_as=enable
5 |
--------------------------------------------------------------------------------
/test/codebases/coverage-ok/example.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | let x: number = 100;
4 |
--------------------------------------------------------------------------------
/test/codebases/coverage-ok2/.flowconfig:
--------------------------------------------------------------------------------
1 | [options]
2 | esproposal.class_static_fields=enable
3 | esproposal.class_instance_fields=enable
4 | esproposal.export_star_as=enable
5 |
--------------------------------------------------------------------------------
/test/codebases/coverage-ok2/example.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | let x: number;
4 | let y: number;
5 | let z;
6 |
--------------------------------------------------------------------------------
/test/codebases/coverage-sync-remove/.flowconfig:
--------------------------------------------------------------------------------
1 | [options]
2 | esproposal.class_static_fields=enable
3 | esproposal.class_instance_fields=enable
4 | esproposal.export_star_as=enable
5 |
--------------------------------------------------------------------------------
/test/codebases/coverage-sync-remove/example.fixed:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 |
4 | let x: number = 100;
5 | let x2: number = 100;
6 | let x3: number = 100;
7 | let x4;
8 | let x5;
9 |
--------------------------------------------------------------------------------
/test/codebases/coverage-sync-remove/example.js:
--------------------------------------------------------------------------------
1 | // @flow
2 | /* eslint "flowtype-errors/enforce-min-coverage": [2, 30] */
3 |
4 | let x: number = 100;
5 | let x2: number = 100;
6 | let x3: number = 100;
7 | let x4;
8 | let x5;
9 |
--------------------------------------------------------------------------------
/test/codebases/coverage-sync-update/.flowconfig:
--------------------------------------------------------------------------------
1 | [options]
2 | esproposal.class_static_fields=enable
3 | esproposal.class_instance_fields=enable
4 | esproposal.export_star_as=enable
5 |
--------------------------------------------------------------------------------
/test/codebases/coverage-sync-update/example.fixed:
--------------------------------------------------------------------------------
1 | // @flow
2 | /* eslint "flowtype-errors/enforce-min-coverage": [2, 33] */
3 |
4 | let x: number = 100;
5 | let x2;
6 | let x3;
7 | let x4;
8 | let x5;
9 |
--------------------------------------------------------------------------------
/test/codebases/coverage-sync-update/example.js:
--------------------------------------------------------------------------------
1 | // @flow
2 | /* eslint "flowtype-errors/enforce-min-coverage": [2, 5] */
3 |
4 | let x: number = 100;
5 | let x2;
6 | let x3;
7 | let x4;
8 | let x5;
9 |
--------------------------------------------------------------------------------
/test/codebases/flow-pragma-1/.flowconfig:
--------------------------------------------------------------------------------
1 | [options]
2 | esproposal.class_static_fields=enable
3 | esproposal.class_instance_fields=enable
4 | esproposal.export_star_as=enable
5 |
--------------------------------------------------------------------------------
/test/codebases/flow-pragma-1/example.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | function test(x: string): boolean {
4 | return 'string';
5 | }
6 |
7 | test(x);
8 |
9 | function square(x): number {
10 | return x * x;
11 | }
12 |
13 | function incorrectSquare(x): number {
14 | return x * 'x';
15 | }
16 |
--------------------------------------------------------------------------------
/test/codebases/flow-pragma-2/.flowconfig:
--------------------------------------------------------------------------------
1 | [options]
2 | esproposal.class_static_fields=enable
3 | esproposal.class_instance_fields=enable
4 | esproposal.export_star_as=enable
5 |
--------------------------------------------------------------------------------
/test/codebases/flow-pragma-2/example.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @flow
3 | */
4 |
5 | function test(x: string): boolean {
6 | return 'string';
7 | }
8 |
9 | test(x);
10 |
11 | function square(x): number {
12 | return x * x;
13 | }
14 |
15 | function incorrectSquare(x): number {
16 | return x * 'x';
17 | }
18 |
--------------------------------------------------------------------------------
/test/codebases/html-support/.flowconfig:
--------------------------------------------------------------------------------
1 | [options]
2 | esproposal.class_static_fields=enable
3 | esproposal.class_instance_fields=enable
4 | esproposal.export_star_as=enable
5 |
--------------------------------------------------------------------------------
/test/codebases/html-support/a.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
16 |
--------------------------------------------------------------------------------
/test/codebases/html-support/b.vue:
--------------------------------------------------------------------------------
1 |
2 | Hello
3 |
4 |
5 |
8 |
--------------------------------------------------------------------------------
/test/codebases/libdefs/.flowconfig:
--------------------------------------------------------------------------------
1 | [options]
2 | esproposal.class_static_fields=enable
3 | esproposal.class_instance_fields=enable
4 | esproposal.export_star_as=enable
5 |
--------------------------------------------------------------------------------
/test/codebases/libdefs/example.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @flow
3 | */
4 | add(1, '2'); // add() is from the libdef
5 |
6 | const str: string = Date.now();
7 |
--------------------------------------------------------------------------------
/test/codebases/libdefs/flow-typed/libdef.js:
--------------------------------------------------------------------------------
1 | declare function add(a: number, b: number): number;
2 |
--------------------------------------------------------------------------------
/test/codebases/no-flow-pragma/.flowconfig:
--------------------------------------------------------------------------------
1 | [options]
2 | esproposal.class_static_fields=enable
3 | esproposal.class_instance_fields=enable
4 | esproposal.export_star_as=enable
5 |
--------------------------------------------------------------------------------
/test/codebases/no-flow-pragma/example.js:
--------------------------------------------------------------------------------
1 | function test(x: string): boolean {
2 | return 'string';
3 | }
4 |
5 | test(x);
6 |
7 | function square(x): number {
8 | return x * x;
9 | }
10 |
11 | function incorrectSquare(x): number {
12 | return x * 'x';
13 | }
14 |
--------------------------------------------------------------------------------
/test/codebases/project-1/.flowconfig:
--------------------------------------------------------------------------------
1 | [options]
2 | esproposal.class_static_fields=enable
3 | esproposal.class_instance_fields=enable
4 | esproposal.export_star_as=enable
5 |
--------------------------------------------------------------------------------
/test/codebases/project-1/1.example.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @flow
3 | */
4 | function test(x: string): boolean {
5 | return 'string';
6 | }
7 |
8 | test(x);
9 |
10 | function square(x): number {
11 | return x * x;
12 | }
13 |
14 | function incorrectSquare(x): number {
15 | return x * 'x';
16 | }
17 |
--------------------------------------------------------------------------------
/test/codebases/project-1/2.example.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @flow
3 | */
4 | function test(x) {
5 | return x;
6 | }
7 |
8 | export function square(x) {
9 | return x;
10 | }
11 |
12 | test(x);
13 | square();
14 |
--------------------------------------------------------------------------------
/test/codebases/project-1/3.example.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @flow
3 | */
4 | export function square(x: number) {
5 | return x * x;
6 | }
7 |
8 | export function moo(): number {
9 | return 'undefined';
10 | }
11 |
12 | export function who(some: string): number {
13 | return some;
14 | }
15 |
16 | var str: number = 'hello world!';
17 |
18 | const who = {};
19 |
20 | moo(str + who);
21 |
--------------------------------------------------------------------------------
/test/codebases/project-1/4.example.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @flow
3 | */
4 | import React, { Component } from 'react';
5 |
6 | type Props = {
7 | firstName: number,
8 | lastName: string
9 | };
10 |
11 | class Foo extends Component {
12 | props: Props
13 |
14 | render() {
15 | return (
16 |
17 |
18 | Hello {this.props.firstName} {this.props.lastName}
19 |
20 |
21 | );
22 | }
23 | }
24 |
25 | export default class Bar extends Component<{}, {}> {
26 | render() {
27 | return ;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/test/codebases/project-1/5.example.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @flow
3 | */
4 | export function s(x: number) {
5 | return x * x;
6 | }
7 |
8 | s('4');
9 |
--------------------------------------------------------------------------------
/test/codebases/project-1/6.example.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @flow
3 | */
4 | export function foo(bar: { baz: string }) {
5 | console.log(foo);
6 | }
7 |
8 | foo(1234);
9 |
10 | foo({ xyz: 'abc' });
11 |
--------------------------------------------------------------------------------
/test/codebases/project-1/7.example.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @flow
3 | */
4 | import { s } from './5.example.js';
5 |
6 | s('4');
7 |
--------------------------------------------------------------------------------
/test/codebases/project-1/8.example.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @flow
3 | */
4 | import { foo } from './6.example.js';
5 |
6 | foo(1234);
7 |
8 | foo({ xyz: 'abc' });
9 |
--------------------------------------------------------------------------------
/test/codebases/project-1/9.example.import.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @flow
3 | */
4 | import React from 'react';
5 |
6 | export default function Hello({ name = 'World' }: { name: string }) {
7 | return Hello, {name}!
;
8 | }
9 |
--------------------------------------------------------------------------------
/test/codebases/project-1/9.example.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @flow
3 | */
4 | import React from 'react';
5 | import ReactDOM from 'react-dom';
6 | import Hello from './9.example.import.js';
7 |
8 | ReactDOM.render(, document.getElementById('app'));
9 |
--------------------------------------------------------------------------------
/test/codebases/run-all-flowdir/subdir/.flowconfig:
--------------------------------------------------------------------------------
1 | [options]
2 | all=true
3 |
--------------------------------------------------------------------------------
/test/codebases/run-all-flowdir/subdir/example.js:
--------------------------------------------------------------------------------
1 | function test(x: string): boolean {
2 | return 'string';
3 | }
4 |
5 | test(x);
6 |
7 | function square(x): number {
8 | return x * x;
9 | }
10 |
11 | function incorrectSquare(x): number {
12 | return x * 'x';
13 | }
14 |
--------------------------------------------------------------------------------
/test/codebases/run-all/.flowconfig:
--------------------------------------------------------------------------------
1 | [options]
2 | all=true
3 |
--------------------------------------------------------------------------------
/test/codebases/run-all/example.js:
--------------------------------------------------------------------------------
1 | function test(x: string): boolean {
2 | return 'string';
3 | }
4 |
5 | test(x);
6 |
7 | function square(x): number {
8 | return x * x;
9 | }
10 |
11 | function incorrectSquare(x): number {
12 | return x * 'x';
13 | }
14 |
--------------------------------------------------------------------------------
/test/codebases/uncovered-example/.flowconfig:
--------------------------------------------------------------------------------
1 | [options]
2 | esproposal.class_static_fields=enable
3 | esproposal.class_instance_fields=enable
4 | esproposal.export_star_as=enable
5 |
--------------------------------------------------------------------------------
/test/codebases/uncovered-example/example.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | const x: any = 2;
4 |
5 | const fn = (input): any => {
6 | return input;
7 | };
8 |
9 | fn([
10 | 1,
11 | // newline break
12 | 2,
13 | ]);
14 |
15 | // errors are typed "any"
16 | Promise.resolve().catch((err) => {
17 | if (typeof err === "string") {
18 | return err;
19 | }
20 | });
21 |
--------------------------------------------------------------------------------
/test/codebases/warnings-all/.flowconfig:
--------------------------------------------------------------------------------
1 | [lints]
2 | all=error
3 | unclear-type=warn
4 |
5 | [options]
6 | include_warnings=true
7 |
--------------------------------------------------------------------------------
/test/codebases/warnings-all/example.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | /*
4 | * This file should trigger a warning for `x` being of
5 | * unclear type since we set `include_warnings=true`
6 | * in the `.flowconfig` file.
7 | */
8 |
9 | function identity(x: any) {
10 | return x;
11 | }
12 |
--------------------------------------------------------------------------------
/test/codebases/warnings-default/.flowconfig:
--------------------------------------------------------------------------------
1 | [lints]
2 | all=error
3 | unclear-type=warn
4 |
--------------------------------------------------------------------------------
/test/codebases/warnings-default/example.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | /*
4 | * This file shouldn't trigger any warnings despite the fact
5 | * that unclear-type was set to warn and indentity's argument
6 | * `x` being of unclear type. This is because flow's default
7 | * behavior is to suppress warnings in the CLI output unless
8 | * `include_warnings` is turned on in your options.
9 | */
10 |
11 | function identity(x: any) {
12 | return x;
13 | }
14 |
--------------------------------------------------------------------------------
/test/codebases/warnings-mixed/.flowconfig:
--------------------------------------------------------------------------------
1 | [lints]
2 | all=error
3 | unclear-type=warn
4 |
5 | [options]
6 | include_warnings=true
7 |
--------------------------------------------------------------------------------
/test/codebases/warnings-mixed/example.js:
--------------------------------------------------------------------------------
1 | // @flow
2 |
3 | /*
4 | * This file should trigger a warning for `x` being of
5 | * unclear type and an error for the return statement
6 | * of incorrectMean since its type doesn't match the
7 | * hint we gave saying it should be a string.
8 | */
9 |
10 | function identity(x: any) {
11 | return x;
12 | }
13 |
14 | function mean(x): number {
15 | return x.reduce((acc, cur) => acc + cur) / x.length;
16 | }
17 |
18 | function incorrectMean(x): string {
19 | return x.reduce((acc, cur) => acc + cur) / x.length;
20 | }
21 |
--------------------------------------------------------------------------------
/test/format.spec.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-nested-ternary */
2 | import path from 'path';
3 | import { expect as chaiExpect } from 'chai';
4 | import { existsSync, readFileSync, writeFileSync, unlinkSync } from 'fs';
5 | // $FlowIgnore
6 | import execa from 'execa';
7 | import { collect } from '../src/collect';
8 |
9 | jest.setTimeout(process.platform === 'win32' ? 30000 : 10000);
10 |
11 | const testFilenames = [
12 | '1.example.js',
13 | '2.example.js',
14 | '3.example.js',
15 | '4.example.js',
16 | '5.example.js',
17 | '6.example.js',
18 | '7.example.js',
19 | '8.example.js',
20 | '9.example.js',
21 | '10.example.js',
22 | ];
23 |
24 | describe('Format', () => {
25 | for (const filename of testFilenames) {
26 | it(`${filename} - should have expected properties`, () => {
27 |
28 | const root = path.resolve(process.cwd(), 'test');
29 | const filepath = path.join(root, filename);
30 | const stdin = readFileSync(filepath).toString();
31 | const parsedJSONArray = collect(stdin, root, true, filepath, { line: 0, column: 0 });
32 |
33 | chaiExpect(parsedJSONArray).to.be.an('array');
34 |
35 | // Filter out the 'path' property because this changes between environments
36 | expect(
37 | parsedJSONArray.map(e => ({
38 | end: e.end,
39 | type: e.type,
40 | loc: { start: e.loc.start, end: e.loc.end },
41 | message: e.message,
42 | start: e.start
43 | }))
44 | ).toMatchSnapshot();
45 |
46 | for (const e of parsedJSONArray) {
47 | if (e !== false) {
48 | chaiExpect(e.type).to.be.a('string');
49 | chaiExpect(e.path)
50 | .to.be.a('string')
51 | .that.contains(path.join(process.cwd(), 'test'));
52 | chaiExpect(e.path)
53 | .to.be.a('string')
54 | .that.contains('.example.js');
55 | }
56 | }
57 | });
58 | }
59 | });
60 |
61 | const ESLINT_PATH = path.resolve('./node_modules/eslint/bin/eslint.js');
62 |
63 | async function runEslint(cwd) {
64 | const result = await execa(ESLINT_PATH, ['**/*.{js,vue}', '--fix'], { cwd, stripEof: false });
65 | result.stdout = result.stdout && result.stdout.toString();
66 | result.stderr = result.stderr && result.stderr.toString();
67 | return result;
68 | }
69 |
70 | const codebases = [
71 | 'column-offset',
72 | 'coverage-fail',
73 | 'coverage-fail2',
74 | 'coverage-ok',
75 | 'coverage-ok2',
76 | 'coverage-sync-remove',
77 | 'coverage-sync-update',
78 | 'flow-pragma-1',
79 | 'flow-pragma-2',
80 | 'html-support',
81 | 'libdefs',
82 | 'no-flow-pragma',
83 | 'project-1',
84 | 'run-all',
85 | 'run-all-flowdir',
86 | 'warnings-all',
87 | 'warnings-default',
88 | 'warnings-mixed',
89 | 'uncovered-example'
90 | ];
91 |
92 | const eslintConfig = (enforceMinCoverage, updateCommentThreshold, checkUncovered, html) => `
93 | const Module = require('module');
94 | const path = require('path');
95 | const original = Module._resolveFilename;
96 |
97 | // Hack to allow eslint to find the plugins
98 | Module._resolveFilename = function(request, parent, isMain) {
99 | if (request === 'eslint-plugin-flowtype-errors') {
100 | return require.resolve('../../../');
101 | }
102 | if (request === 'eslint-plugin-html') {
103 | return require.resolve('../../../node_modules/eslint-plugin-html');
104 | }
105 | if (request === 'eslint-plugin-vue') {
106 | return require.resolve('../../../node_modules/eslint-plugin-vue');
107 | }
108 | return original.call(this, request, parent, isMain);
109 | };
110 |
111 | module.exports = {
112 | parser: 'babel-eslint',
113 | root: true, // Make ESLint ignore configuration files in parent folders
114 | env: {
115 | node: true,
116 | es6: true
117 | },
118 | plugins: [${html ? `'html', 'vue',` : ''}'flowtype-errors'],
119 | settings: {
120 | 'flowtype-errors': {
121 | stopOnExit: 'true'
122 | }
123 | },
124 | rules: {
125 | ${updateCommentThreshold
126 | ? [
127 | `'flowtype-errors/enforce-min-coverage': [2, ${enforceMinCoverage}],`,
128 | `'flowtype-errors/enforce-min-coverage-comments-sync': [2, ${enforceMinCoverage}, ${updateCommentThreshold}],`,
129 | ].join('\n')
130 | : enforceMinCoverage
131 | ? `'flowtype-errors/enforce-min-coverage': [2, ${enforceMinCoverage}],`
132 | : ``
133 | }
134 | ${checkUncovered ? `'flowtype-errors/uncovered': 2,` : ''}
135 | 'flowtype-errors/show-errors': 2,
136 | 'flowtype-errors/show-warnings': 1
137 | }
138 | };
139 | `;
140 |
141 | describe('Check codebases', () => {
142 | for (const codebase of codebases) {
143 | let folder;
144 | let title;
145 |
146 | if (Array.isArray(codebase)) {
147 | title = codebase[0];
148 | folder = codebase[1];
149 | } else {
150 | title = codebase;
151 | folder = codebase;
152 | }
153 |
154 | // eslint-disable-next-line no-loop-func
155 | it(`${title} - eslint should give expected output`, async() => {
156 | const fullFolder = path.resolve(`./test/codebases/${folder}`);
157 | const exampleJsFilePath = path.resolve(`./test/codebases/${folder}/example.js`);
158 | const exampleJsFixedFilePath = path.resolve(`./test/codebases/${folder}/example.fixed`);
159 | const hasFix = existsSync(exampleJsFixedFilePath)
160 | const configPath = path.resolve(fullFolder, '.eslintrc.js');
161 |
162 | const contentsBefore = hasFix && readFileSync(exampleJsFilePath, 'utf8')
163 | const contentsExpected = hasFix && readFileSync(exampleJsFixedFilePath, 'utf8')
164 |
165 | // Write config file
166 | writeFileSync(
167 | configPath,
168 | eslintConfig(
169 | folder.match(/^coverage-/) ? 50 : 0,
170 | folder.match(/^coverage-sync/) ? 10 : 0,
171 | !!folder.match(/^uncovered-/),
172 | /html-support/.test(folder)
173 | )
174 | );
175 |
176 | // Spawn a eslint process
177 | const { stdout, stderr } = await runEslint(fullFolder).catch(e => e);
178 |
179 | const regexp = new RegExp(
180 | `^${fullFolder.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')}.+\\.(js|vue)$`,
181 | 'gm'
182 | ); // Escape regexp
183 |
184 | const contentsAfter = hasFix && readFileSync(exampleJsFilePath, 'utf8')
185 |
186 | // Revert the file to before it was fixed, since this file is checked into git.
187 | if (hasFix && contentsBefore !== contentsAfter) writeFileSync(exampleJsFilePath, contentsBefore)
188 |
189 | // Strip root from filenames
190 | expect(
191 | stdout.replace(regexp, match =>
192 | match.replace(fullFolder, '.').replace(/\\/g, '/')
193 | )
194 | ).toMatchSnapshot();
195 |
196 | expect(stderr).toEqual('');
197 |
198 | if (hasFix) {
199 | expect(contentsAfter).toEqual(contentsExpected);
200 | }
201 |
202 | // Clean up
203 | unlinkSync(configPath);
204 | });
205 | }
206 | });
207 |
--------------------------------------------------------------------------------