rule-implementation

Guide SonarJS rule implementation and false positive resolution for JavaScript, TypeScript, and CSS.

1.3k|191|Updated May 15, 2012
One-click install
npx skills add https://github.com/SonarSource/SonarJS --skill rule-implementation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rule-implementation
Source: https://github.com/SonarSource/SonarJS/tree/main/.claude/skills/rule-implementation
Command: npx skills add https://github.com/SonarSource/SonarJS --skill rule-implementation

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides comprehensive guidance for implementing and fixing SonarJS rules, including resolving false positives and understanding rule configurations.

Core Features & Use Cases

  • Rule Implementation Guidance: Offers detailed steps and best practices for implementing SonarJS rules.
  • False Positive Resolution: Helps identify and resolve false positives by analyzing rule implementations and control flows.
  • Rule Configuration Architecture: Explains the configuration layers and workflows for external rule configurations.
  • AST Traversal Strategy: Provides strategies for efficient and safe AST traversal in rule implementations.
  • Type Safety: Offers guidelines for maintaining type safety in TypeScript rule implementations.
  • FP Remediation Quality: Ensures high-quality remediation by avoiding suppressions that are not justified.
  • Decorator Design: Offers best practices for designing decorators that correctly identify owning components.
  • Code Style: Provides recommendations for maintaining clean and efficient code style in rule implementations.

Quick Start

Use the rule-implementation skill to learn how to implement a new SonarJS rule or resolve a false positive in an existing rule.

Frequently Asked Questions about rule-implementation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I resolve false positives in SonarJS rules?

Resolve false positives in SonarJS rules by analyzing the rule implementation and control flow to identify detection flaws. This approach ensures high-quality remediation without relying on unjustified issue suppressions.

What is the best way to implement AST traversal for SonarJS rule configuration?

The best way to implement AST traversal for SonarJS rules is to apply safe and efficient traversal strategies that match the expected configuration architecture. This ensures rules accurately target specific code patterns without performance bottlenecks.

How do I maintain type safety when implementing SonarJS rules for TypeScript?

Maintain type safety in TypeScript SonarJS rules by following specific implementation guidelines that respect the language's strict typing constraints. This prevents runtime errors during static analysis and ensures accurate rule evaluation.

Does SonarJS rule implementation require configuring decorators for component ownership?

SonarJS rule implementation often requires designing decorators to correctly identify owning components within the codebase. Proper decorator design ensures the rule accurately targets the intended architectural boundaries during static analysis.

Why does my SonarJS rule configuration fail to catch specific JavaScript code patterns?

Your SonarJS rule configuration may fail due to incorrect AST traversal logic or insufficient understanding of the rule's configuration layers. Analyzing the rule's implementation strategy and control flow helps identify and fix these detection gaps.

Can I use this SonarJS rule guidance for CSS rule development?

Yes, you can use this guidance for CSS rule development alongside JavaScript and TypeScript. It provides comprehensive best practices for rule implementation, code style recommendations, and configuration architecture applicable across these languages.