eslint-config-pretty-strict

8.1.2 • Public • Published

eslint-config-pretty-strict

build status npm version

A strict ESLint config with Prettier as a code formatter.

Any style guide written in English is either so brief that it’s ambiguous, or so long that no one reads it.

—Bob Nystrom

This config provides reasonable ESLint rules to prevent errors, enforce best practices and keep a consistent style. Though you may configure it to your needs.

Formatting is a computer's job.

—Kent Beck

Also, it automates code formatting with Prettier and autofixable ESLint rules to ensure consistent and legible formatting. The ESLint rules are carefully configured not to conflict with Prettier in any way.

By using eslint-plugin-prettier, Prettier is seamlessly integrated with ESLint. So you don't have to run these tools separately because ESLint reports the formatting problems detected by Prettier and lets you automatically fix them with the --fix option.

Installing

Install eslint-config-pretty-strict and its peer dependencies (eslint, eslint-plugin-prettier and prettier):

npm install --save-dev --save-exact eslint-config-pretty-strict eslint eslint-plugin-prettier prettier

Then, in your .eslintrc file, extend this config:

{
  "extends": ["eslint-config-pretty-strict"],
  "parserOptions": {
    "ecmaVersion": 2020
  }
}

Note that you should also set the ecmaVersion option according to the ECMAScript syntax you use, so that ESLint doesn't output a parsing error.

Using

Run ESLint via the command line interface with:

./node_modules/.bin/eslint .

# Alternatively, automatically fix most problems with the --fix option
./node_modules/.bin/eslint . --fix

Usually, you want to run ESLint from a "lint" npm script, both locally and in your CI server.

You may want to install an ESLint plugin for your text editor, so that you can see and fix style problems directly in your editor. You may also want to use a Prettier plugin to automatically format on file save or with a keyboard shortcut.

Configuring

What if I don't agree with some rule?

You can configure any ESLint setting or rule. Also, Prettier can be configured via a configuration file or the eslint-plugin-prettier prettier/prettier option.

Sometimes, you may want to disable a rule only on some file or line of code by using configuration comments.

Package Sidebar

Install

npm i eslint-config-pretty-strict

Weekly Downloads

28

Version

8.1.2

License

MIT

Unpacked Size

15 kB

Total Files

4

Last publish

Collaborators

  • rtomrud