eslint-plugin-class-methods-preprocessors

0.0.3 • Public • Published

eslint-plugin-class-methods-preprocessors

This rule enforces you to add a preprocessor to class methods. It is inspired from object oriented programming patterns to enforce the use of preprocessors specially for methods

Examples for incorrect code

import { Injectable } from '@nestjs/common';

@Injectable()
export class AppService {
    getHello(): string {
// ---^ Pre processor missing for the class method
        return 'Hello World!';
    }
}

Correction

import { Injectable } from '@nestjs/common';

@Injectable()
export class AppService {
    public getHello(): string {
        return 'Hello World!';
    }
}

Installation instructions

Install the package as a dev dependancy npm i -D eslint-plugin-class-methods-preprocessors

Add eslint-plugin-class-methods-preprocessors to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        ...
        "class-methods-preprocessors"
    ]
}
{
    "rules": {
        ...
        "class-methods-preprocessors/enforce-methods-preprocessors": "warn"
    }
}

Readme

Keywords

none

Package Sidebar

Install

npm i eslint-plugin-class-methods-preprocessors

Weekly Downloads

3

Version

0.0.3

License

ISC

Unpacked Size

3.44 kB

Total Files

4

Last publish

Collaborators

  • usmanfaisal60