vite-plugin-autojs6 0.0.0-stage → 0.1.1

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.
@@ -0,0 +1,341 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import http from "node:http";
4
+ const DEFAULT_BUILTIN_MODULES = [
5
+ // AutoJs6 augmentable API (既可作为全局对象使用, 也可 require 载入)
6
+ "app",
7
+ "auto",
8
+ "automator",
9
+ "barcode",
10
+ "base64",
11
+ "canvas",
12
+ "colors",
13
+ "console",
14
+ "continuation",
15
+ "crypto",
16
+ "device",
17
+ "dialogs",
18
+ "engines",
19
+ "events",
20
+ "files",
21
+ "floaty",
22
+ "flow",
23
+ "http",
24
+ "i18n",
25
+ "images",
26
+ "media",
27
+ "mediainfo",
28
+ "notice",
29
+ "ocr",
30
+ "opencc",
31
+ "pinyin",
32
+ "qrcode",
33
+ "sensors",
34
+ "shell",
35
+ "shizuku",
36
+ "speech",
37
+ "sqlite",
38
+ "storages",
39
+ "threads",
40
+ "timers",
41
+ "toast",
42
+ "tts",
43
+ "ui",
44
+ "util",
45
+ "web",
46
+ "zip",
47
+ // Node.js 兼容模块 (6.8.0 起由「脚本库」插件提供)
48
+ "fs",
49
+ "path",
50
+ "os",
51
+ "process",
52
+ "buffer",
53
+ "nodejs",
54
+ "lodash",
55
+ "axios",
56
+ "cheerio",
57
+ "dayjs",
58
+ "pangu",
59
+ // 其他内置资源模块
60
+ "result-adapter"
61
+ ];
62
+ function isIdentifier(name2) {
63
+ return /^[A-Za-z_$][\w$]*$/.test(name2);
64
+ }
65
+ function builtinModuleCode(name2) {
66
+ const fallback = `require(${JSON.stringify(name2)})`;
67
+ if (!isIdentifier(name2)) {
68
+ return `export default ${fallback};`;
69
+ }
70
+ return [
71
+ `/* AutoJs6 内置模块: ${name2} */`,
72
+ `var __autojs6Module = typeof ${name2} !== 'undefined' ? ${name2} : ${fallback};`,
73
+ "export default __autojs6Module;"
74
+ ].join("\n");
75
+ }
76
+ const name = "vite-plugin-autojs6";
77
+ const DEFAULT_HTTP_PORT = 10347;
78
+ const COMMANDS = {
79
+ save: "saveProject",
80
+ run: "runProject"
81
+ };
82
+ const TAG = `\x1B[36m[${name}]\x1B[0m`;
83
+ function resolveDeploy(options, root, mode) {
84
+ if (!options || options.enabled === false || !matchMode(options.modes, mode)) {
85
+ return null;
86
+ }
87
+ return {
88
+ command: COMMANDS[options.command ?? "save"],
89
+ host: options.host ?? "127.0.0.1",
90
+ port: options.port ?? readExtensionPort(root) ?? DEFAULT_HTTP_PORT,
91
+ timeout: options.timeout ?? 1500,
92
+ silent: options.onError === "silent"
93
+ };
94
+ }
95
+ function matchMode(modes, mode) {
96
+ if (!modes || modes === "dev") {
97
+ return mode.startsWith("development");
98
+ }
99
+ return modes === "all" || modes.includes(mode);
100
+ }
101
+ function readExtensionPort(root) {
102
+ try {
103
+ const text = fs.readFileSync(path.join(root, ".vscode", "settings.json"), "utf8");
104
+ const matched = /"autojs6\.http\.port"\s*:\s*(\d+)/.exec(text);
105
+ return matched ? Number(matched[1]) : void 0;
106
+ } catch {
107
+ return void 0;
108
+ }
109
+ }
110
+ function createDeployer(settings, logger) {
111
+ const target = `${settings.host}:${settings.port}`;
112
+ let inflight = false;
113
+ let lastError = "";
114
+ function report(message) {
115
+ if (settings.silent || message === lastError) {
116
+ return;
117
+ }
118
+ lastError = message;
119
+ logger.warn(`${TAG} ${message}`);
120
+ }
121
+ return {
122
+ trigger(projectDir) {
123
+ if (!fs.existsSync(path.join(projectDir, "project.json"))) {
124
+ report(
125
+ "产物目录缺少 project.json, 已跳过同步到设备.\n AutoJs6 依赖它识别项目, 请确认 assets 选项包含 project.json."
126
+ );
127
+ return null;
128
+ }
129
+ if (inflight) {
130
+ return null;
131
+ }
132
+ inflight = true;
133
+ void (async () => {
134
+ try {
135
+ await sendProject(settings, projectDir);
136
+ if (lastError) {
137
+ lastError = "";
138
+ logger.info(`${TAG} 已恢复与 VSCode 扩展的连接 (${target})`);
139
+ }
140
+ } catch (error) {
141
+ report(describeError(error, settings, target));
142
+ } finally {
143
+ inflight = false;
144
+ }
145
+ })();
146
+ return `已请求同步到设备 (${target})`;
147
+ }
148
+ };
149
+ }
150
+ function sendProject(settings, projectDir) {
151
+ const query = `cmd=${encodeURIComponent(settings.command)}&path=${encodeURIComponent(projectDir)}`;
152
+ return new Promise((resolve, reject) => {
153
+ const request = http.request(
154
+ {
155
+ host: settings.host,
156
+ port: settings.port,
157
+ path: `/exec?${query}`,
158
+ method: "GET",
159
+ agent: false,
160
+ timeout: settings.timeout
161
+ },
162
+ (response) => {
163
+ response.resume();
164
+ response.on("end", () => resolve());
165
+ }
166
+ );
167
+ request.on("timeout", () => {
168
+ request.destroy(new Error(`timeout after ${settings.timeout}ms`));
169
+ });
170
+ request.on("error", reject);
171
+ request.end();
172
+ });
173
+ }
174
+ function describeError(error, settings, target) {
175
+ if (error.code === "ECONNREFUSED") {
176
+ return `无法连接 VSCode 扩展的 HTTP 命令桥 (${target}): 端口无人监听.
177
+ 请确认 VSCode 已打开且 AutoJs6 扩展已连接设备;
178
+ 不需要自动同步时把 deploy 设为 false (或删掉 deploy 选项).`;
179
+ }
180
+ if (error.code === "ETIMEDOUT" || /timeout/i.test(error.message ?? "")) {
181
+ return `VSCode 扩展响应超时 (${target}, ${settings.timeout}ms), 本次同步可能未完成.`;
182
+ }
183
+ return `同步到设备失败 (${target}): ${error.message || String(error)}`;
184
+ }
185
+ const VIRTUAL_PREFIX = `\0${name}:builtin:`;
186
+ const DEFAULT_ASSETS = ["project.json", "res", "images"];
187
+ function autojs6(options = {}) {
188
+ const {
189
+ entry = "src/main.ts",
190
+ uiEntry,
191
+ outDir = "dist",
192
+ fileName = "main.js",
193
+ uiMode = false,
194
+ assets = DEFAULT_ASSETS,
195
+ builtinModules = [],
196
+ target = "es2018",
197
+ banner = "",
198
+ define = {},
199
+ strict = false,
200
+ log = true,
201
+ deploy
202
+ } = options;
203
+ const builtinSet = /* @__PURE__ */ new Set([...DEFAULT_BUILTIN_MODULES, ...builtinModules]);
204
+ let resolved;
205
+ let isDev = false;
206
+ let entryFile = entry;
207
+ let deployer = null;
208
+ return {
209
+ name,
210
+ // 必须先于 vite:resolve 拦截内置模块名
211
+ enforce: "pre",
212
+ config(userConfig, env) {
213
+ const root = path.resolve(userConfig.root ?? process.cwd());
214
+ isDev = !env.mode.startsWith("production");
215
+ const useUiEntry = uiMode && !!uiEntry && fs.existsSync(path.resolve(root, uiEntry));
216
+ entryFile = useUiEntry ? uiEntry : entry;
217
+ return {
218
+ build: {
219
+ outDir,
220
+ emptyOutDir: true,
221
+ target,
222
+ minify: options.minify ?? !isDev,
223
+ sourcemap: options.sourcemap ?? false,
224
+ reportCompressedSize: false,
225
+ // 产物是给移动端脚本引擎用的, 体积警告没有意义
226
+ chunkSizeWarningLimit: 4096,
227
+ lib: {
228
+ entry: path.resolve(root, entryFile),
229
+ formats: ["cjs"],
230
+ fileName: () => fileName
231
+ },
232
+ rollupOptions: {
233
+ output: {
234
+ format: "cjs",
235
+ entryFileNames: fileName,
236
+ // 运行时没有 import() 能力, 动态导入必须内联
237
+ inlineDynamicImports: true,
238
+ exports: "auto",
239
+ // 默认不写 "use strict": AutoJs6 脚本不需要它, 产物保持干净
240
+ strict
241
+ }
242
+ }
243
+ },
244
+ define: {
245
+ ...define
246
+ }
247
+ };
248
+ },
249
+ configResolved(config) {
250
+ resolved = config;
251
+ const settings = resolveDeploy(deploy, config.root, config.mode);
252
+ deployer = settings ? createDeployer(settings, config.logger) : null;
253
+ },
254
+ buildStart() {
255
+ const file = path.resolve(resolved.root, entryFile);
256
+ if (!fs.existsSync(file)) {
257
+ this.error(
258
+ `找不到入口脚本: ${path.relative(resolved.root, file)}
259
+ 请检查 autojs6() 的 entry 选项.`
260
+ );
261
+ }
262
+ },
263
+ resolveId(source) {
264
+ if (builtinSet.has(source)) {
265
+ return VIRTUAL_PREFIX + source;
266
+ }
267
+ return null;
268
+ },
269
+ load(id) {
270
+ if (id.startsWith(VIRTUAL_PREFIX)) {
271
+ return builtinModuleCode(id.slice(VIRTUAL_PREFIX.length));
272
+ }
273
+ return null;
274
+ },
275
+ /**
276
+ * 产物头部由这里写入, 而不是用 `output.banner`.
277
+ *
278
+ * 原因: `"ui";` 必须是脚本的第一个有效语句, 并且要在压缩之后写入,
279
+ * 否则头部注释会被 minifier 删掉. 没有 `"ui";` 和自定义 banner 时
280
+ * 不写任何头部, 产物第一行就是代码.
281
+ */
282
+ generateBundle(_outputOptions, bundle) {
283
+ const prefix = buildBanner({ uiMode, banner });
284
+ for (const chunk of Object.values(bundle)) {
285
+ if (chunk.type === "chunk" && chunk.isEntry) {
286
+ if (prefix) {
287
+ chunk.code = prefix + "\n" + chunk.code;
288
+ }
289
+ if (!uiMode && /\bui\.(layout|layoutFile)\s*\(/.test(chunk.code)) {
290
+ resolved.logger.warn(
291
+ '检测到 ui.layout* 调用, 但当前不是 UI 模式 (产物缺少首行 "ui";).\n 请用 npm run dev:ui / npm run build:ui 构建, 或在 autojs6() 里设置 uiMode: true.',
292
+ { timestamp: true }
293
+ );
294
+ }
295
+ break;
296
+ }
297
+ }
298
+ },
299
+ writeBundle(_outputOptions, bundle) {
300
+ const root = resolved.root;
301
+ const outDirAbs = path.resolve(root, resolved.build.outDir);
302
+ const copied = [];
303
+ for (const asset of assets === false ? [] : assets) {
304
+ const from = path.resolve(root, asset);
305
+ const to = path.resolve(outDirAbs, asset);
306
+ if (to === from || from.startsWith(outDirAbs + path.sep)) continue;
307
+ if (!fs.existsSync(from)) continue;
308
+ fs.cpSync(from, to, { recursive: true, dereference: true, preserveTimestamps: true });
309
+ copied.push(asset);
310
+ }
311
+ const deployHint = deployer?.trigger(outDirAbs) ?? null;
312
+ if (!log) {
313
+ return;
314
+ }
315
+ const mainAsset = bundle[fileName];
316
+ const size = mainAsset && "code" in mainAsset ? Buffer.byteLength(mainAsset.code) : 0;
317
+ const kb = (size / 1024).toFixed(1);
318
+ const tag = isDev ? "dev" : "build";
319
+ const ui = uiMode ? " · UI 模式" : "";
320
+ resolved.logger.info(
321
+ `\x1B[36m[${name}]\x1B[0m ${tag} 产物 → ${path.relative(root, path.join(outDirAbs, fileName))} (${kb} kB)${ui}` + (copied.length ? ` · 已同步 ${copied.join(", ")}` : "") + (deployHint ? ` · ${deployHint}` : ""),
322
+ { timestamp: true }
323
+ );
324
+ }
325
+ };
326
+ }
327
+ function buildBanner(input) {
328
+ const lines = [];
329
+ if (input.uiMode) {
330
+ lines.push('"ui";');
331
+ }
332
+ if (input.banner) {
333
+ lines.push(input.banner);
334
+ }
335
+ return lines.join("\n");
336
+ }
337
+ export {
338
+ DEFAULT_BUILTIN_MODULES,
339
+ autojs6,
340
+ autojs6 as default
341
+ };
@@ -0,0 +1,81 @@
1
+ /**
2
+ * 插件选项.
3
+ */
4
+ export interface AutoJs6Options {
5
+ /** 入口脚本, 相对项目根目录. 默认 `src/main.ts` */
6
+ entry?: string;
7
+ /**
8
+ * UI 模式的入口脚本, 相对项目根目录.
9
+ * 仅在 `uiMode` 为 `true` 时生效, 未设置时沿用 `entry`.
10
+ */
11
+ uiEntry?: string;
12
+ /** 产物目录, 相对项目根目录. 默认 `dist` */
13
+ outDir?: string;
14
+ /** 产物文件名. 默认 `main.js` */
15
+ fileName?: string;
16
+ /**
17
+ * 是否为 UI 模式脚本.
18
+ * 开启后会在产物首行写入 `"ui";` 指令 (AutoJs6 要求它是第一个有效语句).
19
+ */
20
+ uiMode?: boolean;
21
+ /**
22
+ * 需要一并拷贝到产物目录的文件/目录 (相对项目根目录).
23
+ * 默认 `['project.json', 'res', 'images']`; 传 `false` 关闭.
24
+ */
25
+ assets?: string[] | false;
26
+ /** 额外视为 AutoJs6 内置模块的模块名 */
27
+ builtinModules?: string[];
28
+ /** 编译目标. Rhino 引擎建议 `es2018`. 默认 `es2018` */
29
+ target?: string;
30
+ /** 是否压缩. 默认生产模式 (`--mode production*`) 下为 `true` */
31
+ minify?: boolean;
32
+ /** 是否生成 sourcemap. 默认 `false` (AutoJs6 内部不使用 `.map` 文件) */
33
+ sourcemap?: boolean;
34
+ /** 追加到产物头部的注释 (默认不写任何注释) */
35
+ banner?: string;
36
+ /**
37
+ * 是否在产物中写入 `"use strict";`.
38
+ * @default false
39
+ */
40
+ strict?: boolean;
41
+ /** 额外注入的编译期常量 */
42
+ define?: Record<string, string>;
43
+ /** 构建结束后是否打印产物信息. 默认 `true` */
44
+ log?: boolean;
45
+ /**
46
+ * 构建结束后把产物目录同步到手机 (调用 AutoJs6 VSCode 扩展).
47
+ *
48
+ * 走扩展的本机 HTTP 命令桥 (`/exec?cmd=saveProject&path=...`), 不需要 adb;
49
+ * 要求 VSCode 正在运行、AutoJs6 扩展已激活且至少有一台设备已连接.
50
+ * 传 `false` 等价于关闭, 也是默认行为.
51
+ */
52
+ deploy?: DeployOptions | false;
53
+ }
54
+ /**
55
+ * 自动同步到设备的配置. 由 `autojs6()` 的 `deploy` 选项使用.
56
+ *
57
+ * 依赖 AutoJs6-VSCode-Extension (≥ 1.0.13) 的 HTTP 命令桥, 需要 AutoJs6 ≥ 6.8.0
58
+ * 才有增量同步与删除文件的语义.
59
+ */
60
+ export interface DeployOptions {
61
+ /** 是否启用. 默认 `false` */
62
+ enabled?: boolean;
63
+ /** 扩展侧命令: `save` 只保存项目, `run` 保存后立即运行. 默认 `save` */
64
+ command?: "save" | "run";
65
+ /** 扩展 HTTP 命令桥的地址. 默认 `127.0.0.1` */
66
+ host?: string;
67
+ /**
68
+ * 命令桥端口. 未设置时读取工作区 `.vscode/settings.json` 的 `autojs6.http.port`,
69
+ * 仍取不到则用扩展的默认值 `10347`.
70
+ */
71
+ port?: number;
72
+ /**
73
+ * 触发同步的构建模式. 默认 `dev` (即 `--mode development*`);
74
+ * 传 `all` 不限制, 或传模式名数组精确匹配.
75
+ */
76
+ modes?: "dev" | "all" | string[];
77
+ /** 请求超时 (毫秒). 默认 `1500` */
78
+ timeout?: number;
79
+ /** 连接扩展失败时的行为: `warn` 打印一次警告 (默认), `silent` 完全静默 */
80
+ onError?: "warn" | "silent";
81
+ }
package/package.json CHANGED
@@ -1,6 +1,67 @@
1
1
  {
2
2
  "name": "vite-plugin-autojs6",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "type": "module",
5
+ "homepage": "https://github.com/WhiteSevs/vite-plugin-autojs6",
6
+ "description": "AutoJs6 的 Vite 构建插件: TypeScript + ESM → 单文件脚本, 类型提示来自 @sm003/autojs6-dts",
7
+ "keywords": [
8
+ "autojs",
9
+ "autojs6",
10
+ "vite",
11
+ "vite-plugin",
12
+ "rhino",
13
+ "typescript"
14
+ ],
15
+ "license": "MIT",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/plugin/index.d.ts",
19
+ "import": "./dist/plugin/index.js",
20
+ "require": "./dist/plugin/index.cjs"
21
+ },
22
+ "./package.json": "./package.json"
23
+ },
24
+ "main": "./dist/plugin/index.cjs",
25
+ "module": "./dist/plugin/index.js",
26
+ "types": "./dist/plugin/index.d.ts",
27
+ "files": [
28
+ "dist",
29
+ "bin",
30
+ "README.md",
31
+ "LICENSE",
32
+ "template/**/*",
33
+ "!template/node_modules/**",
34
+ "!template/dist/**",
35
+ "!template/pnpm-lock.yaml",
36
+ "!template/pnpm-workspace.yaml"
37
+ ],
38
+ "bin": {
39
+ "vite-plugin-autojs6": "./bin/create.mjs"
40
+ },
41
+ "dependencies": {
42
+ "@sm003/autojs6-dts": "^4.87.0"
43
+ },
44
+ "peerDependencies": {
45
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^22.10.2",
49
+ "oxfmt": "^0.79.0",
50
+ "oxlint": "^1.92.0",
51
+ "typescript": "^5.9.3",
52
+ "vite": "^7.3.8"
53
+ },
54
+ "engines": {
55
+ "node": ">=18"
56
+ },
57
+ "scripts": {
58
+ "build": "oxfmt && node scripts/build.mjs",
59
+ "typecheck": "tsc -p tsconfig.json --noEmit",
60
+ "lint": "oxlint",
61
+ "lint:fix": "oxlint --fix",
62
+ "format": "oxfmt",
63
+ "format:check": "oxfmt --check",
64
+ "check": "npm run typecheck && npm run lint && npm run format:check && npm run build",
65
+ "create": "node bin/create.mjs"
66
+ }
6
67
  }
@@ -0,0 +1,39 @@
1
+ {
2
+ // oxfmt 配置 (JSONC, 允许注释)
3
+ // 用法: npm run format / npm run format:check
4
+ // 说明: oxfmt 只会自动读取 .oxfmtrc.json / .oxfmtrc.jsonc / oxfmt.config.ts,
5
+ // 文件名里的 `rc` 不能省略, 否则会提示 "No config found" 并回落到默认值.
6
+ "$schema": "./node_modules/oxfmt/configuration_schema.json",
7
+
8
+ // 与仓库现有风格保持一致
9
+ "printWidth": 100,
10
+ "tabWidth": 2,
11
+ "useTabs": false,
12
+ "semi": true,
13
+ "singleQuote": false,
14
+ "quoteProps": "as-needed",
15
+ "trailingComma": "none",
16
+ "bracketSpacing": true,
17
+ "bracketSameLine": false,
18
+ "arrowParens": "always",
19
+ "endOfLine": "lf",
20
+ "insertFinalNewline": true,
21
+
22
+ // package.json 的字段顺序是手写的, 不希望被重排
23
+ "sortPackageJson": false,
24
+ // 导入顺序保持原样 (按可读性分组, 不做字母序排序)
25
+ "sortImports": false,
26
+
27
+ // Rhino 产物、依赖目录不参与格式化
28
+ "ignorePatterns": ["**/dist/**", "**/node_modules/**", "pnpm-lock.yaml"],
29
+
30
+ "overrides": [
31
+ {
32
+ // JSON 不允许尾随逗号
33
+ "files": ["**/*.json", "**/*.jsonc"],
34
+ "options": {
35
+ "trailingComma": "none"
36
+ }
37
+ }
38
+ ]
39
+ }
@@ -0,0 +1,76 @@
1
+ {
2
+ // oxlint 配置 (JSONC, 允许注释)
3
+ // 用法: npm run lint / npm run lint:fix
4
+ // 说明: oxlint 只认 .oxlintrc.json / .oxlintrc.jsonc / oxlint.config.ts, 文件名里的 `rc` 不能省.
5
+ "$schema": "./node_modules/oxlint/configuration_schema.json",
6
+
7
+ // AutoJs6 的 Rhino 引擎按 ES2018 解析脚本 (构建 target 也是 es2018)
8
+ "env": {
9
+ "es2018": true
10
+ },
11
+
12
+ "plugins": ["typescript", "unicorn", "oxc"],
13
+
14
+ "categories": {
15
+ "correctness": "error",
16
+ "suspicious": "warn"
17
+ },
18
+
19
+ "rules": {
20
+ // log / console 是脚本的主要输出方式
21
+ "no-console": "off",
22
+ // AutoJs6 的全局对象 (device / app / ocr / ui ...) 由 @sm003/autojs6-dts 提供类型,
23
+ // 未定义变量交给 tsc 检查, lint 不重复报一遍
24
+ "no-undef": "off",
25
+ "no-unused-vars": "off",
26
+ // `import path from 'path'` 会被插件转成 require("path"), 不能写成 node:path
27
+ "unicorn/prefer-node-protocol": "off",
28
+
29
+ // ---- 限制在 ES2018: 下面这些全局/API 都是 ES2019+, AutoJs6 上没有 ----
30
+ "no-restricted-globals": [
31
+ "error",
32
+ { "name": "globalThis", "message": "ES2020, AutoJs6 (Rhino) 没有 globalThis" },
33
+ { "name": "BigInt", "message": "ES2020, AutoJs6 (Rhino) 没有 BigInt" },
34
+ { "name": "WeakRef", "message": "ES2021, AutoJs6 (Rhino) 不支持" },
35
+ { "name": "FinalizationRegistry", "message": "ES2021, AutoJs6 (Rhino) 不支持" },
36
+ { "name": "AggregateError", "message": "ES2021, AutoJs6 (Rhino) 不支持" }
37
+ ],
38
+ "no-restricted-properties": [
39
+ "error",
40
+ { "property": "flat", "message": "Array.prototype.flat 是 ES2019" },
41
+ { "property": "flatMap", "message": "Array.prototype.flatMap 是 ES2019" },
42
+ {
43
+ "property": "trimStart",
44
+ "message": "String.prototype.trimStart 是 ES2019, 改用 replace(/^\\s+/, '')"
45
+ },
46
+ {
47
+ "property": "trimEnd",
48
+ "message": "String.prototype.trimEnd 是 ES2019, 改用 replace(/\\s+$/, '')"
49
+ },
50
+ { "property": "matchAll", "message": "String.prototype.matchAll 是 ES2020" },
51
+ {
52
+ "property": "replaceAll",
53
+ "message": "String.prototype.replaceAll 是 ES2021, 改用 replace(/g)"
54
+ },
55
+ { "property": "at", "message": "Array.prototype.at 是 ES2022, 改用 arr[arr.length - 1]" },
56
+ { "property": "findLast", "message": "Array.prototype.findLast 是 ES2023" },
57
+ { "property": "findLastIndex", "message": "Array.prototype.findLastIndex 是 ES2023" },
58
+ { "object": "Object", "property": "fromEntries", "message": "Object.fromEntries 是 ES2019" },
59
+ {
60
+ "object": "Object",
61
+ "property": "hasOwn",
62
+ "message": "Object.hasOwn 是 ES2022, 改用 Object.prototype.hasOwnProperty.call()"
63
+ },
64
+ { "object": "Object", "property": "groupBy", "message": "Object.groupBy 是 ES2024" },
65
+ { "object": "Promise", "property": "allSettled", "message": "Promise.allSettled 是 ES2020" },
66
+ { "object": "Promise", "property": "any", "message": "Promise.any 是 ES2021" },
67
+ {
68
+ "object": "Promise",
69
+ "property": "withResolvers",
70
+ "message": "Promise.withResolvers 是 ES2024"
71
+ }
72
+ ]
73
+ },
74
+
75
+ "ignorePatterns": ["dist", "node_modules"]
76
+ }