Files
2026Technology-Competition/data/import-verification/02-standard-formats/results/standard-rules-md.yaml
T

71 lines
3.3 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# [DUPLICATE: exact] 重复自定义规则 no-hardcoded-secret(检测目标完全一致)
# 如需启用,删除以下每行开头的 # 即可
# - id: no-hardcoded-credentials
# severity: error
# description: 禁止在源码中硬编码密码、令牌、API Key 等敏感凭证
# message: 检测到疑似硬编码凭证,请使用环境变量或密钥管理服务注入
# languages: [javascript, typescript, java]
# duplicateOf: custom/no-hardcoded-secret
# duplicateLevel: exact
# [DUPLICATE: exact] 重复 eslint/no-eval(检测目标完全一致)
# 如需启用,删除以下每行开头的 # 即可
# - id: no-eval
# severity: error
# description: 禁止使用 eval() 函数
# message: eval() 存在安全风险,请使用 JSON.parse() 或 Function 构造器替代
# languages: [javascript, typescript]
# duplicateOf: eslint/no-eval
# duplicateLevel: exact
- id: no-innerhtml-assignment
severity: warning
description: 禁止直接赋值 innerHTML,防止 XSS
message: 避免直接操作 innerHTML,请使用 textContent 或 DOMPurify 清洗
- id: constant-screaming-snake-case
severity: warning
description: 常量命名必须使用全大写加下划线(SCREAMING_SNAKE_CASE
message: 常量命名应使用 SCREAMING_SNAKE_CASE,如 MAX_RETRY_COUNT
languages: [javascript, typescript, java]
- id: boolean-name-prefix
severity: info
description: 布尔变量和方法名应以 is/has/can/should 开头
message: 布尔变量和方法名应以 is/has/can/should 开头,以提升可读性
languages: [javascript, typescript]
- id: no-deeply-nested-loops
severity: warning
description: 禁止三层及以上嵌套循环
message: 检测到深层嵌套循环(≥3 层)时,建议重构为扁平结构或使用查找表优化
languages: [javascript, typescript, java]
- id: no-sync-api-in-async-function
severity: warning
description: 异步函数内禁止调用同步阻塞 API
message: 在 async 函数中调用同步 API 会阻塞事件循环,请改用异步版本
languages: [javascript, typescript]
- id: explicit-type-annotations
severity: info
description: 函数参数和返回值应显式标注 TypeScript 类型
message: 函数参数和返回值请显式标注 TypeScript 类型,提升类型安全性
languages: [typescript]
# [DUPLICATE: exact] 重复自定义规则 no-magic-numbers(检测目标完全一致)
# 如需启用,删除以下每行开头的 # 即可
# - id: no-magic-numbers
# severity: info
# description: 禁止在代码中直接使用魔法数字
# message: 魔法数字应提取为命名常量以提升可维护性
# languages: [javascript, typescript]
# duplicateOf: custom/no-magic-numbers
# duplicateLevel: exact
- id: require-error-context
severity: warning
description: throw 语句必须携带错误上下文信息
message: throw 语句必须携带错误上下文信息,便于问题定位
languages: [javascript, typescript, java]
- id: no-todo-comments
severity: info
description: 生产代码中不应遗留 TODO/FIXME/HACK 注释
message: TODO/FIXME/HACK 注释请在发布前处理
excludeLanguages: [sql]
- id: require-doc-comments
severity: info
description: 公共函数应添加文档注释
message: 公共函数请添加 JSDoc/Javadoc 注释,说明用途、参数和返回值
languages: [javascript, typescript, java]