Skip to main content

Tooling

Tools like ESLint and Prettier come as an option with create-discord-bot. These tools can aid your development experience greatly by catching some bugs before production and formatting your code to make it more readable.

ESLint

ESLint statically analyzes your code to find problems quickly. It is built into most text editors, and you can run ESLint as part of your continuous integration pipeline.

- ESLint.org

Editor Setup

If you want to get the live code linting and quick fixes recommendations while editing, you can integrate ESLint into your editor using extensions/addons.

Configuration

You can configure ESLint to your liking to enable or disable specific linting properties or change if it's a warning or error. However, there are very high-quality preconfigured ESLint configurations that can fast track your development.

For more configurations visit awesome-eslint.

Usage

Though it is recommended to use Editor Integration for linting, you can still use ESLint's powerful CLI to lint multiple files or folders at once. Learn more

You can run the following command to lint specific files:

npx eslint file1.js src/file2.js lib/file3.js # etc...

Or this command for directories and all of it's files:

npx eslint directory/**/* # ** means all folders and * means all files

You can also use globs to select a large amount of files:

npx eslint *.js # all javascript files in `root`
npx eslint **/*.js #all javascript files in `root` and in all folders that are in `root`.

Learn more about globs or test glob patterns

Prettier

What is Prettier?

  • An opinionated code formatter
  • Supports many languages
  • Integrates with most editors
  • Has few options

Why?

  • Your code is formatted on save
  • No need to discuss style in code review
  • Saves you time and energy
  • And more

- Prettier.io

Editor Setup

We recommended integrating Prettier with your editor to get formatting on save, easier usage, and better developer experience. Due to this, Prettier has integrations for most code editors. Learn more

See more

Configuration

Though Prettier is opinionated and comes with its high-quality configuration, you can still change aspects of it. Things like single or double quotes, tabs or spaces, etcetera. Read about it here

Usage

Though it is recommended to use Editor Integration for formatting your code, you can still use Prettier's powerful CLI to format multiple files or folders at once. Learn more

You can run the following command to format a specific file:

npx prettier --write file1.js # --write makes prettier apply it's changes.

Or this command for directories and all of it's files:

npx prettier directory/**/* # ** means all folders and * means all files

You can also use globs to select a large amount of files:

npx prettier *.js # all javascript files in `root`
npx prettier **/*.js #all javascript files in `root` and in all folders that are in `root`.

Learn more about globs or test glob patterns