From b297b52833ed63900f856344226bb267e8ca8686 Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Thu, 31 Dec 2020 11:26:03 +0100 Subject: [PATCH] chore: lint --- .eslintignore | 2 ++ .eslintrc.js | 17 +++++++++----- package.json | 2 ++ src/components/Popover.vue | 32 ++++++++++++++++---------- src/directives/v-close-popover.js | 8 ++++--- src/directives/v-tooltip.spec.js | 1 - src/index.js | 2 +- src/lib/tooltip.js | 10 +++++---- src/utils.js | 2 +- tests/unit/.eslintrc.js | 6 ++--- vue.config.js | 2 +- yarn.lock | 37 ++++++++++++++++++++++++++++--- 12 files changed, 87 insertions(+), 34 deletions(-) diff --git a/.eslintignore b/.eslintignore index b9470778..892b9e27 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,4 @@ node_modules/ dist/ +docs/ +docs-src/ diff --git a/.eslintrc.js b/.eslintrc.js index 779eecdf..00b5e0ef 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,18 +1,25 @@ module.exports = { root: true, - parser: 'babel-eslint', parserOptions: { - sourceType: 'module' + parser: 'babel-eslint', + ecmaVersion: 2017, + sourceType: 'module', }, // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style - extends: 'standard', + extends: [ + 'standard', + 'plugin:vue/recommended', + ], // required to lint *.vue files + plugins: [ + 'vue', + ], env: { browser: true, jest: true, }, // add your custom rules here - 'rules': { + rules: { // allow paren-less arrow functions 'arrow-parens': 0, // allow async-await @@ -24,5 +31,5 @@ module.exports = { // beware of returning assignement 'no-return-assign': 'off', 'no-extend-native': 'warn', - } + }, } diff --git a/package.json b/package.json index 3af4bab5..f7862522 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "dev": "cross-env NODE_ENV=development rollup --config build/rollup.config.es.js --watch", "prepublishOnly": "npm run test && npm run build", "test": "npm run test:types && npm run test:unit", + "lint": "eslint . --ext .js,.vue", "test:unit": "vue-cli-service test:unit", "test:types": "cd ./tests/types && tsc --noEmit" }, @@ -53,6 +54,7 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^4.1.1", "eslint-plugin-standard": "^5.0.0", + "eslint-plugin-vue": "^7.4.0", "faker": "^4.1.0", "highlight.js": "^9.7.0", "jest": "^26.6.3", diff --git a/src/components/Popover.vue b/src/components/Popover.vue index 04581db5..1d0a1674 100644 --- a/src/components/Popover.vue +++ b/src/components/Popover.vue @@ -14,8 +14,8 @@
+
-
+
@@ -499,10 +505,10 @@ export default { const events = typeof this.trigger === 'string' ? this.trigger - .split(' ') - .filter( - trigger => ['click', 'hover', 'focus'].indexOf(trigger) !== -1 - ) + .split(' ') + .filter( + trigger => ['click', 'hover', 'focus'].indexOf(trigger) !== -1, + ) : [] events.forEach(event => { @@ -675,10 +681,12 @@ export default { if (typeof document !== 'undefined' && typeof window !== 'undefined') { if (isIOS) { - document.addEventListener('touchend', handleGlobalTouchend, supportsPassive ? { - passive: true, - capture: true, - } : true) + document.addEventListener('touchend', handleGlobalTouchend, supportsPassive + ? { + passive: true, + capture: true, + } + : true) } else { window.addEventListener('click', handleGlobalClick, true) } @@ -695,7 +703,7 @@ function handleGlobalTouchend (event) { function handleGlobalClose (event, touch = false) { // Delay so that close directive has time to set values for (let i = 0; i < openPopovers.length; i++) { - let popover = openPopovers[i] + const popover = openPopovers[i] if (popover.$refs.popover) { const contains = popover.$refs.popover.contains(event.target) requestAnimationFrame(() => { diff --git a/src/directives/v-close-popover.js b/src/directives/v-close-popover.js index 4543f01b..45a30ab1 100644 --- a/src/directives/v-close-popover.js +++ b/src/directives/v-close-popover.js @@ -2,9 +2,11 @@ import { supportsPassive } from '../utils' function addListeners (el) { el.addEventListener('click', onClick) - el.addEventListener('touchstart', onTouchStart, supportsPassive ? { - passive: true, - } : false) + el.addEventListener('touchstart', onTouchStart, supportsPassive + ? { + passive: true, + } + : false) } function removeListeners (el) { diff --git a/src/directives/v-tooltip.spec.js b/src/directives/v-tooltip.spec.js index de8b9703..ef2c0d98 100644 --- a/src/directives/v-tooltip.spec.js +++ b/src/directives/v-tooltip.spec.js @@ -1,5 +1,4 @@ import * as VTooltip from './v-tooltip' -import { destroyTooltip } from './v-tooltip' jest.mock('../lib/tooltip') diff --git a/src/index.js b/src/index.js index 5dfcb060..3cf65eff 100644 --- a/src/index.js +++ b/src/index.js @@ -18,7 +18,7 @@ export function install (Vue, options = {}) { Vue.directive('tooltip', vtooltip) Vue.directive('close-popover', vclosepopover) - Vue.component('v-popover', Popover) + Vue.component('VPopover', Popover) } export const VTooltip = vtooltip diff --git a/src/lib/tooltip.js b/src/lib/tooltip.js index 24f2be95..1837f8ef 100644 --- a/src/lib/tooltip.js +++ b/src/lib/tooltip.js @@ -630,10 +630,12 @@ if (typeof document !== 'undefined') { for (let i = 0; i < openTooltips.length; i++) { openTooltips[i]._onDocumentTouch(event) } - }, supportsPassive ? { - passive: true, - capture: true, - } : true) + }, supportsPassive + ? { + passive: true, + capture: true, + } + : true) } /** diff --git a/src/utils.js b/src/utils.js index a8d7ad45..2a1a1491 100644 --- a/src/utils.js +++ b/src/utils.js @@ -70,7 +70,7 @@ export let supportsPassive = false if (typeof window !== 'undefined') { supportsPassive = false try { - var opts = Object.defineProperty({}, 'passive', { + const opts = Object.defineProperty({}, 'passive', { get () { supportsPassive = true }, diff --git a/tests/unit/.eslintrc.js b/tests/unit/.eslintrc.js index 013a195b..c529c260 100644 --- a/tests/unit/.eslintrc.js +++ b/tests/unit/.eslintrc.js @@ -1,5 +1,5 @@ module.exports = { env: { - jest: true - } -} \ No newline at end of file + jest: true, + }, +} diff --git a/vue.config.js b/vue.config.js index 428ff4c5..5b964829 100644 --- a/vue.config.js +++ b/vue.config.js @@ -36,7 +36,7 @@ module.exports = { css: { loaderOptions: { sass: { - data: `@import "~@/style/imports.scss";`, + data: '@import "~@/style/imports.scss";', }, }, }, diff --git a/yarn.lock b/yarn.lock index 2a39593a..95033fe0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2216,7 +2216,7 @@ acorn-globals@^6.0.0: acorn "^7.1.1" acorn-walk "^7.1.1" -acorn-jsx@^5.3.1: +acorn-jsx@^5.2.0, acorn-jsx@^5.3.1: version "5.3.1" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.1.tgz#fc8661e11b7ac1539c47dbfea2e72b3af34d267b" integrity sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng== @@ -5357,6 +5357,16 @@ eslint-plugin-standard@^5.0.0: resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-5.0.0.tgz#c43f6925d669f177db46f095ea30be95476b1ee4" integrity sha512-eSIXPc9wBM4BrniMzJRBm2uoVuXz2EPa+NXPk2+itrVt+r5SbKFERx/IgrK/HmfjddyKVz2f+j+7gBRvu19xLg== +eslint-plugin-vue@^7.4.0: + version "7.4.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-vue/-/eslint-plugin-vue-7.4.0.tgz#27324cbe8f00705708c9fa9e8c0401d8f0742c20" + integrity sha512-bYJV3nHSGV5IL40Ti1231vlY8I2DzjDHYyDjRv9Z1koEI7qyV2RR3+uKMafHdOioXYH9W3e1+iwe4wy7FIBNCQ== + dependencies: + eslint-utils "^2.1.0" + natural-compare "^1.4.0" + semver "^7.3.2" + vue-eslint-parser "^7.3.0" + eslint-scope@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848" @@ -5365,7 +5375,7 @@ eslint-scope@^4.0.3: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint-scope@^5.1.1: +eslint-scope@^5.0.0, eslint-scope@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== @@ -5433,6 +5443,15 @@ eslint@^7.16.0: text-table "^0.2.0" v8-compile-cache "^2.0.3" +espree@^6.2.1: + version "6.2.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-6.2.1.tgz#77fc72e1fd744a2052c20f38a5b575832e82734a" + integrity sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw== + dependencies: + acorn "^7.1.1" + acorn-jsx "^5.2.0" + eslint-visitor-keys "^1.1.0" + espree@^7.3.0, espree@^7.3.1: version "7.3.1" resolved "https://registry.yarnpkg.com/espree/-/espree-7.3.1.tgz#f2df330b752c6f55019f8bd89b7660039c1bbbb6" @@ -5447,7 +5466,7 @@ esprima@^4.0.0, esprima@^4.0.1: resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== -esquery@^1.2.0: +esquery@^1.0.1, esquery@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.3.1.tgz#b78b5828aa8e214e29fb74c4d5b752e1c033da57" integrity sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ== @@ -12535,6 +12554,18 @@ void-elements@^2.0.1: resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" integrity sha1-wGavtYK7HLQSjWDqkjkulNXp2+w= +vue-eslint-parser@^7.3.0: + version "7.3.0" + resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-7.3.0.tgz#894085839d99d81296fa081d19643733f23d7559" + integrity sha512-n5PJKZbyspD0+8LnaZgpEvNCrjQx1DyDHw8JdWwoxhhC+yRip4TAvSDpXGf9SWX6b0umeB5aR61gwUo6NVvFxw== + dependencies: + debug "^4.1.1" + eslint-scope "^5.0.0" + eslint-visitor-keys "^1.1.0" + espree "^6.2.1" + esquery "^1.0.1" + lodash "^4.17.15" + vue-hot-reload-api@^2.3.0: version "2.3.4" resolved "https://registry.yarnpkg.com/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz#532955cc1eb208a3d990b3a9f9a70574657e08f2"