Skip to content

Commit 7cd1dcd

Browse files
authored
🐛 修复 ESLint 支持CATApi / Headers 问题 (#386)
补充 #385 缺失的部分
1 parent e2c860d commit 7cd1dcd

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

packages/eslint/compat-grant.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const compat_grant = require("eslint-plugin-userscripts/dist/data/compat-grant.js");
2+
const compatMap = {
3+
CAT_userConfig: [{ type: "scriptcat", versionConstraint: ">=0.11.0-beta" }],
4+
CAT_fileStorage: [{ type: "scriptcat", versionConstraint: ">=0.11.0" }],
5+
...compat_grant.compatMap,
6+
};
7+
8+
const gmPolyfillOverride = {
9+
...compat_grant.gmPolyfillOverride,
10+
};
11+
12+
module.exports = { compatMap, gmPolyfillOverride };

packages/eslint/compat-headers.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const compat_headers = require("eslint-plugin-userscripts/dist/data/compat-headers.js");
2+
3+
const compatMap = {
4+
...compat_headers.compatMap,
5+
nonFunctional: {
6+
...compat_headers.compatMap.nonFunctional,
7+
// 覆盖或新增新的属性
8+
background: [],
9+
crontab: [],
10+
cloudCat: [],
11+
cloudServer: [],
12+
exportValue: [],
13+
exportCookie: [],
14+
scriptUrl: [],
15+
storageName: [],
16+
},
17+
};
18+
19+
module.exports = { compatMap };

rspack.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ export default defineConfig({
5252
alias: {
5353
"@App": path.resolve(__dirname, "src/"),
5454
"@Packages": path.resolve(__dirname, "packages/"),
55+
// 改写eslint-plugin-userscripts以适配脚本猫,打包时重定义模块路径
56+
"../data/compat-grant": path.resolve(__dirname, "packages/eslint/compat-grant"),
57+
"../data/compat-headers": path.resolve(__dirname, "packages/eslint/compat-headers"),
5558
},
5659
fallback: {
5760
child_process: false,

0 commit comments

Comments
 (0)