Skip to content

Commit 42ee42d

Browse files
committed
refactor: fix eslint
1 parent 1a2be37 commit 42ee42d

File tree

11 files changed

+134
-91
lines changed

11 files changed

+134
-91
lines changed

.eslintignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
!.vuepress
2+
23
.cache
34
.temp
4-
dist
5+
node_modules
6+
dist
7+
docs/src/api/default/*.js

.eslintrc.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
module.exports = {
22
env: {
33
browser: true,
4-
es2021: true
4+
es2021: true,
5+
'jest/globals': true
56
},
67
extends: [
78
'plugin:vue/vue3-essential',
@@ -12,7 +13,8 @@ module.exports = {
1213
sourceType: 'module'
1314
},
1415
plugins: [
15-
'vue'
16+
'vue',
17+
'jest'
1618
],
1719
rules: {
1820
}

core/src/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function traverse (obj, ...keys) {
141141
if (keys.length === 0) { return obj }
142142

143143
for (const key of keys[0]) {
144-
if (obj.hasOwnProperty(key)) {
144+
if (key in obj) {
145145
const res = traverse(obj[key], ...keys.slice(1))
146146
if (res !== undefined) {
147147
return res

core/test/core.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import VueCron from '../src/core.vue'
44

55
test('test VueCron', async () => {
66
// render the component
7-
const onUpdateValue = jest.fn()
87
let slotProps = null
98

109
const wrapper = mount(VueCron, {

core/test/multiple.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import multiple from '../src/fields/multiple'
2-
import util from '../src/util'
32
import types from '../src/types'
3+
import util from '../src/util'
44
const { strToArray, arrayToStr } = multiple
5-
const { Range, genItems } = util
5+
const { genItems } = util
66
const { Field } = types
77

88
const r = (min, max) => {

light/src/CronEditor.vue

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<span>{{period.prefix}}</span>
66
<custom-select v-bind="period.attrs" v-on="period.events" :items="period.items" item-value="id" :cols="cols('period')" :width="width('period')" />
77
<span>{{period.suffix}}</span>
8-
8+
99
<template v-for="f in fields" :key="f.id">
1010
<span>{{f.prefix}}</span>
1111
<custom-select v-bind="f.attrs" v-on="f.events" :items="f.items" :cols="cols(f.id)" :width="width(f.id)" multiple>{{f.selectedStr}}</custom-select>
@@ -20,33 +20,31 @@ import CronCore from '@vue-js-cron/core'
2020
import CustomSelect from './components/CustomSelect.vue'
2121
2222
export default {
23-
name: "VueCronEditor",
24-
components:{
25-
'CronCore': CronCore.component,
26-
CustomSelect
27-
},
28-
props:{
29-
cols: {
30-
type: Function,
31-
default: (fieldId) => {
32-
33-
if(fieldId == 'minute') return 5
34-
else if (fieldId == 'hour') return 4
35-
else if (fieldId == 'day') return 4
36-
else return 1
37-
38-
}
39-
},
40-
width: {
41-
type: Function,
42-
default: (fieldId) => {
43-
if(fieldId == 'minute') return '10em'
44-
else if (fieldId == 'hour') return '8em'
45-
else if (fieldId == 'day') return '8em'
46-
else return 'unset'
47-
}
48-
}
23+
name: 'VueCronEditor',
24+
components: {
25+
CronCore: CronCore.component,
26+
CustomSelect
27+
},
28+
props: {
29+
cols: {
30+
type: Function,
31+
default: (fieldId) => {
32+
if (fieldId === 'minute') return 5
33+
else if (fieldId === 'hour') return 4
34+
else if (fieldId === 'day') return 4
35+
else return 1
36+
}
4937
},
50-
emits:['update:model-value', 'error']
38+
width: {
39+
type: Function,
40+
default: (fieldId) => {
41+
if (fieldId === 'minute') return '10em'
42+
else if (fieldId === 'hour') return '8em'
43+
else if (fieldId === 'day') return '8em'
44+
else return 'unset'
45+
}
46+
}
47+
},
48+
emits: ['update:model-value', 'error']
5149
}
52-
</script>
50+
</script>

light/src/index.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Import vue component
2-
import component from './CronEditor.vue'
32
import core from '@vue-js-cron/core'
3+
import component from './CronEditor.vue'
44

55
// Declare install function executed by Vue.use()
66
export function install (Vue) {
@@ -16,16 +16,5 @@ const plugin = {
1616
util: core.util
1717
}
1818

19-
// Auto-install when vue is found (eg. in browser via <script> tag)
20-
/* let GlobalVue = null;
21-
if (typeof window !== 'undefined') {
22-
GlobalVue = window.Vue;
23-
} else if (typeof global !== 'undefined') {
24-
GlobalVue = global.Vue;
25-
}
26-
if (GlobalVue) {
27-
GlobalVue.use(plugin);
28-
} */
29-
3019
// To allow use as module (npm/webpack/etc.) export component
3120
export default plugin

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"test": "yarn test-core",
2424
"test-core": "cd core && yarn test",
2525
"dry-run": "multi-semantic-release --dry-run",
26-
"lint": "eslint **/src/**/*.js **/dev/**/*.js **/src/**/*.vue **/dev/**/*.vue **/.vuepress/**/*.js **/.vuepress/**/*.vue",
27-
"lint-fix": "eslint --fix **/src/**/*.js **/dev/**/*.js **/src/**/*.vue **/dev/**/*.vue **/.vuepress/**/*.js **/.vuepress/**/*.vue"
26+
"lint": "eslint '**/*.js' '**/*.vue'",
27+
"lint-fix": "eslint --fix '**/*.js' '**/*.vue'"
2828
},
2929
"devDependencies": {
3030
"@babel/core": "^7.12.13",
@@ -42,6 +42,7 @@
4242
"eslint": "^8.0.1",
4343
"eslint-config-standard": "^17.0.0",
4444
"eslint-plugin-import": "^2.25.2",
45+
"eslint-plugin-jest": "^26.8.2",
4546
"eslint-plugin-n": "^15.0.0",
4647
"eslint-plugin-promise": "^6.0.0",
4748
"eslint-plugin-vue": "^9.3.0",

vuetify/src/CronEditor.vue

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
<custom-select v-bind="period.attrs" :items="period.items" v-on="period.events" item-value="id" :density="density" :variant="variant"></custom-select>
99
</v-col>
1010
<v-col v-if="period.suffix" class="flex-grow-0">{{period.suffix}}</v-col>
11-
12-
11+
1312
<template v-for="f in fields" :key="f.id">
1413
<v-col v-if="f.prefix" class="flex-grow-0">{{f.prefix}}</v-col>
1514
<v-col cols="auto">
@@ -28,36 +27,34 @@ import CronCore from '@vue-js-cron/core'
2827
import CustomSelect from './components/CustomSelect.vue'
2928
3029
export default {
31-
name: "VueCronEditor",
32-
components:{
33-
'CronCore': CronCore.component,
34-
CustomSelect
30+
name: 'VueCronEditor',
31+
components: {
32+
CronCore: CronCore.component,
33+
CustomSelect
34+
},
35+
props: {
36+
variant: {
37+
type: String,
38+
default: 'elevated'
3539
},
36-
props: {
37-
variant: {
38-
type: String,
39-
default: 'elevated'
40-
},
41-
density: {
42-
type: String,
43-
default: 'default'
44-
},
45-
cols: {
46-
type: Function,
47-
default: (fieldId) => {
48-
49-
if(fieldId == 'minute') return 5
50-
else if (fieldId == 'hour') return 4
51-
else if (fieldId == 'day') return 4
52-
else return 1
53-
54-
}
55-
},
40+
density: {
41+
type: String,
42+
default: 'default'
5643
},
57-
emits: ['update:model-value', 'error']
44+
cols: {
45+
type: Function,
46+
default: (fieldId) => {
47+
if (fieldId === 'minute') return 5
48+
else if (fieldId === 'hour') return 4
49+
else if (fieldId === 'day') return 4
50+
else return 1
51+
}
52+
}
53+
},
54+
emits: ['update:model-value', 'error']
5855
}
5956
</script>
6057

6158
<style lang="css">
6259
63-
</style>
60+
</style>

vuetify/src/index.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Import vue component
2-
import component from './CronEditor.vue'
32
import core from '@vue-js-cron/core'
3+
import component from './CronEditor.vue'
44

55
// Declare install function executed by Vue.use()
66
export function install (Vue) {
@@ -16,16 +16,5 @@ const plugin = {
1616
util: core.util
1717
}
1818

19-
// Auto-install when vue is found (eg. in browser via <script> tag)
20-
/* let GlobalVue = null;
21-
if (typeof window !== 'undefined') {
22-
GlobalVue = window.Vue;
23-
} else if (typeof global !== 'undefined') {
24-
GlobalVue = global.Vue;
25-
}
26-
if (GlobalVue) {
27-
GlobalVue.use(plugin);
28-
} */
29-
3019
// To allow use as module (npm/webpack/etc.) export component
3120
export default plugin

0 commit comments

Comments
 (0)