eslint-plugin-regular-expression

0.1.8 • Public • Published

eslint-plugin-regular-expression

logo

Custom ESLint rules with regexp

logo

Overview

eslint-plugin-regular-expression is a plugin that enables defining ESLint rules using regular expressions. You can specify forbidden or required patterns for variable names, function names, string literals, and more.

Features

  • Ban Patterns: Prohibit specific patterns using regular expressions for variable names, function names, strings, and more.
  • Require Patterns: Enforce the presence of specific patterns (expressed with regular expressions) in your code.

Installation

Install with the following command:

npm i eslint eslint-plugin-regular-expression -D

Usage

After installation, add the plugin to your ESLint config. eslint-plugin-regular-expression supports Flat Config.

Example:

eslint.config.js

import regexpRules from 'eslint-plugin-regular-expression';

export default [
  {
    files: ["*.js", "*.ts"],
    plugins: {
      'regexp-rules': regexpRules,
    },
    rules: {
      'regexp-rules/banned': ['error', { patterns: ["forbidde*"] }],
      'regexp-rules/required': ['error', { patterns: ["required"] }],
    },
  },
];

In this example:

  • The banned rule prohibits patterns matching forbidde*.
  • The required rule enforces that the pattern required appears somewhere in the code.

This plugin can be used in both JavaScript and TypeScript projects.

Document

English | 日本語

Package Sidebar

Install

npm i eslint-plugin-regular-expression

Weekly Downloads

6

Version

0.1.8

License

MIT

Unpacked Size

14.5 kB

Total Files

14

Last publish

Collaborators

  • takasqr