extends uses a config file which applies set of rules when you add that to the extends options. A plugin on the other hand provides you with a set of rules that you can individually apply depending on your need. Just having a plugin does not enforce any rule. You have to choose which rules you need. A plugin may provide you with zero, one, or more configuration files. If the plugin provides configuration file, then you can load that in your extends section after adding the plugin in the plugins section.

So essentially, plugins given you some rules that have been coded and you can choose which ones are relevant. It may also provide config files to apply rules that the authors think are logically grouped/relevant but providing a config file is not mandatory for a plugin. extends, on the other hand, provides you the ability to apply rules in bulk based on config file specifications.

Example Plugin - eslint-plugin-react

{
  "plugins": [
    "react"
  ],
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended"
  ]
}

Example Config - eslint-config-google

{
  "extends": [
    "google"
  ]
}
Answer from shmit on Stack Overflow
🌐
ESLint
eslint.org › docs › latest › extend › ways-to-extend
Ways to Extend ESLint - ESLint - Pluggable JavaScript Linter
ESLint ships with a built-in JavaScript parser (Espree), but custom parsers allow you to lint other languages or to extend the linting capabilities of the built-in parser.
🌐
ESLint
eslint.org › docs › latest › extend
Extend ESLint - ESLint - Pluggable JavaScript Linter
Selecting a version will take you to the chosen version of the ESLint docs. Version ... Results will be shown and updated as you type. ... This guide is intended for those who wish to extend the functionality of ESLint.
🌐
GitHub
github.com › eslint › eslint › issues › 19116
Change Request: Flat config extends · Issue #19116 · eslint/eslint
November 7, 2024 - In flat configs, extends will not trigger any file loading. Instead, it will allow string identifiers for configs contained in plugins as well as objects. Here's a simple example: import js from "@eslint/js"; export default [ { plugins: { js }, files: ["**/*.js"], extends: ["js/recommended"], rules: { "prefer-const": "off" } } ];
Published   Nov 07, 2024
🌐
Prateeksurana
prateeksurana.me › blog › difference-between-eslint-extends-and-plugins
What is the difference between extends and plugins in ESLint config
Similar to plugins shareable configs are also published with names in the format of eslint-config-<config-name>. To use the shareable config, you need to install it from npm similar to what we saw with plugins and then you can extend the ESLint config of your project with the extends key, so if you have installed a config called eslint-config-awesome then you can use it in your config like this -
Top answer
1 of 4
148

extends uses a config file which applies set of rules when you add that to the extends options. A plugin on the other hand provides you with a set of rules that you can individually apply depending on your need. Just having a plugin does not enforce any rule. You have to choose which rules you need. A plugin may provide you with zero, one, or more configuration files. If the plugin provides configuration file, then you can load that in your extends section after adding the plugin in the plugins section.

So essentially, plugins given you some rules that have been coded and you can choose which ones are relevant. It may also provide config files to apply rules that the authors think are logically grouped/relevant but providing a config file is not mandatory for a plugin. extends, on the other hand, provides you the ability to apply rules in bulk based on config file specifications.

Example Plugin - eslint-plugin-react

{
  "plugins": [
    "react"
  ],
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended"
  ]
}

Example Config - eslint-config-google

{
  "extends": [
    "google"
  ]
}
2 of 4
51

In addition to shmit's good answer:

extends

is about extending configurations in general, not only plugins. Potential values are:

  • "eslint:recommended"
  • "eslint:all"
  • Shareable configuration from npm package (eslint-config-xxx or scoped name)
  • Plugin configuration from npm package (eslint-plugin-xxx or scoped name)
  • Another configuration file, like "./my/path/.eslintrc.js"

Plugin notation: plugin:<package name>/<configuration name>, e.g. for eslint-plugin-react:

Copy "extends": ["plugin:react/recommended"]

By extending from a plugin config, we can get recommended rules without adding them manually.

plugins

A plugin is a special eslint npm package, that provides additional rule definitions (rules), environments, processors and configs for different configurations of recommended / default rule values.

The plugins property in .eslintrc.js is merely a flag to enable a given plugin after installation with npm i. We now can refer to the plugin's rules, but have to set all rules values manually.

Think of plugins as a way to activate a plugin - to use its rules, you need to add the plugin once in the chain in every case.

plugins is not needed in your own config, if it is already defined in a configuration, that you extend from by extends.

Example:

eslint-plugin-react already contains plugins: [ 'react' ], hence this entry is not needed anymore in own config and plugin rules can be used directly.

🌐
ESLint
eslint.org › docs › latest › use › configure › configuration-files
Configuration Files - ESLint - Pluggable JavaScript Linter
The extends key is an array of values indicating which configurations to extend from. The elements of the extends array can be one of three values: a string that specifies the name of a configuration in a plugin ...
🌐
ESLint
eslint.org › docs › latest › extend › custom-rules
Custom Rules - ESLint - Pluggable JavaScript Linter
The core rules shipped in the eslint package are not considered part of the public API and are not designed to be extended from. Building on top of these rules is fragile and will most likely result in your rules breaking completely at some ...
Find elsewhere
🌐
GitHub
github.com › eslint › eslint › discussions › 15704
Issue with the `extends` priority · eslint/eslint · Discussion #15704
If you don't want to detail each conflicting rule manually you could try moving just plugin:@typescript-eslint/recommended to an override. { extends: ['airbnb-typescript'], overrides: [ { files: ['*.ts', '*.tsx'], extends: ['plugin:@typescript-eslint/recommended'], }, ], };
Author   eslint
🌐
Stack Overflow
stackoverflow.com › questions › 77061899 › how-to-extend-and-override-rules-config-in-eslint
How to extend and override rules config in ESLint?
{ "extends": ["next", "prettier"], "plugins": ["prettier", "@typescript-eslint", "unused-imports"], "rules": { "no-unused-vars": "off", "no-duplicate-imports": "off", "no-console": "warn", "no-return-await": "warn", "no-useless-return": "warn", "no-var": "warn", "react-hooks/exhaustive-deps": "off", "import/order": [ "warn", { "groups": ["type", "builtin", "external", "internal", "parent", "sibling", "index", "object"], "newlines-between": "always" } ], } }
🌐
ESLint
eslint.org › docs › latest › use › configure › plugins
Configure Plugins - ESLint - Pluggable JavaScript Linter
Selecting a version will take you to the chosen version of the ESLint docs. Version ... Results will be shown and updated as you type. ... This page explains how to configure plugins using the flat config format. You can extend ESLint with plugins in a variety of different ways.
🌐
ESLint
eslint.org › docs › latest › use › migrate-to-9.0.0
Migrate to v9.x - ESLint - Pluggable JavaScript Linter
Extend ESLint · Ways to Extend ESLint · Create Plugins · Custom Rule Tutorial · Custom Rules · Custom Processors · Languages · Migration to Flat Config · Share Configurations · Custom Formatters · Custom Parsers · Stats Data · integrate ESLint · Integrate with the Node.js API Tutorial ·
🌐
TypeScript ESlint
typescript-eslint.io › packages › typescript-eslint
typescript-eslint | typescript-eslint
We found that this is a common operation when writing ESLint configs which is why we provided this convenience property. For example, in codebases with type-aware linting, a config object like the following is a common way to disable TypeScript-specific linting setups on JavaScript files: export default tseslint.config({ files: ['**/*.js'], extends: [tseslint.configs.disableTypeChecked], rules: { // turn off other type-aware rules 'other-plugin/typed-rule': 'off', // turn off rules that don't apply to JS code '@typescript-eslint/explicit-function-return-type': 'off', }, });
🌐
ESLint
eslint.org › docs › latest › extend › shareable-configs
Share Configurations - ESLint - Pluggable JavaScript Linter
// eslint.config.js import { defineConfig } from "eslint/config"; import myconfig from "eslint-config-myconfig"; export default defineConfig([ { files: ["**/*.js"], extends: [myconfig], // anything from here will override myconfig rules: { "no-unused-vars": "warn", }, }, ]);
🌐
ESLint
eslint.org › docs › latest › use › getting-started
Getting Started with ESLint - ESLint - Pluggable JavaScript Linter
import { defineConfig } from "eslint/config"; import globals from "globals"; import js from "@eslint/js"; export default defineConfig([ { files: ["**/*.js"], languageOptions: { globals: globals.browser } }, { files: ["**/*.js"], plugins: { js }, extends: ["js/recommended"] }, ]);
🌐
Medium
allalmohamedlamine.medium.com › eslint-flat-config-and-new-system-an-ultimate-deep-dive-2023-46aa151cbf2b
Eslint flat config and new system an ultimate deep dive 2023 | by Mohamed Lamine Allal | Medium
November 27, 2023 - The goals and design choices when making flat config (Eslint team) What changed between the old and the new and what to look-up for ... Packcages no more strings. Now we import all. And we can add things better · Custom parsers and parser options (mostly the same, but better) [no you import, object config] Plugins and their loading and their config, and the naming and the rules · The naming convention when you import plugins the strong guide ... How to extends and configure old plugins and packages, the new way and using a helper that translates old configs and backward compatibility
🌐
Mastering JS
masteringjs.io › tutorials › eslint › config
Intro to ESLint Config Files - Mastering JS
Listing out every single ESLint rule you want to use is often infeasible, so ESLint provides an extends option that lets you extend an existing ESLint config, and make overrides.
🌐
Eslint
eslint.style › guide › config-presets
Shared Configurations | ESLint Stylistic
// Legacy config is no longer supported in v4+ // Please use v3.x if you need to use legacy config // We encourage you to migrate to flat config soon // .eslintrc.js module.exports = { extends: [ 'plugin:@stylistic/all-extends' ], rules: { // ...your other rules } }