Skip to content

Commit 4bf6c0c

Browse files
committed
Fix code style issues
1 parent a54c412 commit 4bf6c0c

File tree

7 files changed

+1365
-1352
lines changed

7 files changed

+1365
-1352
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"env": {
1212
"browser": true,
1313
"node": true,
14-
"es6": true
14+
"es6": true,
15+
"jasmine": true
1516
},
1617

1718
"extends": "standard"

src/components/Select.vue

Lines changed: 59 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,9 @@
370370
*/
371371
options: {
372372
type: Array,
373-
default() {
373+
default () {
374374
return []
375-
},
375+
}
376376
},
377377
378378
/**
@@ -469,13 +469,13 @@
469469
*/
470470
getOptionLabel: {
471471
type: Function,
472-
default(option) {
472+
default (option) {
473473
if (typeof option === 'object') {
474474
if (this.label && option[this.label]) {
475475
return option[this.label]
476476
}
477477
}
478-
return option;
478+
return option
479479
}
480480
},
481481
@@ -538,7 +538,7 @@
538538
*/
539539
createOption: {
540540
type: Function,
541-
default(newOption) {
541+
default (newOption) {
542542
if (typeof this.mutableOptions[0] === 'object') {
543543
newOption = {[this.label]: newOption}
544544
}
@@ -583,10 +583,10 @@
583583
dir: {
584584
type: String,
585585
default: 'auto'
586-
},
586+
}
587587
},
588588
589-
data() {
589+
data () {
590590
return {
591591
search: '',
592592
open: false,
@@ -598,12 +598,12 @@
598598
watch: {
599599
/**
600600
* When the value prop changes, update
601-
* the internal mutableValue.
601+
* the internal mutableValue.
602602
* @param {mixed} val
603603
* @return {void}
604604
*/
605-
value(val) {
606-
this.mutableValue = val
605+
value (val) {
606+
this.mutableValue = val
607607
},
608608
609609
/**
@@ -612,11 +612,11 @@
612612
* @param {string|object} old
613613
* @return {void}
614614
*/
615-
mutableValue(val, old) {
615+
mutableValue (val, old) {
616616
if (this.multiple) {
617-
this.onChange ? this.onChange(val) : null
617+
if (this.onChange) this.onChange(val)
618618
} else {
619-
this.onChange && val !== old ? this.onChange(val) : null
619+
if (this.onChange && val !== old) this.onChange(val)
620620
}
621621
},
622622
@@ -626,40 +626,40 @@
626626
* @param {array} val
627627
* @return {void}
628628
*/
629-
options(val) {
629+
options (val) {
630630
this.mutableOptions = val
631631
},
632632
633633
/**
634-
* Maybe reset the mutableValue
634+
* Maybe reset the mutableValue
635635
* when mutableOptions change.
636636
* @return {[type]} [description]
637637
*/
638-
mutableOptions() {
638+
mutableOptions () {
639639
if (!this.taggable && this.resetOnOptionsChange) {
640-
this.mutableValue = this.multiple ? [] : null
640+
this.mutableValue = this.multiple ? [] : null
641641
}
642642
},
643643
644644
/**
645-
* Always reset the mutableValue when
645+
* Always reset the mutableValue when
646646
* the multiple prop changes.
647647
* @param {Boolean} val
648648
* @return {void}
649649
*/
650-
multiple(val) {
651-
this.mutableValue = val ? [] : null
650+
multiple (val) {
651+
this.mutableValue = val ? [] : null
652652
}
653653
},
654654
655655
/**
656656
* Clone props into mutable values,
657657
* attach any event listeners.
658658
*/
659-
created() {
660-
this.mutableValue = this.value
659+
created () {
660+
this.mutableValue = this.value
661661
this.mutableOptions = this.options.slice(0)
662-
this.mutableLoading = this.loading
662+
this.mutableLoading = this.loading
663663
664664
this.$on('option:created', this.maybePushTag)
665665
},
@@ -671,7 +671,7 @@
671671
* @param {Object|String} option
672672
* @return {void}
673673
*/
674-
select(option) {
674+
select (option) {
675675
if (this.isOptionSelected(option)) {
676676
this.deselect(option)
677677
} else {
@@ -696,15 +696,15 @@
696696
* @param {Object|String} option
697697
* @return {void}
698698
*/
699-
deselect(option) {
699+
deselect (option) {
700700
if (this.multiple) {
701701
let ref = -1
702702
this.mutableValue.forEach((val) => {
703-
if (val === option || typeof val === 'object' && val[this.label] === option[this.label]) {
703+
if (val === option || (typeof val === 'object' && val[this.label] === option[this.label])) {
704704
ref = val
705705
}
706706
})
707-
var index = this.mutableValue.indexOf(ref)
707+
const index = this.mutableValue.indexOf(ref)
708708
this.mutableValue.splice(index, 1)
709709
} else {
710710
this.mutableValue = null
@@ -716,7 +716,7 @@
716716
* @param {Object|String} option
717717
* @return {void}
718718
*/
719-
onAfterSelect(option) {
719+
onAfterSelect (option) {
720720
if (this.closeOnSelect) {
721721
this.open = !this.open
722722
this.$refs.search.blur()
@@ -732,8 +732,9 @@
732732
* @param {Event} e
733733
* @return {void}
734734
*/
735-
toggleDropdown(e) {
736-
if (e.target === this.$refs.openIndicator || e.target === this.$refs.search || e.target === this.$refs.toggle || e.target === this.$el) {
735+
toggleDropdown (e) {
736+
if (e.target === this.$refs.openIndicator || e.target === this.$refs.search ||
737+
e.target === this.$refs.toggle || e.target === this.$el) {
737738
if (this.open) {
738739
this.$refs.search.blur() // dropdown will close on blur
739740
} else {
@@ -750,16 +751,15 @@
750751
* @param {Object|String} option
751752
* @return {Boolean} True when selected | False otherwise
752753
*/
753-
isOptionSelected(option) {
754+
isOptionSelected (option) {
754755
if (this.multiple && this.mutableValue) {
755756
let selected = false
756757
this.mutableValue.forEach(opt => {
757758
if (typeof opt === 'object' && opt[this.label] === option[this.label]) {
758759
selected = true
759760
} else if (typeof opt === 'object' && opt[this.label] === option) {
760761
selected = true
761-
}
762-
else if (opt === option) {
762+
} else if (opt === option) {
763763
selected = true
764764
}
765765
})
@@ -774,7 +774,7 @@
774774
* Otherwise, blur the search input to close the dropdown.
775775
* @return {void}
776776
*/
777-
onEscape() {
777+
onEscape () {
778778
if (!this.search.length) {
779779
this.$refs.search.blur()
780780
} else {
@@ -787,7 +787,7 @@
787787
* @emits {search:blur}
788788
* @return {void}
789789
*/
790-
onSearchBlur() {
790+
onSearchBlur () {
791791
if (this.clearSearchOnBlur) {
792792
this.search = ''
793793
}
@@ -800,7 +800,7 @@
800800
* @emits {search:focus}
801801
* @return {void}
802802
*/
803-
onSearchFocus() {
803+
onSearchFocus () {
804804
this.open = true
805805
this.$emit('search:focus')
806806
},
@@ -810,10 +810,18 @@
810810
* text in the search input, & there's tags to delete
811811
* @return {this.value}
812812
*/
813-
maybeDeleteValue() {
813+
maybeDeleteValue () {
814+
let value = null
815+
814816
if (!this.$refs.search.value.length && this.mutableValue) {
815-
return this.multiple ? this.mutableValue.pop() : this.mutableValue = null
817+
if (this.multiple) {
818+
value = this.mutableValue.pop()
819+
} else {
820+
value = this.mutableValue = null
821+
}
816822
}
823+
824+
return value
817825
},
818826
819827
/**
@@ -823,7 +831,7 @@
823831
* @param {Object || String} option
824832
* @return {boolean}
825833
*/
826-
optionExists(option) {
834+
optionExists (option) {
827835
let exists = false
828836
829837
this.mutableOptions.forEach(opt => {
@@ -844,7 +852,7 @@
844852
* @param {Object || String} option
845853
* @return {void}
846854
*/
847-
maybePushTag(option) {
855+
maybePushTag (option) {
848856
if (this.pushTags) {
849857
this.mutableOptions.push(option)
850858
}
@@ -857,7 +865,7 @@
857865
* Classes to be output on .dropdown
858866
* @return {Object}
859867
*/
860-
dropdownClasses() {
868+
dropdownClasses () {
861869
return {
862870
open: this.dropdownOpen,
863871
single: !this.multiple,
@@ -874,7 +882,7 @@
874882
* If search text should clear on blur
875883
* @return {Boolean} True when single and clearSearchOnSelect
876884
*/
877-
clearSearchOnBlur() {
885+
clearSearchOnBlur () {
878886
return this.clearSearchOnSelect && !this.multiple
879887
},
880888
@@ -883,7 +891,7 @@
883891
* search input
884892
* @return {Boolean} True if non empty value
885893
*/
886-
searching() {
894+
searching () {
887895
return !!this.search
888896
},
889897
@@ -892,7 +900,7 @@
892900
* dropdown menu.
893901
* @return {Boolean} True if open
894902
*/
895-
dropdownOpen() {
903+
dropdownOpen () {
896904
return this.noDrop ? false : this.open && !this.mutableLoading
897905
},
898906
@@ -901,9 +909,9 @@
901909
* & there is no value selected.
902910
* @return {String} Placeholder text
903911
*/
904-
searchPlaceholder() {
912+
searchPlaceholder () {
905913
if (this.isValueEmpty && this.placeholder) {
906-
return this.placeholder;
914+
return this.placeholder
907915
}
908916
},
909917
@@ -915,7 +923,7 @@
915923
*
916924
* @return {array}
917925
*/
918-
filteredOptions() {
926+
filteredOptions () {
919927
if (!this.filterable && !this.taggable) {
920928
return this.mutableOptions.slice()
921929
}
@@ -937,22 +945,22 @@
937945
* Check if there aren't any options selected.
938946
* @return {Boolean}
939947
*/
940-
isValueEmpty() {
948+
isValueEmpty () {
941949
if (this.mutableValue) {
942950
if (typeof this.mutableValue === 'object') {
943951
return !Object.keys(this.mutableValue).length
944952
}
945953
return !this.mutableValue.length
946954
}
947955
948-
return true;
956+
return true
949957
},
950958
951959
/**
952960
* Return the current value in array format.
953961
* @return {Array}
954962
*/
955-
valueAsArray() {
963+
valueAsArray () {
956964
if (this.multiple) {
957965
return this.mutableValue
958966
} else if (this.mutableValue) {
@@ -961,7 +969,7 @@
961969
962970
return []
963971
}
964-
},
972+
}
965973
966974
}
967975
</script>

src/dev.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ Vue.config.devtools = true
1414
new Vue({
1515
el: '#app',
1616
data: {
17-
placeholder: "placeholder",
17+
placeholder: 'placeholder',
1818
value: null,
1919
options: countries,
2020
ajaxRes: [],
2121
people: []
2222
},
2323
methods: {
24-
search(search, loading) {
24+
search (search, loading) {
2525
loading(true)
2626
this.getRepositories(search, loading, this)
2727
},
28-
searchPeople(search, loading) {
28+
searchPeople (search, loading) {
2929
loading(true)
3030
this.getPeople(loading, this)
3131
},

0 commit comments

Comments
 (0)