Skip to content

Commit 2872a20

Browse files
authored
refactor: add max-len rule (#720)
1 parent 51dcc9e commit 2872a20

File tree

128 files changed

+3096
-1767
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+3096
-1767
lines changed

Diff for: .eslintrc

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
"plugin:vue-libs/recommended",
1313
"plugin:flowtype/recommended"
1414
],
15-
rules: {
15+
"rules": {
1616
"no-debugger": 2,
17-
"no-proto": 0
17+
"no-proto": 0,
18+
"max-len": 2
1819
}
1920
}

Diff for: docs/api/options.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ const wrapper = shallowMount(Component, {
8282
foo: '<p slot-scope="props">{{props.index}},{{props.text}}</p>'
8383
}
8484
})
85-
expect(wrapper.find('#fooWrapper').html()).toBe('<div id="fooWrapper"><p>0,text1</p><p>1,text2</p><p>2,text3</p></div>')
85+
expect(wrapper.find('#fooWrapper').html()).toBe(
86+
`<div id="fooWrapper"><p>0,text1</p><p>1,text2</p><p>2,text3</p></div>`
87+
)
8688
```
8789

8890
## stubs

Diff for: docs/api/wrapper-array/filter.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ import { shallowMount } from '@vue/test-utils'
1818
import Foo from './Foo.vue'
1919

2020
const wrapper = shallowMount(Foo)
21-
const filteredDivArray = wrapper.findAll('div').filter(w => !w.hasClass('filtered'))
21+
const filteredDivArray = wrapper.findAll('div')
22+
.filter(w => !w.hasClass('filtered'))
2223
```

Diff for: docs/guides/common-tips.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Vue Test Utils allows you to mount a component without rendering its child compo
2323
```js
2424
import { shallowMount } from '@vue/test-utils'
2525

26-
const wrapper = shallowMount(Component) // returns a Wrapper containing a mounted Component instance
26+
const wrapper = shallowMount(Component)
2727
wrapper.vm // the mounted Vue instance
2828
```
2929

@@ -125,7 +125,9 @@ const $route = {
125125

126126
mount(Component, {
127127
mocks: {
128-
$route // adds the mocked `$route` object to the Vue instance before mounting component
128+
// adds mocked `$route` object to the Vue instance
129+
// before mounting component
130+
$route
129131
}
130132
})
131133
```

Diff for: docs/guides/using-with-vuex.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ describe('Actions.vue', () => {
6969
})
7070
})
7171

72-
it('calls store action "actionInput" when input value is "input" and an "input" event is fired', () => {
72+
it('dispatches "actionInput" when input event value is "input"', () => {
7373
const wrapper = shallowMount(Actions, { store, localVue })
7474
const input = wrapper.find('input')
7575
input.element.value = 'input'
7676
input.trigger('input')
7777
expect(actions.actionInput).toHaveBeenCalled()
7878
})
7979

80-
it('does not call store action "actionInput" when input value is not "input" and an "input" event is fired', () => {
80+
it('does not dispatch "actionInput" when event value is not "input"', () => {
8181
const wrapper = shallowMount(Actions, { store, localVue })
8282
const input = wrapper.find('input')
8383
input.element.value = 'not input'

Diff for: docs/ja/api/options.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ const wrapper = shallowMount(Component, {
7777
foo: '<p slot-scope="props">{{props.index}},{{props.text}}</p>'
7878
}
7979
})
80-
expect(wrapper.find('#fooWrapper').html()).toBe('<div id="fooWrapper"><p>0,text1</p><p>1,text2</p><p>2,text3</p></div>')
80+
expect(wrapper.find('#fooWrapper').html()).toBe(
81+
`<div id="fooWrapper"><p>0,text1</p><p>1,text2</p><p>2,text3</p></div>`
82+
)
8183
```
8284

8385
## stubs

Diff for: docs/ja/api/wrapper-array/filter.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ import { shallowMount } from '@vue/test-utils'
1818
import Foo from './Foo.vue'
1919

2020
const wrapper = shallowMount(Foo)
21-
const filteredDivArray = wrapper.findAll('div').filter(w => !w.hasClass('filtered'))
21+
const filteredDivArray = wrapper.findAll('div')
22+
.filter(w => !w.hasClass('filtered'))
2223
```

Diff for: docs/ja/guides/using-with-vuex.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ describe('Actions.vue', () => {
6868
})
6969
})
7070

71-
it('calls store action actionInput when input value is input and an input event is fired', () => {
71+
it('dispatches "actionInput" when input event value is "input"', () => {
7272
const wrapper = shallowMount(Actions, { store, localVue })
7373
const input = wrapper.find('input')
7474
input.element.value = 'input'
7575
input.trigger('input')
7676
expect(actions.actionInput).toHaveBeenCalled()
7777
})
7878

79-
it('does not call store action actionInput when input value is not input and an input event is fired', () => {
79+
it('does not dispatch "actionInput" when event value is not "input"', () => {
8080
const wrapper = shallowMount(Actions, { store, localVue })
8181
const input = wrapper.find('input')
8282
input.element.value = 'not input'

Diff for: docs/zh/api/options.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ const wrapper = shallowMount(Component, {
8282
foo: '<p slot-scope="props">{{props.index}},{{props.text}}</p>'
8383
}
8484
})
85-
expect(wrapper.find('#fooWrapper').html()).toBe('<div id="fooWrapper"><p>0,text1</p><p>1,text2</p><p>2,text3</p></div>')
85+
expect(wrapper.find('#fooWrapper').html()).toBe(
86+
`<div id="fooWrapper"><p>0,text1</p><p>1,text2</p><p>2,text3</p></div>`
87+
)
8688
```
8789

8890
## stubs

Diff for: docs/zh/api/wrapper-array/filter.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ import { shallowMount } from '@vue/test-utils'
1818
import Foo from './Foo.vue'
1919

2020
const wrapper = shallowMount(Foo)
21-
const filteredDivArray = wrapper.findAll('div').filter(w => !w.hasClass('filtered'))
21+
const filteredDivArray = wrapper.findAll('div')
22+
.filter(w => !w.hasClass('filtered'))
2223
```

Diff for: flow/options.flow.js

+19-18
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
declare type Options = { // eslint-disable-line no-undef
2-
attachToDocument?: boolean,
3-
propsData?: Object,
4-
mocks?: Object,
5-
methods?: Object,
6-
slots?: Object,
7-
scopedSlots?: Object,
8-
localVue?: Component,
9-
provide?: Object,
10-
stubs?: Object,
11-
context?: Object,
12-
attrs?: Object,
13-
listeners?: Object,
14-
logModifiedComponents?: boolean,
15-
sync?: boolean
16-
}
1+
declare type Options = {
2+
// eslint-disable-line no-undef
3+
attachToDocument?: boolean,
4+
propsData?: Object,
5+
mocks?: Object,
6+
methods?: Object,
7+
slots?: Object,
8+
scopedSlots?: Object,
9+
localVue?: Component,
10+
provide?: Object,
11+
stubs?: Object,
12+
context?: Object,
13+
attrs?: Object,
14+
listeners?: Object,
15+
logModifiedComponents?: boolean,
16+
sync?: boolean
17+
};
1718

18-
declare type SlotValue = Component | string | Array<Component | string>
19+
declare type SlotValue = Component | string | Array<Component | string>;
1920

20-
declare type SlotsObject = {[name: string]: SlotValue}
21+
declare type SlotsObject = { [name: string]: SlotValue };

Diff for: flow/vue.flow.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
// Importing these types declares them, so they are available globally
44

5-
declare type Component = Object | Function // eslint-disable-line no-undef
6-
declare type VNode = Object // eslint-disable-line no-undef
5+
declare type Component = Object | Function; // eslint-disable-line no-undef
6+
declare type VNode = Object; // eslint-disable-line no-undef

Diff for: flow/wrapper.flow.js

+42-38
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,48 @@
33
import type Wrapper from '~src/Wrapper'
44
import type WrapperArray from '~src/WrapperArray'
55

6-
declare type Selector = any
6+
declare type Selector = any;
77

8-
declare interface BaseWrapper { // eslint-disable-line no-undef
9-
at(index: number): Wrapper | void,
10-
attributes(): { [name: string]: string } | void,
11-
classes(): Array<string> | void,
12-
contains(selector: Selector): boolean | void,
13-
emitted(event?: string): { [name: string]: Array<Array<any>> } | Array<Array<any>> | void,
14-
emittedByOrder(): Array<{ name: string; args: Array<any> }> | void,
15-
exists(): boolean,
16-
filter(predicate: Function): WrapperArray | void,
17-
visible(): boolean | void,
18-
hasAttribute(attribute: string, value: string): boolean | void,
19-
hasClass(className: string): boolean | void,
20-
hasProp(prop: string, value: string): boolean | void,
21-
hasStyle(style: string, value: string): boolean | void,
22-
find(selector: Selector): Wrapper | void,
23-
findAll(selector: Selector): WrapperArray | void,
24-
html(): string | void,
25-
is(selector: Selector): boolean | void,
26-
isEmpty(): boolean | void,
27-
isVisible(): boolean | void,
28-
isVueInstance(): boolean | void,
29-
name(): string | void,
30-
props(): { [name: string]: any } | void,
31-
text(): string | void,
32-
setData(data: Object): void,
33-
setComputed(computed: Object): void,
34-
setMethods(methods: Object): void,
35-
setValue(value: any): void,
36-
setChecked(checked: boolean): void,
37-
setSelected(): void,
38-
setProps(data: Object): void,
39-
trigger(type: string, options: Object): void,
40-
destroy(): void
8+
declare interface BaseWrapper {
9+
// eslint-disable-line no-undef
10+
at(index: number): Wrapper | void;
11+
attributes(): { [name: string]: string } | void;
12+
classes(): Array<string> | void;
13+
contains(selector: Selector): boolean | void;
14+
emitted(
15+
event?: string
16+
): { [name: string]: Array<Array<any>> } | Array<Array<any>> | void;
17+
emittedByOrder(): Array<{ name: string, args: Array<any> }> | void;
18+
exists(): boolean;
19+
filter(predicate: Function): WrapperArray | void;
20+
visible(): boolean | void;
21+
hasAttribute(attribute: string, value: string): boolean | void;
22+
hasClass(className: string): boolean | void;
23+
hasProp(prop: string, value: string): boolean | void;
24+
hasStyle(style: string, value: string): boolean | void;
25+
find(selector: Selector): Wrapper | void;
26+
findAll(selector: Selector): WrapperArray | void;
27+
html(): string | void;
28+
is(selector: Selector): boolean | void;
29+
isEmpty(): boolean | void;
30+
isVisible(): boolean | void;
31+
isVueInstance(): boolean | void;
32+
name(): string | void;
33+
props(): { [name: string]: any } | void;
34+
text(): string | void;
35+
setData(data: Object): void;
36+
setComputed(computed: Object): void;
37+
setMethods(methods: Object): void;
38+
setValue(value: any): void;
39+
setChecked(checked: boolean): void;
40+
setSelected(): void;
41+
setProps(data: Object): void;
42+
trigger(type: string, options: Object): void;
43+
destroy(): void;
4144
}
4245

43-
declare type WrapperOptions = { // eslint-disable-line no-undef
44-
attachedToDocument: boolean,
45-
sync?: boolean
46-
}
46+
declare type WrapperOptions = {
47+
// eslint-disable-line no-undef
48+
attachedToDocument: boolean,
49+
sync?: boolean
50+
};

Diff for: packages/create-instance/add-mocks.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ import $$Vue from 'vue'
33
import { warn } from 'shared/util'
44

55
export default function addMocks (mockedProperties: Object, Vue: Component) {
6-
Object.keys(mockedProperties).forEach((key) => {
6+
Object.keys(mockedProperties).forEach(key => {
77
try {
88
Vue.prototype[key] = mockedProperties[key]
99
} catch (e) {
10-
warn(`could not overwrite property ${key}, this usually caused by a plugin that has added the property as a read-only value`)
10+
warn(
11+
`could not overwrite property ${key}, this is ` +
12+
`usually caused by a plugin that has added ` +
13+
`the property as a read-only value`
14+
)
1115
}
1216
$$Vue.util.defineReactive(Vue, key, mockedProperties[key])
1317
})

Diff for: packages/create-instance/add-slots.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ function createVNodesForSlot (
1111
slotValue: SlotValue,
1212
name: string
1313
): VNode | string {
14-
if (typeof slotValue === 'string' &&
15-
!startsWithTag(slotValue)) {
14+
if (typeof slotValue === 'string' && !startsWithTag(slotValue)) {
1615
return slotValue
1716
}
1817

19-
const el = typeof slotValue === 'string'
20-
? compileToFunctions(slotValue)
21-
: slotValue
18+
const el =
19+
typeof slotValue === 'string' ? compileToFunctions(slotValue) : slotValue
2220

2321
const vnode = h(el)
2422
vnode.data.slot = name

Diff for: packages/create-instance/create-functional-component.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ function createFunctionalSlots (slots = {}, h) {
1616
Object.keys(slots).forEach(slotType => {
1717
if (Array.isArray(slots[slotType])) {
1818
slots[slotType].forEach(slot => {
19-
const component = typeof slot === 'string' ? compileToFunctions(slot) : slot
19+
const component =
20+
typeof slot === 'string' ? compileToFunctions(slot) : slot
2021
const newSlot = h(component)
2122
newSlot.data.slot = slotType
2223
children.push(newSlot)
2324
})
2425
} else {
25-
const component = typeof slots[slotType] === 'string' ? compileToFunctions(slots[slotType]) : slots[slotType]
26+
const component =
27+
typeof slots[slotType] === 'string'
28+
? compileToFunctions(slots[slotType])
29+
: slots[slotType]
2630
const slot = h(component)
2731
slot.data.slot = slotType
2832
children.push(slot)
@@ -31,7 +35,10 @@ function createFunctionalSlots (slots = {}, h) {
3135
return children
3236
}
3337

34-
export default function createFunctionalComponent (component: Component, mountingOptions: Options) {
38+
export default function createFunctionalComponent (
39+
component: Component,
40+
mountingOptions: Options
41+
) {
3542
if (mountingOptions.context && typeof mountingOptions.context !== 'object') {
3643
throwError('mount.context must be an object')
3744
}
@@ -44,7 +51,12 @@ export default function createFunctionalComponent (component: Component, mountin
4451
return h(
4552
component,
4653
mountingOptions.context || component.FunctionalRenderContext,
47-
(mountingOptions.context && mountingOptions.context.children && mountingOptions.context.children.map(x => typeof x === 'function' ? x(h) : x)) || createFunctionalSlots(mountingOptions.slots, h)
54+
(mountingOptions.context &&
55+
mountingOptions.context.children &&
56+
mountingOptions.context.children.map(
57+
x => (typeof x === 'function' ? x(h) : x)
58+
)) ||
59+
createFunctionalSlots(mountingOptions.slots, h)
4860
)
4961
},
5062
name: component.name,

0 commit comments

Comments
 (0)