Donov4n/eslint-plugin-class-methods-use-this-regex

An enhanced version of the ESLint class-methods-use-this rule with RegExp exceptMethods option

★ 0Forks 0JavaScriptGitHub ↗Compare

Project website ↗

README

eslint-plugin-class-methods-use-this-regex

An enhanced version of the ESLint class-methods-use-this rule where the exceptMethods option accepts regular expressions instead of plain method names.

Installation

Install ESLint and eslint-plugin-class-methods-use-this-regex:

# - NPM
npm i eslint eslint-plugin-class-methods-use-this-regex --save-dev

# - Yarn
yarn add eslint eslint-plugin-class-methods-use-this-regex --dev

Usage

Add class-methods-use-this-regex to the plugins section of your eslint.config.mjs configuration file, and
configure the rule under the rules section. Don't forget to disable the core rule class-methods-use-this:

import classMethodsUseThisRegex from 'eslint-plugin-class-methods-use-this-regex';

export default [
    {
        plugins: {
            'class-methods-use-this-regex': classMethodsUseThisRegex,
        },
        rules: {
            'class-methods-use-this': 'off',
            'class-methods-use-this-regex/class-methods-use-this': ['error', {
                exceptMethods: ['^render.*$'],
            }],
        },
    },
];

... Or if you're still using the legacy (.eslintrc) configuration system:

{
    "plugins": ["class-methods-use-this-regex"],
    "rules": {
        "class-methods-use-this": ["off"],
        "class-methods-use-this-regex/class-methods-use-this": ["error", {
            "exceptMethods": ["^render.*$"]
        }]
    }
}

Contributors

tx44Donov4ngreenkeeper[bot]

Issues