No description
Find a file
2024-05-02 00:25:39 -06:00
lib Copy eslint ast-utils to fix incorrect imports 2024-05-02 00:24:11 -06:00
smoke-tests Fix export of complexity rule 2024-05-02 00:10:14 -06:00
tests Add cyclomatic-complexity rule 2024-05-02 00:02:35 -06:00
.gitignore Package setup 2019-05-01 10:44:22 -06:00
eslint.config.js Fix export of complexity rule 2024-05-02 00:10:14 -06:00
package-lock.json Update to deployed version so smoke tests work 2024-05-02 00:25:39 -06:00
package.json Update to deployed version so smoke tests work 2024-05-02 00:25:39 -06:00
README.md Fix export of complexity rule 2024-05-02 00:10:14 -06:00

Do This

A set of ESLint rules to make your code better.

Included Rules

no-inhuman-const

The only value of higher-order programming languages is clearly communicating with other developers. Only strings and numbers are actually constant values, and are the only values that should be assigned to const when it's instantiated.

Read Stop Writing Inhuman const.

no-multiple-exit

Functions should have a single entry point and a single exit point. More than one exit point is a recipe for buggy edge cases and untraceable code execution paths.

uppercase-const

A common pattern is to use an upper-, snake-case name for constants. This makes them easy to pick out, and most syntax highlighters will provide a special color

cyclomatic-complexity

The default complexity rule in ESLint includes rules that do not affect the number of linearly independent code paths. For example: default values for parameters. This rule only counts linearly independent code paths to increase complexity.

Install

npm install eslint-plugin-do-this

Use

Add the plugin to your ESLint configuration:

import doThis from "eslint-plugin-do-this";

// ...

"plugins": [
    "do-this": doThis
]

Then, enable the rules you want:

"rules": {
    "do-this/no-inhuman-const": "error",
    "do-this/no-multiple-exit": "error",
    "do-this/uppercase-const": "error",
    "do-this/cyclomatic-complexity": [
        "error",
        {
            "maximum": 3
        }
    ]
}