Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Dec 31, 2020
1 parent d80c98f commit b297b52
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules/
dist/
docs/
docs-src/
17 changes: 12 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -24,5 +31,5 @@ module.exports = {
// beware of returning assignement
'no-return-assign': 'off',
'no-extend-native': 'warn',
}
},
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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",
Expand Down
32 changes: 20 additions & 12 deletions src/components/Popover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</div>

<div
ref="popover"
:id="popoverId"
ref="popover"
:class="[popoverBaseClass, popoverClass, cssClass]"
:style="{
visibility: isOpen ? 'visible' : 'hidden',
Expand All @@ -37,9 +37,15 @@
/>
</div>

<ResizeObserver v-if="handleResize" @notify="$_handleResize" />
<ResizeObserver
v-if="handleResize"
@notify="$_handleResize"
/>
</div>
<div ref="arrow" :class="popoverArrowClass"></div>
<div
ref="arrow"
:class="popoverArrowClass"
/>
</div>
</div>
</div>
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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)
}
Expand All @@ -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(() => {
Expand Down
8 changes: 5 additions & 3 deletions src/directives/v-close-popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion src/directives/v-tooltip.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as VTooltip from './v-tooltip'
import { destroyTooltip } from './v-tooltip'

jest.mock('../lib/tooltip')

Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/lib/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
env: {
jest: true
}
}
jest: true,
},
}
2 changes: 1 addition & 1 deletion vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = {
css: {
loaderOptions: {
sass: {
data: `@import "~@/style/imports.scss";`,
data: '@import "~@/style/imports.scss";',
},
},
},
Expand Down
37 changes: 34 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand Down Expand Up @@ -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"
Expand All @@ -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==
Expand Down Expand Up @@ -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"
Expand All @@ -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==
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit b297b52

Please sign in to comment.