Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-rule-composer

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-rule-composer

A utility for composing ESLint rules from other ESLint rules

  • 0.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.5M
decreased by-23.33%
Maintainers
1
Weekly downloads
 
Created

What is eslint-rule-composer?

The eslint-rule-composer npm package is a utility for composing and configuring ESLint rules. It provides a set of functions to help developers extend and modify the behavior of existing ESLint rules without having to write a new rule from scratch. This can be particularly useful for creating project-specific versions of general rules or for combining the checks of multiple rules into a single, more efficient rule.

What are eslint-rule-composer's main functionalities?

Joining Rules

This feature allows you to combine the reports of two or more rules into a single rule. This is useful when you want to enforce multiple related coding standards without requiring separate rules for each one.

const { joinReports } = require('eslint-rule-composer');
const ruleA = require('eslint/lib/rules/rule-a');
const ruleB = require('eslint/lib/rules/rule-b');

module.exports = joinReports(ruleA, ruleB);

Filtering Reports

This feature allows you to modify the behavior of an existing rule by filtering out reports based on specific criteria. This can be useful for ignoring certain patterns or node types that the original rule would normally report.

const { filterReports } = require('eslint-rule-composer');
const originalRule = require('eslint/lib/rules/some-rule');

const filteredRule = filterReports(originalRule, (problem, metadata) => {
  return problem.node.type !== 'Identifier';
});

module.exports = filteredRule;

Mapping Reports

This feature allows you to modify the reports generated by an existing rule. This can include changing the message, severity, or any other property of the report. It's useful for customizing the feedback provided by a rule to better fit your project's guidelines.

const { mapReports } = require('eslint-rule-composer');
const originalRule = require('eslint/lib/rules/another-rule');

const mappedRule = mapReports(originalRule, (problem, metadata) => {
  problem.message = 'Custom message: ' + problem.message;
  return problem;
});

module.exports = mappedRule;

Other packages similar to eslint-rule-composer

Keywords

FAQs

Package last updated on 16 Apr 2018

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