Socket
Socket
Sign inDemoInstall

@typescript-eslint/rule-tester

Package Overview
Dependencies
Maintainers
2
Versions
972
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@typescript-eslint/rule-tester

Tooling to test ESLint rules


Version published
Weekly downloads
273K
decreased by-4.22%
Maintainers
2
Weekly downloads
 
Created

What is @typescript-eslint/rule-tester?

@typescript-eslint/rule-tester is a utility package designed to help developers test custom ESLint rules for TypeScript code. It provides a framework for writing unit tests for ESLint rules, ensuring that they behave as expected when applied to TypeScript code.

What are @typescript-eslint/rule-tester's main functionalities?

Testing ESLint Rules

This feature allows you to test custom ESLint rules by providing valid and invalid code samples. The RuleTester runs the rule against these samples and checks if the expected errors are reported.

const { RuleTester } = require('@typescript-eslint/rule-tester');
const rule = require('path/to/your/custom-rule');

const ruleTester = new RuleTester({
  parser: '@typescript-eslint/parser',
});

ruleTester.run('your-rule-name', rule, {
  valid: [
    {
      code: 'const x: number = 42;',
    },
  ],
  invalid: [
    {
      code: 'const x: string = 42;',
      errors: [{ messageId: 'expectedNumber' }],
    },
  ],
});
0

Keywords

FAQs

Package last updated on 24 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc