ronapelbaum / eslint-plugin-arguments

eslint plugin to disallow calling method with inline literals as arguments

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

eslint-plugin-arguments

npm version Build Status Coverage Status StackShare

eslint plugin to disallow calling method with inline literals as arguments

Supported Rules

no-literal-arguments

Methods array: array with the method names that you want to check.

{
    "rules": {
        "arguments/no-literal-arguments": [
            "error", 
            [
                "foo"
            ]
        ]
    }
}

When this rule is defined:

foo(); \\ OK  
foo(x); \\ OK  
foo(A.x); \\ OK
goo('x'); \\OK
bar.foo(x); \\ OK

foo('x'); \\ BAD 
foo("x"); \\ BAD  
foo(10); \\ BAD
bar.foo('x'); \\ BAD

Common Usage: you need to block somthing like props.getProp('id') in order to use only props.getProp(constants.ID)

Installation

npm i -D eslint eslint-plugin-arguments

Note: If you installed eslint globally (using the -g flag) then you must also install eslint-plugin-arguments globally.

Usage

Add arguments to the plugins section of your .eslintrc.json configuration file. (You can omit the eslint-plugin- prefix):

{
    "plugins": [
        "arguments"
    ]
}

About

eslint plugin to disallow calling method with inline literals as arguments

License:MIT License


Languages

Language:JavaScript 100.0%