Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

Latest commit

 

History

History
73 lines (48 loc) · 1.9 KB

README.md

File metadata and controls

73 lines (48 loc) · 1.9 KB

eslint-plugin-bitburning

Various eslint rules I wrote to reduce bugs in my bitburner scripts.

Current TODOS:

  • Require async functions (excluding main) to end with Async
  • Require await before NS functions: hack, grow, weaken, sleep, prompt, wget, scp, write, writePort
  • Require await before async functions (functions ending with Async)
  • Require guards
  • Require that js files export a function with their filename
  • Automatically fix js files that are missing a function with their filename
  • Automatically add guard statements
  • Require constants in constants.js to use SCREAMING_SNAKE_CASE

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-bitburning:

npm install eslint-plugin-bitburning --save-dev

Usage

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

{
    "plugins": [
        "bitburning"
    ]
}

Then configure the rules you want to use under the rules section.

{
    "rules": {
        "bitburning/rule-name": 2
    }
}

Supported Rules

await-async-functions

Requires that functions ending in Async are awaited. I know there's a lot more you can do with promises besides awaiting them, but in the context of bitburner it's rare.

await-ns-functions

Requires that ns functions that return promises are awaited. Since the game makes that mandatory.

export-filename

Requires that a file define a function or class that matches its filename.

require-async-suffix

Requires that async functions end with Async. This helps prevent dangling promises as we're not using typescript.

require-guards

Requires that all arguments without default values are checked for undefined. This helps prevent errors when you call functions with the wrong number of arguments.