eslint-plugin-aurora-999 0.1.2 → 0.1.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/README.md +25 -2
- package/lib/configs/base-config.js +40 -7
- package/lib/rules/base-check.js +3 -35
- package/lib/rules/trial-check.js +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,6 +51,30 @@ module.exports = [
|
|
|
51
51
|
npx eslint .
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
+
## 打包与发布
|
|
55
|
+
|
|
56
|
+
在本项目根目录下执行。
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# 1) 登录 npm(如已登录可跳过)
|
|
60
|
+
npm login
|
|
61
|
+
|
|
62
|
+
# 2) 更新版本号(按需选择 patch/minor/major)
|
|
63
|
+
npm version patch
|
|
64
|
+
|
|
65
|
+
# 3) 本地打包(生成 .tgz 包,用于自测/分发)
|
|
66
|
+
npm pack
|
|
67
|
+
|
|
68
|
+
# 4) 发布到 npm
|
|
69
|
+
npm publish
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
如果你想先确认发布内容是否正确,可以先运行:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npm publish --dry-run
|
|
76
|
+
```
|
|
77
|
+
|
|
54
78
|
## configs
|
|
55
79
|
|
|
56
80
|
### `configs.recommended(baseDir)`
|
|
@@ -68,8 +92,7 @@ npx eslint .
|
|
|
68
92
|
## rules
|
|
69
93
|
|
|
70
94
|
- `aurora/base-check`
|
|
71
|
-
-
|
|
72
|
-
- 禁止 `debugger`
|
|
95
|
+
- 当前版本默认不做检查(已禁用,保留 rule id 以兼容历史配置)
|
|
73
96
|
- `aurora/trial-check`
|
|
74
97
|
- 仅对 `*trialService.ts` 生效(不要求目录结构)
|
|
75
98
|
- 约束 `TrialGenerator` 子类、`generate()` 方法以及返回值包含 `target_answer`
|
|
@@ -17,13 +17,45 @@ function eslintBaseConfig(baseDir) {
|
|
|
17
17
|
const tsconfigPath = path.join(baseDir, "tsconfig.json");
|
|
18
18
|
const hasTsConfig = fs.existsSync(tsconfigPath);
|
|
19
19
|
|
|
20
|
+
const auroraBaseRules = {
|
|
21
|
+
// 不必要的空行、空格
|
|
22
|
+
"no-trailing-spaces": "error",
|
|
23
|
+
"no-mixed-spaces-and-tabs": "error",
|
|
24
|
+
"no-whitespace-before-property": "error",
|
|
25
|
+
|
|
26
|
+
// 检查未使用的变量、函数、导入等(JS 默认用 ESLint 原生规则)
|
|
27
|
+
"no-unused-vars": ["error", { args: "none", ignoreRestSiblings: true }],
|
|
28
|
+
"no-unused-expressions": "error",
|
|
29
|
+
"no-duplicate-imports": "error",
|
|
30
|
+
|
|
31
|
+
// 命名规范
|
|
32
|
+
camelcase: "error",
|
|
33
|
+
"new-cap": ["error", { newIsCap: true, capIsNew: false }],
|
|
34
|
+
"no-underscore-dangle": ["error", { allowAfterThis: true }],
|
|
35
|
+
|
|
36
|
+
// 使用 const 和 let 而不是 var
|
|
37
|
+
"no-var": "error",
|
|
38
|
+
"prefer-const": "error",
|
|
39
|
+
"block-scoped-var": "error",
|
|
40
|
+
};
|
|
41
|
+
|
|
20
42
|
const typescriptRulesToDisable = {
|
|
21
|
-
"@typescript-eslint/no-unused-vars": "off",
|
|
22
|
-
"no-unused-vars": "off",
|
|
23
|
-
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
24
43
|
"@typescript-eslint/no-explicit-any": "off",
|
|
25
44
|
};
|
|
26
45
|
|
|
46
|
+
const typescriptRuleOverrides = {
|
|
47
|
+
// TS 文件里用 @typescript-eslint 版本替代(避免误报)
|
|
48
|
+
"no-unused-vars": "off",
|
|
49
|
+
"@typescript-eslint/no-unused-vars": [
|
|
50
|
+
"error",
|
|
51
|
+
{ args: "none", ignoreRestSiblings: true },
|
|
52
|
+
],
|
|
53
|
+
"no-unused-expressions": "off",
|
|
54
|
+
"@typescript-eslint/no-unused-expressions": "error",
|
|
55
|
+
"no-redeclare": "off",
|
|
56
|
+
"@typescript-eslint/no-redeclare": "error",
|
|
57
|
+
};
|
|
58
|
+
|
|
27
59
|
const baseConfig = {
|
|
28
60
|
languageOptions: {
|
|
29
61
|
ecmaVersion: 2022,
|
|
@@ -36,8 +68,7 @@ function eslintBaseConfig(baseDir) {
|
|
|
36
68
|
},
|
|
37
69
|
rules: {
|
|
38
70
|
...js.configs.recommended.rules,
|
|
39
|
-
|
|
40
|
-
"no-console": "warn",
|
|
71
|
+
...auroraBaseRules,
|
|
41
72
|
semi: ["error", "always"],
|
|
42
73
|
},
|
|
43
74
|
};
|
|
@@ -55,7 +86,9 @@ function eslintBaseConfig(baseDir) {
|
|
|
55
86
|
},
|
|
56
87
|
rules: {
|
|
57
88
|
...(config.rules || {}),
|
|
89
|
+
...auroraBaseRules,
|
|
58
90
|
...typescriptRulesToDisable,
|
|
91
|
+
...typescriptRuleOverrides,
|
|
59
92
|
},
|
|
60
93
|
}))
|
|
61
94
|
: [
|
|
@@ -63,7 +96,9 @@ function eslintBaseConfig(baseDir) {
|
|
|
63
96
|
{
|
|
64
97
|
files: ["**/*.ts", "**/*.tsx"],
|
|
65
98
|
rules: {
|
|
99
|
+
...auroraBaseRules,
|
|
66
100
|
...typescriptRulesToDisable,
|
|
101
|
+
...typescriptRuleOverrides,
|
|
67
102
|
},
|
|
68
103
|
},
|
|
69
104
|
];
|
|
@@ -87,8 +122,6 @@ function eslintBaseConfig(baseDir) {
|
|
|
87
122
|
"import/extensions": [".js", ".jsx", ".ts", ".tsx"],
|
|
88
123
|
},
|
|
89
124
|
rules: {
|
|
90
|
-
...importPlugin.configs.recommended.rules,
|
|
91
|
-
"import/no-unresolved": "error",
|
|
92
125
|
"import/extensions": ["error", "never", { js: "never", jsx: "never", ts: "never", tsx: "never" }],
|
|
93
126
|
},
|
|
94
127
|
};
|
package/lib/rules/base-check.js
CHANGED
|
@@ -8,16 +8,7 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* @param {import('estree').Expression} callee
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
if (!callee || callee.type !== "MemberExpression") return;
|
|
13
|
-
if (!callee.object || callee.object.type !== "Identifier" || callee.object.name !== "console") return;
|
|
14
|
-
|
|
15
|
-
if (callee.property?.type === "Identifier") return callee.property.name;
|
|
16
|
-
if (callee.property?.type === "Literal" && typeof callee.property.value === "string") {
|
|
17
|
-
return callee.property.value;
|
|
18
|
-
}
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
11
|
+
// base-check 已禁用;保留文件结构以便未来按需恢复
|
|
21
12
|
|
|
22
13
|
module.exports = {
|
|
23
14
|
meta: {
|
|
@@ -28,8 +19,7 @@ module.exports = {
|
|
|
28
19
|
},
|
|
29
20
|
schema: [],
|
|
30
21
|
messages: {
|
|
31
|
-
|
|
32
|
-
noDebugger: "生产代码中禁止使用 debugger",
|
|
22
|
+
baseCheckDisabled: "Aurora base-check 已禁用(不再检查 console/debugger)",
|
|
33
23
|
},
|
|
34
24
|
},
|
|
35
25
|
|
|
@@ -49,28 +39,6 @@ module.exports = {
|
|
|
49
39
|
if (lower.includes(part)) return {};
|
|
50
40
|
}
|
|
51
41
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
CallExpression(node) {
|
|
56
|
-
const name = getConsoleMethodName(node.callee);
|
|
57
|
-
if (!name) return;
|
|
58
|
-
|
|
59
|
-
if (bannedConsoleMethods.has(name)) {
|
|
60
|
-
context.report({
|
|
61
|
-
node,
|
|
62
|
-
messageId: "noConsole",
|
|
63
|
-
data: { name },
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
DebuggerStatement(node) {
|
|
69
|
-
context.report({
|
|
70
|
-
node,
|
|
71
|
-
messageId: "noDebugger",
|
|
72
|
-
});
|
|
73
|
-
},
|
|
74
|
-
};
|
|
42
|
+
return {};
|
|
75
43
|
},
|
|
76
44
|
};
|
package/lib/rules/trial-check.js
CHANGED
|
@@ -67,6 +67,12 @@ module.exports = {
|
|
|
67
67
|
return {};
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
// 调试用:确认规则是否对该文件生效(不影响 lint 结果)
|
|
71
|
+
if (process.env.AURORA_ESLINT_DEBUG === "1") {
|
|
72
|
+
// eslint-disable-next-line no-console
|
|
73
|
+
console.log(`[aurora] trial-check enabled: ${fileName}`);
|
|
74
|
+
}
|
|
75
|
+
|
|
70
76
|
let hasGeneratorClass = false;
|
|
71
77
|
|
|
72
78
|
return {
|