@hzw-tech/utils 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eslint.js +5 -3
- package/dist/utils.js +29 -0
- package/dist/vite.js +4 -7
- package/package.json +1 -1
package/dist/eslint.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { antfu } from '@antfu/eslint-config'
|
|
2
|
+
import { mergeObject } from './utils.js'
|
|
2
3
|
|
|
3
4
|
function eslint(options) {
|
|
4
|
-
|
|
5
|
+
const optionsDefault = {
|
|
5
6
|
formatters: true,
|
|
6
7
|
vue: {
|
|
7
8
|
overrides: {
|
|
8
9
|
'vue/component-definition-name-casing': ['error', 'kebab-case'],
|
|
9
10
|
'vue/component-name-in-template-casing': ['error', 'kebab-case'],
|
|
11
|
+
'vue/custom-event-name-casing': ['error', 'kebab-case'],
|
|
10
12
|
},
|
|
11
13
|
},
|
|
12
14
|
rules: {
|
|
@@ -52,8 +54,8 @@ function eslint(options) {
|
|
|
52
54
|
'**/auto-import?(s).d.ts',
|
|
53
55
|
'**/components.d.ts',
|
|
54
56
|
],
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
}
|
|
58
|
+
return antfu(mergeObject(optionsDefault, options))
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
export default eslint
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function getType(data) {
|
|
2
|
+
const typeStr = Object.prototype.toString.call(data)
|
|
3
|
+
const end = typeStr.length - 1
|
|
4
|
+
return typeStr.substring(8, end)
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function mergeObject(oldObj, newObj) {
|
|
8
|
+
if (getType(oldObj) !== 'Object') {
|
|
9
|
+
console.error('utils.mergeObjectParams方法传递的默认参数不是Object类型')
|
|
10
|
+
return newObj
|
|
11
|
+
}
|
|
12
|
+
if (!newObj) {
|
|
13
|
+
return oldObj
|
|
14
|
+
}
|
|
15
|
+
for (const key in oldObj) {
|
|
16
|
+
if (Object.prototype.hasOwnProperty.call(oldObj, key)) {
|
|
17
|
+
const item = oldObj[key]
|
|
18
|
+
// 仅当新对象是Object类型才进行比对,其他类型的newObj不变
|
|
19
|
+
if (getType(newObj) === 'Object') {
|
|
20
|
+
if (newObj[key] === undefined) {
|
|
21
|
+
newObj[key] = item
|
|
22
|
+
} else if (getType(item) === 'Object') {
|
|
23
|
+
mergeObject(item, newObj[key])
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return newObj
|
|
29
|
+
}
|
package/dist/vite.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
2
|
import AutoImportVite from 'unplugin-auto-import/vite'
|
|
3
|
+
import { mergeObject } from './utils.js'
|
|
3
4
|
|
|
4
5
|
function autoImport(options) {
|
|
5
6
|
const { mode } = process.env
|
|
@@ -28,13 +29,9 @@ function scss(options) {
|
|
|
28
29
|
if (options && options.additionalData) {
|
|
29
30
|
additionalData = options.additionalData
|
|
30
31
|
}
|
|
31
|
-
return {
|
|
32
|
-
additionalData
|
|
33
|
-
|
|
34
|
-
${additionalData}
|
|
35
|
-
`,
|
|
36
|
-
...options,
|
|
37
|
-
}
|
|
32
|
+
return mergeObject({
|
|
33
|
+
additionalData,
|
|
34
|
+
}, options)
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
export default {
|