80

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.

6 Answers 6

60

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: ✅

1
  • 2
    Outdated, see Pere's answer for correct answer as of 2023-03-07.
    – Oktokolo
    Commented Mar 7, 2023 at 20:47
19

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

8

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.

4
  • 2
    "The --print-config option must be used with exactly one file name."
    – caduceus
    Commented Oct 29, 2020 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
    Commented Oct 31, 2020 at 22:04
  • Getting "The --print-config option must be used with exactly one file name." Commented Apr 18, 2021 at 15:18
  • According to the doc you should specify a file, and eslint tells you the configuration to be used for it. *.* does not make sense.
    – Jack Lu
    Commented Sep 1, 2021 at 8:48
6

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

4

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.

1
3

From the source code, I found:

https://github.com/eslint/eslint/blob/3642d0bb6ced17eeed50c030531a3ddbeb939f29/lib/config.js#L189-L192

So the real config is here: https://github.com/eslint/eslint/blob/3642d0bb6ced17eeed50c030531a3ddbeb939f29/conf/eslint.json

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.