一键导入
sonar-compliance-testing
SonarQube compliance rules for TypeScript/React code and tests (assertions, complexity, ternaries) — assign to frontend test phases
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
SonarQube compliance rules for TypeScript/React code and tests (assertions, complexity, ternaries) — assign to frontend test phases
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Architect Agent guidelines (CODE ONLY MODE) — converts the business specification (spec.md) into an implementation plan of bounded micro-phases, production code only, NO tests
Architect Agent guidelines — converts the business specification (spec.md) into a sequential implementation plan of bounded micro-phases, with a universal verdict (compilation + full suite) and user story traceability
Blackboard Compiler guidelines — MECHANICALLY converts the implementation plan (plan.md) into a strict blackboard.yaml for the orchestrator
PO Agent guidelines — turns a raw need (need.md) into a refined business specification (spec.md) with user stories, testable acceptance criteria and an explicit scope
Screaming Architecture project structure (grouped by business feature) — assign to phases creating the tree structure or new modules
Java/Spring Boot production code rules (records, constructor injection, layer separation) — assign to backend feature phases
| name | sonar-compliance-testing |
| description | SonarQube compliance rules for TypeScript/React code and tests (assertions, complexity, ternaries) — assign to frontend test phases |
// ❌ BLOCKER - Test without assertion (S2699)
it('should do something', () => {
render(<Component />);
});
// ✅ CORRECT - Always add an assertion
it('should do something', () => {
render(<Component />);
expect(screen.getByText('Expected')).toBeInTheDocument();
});
// ❌ MAJOR - Nested ternary
const result = a ? (b ? 'x' : 'y') : 'z';
// ✅ CORRECT - Extract to function or use if/else
const getResult = () => {
if (!a) return 'z';
return b ? 'x' : 'y';
};
// ❌ CRITICAL - Complexity > 15
function complexFunction() {
if (a) {
if (b) {
if (c) {
/* ... */
}
}
}
// More conditions...
}
// ✅ CORRECT - Extract to sub-functions
function complexFunction() {
if (!a) return handleNotA();
if (!b) return handleNotB();
return handleC(c);
}
// ❌ MAJOR - Using && for null check
const value = obj && obj.prop && obj.prop.value;
// ✅ CORRECT - Optional chaining
const value = obj?.prop?.value;
// ❌ BUG - Promise returned where void expected
<button onClick={async () => await fetchData()}/>
// ✅ CORRECT - Wrap the Promise
<button onClick={() => { void fetchData(); }}>
// or
<button onClick={() => { fetchData().catch(console.error); }}>
// ❌ MAJOR - Index used as key
{items.map((item, index) => <Item key={index} />)}
// ✅ CORRECT - Use a unique identifier
{items.map(item => <Item key={item.id} />)}
// If no unique id, generate a stable key
{items.map(item => <Item key={`${item.name}-${item.type}`} />)}
// ❌ MAJOR - Mutable props
interface Props {
value: string;
}
// ✅ CORRECT - Props readonly
interface Props {
readonly value: string;
}
// or use Readonly<>
type Props = Readonly<{
value: string;
}>;
// ❌ MAJOR - Fragment with single child
return <>{content}</>;
// ✅ CORRECT - Return child directly
return content;
// ❌ MAJOR - Object recreated on every render
<Context.Provider value={{ user, setUser }}>
// ✅ CORRECT - Memoize with useMemo
const value = useMemo(() => ({ user, setUser }), [user, setUser]);
<Context.Provider value={value}>
// ❌ MAJOR - Alias of primitive type
type UUID = string;
// ✅ CORRECT - Use type directly
// or create a branded type if need to distinguish
type UUID = string & { readonly __brand: unique symbol };
expect() assertion