dlzn-ui 1.23.0 → 1.25.0

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.
@@ -1,14 +1,28 @@
1
+ import { existsSync } from 'node:fs'
2
+ import { dirname, resolve } from 'node:path'
3
+ import { fileURLToPath } from 'node:url'
1
4
  import antfu, { perfectionist as perfectionistConfigFn } from '@antfu/eslint-config'
2
- import type { Linter } from 'eslint'
3
5
  import perfectionist from 'eslint-plugin-perfectionist'
4
6
  import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
5
- import { resolveOne } from './build/utils.ts'
7
+
8
+ function resolveOne(metaUrl, paths) {
9
+ const here = dirname(fileURLToPath(metaUrl))
10
+ const arr = paths.map((path) => resolve(here, path))
11
+ const result = arr.findIndex((file) => existsSync(file))
12
+
13
+ if (result === -1) {
14
+ throw new Error(`resolveOne: path not found: ${paths.join(', ')}`)
15
+ }
16
+
17
+ return paths[result]
18
+ }
6
19
 
7
20
  const prettierOptions = await import(
8
- resolveOne(import.meta.url, ['./prettier.config.ts', './prettier-config.ts'])
21
+ resolveOne(import.meta.url, ['./prettier.config.mjs', './prettier-config.mjs'])
9
22
  )
10
23
  const perfectionistConfig = await perfectionistConfigFn({})
11
- const eslintConfig: Linter.Config[] = await antfu(
24
+ /** @type {import('eslint').Linter.Config[]} */
25
+ const eslintConfig = await antfu(
12
26
  {
13
27
  formatters: {
14
28
  // 都默认开启了
@@ -195,7 +209,7 @@ const eslintConfig: Linter.Config[] = await antfu(
195
209
  },
196
210
  },
197
211
  )
198
- .override(perfectionistConfig[0].name!, {
212
+ .override(perfectionistConfig[0].name, {
199
213
  rules: {
200
214
  ...perfectionist.configs['recommended-natural'].rules,
201
215
  ...perfectionistConfig[0].rules,
package/package.json CHANGED
@@ -15,14 +15,14 @@
15
15
  "import": "./const/index.mjs",
16
16
  "types": "./const/index.d.ts"
17
17
  },
18
- "./eslint-config": "./eslint-config.ts",
19
- "./prettier-config": "./prettier-config.ts",
20
- "./stylelint-config": "./stylelint-config.ts",
18
+ "./eslint-config": "./eslint-config.mjs",
19
+ "./prettier-config": "./prettier-config.mjs",
20
+ "./stylelint-config": "./stylelint-config.mjs",
21
21
  "./utils": {
22
22
  "import": "./utils/index.mjs",
23
23
  "types": "./utils/index.d.ts"
24
24
  },
25
- "./vite-config": "./vite-config.ts"
25
+ "./vite-config": "./vite-config.mjs"
26
26
  },
27
27
  "keywords": [],
28
28
  "license": "MIT",
@@ -49,7 +49,6 @@
49
49
  "stylelint-config-recess-order": "^7.7.0",
50
50
  "stylelint-config-recommended-vue": "^2.0.0",
51
51
  "stylelint-config-standard": "^40.0.0",
52
- "stylelint-define-config": "^17.14.0",
53
52
  "stylelint-order": "^8.1.1",
54
53
  "stylelint-use-nesting": "^6.0.2",
55
54
  "tailwindcss": "^4.3.3",
@@ -64,6 +63,6 @@
64
63
  "**/*.css"
65
64
  ],
66
65
  "type": "module",
67
- "version": "1.23.0",
66
+ "version": "1.25.0",
68
67
  "scripts": {}
69
68
  }
@@ -3,10 +3,23 @@
3
3
  * @description: 还有些是 prettier-plugin-tailwindcss 的配置 https://github.com/tailwindlabs/prettier-plugin-tailwindcss
4
4
  */
5
5
 
6
- import type { Config } from 'prettier'
7
- import type { PluginOptions } from 'prettier-plugin-tailwindcss'
8
- import { resolveOne } from './build/utils.ts'
6
+ import { existsSync } from 'node:fs'
7
+ import { dirname, resolve } from 'node:path'
8
+ import { fileURLToPath } from 'node:url'
9
9
 
10
+ function resolveOne(metaUrl, paths) {
11
+ const here = dirname(fileURLToPath(metaUrl))
12
+ const arr = paths.map((path) => resolve(here, path))
13
+ const result = arr.findIndex((file) => existsSync(file))
14
+
15
+ if (result === -1) {
16
+ throw new Error(`resolveOne: path not found: ${paths.join(', ')}`)
17
+ }
18
+
19
+ return result[result]
20
+ }
21
+
22
+ /** @type {import('prettier').Config & import('prettier-plugin-tailwindcss').PluginOptions} */
10
23
  export default {
11
24
  $schema: 'https://json.schemastore.org/prettierrc',
12
25
  arrowParens: 'always', // 单参数箭头函数参数周围使用圆括号-eg: (x) => x
@@ -33,4 +46,4 @@ export default {
33
46
  trailingComma: 'all',
34
47
  useTabs: false, // 使用空格代替tab缩进
35
48
  vueIndentScriptAndStyle: false, // 不对vue中的script及style标签缩进
36
- } satisfies Config & PluginOptions
49
+ }
@@ -1,9 +1,9 @@
1
1
  // [插件集合](https://stylelint.io/awesome-stylelint/)
2
2
  // [stylelint 内置规则集](https://stylelint.io/user-guide/rules)
3
3
  // 最新的版本去除了很多配置,比如缩进, 抛弃的规则 可在 @stylistic/stylelint-config(https://github.com/stylelint-stylistic/stylelint-config/blob/main/stylelint.config.js) 中找回
4
- import defineConfig from 'stylelint-define-config'
4
+ /** @type {import('stylelint').Config} */
5
5
 
6
- export default defineConfig({
6
+ export default {
7
7
  cache: true,
8
8
  extends: [
9
9
  '@stylistic/stylelint-config',
@@ -70,4 +70,4 @@ export default defineConfig({
70
70
  ],
71
71
  'value-keyword-case': ['lower', { ignoreFunctions: ['v-bind'] }],
72
72
  },
73
- })
73
+ }
@@ -0,0 +1,52 @@
1
+ import { existsSync } from 'node:fs'
2
+ import { dirname, resolve } from 'node:path'
3
+ import { fileURLToPath } from 'node:url'
4
+ import tailwindcss from '@tailwindcss/vite'
5
+ import vue from '@vitejs/plugin-vue'
6
+ import tailwindAutoReference from 'vite-plugin-vue-tailwind-auto-reference'
7
+
8
+ /**
9
+ * @typedef {import('vite').ConfigEnv} ConfigEnv
10
+ * @typedef {typeof import('vite-plugin-vue-tailwind-auto-reference').default} TailwindAutoReference
11
+ * @typedef {Parameters<TailwindAutoReference>} TailwindAutoReferenceParameters
12
+ * @typedef {{ tailwindAutoReferenceParameters?: TailwindAutoReferenceParameters }} DlznViteOptions
13
+ * @typedef {import('vite').UserConfig} UserConfig
14
+ */
15
+
16
+ function resolveOne(metaUrl, paths) {
17
+ const here = dirname(fileURLToPath(metaUrl))
18
+ const arr = paths.map((path) => resolve(here, path))
19
+ const result = arr.findIndex((file) => existsSync(file))
20
+
21
+ if (result === -1) {
22
+ throw new Error(`resolveOne: path not found: ${paths.join(', ')}`)
23
+ }
24
+
25
+ return paths[result]
26
+ }
27
+
28
+ /**
29
+ * @param {ConfigEnv} _env
30
+ * @param {DlznViteOptions} options
31
+ * @returns {UserConfig} Vite config
32
+ */
33
+ export default (_env, options) => {
34
+ return {
35
+ plugins: [
36
+ vue({
37
+ // features: {
38
+ // optionsAPI: false, // 不能删掉,tdesign 内部使用到了
39
+ // },
40
+ }),
41
+ tailwindAutoReference(
42
+ options.tailwindAutoReferenceParameters?.[0] ??
43
+ resolveOne(import.meta.url, [
44
+ './assets/css/tailwindcss-entry.css',
45
+ './src/assets/css/tailwindcss-entry.css',
46
+ ]),
47
+ options.tailwindAutoReferenceParameters?.[1],
48
+ ),
49
+ tailwindcss(),
50
+ ],
51
+ }
52
+ }
package/vite-config.ts DELETED
@@ -1,31 +0,0 @@
1
- import type { ConfigEnv, UserConfig } from 'vite'
2
- import tailwindcss from '@tailwindcss/vite'
3
- import vue from '@vitejs/plugin-vue'
4
- import tailwindAutoReference from 'vite-plugin-vue-tailwind-auto-reference'
5
- import { resolveOne } from './build/utils.ts'
6
-
7
- export default (
8
- _env: ConfigEnv,
9
- options: {
10
- tailwindAutoReferenceParameters?: Parameters<typeof tailwindAutoReference>
11
- },
12
- ): UserConfig => {
13
- return {
14
- plugins: [
15
- vue({
16
- // features: {
17
- // optionsAPI: false, // 不能删掉,tdesign 内部使用到了
18
- // },
19
- }),
20
- tailwindAutoReference(
21
- options.tailwindAutoReferenceParameters?.[0] ??
22
- resolveOne(import.meta.url, [
23
- './assets/css/tailwindcss-entry.css',
24
- './src/assets/css/tailwindcss-entry.css',
25
- ]),
26
- options.tailwindAutoReferenceParameters?.[1],
27
- ),
28
- tailwindcss(),
29
- ],
30
- }
31
- }