test-rule

Create and execute test cases for SonarJS rules using rule tester options.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill facilitates the creation and execution of tests for SonarJS rules, streamlining the testing process for rule developers.

Core Features & Use Cases

  • Test Creation: Provides templates and instructions for writing comprehensive test cases.
  • Test Execution: Employs various rule tester options to execute tests efficiently.
  • Use Case: Ideal for developers tasked with writing tests for new or updated SonarJS rules, or for anyone looking to ensure their rules meet quality standards.

Quick Start

Use the test-rule skill to run tests for rule S1234 with npx tsx --test packages/analysis/src/jsts/rules/S1234/**/*.test.ts.

Frequently Asked Questions about test-rule

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

FAQPage Schema
How do I create and execute unit tests for SonarJS rules in TypeScript?

You can execute tests for a specific SonarJS rule using the command `npx tsx --test packages/analysis/src/jsts/rules/S1234/**/*.test.ts`. This command targets all test files within the specified rule directory for efficient validation.

What is the best way to validate new JavaScript and TypeScript rules for code quality?

Validating new JavaScript and TypeScript rules for code quality is best achieved by developing comprehensive test cases. This Skill provides templates and various rule tester options to ensure your rules meet quality and security standards through automated testing.

Do I need any external dependencies to run SonarJS rule tests?

No external dependencies are required to run SonarJS rule tests with this Skill. It operates independently without listed dependencies, allowing you to directly create and execute tests for your TypeScript-based JavaScript rules.

Can I use this for testing existing SonarJS rules or only for new rule development?

You can use this for both new and updated SonarJS rules. It facilitates the creation of comprehensive test cases and offers various rule tester options to ensure that any rule, whether new or modified, meets the required quality standards.