Skip to content

Commit 9237aeb

Browse files
author
Damian Dulisz
committed
Add flowtype
1 parent 2cac27a commit 9237aeb

File tree

6 files changed

+36
-13
lines changed

6 files changed

+36
-13
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"presets": ["es2015", "stage-2"],
3-
"plugins": ["transform-runtime", "transform-vue-jsx"],
3+
"plugins": ["transform-runtime", "transform-vue-jsx", "transform-flow-strip-types"],
44
"comments": false
55
}

.eslintrc.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
module.exports = {
22
root: true,
3+
parser: 'babel-eslint',
34
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
4-
extends: 'standard',
5+
extends: [
6+
'standard',
7+
'plugin:flowtype/recommended'
8+
],
59
// required to lint *.vue files
610
plugins: [
7-
'html'
11+
'html',
12+
'flowtype'
813
],
914
// add your custom rules here
1015
'rules': {
1116
// allow paren-less arrow functions
1217
'arrow-parens': 0,
1318
// allow debugger during development
1419
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
20+
},
21+
'settings': {
22+
'flowtype': {
23+
"onlyFilesWithFlowAnnotation": false
24+
}
1525
}
1626
}

.flowconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[include]
2+
./src/
3+
4+
[ignore]
5+
./node_modules/

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@
3939
},
4040
"devDependencies": {
4141
"babel-core": "^6.7.7",
42+
"babel-eslint": "^6.1.2",
4243
"babel-helper-vue-jsx-merge-props": "^2.0.1",
4344
"babel-loader": "^6.2.4",
4445
"babel-plugin-syntax-jsx": "^6.13.0",
46+
"babel-plugin-transform-flow-strip-types": "^6.14.0",
4547
"babel-plugin-transform-runtime": "^6.7.5",
4648
"babel-plugin-transform-vue-jsx": "^2.0.2",
4749
"babel-preset-es2015": "^6.6.0",
@@ -56,13 +58,15 @@
5658
"eslint-config-standard": "^5.1.0",
5759
"eslint-friendly-formatter": "^1.2.2",
5860
"eslint-loader": "^1.3.0",
61+
"eslint-plugin-flowtype": "^2.18.1",
5962
"eslint-plugin-html": "^1.3.0",
6063
"eslint-plugin-promise": "^1.0.8",
6164
"eslint-plugin-standard": "^1.3.2",
6265
"eventsource-polyfill": "^0.9.6",
6366
"express": "^4.13.3",
6467
"extract-text-webpack-plugin": "^1.0.1",
6568
"file-loader": "^0.8.4",
69+
"flow-bin": "^0.32.0",
6670
"function-bind": "^1.0.2",
6771
"html-webpack-plugin": "^2.8.1",
6872
"http-proxy-middleware": "^0.12.0",

src/multiselectMixin.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @flow
2+
13
import deepClone from './utils'
24

35
function includes (str, query) {
@@ -237,12 +239,12 @@ module.exports = {
237239
this.$emit('search-change', this.search, this.id)
238240
}
239241
},
240-
'selected' (newVal, oldVal) {
242+
'selected' (newVal: Object, oldVal: Object) {
241243
this.value = deepClone(this.selected)
242244
}
243245
},
244246
methods: {
245-
updateSearch (query) {
247+
updateSearch (query: string) {
246248
this.search = query.trim().toLowerCase()
247249
},
248250
/**
@@ -251,7 +253,7 @@ module.exports = {
251253
* @param {String}
252254
* @returns {Boolean} returns true if element is available
253255
*/
254-
isExistingOption (query) {
256+
isExistingOption (query: string) {
255257
return !this.options
256258
? false
257259
: this.optionKeys.indexOf(query) > -1
@@ -262,7 +264,7 @@ module.exports = {
262264
* @param {Object||String||Integer} option passed element to check
263265
* @returns {Boolean} returns true if element is selected
264266
*/
265-
isSelected (option) {
267+
isSelected (option: Object) {
266268
/* istanbul ignore else */
267269
if (!this.value) return false
268270
const opt = this.trackBy
@@ -281,7 +283,7 @@ module.exports = {
281283
* @param {Object||String||Integer} option passed element to check
282284
* @returns {Boolean} returns true if element is not selected
283285
*/
284-
isNotSelected (option) {
286+
isNotSelected (option: Object) {
285287
return !this.isSelected(option)
286288
},
287289
/**
@@ -292,7 +294,7 @@ module.exports = {
292294
* @param {Object||String||Integer} Passed option
293295
* @returns {Object||String}
294296
*/
295-
getOptionLabel (option) {
297+
getOptionLabel (option: Object) {
296298
if (typeof option === 'object' && option !== null) {
297299
if (this.customLabel) {
298300
return this.customLabel(option)
@@ -314,7 +316,7 @@ module.exports = {
314316
*
315317
* @param {Object||String||Integer} option to select/deselect
316318
*/
317-
select (option) {
319+
select (option: Object) {
318320
if (this.max && this.multiple && this.value.length === this.max) return
319321
if (option.isTag) {
320322
this.$emit('tag', option.label, this.id)
@@ -352,7 +354,7 @@ module.exports = {
352354
* @param {type} option description
353355
* @returns {type} description
354356
*/
355-
removeElement (option) {
357+
removeElement (option: Object) {
356358
/* istanbul ignore else */
357359
if (!this.allowEmpty && this.value.length <= 1) return
358360

src/pointerMixin.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @flow
2+
13
module.exports = {
24
data () {
35
return {
@@ -27,7 +29,7 @@ module.exports = {
2729
}
2830
},
2931
methods: {
30-
optionHighlight (index, option) {
32+
optionHighlight (index: number, option: Object): Object {
3133
return {
3234
'multiselect__option--highlight': index === this.pointer && this.showPointer,
3335
'multiselect__option--selected': !this.isNotSelected(option)
@@ -70,7 +72,7 @@ module.exports = {
7072
: 0
7173
}
7274
},
73-
pointerSet (index) {
75+
pointerSet (index: number) {
7476
this.pointer = index
7577
}
7678
}

0 commit comments

Comments
 (0)