deedpoll

0.3.0 • Public • Published

deedpoll

Large JavaScript projects often have naming conventions. Usually, the onus is on project maintainers to spot incorrectly named identifiers when reviewing pull requests. deedpoll is a simple tool for enforcing consistent naming of common identifiers such as those used as loop variables.

Consider the following file:

$ cat example.js
function findIndex(array, el) {
  for (var i = 0, len = array.length; i < len; i += 1) {
    if (array[i] === el) {
      return i;
    }
  }
  return -1;
}

Usage is straightforward. Include any number of --rename <bad>:<good> directives and any number of filenames (optionally separated by --):

$ deedpoll --rename array:list --rename i:idx --rename index:idx -- example.js
Expected "list" at example.js:1:19 (found "array")
Expected "idx" at example.js:2:11 (found "i")

The exit code indicates the number of incorrectly named identifiers:

$ echo $?
2

Readme

Keywords

none

Package Sidebar

Install

npm i deedpoll

Weekly Downloads

2

Version

0.3.0

License

none

Last publish

Collaborators

  • davidchambers