Skip to content

Commit 71d34da

Browse files
committed
Add flow and babel with eslint
1 parent 86962ee commit 71d34da

File tree

6 files changed

+172
-10
lines changed

6 files changed

+172
-10
lines changed

.babelrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"presets": ["flow"]
2+
"presets": ["flow"],
3+
"retainLines": true
34
}

.eslintrc.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
module.exports = {
2-
"extends": "airbnb"
3-
};
2+
"extends": [
3+
"airbnb",
4+
"plugin:flowtype/recommended"
5+
],
6+
"parser": "babel-eslint",
7+
"plugins": [
8+
"flowtype"
9+
]
10+
};

.flowconfig

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
[libs]
66

77
[lints]
8+
# all=off by default
9+
all=warn
10+
untyped-type-import=error
11+
sketchy-null-bool=off
812

913
[options]
1014

package-lock.json

+135-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
"main": "dist/index.js",
66
"scripts": {
77
"flow": "flow",
8+
"flow start": "flow start",
9+
"flow stop": "flow stop",
10+
"flow status": "flow status",
11+
"flow coverage": "flow coverage",
812
"test": "mocha --recursive --timeout=10000",
913
"build": "babel src/ -d dist/",
1014
"prepublish": "npm run build"
@@ -26,10 +30,12 @@
2630
"homepage": "https://github.com/vukanac/ci-base-nodejs#readme",
2731
"devDependencies": {
2832
"babel-cli": "^6.26.0",
33+
"babel-eslint": "^8.0.3",
2934
"babel-preset-flow": "^6.23.0",
3035
"chai": "^4.1.2",
3136
"eslint": "^4.13.1",
3237
"eslint-config-airbnb": "^16.1.0",
38+
"eslint-plugin-flowtype": "^2.40.1",
3339
"eslint-plugin-import": "^2.8.0",
3440
"eslint-plugin-jsx-a11y": "^6.0.2",
3541
"eslint-plugin-react": "^7.5.1",

src/index.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
type Person = {
2-
name: string,
3-
age: number
4-
};
1+
/* @flow */
2+
3+
function foo(x: ?number): string {
4+
if (x) {
5+
return `${x}`;
6+
}
7+
return 'default string';
8+
}
9+
10+
// type Person = {
11+
// name: string,
12+
// age: number
13+
// };
14+
15+
16+
foo(1);

0 commit comments

Comments
 (0)