eslint-plugin-pedantor

0.5.4 • Public • Published

eslint-plugin-pedantor

Enforce part of speech and regex naming conventions, currently only on functions.

Ever wanted to insist function names:

  • start with a verb?
  • follow some other part of speech / string pattern?
  • do not contain certain parts of speech / string patterns?

Then this is for you.

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install eslint-plugin-pedantor:

$ npm install eslint-plugin-pedantor --save-dev

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

Usage

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

{
    "plugins": [
        "pedantor"
    ]
}

Then configure the rule. Currently only fxn-name-convention is supported, detailed below.

{
    "rules": {
        "pedantor/fxn-name-convention": [1, {
            allow: ['^#Verb' /*,...*/ ]
            ,disallow: ["/mapper|reducer|controller/i" /*,...*/ ]
            ,assume: {
                "tweet":'Verb'
                ,"/XHR/i":'Verb'
                //,...
            }
        }]
    }
}
 

Each value in allow, disallow can be:

  • a match syntax string used by the natural language processing compromise module
  • or a string-coerced, plain /regex/. So /foo/i +'' == "/foo/i". This enables regular json use.

Note: matching is attempted against the _.lowerCase()d version of the function name. So doThing() becomes do thing.

Given the nlp module is not perfect, or you might want to add your own conventions, you can assign an {} to assume and point some strings or (string-coerced) regex to parts of speech. In the example above, XHR and xhr should be considered a Verb.

Package Sidebar

Install

npm i eslint-plugin-pedantor

Weekly Downloads

3

Version

0.5.4

License

MIT

Last publish

Collaborators

  • jnvm