Skip to content

Commit d76736c

Browse files
committed
Initial Flow support
1 parent 51010a5 commit d76736c

40 files changed

+169
-12
lines changed

.babelrc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
2-
"presets": ['react', 'es2015', 'stage-0'],
3-
"plugins": []
2+
"presets": [
3+
'react',
4+
'es2015',
5+
'stage-0'
6+
],
7+
"plugins": [
8+
'transform-flow-strip-types'
9+
]
410
}

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
interfaces

.eslintrc

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"plugin:ava/recommended"
66
],
77
"plugins": [
8-
"ava"
8+
"ava",
9+
"flowtype",
10+
"flow-vars"
911
],
1012
"rules": {
1113
"indent": [2, 2, {"SwitchCase": 1}],
@@ -20,9 +22,37 @@
2022
"react/prefer-stateless-function": [0],
2123
"no-underscore-dangle": ["error", { "allow": ["_config"] }],
2224
"import/no-unresolved": [0],
23-
"global-require": [0]
25+
"global-require": [0],
26+
"no-duplicate-imports": [0],
27+
"flowtype/require-parameter-type": 1,
28+
"flowtype/require-return-type": [
29+
1,
30+
"always",
31+
{
32+
"annotateUndefined": "never"
33+
}
34+
],
35+
"flowtype/space-after-type-colon": [
36+
1,
37+
"always"
38+
],
39+
"flowtype/space-before-type-colon": [
40+
1,
41+
"never"
42+
],
43+
"flowtype/type-id-match": [
44+
0,
45+
"^([A-Z][a-z0-9]+)+Type$"
46+
],
47+
"flow-vars/define-flow-type": 1,
48+
"flow-vars/use-flow-type": 1,
2449
},
2550
"globals": {
2651
"__PREFIX_LINKS__": true,
2752
},
53+
"settings": {
54+
"flowtype": {
55+
"onlyFilesWithFlowAnnotation": true
56+
}
57+
}
2858
}

.flowconfig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[version]
2+
0.27.0
3+
4+
[ignore]
5+
.*/node_modules/.*
6+
.*/test/.*
7+
8+
[include]
9+
node_modules
10+
11+
[libs]
12+
./interfaces/
13+
node_modules/iflow-debug/index.js.flow
14+
node_modules/iflow-lodash/index.js.flow
15+
node_modules/iflow-react-router/index.js.flow
16+
17+
[options]
18+
esproposal.class_instance_fields=enable
19+
esproposal.class_static_fields=enable
20+
21+
strip_root=true
22+
23+
suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe
24+
suppress_comment= \\(.\\|\n\\)*\\$FlowIssue

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ simple steps:
1717

1818
Test suite can be run via `npm test`.
1919

20+
This project uses [FlowType](https://flowtype.org/) for static type checking.
21+
22+
**Note for Windows Users** - Flow is not currently supported on Windows. Please do not let this prevent you from contributing. If you can use a VM for this part, great! Otherwise, feel free to open a PR and ask for assistance.
23+
2024
The usual contributing steps are:
2125

2226
* Fork the [official repository](https://github.com/gatsbyjs/gatsby).

interfaces/front-matter.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare module 'front-matter' {
2+
declare var exports: (input: string) => { attributes: {}, body: string };
3+
}

interfaces/html-frontmatter.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare module 'html-frontmatter' {
2+
declare var exports: (input: string) => {};
3+
}

interfaces/invariant.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare module 'invariant' {
2+
declare var exports: (condition: any, message: string) => ?Error
3+
}

interfaces/object-assign.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare module 'object-assign' {
2+
declare var exports: (target: Object, ...sources?: Array<Object>) => {};
3+
}

interfaces/parse-filepath.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
declare module 'parse-filepath' {
2+
declare type FileData = {
3+
root: string,
4+
dir: string,
5+
base: string,
6+
ext: string,
7+
name: string,
8+
9+
// aliases
10+
extname: string,
11+
basename: string,
12+
dirname: string,
13+
stem: string,
14+
15+
// original path
16+
path: string,
17+
18+
// getters
19+
absolute: () => string,
20+
isAbsolute: () => Boolean
21+
}
22+
23+
declare var exports: (input: string) => FileData
24+
}

0 commit comments

Comments
 (0)