68

In a .eslintrc file, we can use:

"extends": "eslint:recommended"

to extend the recommended rules provided by eslint, and in the rule list, many of them are marked as "recommended".

My question what is the exact rule definitions for them? I searched in the repo of eslint, but not found it.

Freewind
  • 193,756
  • 157
  • 432
  • 708

6 Answers6

56

Freewind's answer is pointing to a specific commit – now outdated.

All rules are listed here https://eslint.org/docs/latest/rules/. from the list you can easily find the eslint:recommnded rules - as they are marked with this icon: ✅

Mercury
  • 7,430
  • 3
  • 42
  • 54
ChrisV
  • 8,748
  • 3
  • 48
  • 38
7

As of today (February 2023), the list can be found in this file:

https://github.com/eslint/eslint/blob/main/packages/js/src/configs/eslint-recommended.js

Pere
  • 1,647
  • 3
  • 27
  • 52
6

Run this terminal command from the project root to output a complete list of definitions being applied in your setup.

./node_modules/.bin/eslint --print-config *.* > "./.eslintrc.js_fullsettings.js"

If you only have extends: ['eslint:recommended'] in the .eslint file you'll get what you're looking for.

GollyJer
  • 23,857
  • 16
  • 106
  • 174
  • 2
    "The --print-config option must be used with exactly one file name." – caduceus Oct 29 '20 at 11:00
  • The only thing I can think of is maybe you don't have a .eslint config file in the root? Or you have more than one config? Sorry. I haven't had this issue on any of my projects. They all have a `.eslintrc.js` in the root. This may not work with configs at multiple places in the tree. – GollyJer Oct 31 '20 at 22:04
  • Getting "The --print-config option must be used with exactly one file name." – Pritesh Acharya Apr 18 '21 at 15:18
  • According to the [doc](https://eslint.org/docs/user-guide/command-line-interface#--print-config) you should specify a file, and eslint tells you the configuration to be used for it. `*.*` does not make sense. – Jack Lu Sep 01 '21 at 08:48
5

All entries with a checkmark in this list: https://eslint.org/docs/rules/

MakotoE
  • 1,814
  • 1
  • 20
  • 39
3

There's a list here.


Old answer

Eslint no longer shows the list of recommended rules in a single file, so here's a way to get the current list with Node.js:

const { Linter } = require('eslint')
const rules = [...new Linter().getRules().entries()] // all rules
  .filter(data => data[1].meta.docs.recommended)     // filter out unrecommended
  .map(data => data[0])                              // get rule names
console.log(rules.join('\n'))

Here's a live example that can also create an object that basically represents the entire recommended config, a handy markdown chart, or just a simple list of rule names if that's what you need.

Purpzie
  • 31
  • 5
  • This [later commit](https://github.com/eslint/eslint/commit/f42d0afd89874b459fce1eb1998247d53f9aa42b#diff-ba6ef5865cfaa7efd6dfe5089d85709e) reverted the one you linked to, and now the rules are again [in one file](https://github.com/eslint/eslint/blob/master/conf/eslint-recommended.js). Nice live example though! – Dan Dascalescu May 29 '19 at 02:50