diff --git a/.eslintignore b/.eslintignore index 1521c8b76..884a2323e 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1 @@ -dist +**/dist/** diff --git a/.gitignore b/.gitignore index 63161737b..8161b78c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store node_modules/ +.eslintcache # Editor files /.idea diff --git a/.prettierrc.json b/.prettierrc.json index b2095be81..f79acadcb 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,4 +1,6 @@ { "semi": false, - "singleQuote": true + "singleQuote": true, + "trailingComma": "none", + "arrowParens": "avoid" } diff --git a/docs/api/options.md b/docs/api/options.md index 3fa3b0548..68efd2eeb 100644 --- a/docs/api/options.md +++ b/docs/api/options.md @@ -169,7 +169,7 @@ You can also pass a function that takes the props as an argument: ```js shallowMount(Component, { scopedSlots: { - foo: function(props) { + foo: function (props) { return this.$createElement('div', props.index) } } diff --git a/docs/fr/api/options.md b/docs/fr/api/options.md index ed2171e5f..c4a13604d 100644 --- a/docs/fr/api/options.md +++ b/docs/fr/api/options.md @@ -168,7 +168,7 @@ Vous pouvez également passer une fonction qui prend les props comme argument : ```js shallowMount(Component, { scopedSlots: { - foo: function(props) { + foo: function (props) { return this.$createElement('div', props.index) } } diff --git a/docs/fr/guides/common-tips.md b/docs/fr/guides/common-tips.md index f9dad1e0f..da6e8d863 100644 --- a/docs/fr/guides/common-tips.md +++ b/docs/fr/guides/common-tips.md @@ -221,7 +221,7 @@ En pratique, bien que nous appelions et attendions `setData` pour assurer la mis ```js const transitionStub = () => ({ - render: function(h) { + render: function (h) { return this.$options._renderChildren } }) diff --git a/docs/fr/guides/dom-events.md b/docs/fr/guides/dom-events.md index b90f33ea2..0d8bce39e 100644 --- a/docs/fr/guides/dom-events.md +++ b/docs/fr/guides/dom-events.md @@ -144,7 +144,7 @@ Ce composant permet d'incrémenter/décrémenter la quantité à l'aide de diff }, watch: { - quantity: function(newValue) { + quantity: function (newValue) { this.$emit('input', newValue) } } diff --git a/docs/fr/installation/using-other-test-runners.md b/docs/fr/installation/using-other-test-runners.md index d019ec8a9..2ad784d22 100644 --- a/docs/fr/installation/using-other-test-runners.md +++ b/docs/fr/installation/using-other-test-runners.md @@ -12,7 +12,7 @@ Vous trouverez ci-dessous une configuration de base de Karma pour Vue Test Utils // karma.conf.js var webpackConfig = require('./webpack.config.js') -module.exports = function(config) { +module.exports = function (config) { config.set({ frameworks: ['mocha'], files: ['test/**/*.spec.js'], diff --git a/docs/guides/common-tips.md b/docs/guides/common-tips.md index e394786a3..240119ebf 100644 --- a/docs/guides/common-tips.md +++ b/docs/guides/common-tips.md @@ -223,7 +223,7 @@ In practice, although we are calling and awaiting `setData` to ensure the DOM is ```js const transitionStub = () => ({ - render: function(h) { + render: function (h) { return this.$options._renderChildren } }) diff --git a/docs/guides/dom-events.md b/docs/guides/dom-events.md index df0988d45..d203a740c 100644 --- a/docs/guides/dom-events.md +++ b/docs/guides/dom-events.md @@ -142,7 +142,7 @@ This component allows to increment/decrement the quantity using various keys. }, watch: { - quantity: function(newValue) { + quantity: function (newValue) { this.$emit('input', newValue) } } diff --git a/docs/installation/using-other-test-runners.md b/docs/installation/using-other-test-runners.md index 0b49972e0..48349f267 100644 --- a/docs/installation/using-other-test-runners.md +++ b/docs/installation/using-other-test-runners.md @@ -12,7 +12,7 @@ Following is a basic Karma config for Vue Test Utils: // karma.conf.js var webpackConfig = require('./webpack.config.js') -module.exports = function(config) { +module.exports = function (config) { config.set({ frameworks: ['mocha'], files: ['test/**/*.spec.js'], diff --git a/docs/ja/api/options.md b/docs/ja/api/options.md index 7f6a550bd..8d4e8e7cc 100644 --- a/docs/ja/api/options.md +++ b/docs/ja/api/options.md @@ -94,7 +94,7 @@ props を引数に取る関数を渡すことができます。 ```js shallowMount(Component, { scopedSlots: { - foo: function(props) { + foo: function (props) { return this.$createElement('div', props.index) } } diff --git a/docs/ja/guides/dom-events.md b/docs/ja/guides/dom-events.md index 3a3f35aaa..562117299 100644 --- a/docs/ja/guides/dom-events.md +++ b/docs/ja/guides/dom-events.md @@ -134,7 +134,7 @@ it('Click on yes button calls our method with argument "yes"', async () => { } }, watch: { - quantity: function(newValue) { + quantity: function (newValue) { this.$emit('input', newValue) } } diff --git a/docs/ja/guides/getting-started.md b/docs/ja/guides/getting-started.md index d085eb9c7..cdcf63728 100644 --- a/docs/ja/guides/getting-started.md +++ b/docs/ja/guides/getting-started.md @@ -131,7 +131,7 @@ it('will catch the error using done', done => { }) it('will catch the error using a promise', () => { - return Vue.nextTick().then(function() { + return Vue.nextTick().then(function () { expect(true).toBe(false) }) }) diff --git a/docs/ja/installation/testing-single-file-components-with-karma.md b/docs/ja/installation/testing-single-file-components-with-karma.md index 26ef15c6b..9e2c91f2a 100644 --- a/docs/ja/installation/testing-single-file-components-with-karma.md +++ b/docs/ja/installation/testing-single-file-components-with-karma.md @@ -36,7 +36,7 @@ npm install --save-dev @vue/test-utils karma karma-chrome-launcher karma-mocha k var webpackConfig = require('./webpack.config.js') -module.exports = function(config) { +module.exports = function (config) { config.set({ frameworks: ['mocha'], @@ -160,7 +160,7 @@ npm install --save-dev babel-plugin-istanbul ```js // karma.conf.js -module.exports = function(config) { +module.exports = function (config) { config.set({ // ... diff --git a/docs/ru/api/options.md b/docs/ru/api/options.md index 40968a0bc..afeb619f3 100644 --- a/docs/ru/api/options.md +++ b/docs/ru/api/options.md @@ -107,7 +107,7 @@ shallowMount(Component, { ```js shallowMount(Component, { scopedSlots: { - foo: function(props) { + foo: function (props) { return this.$createElement('div', props.index) } } diff --git a/docs/ru/guides/dom-events.md b/docs/ru/guides/dom-events.md index b3ce272cb..5f472fc95 100644 --- a/docs/ru/guides/dom-events.md +++ b/docs/ru/guides/dom-events.md @@ -136,7 +136,7 @@ describe('Click event', () => { }, watch: { - quantity: function(newValue) { + quantity: function (newValue) { this.$emit('input', newValue) } } diff --git a/docs/ru/guides/getting-started.md b/docs/ru/guides/getting-started.md index 77b324fa2..a4cc198d7 100644 --- a/docs/ru/guides/getting-started.md +++ b/docs/ru/guides/getting-started.md @@ -131,7 +131,7 @@ it('должен отлавливать ошибку с использовани }) it('должен отлавливать ошибку с использованием promise', () => { - return Vue.nextTick().then(function() { + return Vue.nextTick().then(function () { expect(true).toBe(false) }) }) diff --git a/docs/ru/installation/testing-single-file-components-with-karma.md b/docs/ru/installation/testing-single-file-components-with-karma.md index 0105006e2..fe2cacf8a 100644 --- a/docs/ru/installation/testing-single-file-components-with-karma.md +++ b/docs/ru/installation/testing-single-file-components-with-karma.md @@ -36,7 +36,7 @@ npm install --save-dev @vue/test-utils karma karma-chrome-launcher karma-mocha k var webpackConfig = require('./webpack.config.js') -module.exports = function(config) { +module.exports = function (config) { config.set({ frameworks: ['mocha'], @@ -160,7 +160,7 @@ npm install --save-dev babel-plugin-istanbul ```js // karma.conf.js -module.exports = function(config) { +module.exports = function (config) { config.set({ // ... diff --git a/docs/zh/api/options.md b/docs/zh/api/options.md index 076090228..40b86c2ad 100644 --- a/docs/zh/api/options.md +++ b/docs/zh/api/options.md @@ -167,7 +167,7 @@ shallowMount(Component, { ```js shallowMount(Component, { scopedSlots: { - foo: function(props) { + foo: function (props) { return this.$createElement('div', props.index) } } diff --git a/docs/zh/guides/common-tips.md b/docs/zh/guides/common-tips.md index 110fc0a96..780c980c9 100644 --- a/docs/zh/guides/common-tips.md +++ b/docs/zh/guides/common-tips.md @@ -222,7 +222,7 @@ test('should render Foo, then hide it', async () => { ```js const transitionStub = () => ({ - render: function(h) { + render: function (h) { return this.$options._renderChildren } }) diff --git a/docs/zh/guides/dom-events.md b/docs/zh/guides/dom-events.md index a3c858807..1af79fc2a 100644 --- a/docs/zh/guides/dom-events.md +++ b/docs/zh/guides/dom-events.md @@ -142,7 +142,7 @@ it('Click on yes button calls our method with argument "yes"', async () => { }, watch: { - quantity: function(newValue) { + quantity: function (newValue) { this.$emit('input', newValue) } } diff --git a/docs/zh/guides/getting-started.md b/docs/zh/guides/getting-started.md index 70f35f93b..7b10a0336 100644 --- a/docs/zh/guides/getting-started.md +++ b/docs/zh/guides/getting-started.md @@ -164,7 +164,7 @@ it('will catch the error using done', done => { }) it('will catch the error using a promise', () => { - return Vue.nextTick().then(function() { + return Vue.nextTick().then(function () { expect(true).toBe(false) }) }) diff --git a/docs/zh/installation/testing-single-file-components-with-karma.md b/docs/zh/installation/testing-single-file-components-with-karma.md index 544ae4521..a1a5dc19c 100644 --- a/docs/zh/installation/testing-single-file-components-with-karma.md +++ b/docs/zh/installation/testing-single-file-components-with-karma.md @@ -36,7 +36,7 @@ npm install --save-dev @vue/test-utils karma karma-chrome-launcher karma-mocha k var webpackConfig = require('./webpack.config.js') -module.exports = function(config) { +module.exports = function (config) { config.set({ frameworks: ['mocha'], @@ -160,7 +160,7 @@ npm install --save-dev babel-plugin-istanbul ```js // karma.conf.js -module.exports = function(config) { +module.exports = function (config) { config.set({ // ... diff --git a/package.json b/package.json index 4ada8c2e2..d75249253 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,10 @@ "docs": "vuepress dev docs", "docs:build": "vuepress build docs", "flow": "flow check", - "lint": "eslint --ext js,vue .", + "lint": "eslint --ext js,vue . --cache", "lint:docs": "eslint --ext js,vue,md docs --ignore-path .gitignore", "lint:fix": "yarn lint -- --fix", - "format": "prettier --write \"**/*.{js,json,vue,md}\"", + "format": "prettier --write \"**/*.{js,json,vue,md}\" --cache", "format:check": "prettier --check \"**/*.{js,json,vue,md}\"", "release": "yarn build && yarn test:unit && lerna publish --conventional-commits -m \"chore(release): publish %s\"", "test": "yarn format:check && yarn lint && yarn lint:docs && yarn flow && yarn test:types && yarn test:unit -w 1 && yarn test:unit:browser", @@ -91,7 +91,7 @@ "karma-spec-reporter": "^0.0.32", "karma-webpack": "^4.0.2", "lint-staged": "^9.5.0", - "prettier": "^1.16.0", + "prettier": "^2.8.1", "puppeteer": "^5.2.1", "rollup-plugin-delete": "^2.0.0", "@rollup/plugin-replace": "^2.3.3", diff --git a/packages/create-instance/create-instance.js b/packages/create-instance/create-instance.js index 3c0ba7d2e..7aaafb962 100644 --- a/packages/create-instance/create-instance.js +++ b/packages/create-instance/create-instance.js @@ -107,7 +107,7 @@ export default function createInstance( const parentComponentOptions = options.parentComponent || {} const originalParentComponentProvide = parentComponentOptions.provide - parentComponentOptions.provide = function() { + parentComponentOptions.provide = function () { return { ...getValuesFromCallableOption.call(this, originalParentComponentProvide), // $FlowIgnore @@ -116,7 +116,7 @@ export default function createInstance( } const originalParentComponentData = parentComponentOptions.data - parentComponentOptions.data = function() { + parentComponentOptions.data = function () { return { ...getValuesFromCallableOption.call(this, originalParentComponentData), vueTestUtils_childProps: { ...options.propsData } @@ -126,7 +126,7 @@ export default function createInstance( parentComponentOptions.$_doNotStubChildren = true parentComponentOptions.$_isWrapperParent = true parentComponentOptions._isFunctionalContainer = componentOptions.functional - parentComponentOptions.render = function(h) { + parentComponentOptions.render = function (h) { return h( Constructor, createContext(options, scopedSlots, this.vueTestUtils_childProps), diff --git a/packages/create-instance/create-scoped-slots.js b/packages/create-instance/create-scoped-slots.js index 50464d9ee..daa4f3cb1 100644 --- a/packages/create-instance/create-scoped-slots.js +++ b/packages/create-instance/create-scoped-slots.js @@ -8,9 +8,9 @@ function isDestructuringSlotScope(slotScope: string): boolean { return /^{.*}$/.test(slotScope) } -function getVueTemplateCompilerHelpers( - _Vue: Component -): { [name: string]: Function } { +function getVueTemplateCompilerHelpers(_Vue: Component): { + [name: string]: Function +} { // $FlowIgnore const vue = new _Vue() const helpers = {} @@ -111,7 +111,7 @@ export default function createScopedSlots( const slotScope = scopedSlotMatches.match && scopedSlotMatches.match[1] - scopedSlots[scopedSlotName] = function(props) { + scopedSlots[scopedSlotName] = function (props) { let res if (isFn) { res = renderFn.call({ ...helpers }, props) diff --git a/packages/create-instance/log-events.js b/packages/create-instance/log-events.js index 9de6abf20..c3fd97f0d 100644 --- a/packages/create-instance/log-events.js +++ b/packages/create-instance/log-events.js @@ -15,7 +15,7 @@ export function logEvents( export function addEventLogger(_Vue: Component): void { _Vue.mixin({ - beforeCreate: function() { + beforeCreate: function () { this.__emitted = Object.create(null) this.__emittedByOrder = [] logEvents(this, this.__emitted, this.__emittedByOrder) diff --git a/packages/shared/validators.js b/packages/shared/validators.js index 986049d33..c72591d22 100644 --- a/packages/shared/validators.js +++ b/packages/shared/validators.js @@ -137,10 +137,10 @@ function makeMap(str: string, expectsLowerCase?: boolean) { map[list[i]] = true } return expectsLowerCase - ? function(val: string) { + ? function (val: string) { return map[val.toLowerCase()] } - : function(val: string) { + : function (val: string) { return map[val] } } diff --git a/packages/test-utils/src/wrapper-array.js b/packages/test-utils/src/wrapper-array.js index f5bd64bf7..e29cb2bed 100644 --- a/packages/test-utils/src/wrapper-array.js +++ b/packages/test-utils/src/wrapper-array.js @@ -5,7 +5,7 @@ import type VueWrapper from './vue-wrapper' import { throwError } from 'shared/util' export default class WrapperArray implements BaseWrapper { - +wrappers: Array + +wrappers: Array; +length: number selector: Selector | void diff --git a/packages/test-utils/src/wrapper.js b/packages/test-utils/src/wrapper.js index bbaae815a..bcf7985ef 100644 --- a/packages/test-utils/src/wrapper.js +++ b/packages/test-utils/src/wrapper.js @@ -29,11 +29,11 @@ import createDOMEvent from './create-dom-event' import { throwIfInstancesThrew } from './error' export default class Wrapper implements BaseWrapper { - +vnode: VNode | null + +vnode: VNode | null; +vm: Component | void _emitted: { [name: string]: Array> } - _emittedByOrder: Array<{ name: string, args: Array }> - +element: Element + _emittedByOrder: Array<{ name: string, args: Array }>; + +element: Element; +options: WrapperOptions isFunctionalComponent: boolean rootNode: VNode | Element @@ -502,9 +502,7 @@ export default class Wrapper implements BaseWrapper { ? value.map((calledWith, index) => { const callParams = calledWith.map(param => typeof param === 'object' - ? JSON.stringify(param) - .replace(/"/g, '') - .replace(/,/g, ', ') + ? JSON.stringify(param).replace(/"/g, '').replace(/,/g, ', ') : param ) diff --git a/test/resources/components/component-with-computed.vue b/test/resources/components/component-with-computed.vue index 02445747a..d608e4885 100644 --- a/test/resources/components/component-with-computed.vue +++ b/test/resources/components/component-with-computed.vue @@ -11,11 +11,8 @@ export default { message: 'egassem' }), computed: { - reversedMessage: function() { - return this.message - .split('') - .reverse() - .join('') + reversedMessage: function () { + return this.message.split('').reverse().join('') } } } diff --git a/test/resources/components/component-with-transitions.vue b/test/resources/components/component-with-transitions.vue index 9af326ce4..e8965da44 100644 --- a/test/resources/components/component-with-transitions.vue +++ b/test/resources/components/component-with-transitions.vue @@ -1,9 +1,7 @@ diff --git a/test/resources/components/component-with-watch-immediate.vue b/test/resources/components/component-with-watch-immediate.vue index f8abce285..736be6939 100644 --- a/test/resources/components/component-with-watch-immediate.vue +++ b/test/resources/components/component-with-watch-immediate.vue @@ -6,7 +6,7 @@