What is @eslint/eslintrc?
The @eslint/eslintrc package is a utility for working with ESLint configuration files. It provides tools to load and parse ESLint configuration files, resolve extends chains, and manage configuration cascading and hierarchy.
What are @eslint/eslintrc's main functionalities?
Loading ESLint Configuration
This feature allows you to load an ESLint configuration file using the ConfigArrayFactory class. The loaded configuration can then be used to configure the ESLint engine.
const { ConfigArrayFactory } = require('@eslint/eslintrc');
const factory = new ConfigArrayFactory();
const configArray = factory.loadFile('.eslintrc.js');
Parsing Configuration Files
This feature is used to parse ESLint configuration files directly. It is part of the legacy API and allows for direct interaction with configuration files.
const { Legacy: { ConfigFile } } = require('@eslint/eslintrc');
const config = ConfigFile.load('.eslintrc');
Resolving Extends Chains
This feature resolves the 'extends' chains in ESLint configuration files, allowing you to get the final configuration that applies to a specific file, taking into account all the extended configurations.
const { CascadingConfigArrayFactory } = require('@eslint/eslintrc');
const factory = new CascadingConfigArrayFactory();
const configArray = factory.getConfigArrayForFile('some-file.js');
Other packages similar to @eslint/eslintrc
eslint
The 'eslint' package is the core linting library that provides the primary functionality for linting JavaScript code. It includes the ability to load and interpret configuration files, which @eslint/eslintrc also does, but as a separate utility focused on configuration management.
eslint-config-prettier
The 'eslint-config-prettier' package is an ESLint configuration that disables rules that might conflict with Prettier. While it does not provide utilities for managing configurations, it is an example of a package that extends ESLint's configuration capabilities.
eslint-plugin-import
The 'eslint-plugin-import' package is a plugin that provides linting rules related to ES6+ import/export syntax. It extends ESLint's functionality with additional rules, similar to how @eslint/eslintrc extends configuration management capabilities.
ESLintRC Library
This repository contains the legacy ESLintRC configuration file format for ESLint. This package is not intended for use outside of the ESLint ecosystem. It is ESLint-specific and not intended for use in other programs.
Note: This package is frozen except for critical bug fixes as ESLint moves to a new config system.
Installation
You can install the package as follows:
npm install @eslint/eslintrc --save-dev
# or
yarn add @eslint/eslintrc -D
Usage
The primary class in this package is FlatCompat
, which is a utility to translate ESLintRC-style configs into flat configs. Here's how you use it inside of your eslint.config.js
file:
import { FlatCompat } from "@eslint/eslintrc";
import js from "@eslint/js";
import path from "path";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
resolvePluginsRelativeTo: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
export default [
...compat.extends("standard", "example"),
...compat.env({
es2020: true,
node: true
}),
...compat.plugins("airbnb", "react"),
...compat.config({
plugins: ["airbnb", "react"],
extends: "standard",
env: {
es2020: true,
node: true
},
rules: {
semi: "error"
}
})
];
License
MIT License
2.0.3 (2023-05-05)
Chores
v2.0.2 - March 28, 2023
e5f9e7e
chore: upgrade espree@9.5.1 (#106) (Milos Djermanovic)
v2.0.1 - March 10, 2023
5ccb30c
chore: upgrade espree@9.5.0 (#104) (Milos Djermanovic)
v2.0.0 - February 25, 2023
013bdf3
feat!: Require eslint:all and eslint:recommended as parameters. (#103) (Nicholas C. Zakas)f7d0f33
chore: Add triage action (#101) (Nicholas C. Zakas)
v1.4.1 - December 30, 2022
5be711e
fix: Update FlatCompat docs + typings to reflect Array (#99) (Wes Bos)
v1.4.0 - December 16, 2022
89c504f
feat: update globals (#98) (Sébastien Règne)5438c6b
ci: add Node v19 (#96) (Milos Djermanovic)
v1.3.3 - October 7, 2022
adafd11
docs: Update README (#92) (Nicholas C. Zakas)56755d9
chore: cascading-config-array: createBaseConfigArray not expect resolver (#95) (coderaiser)
v1.3.2 - September 12, 2022
2a2bef1
fix: Plugins should always use the same reference (#91) (Nicholas C. Zakas)
v1.3.1 - August 26, 2022
495af93
chore: Upgrade to espree@9.4.0 (#87) (Milos Djermanovic)2632367
docs: Update README with FlatCompat options (#86) (Nicholas C. Zakas)ffba0c5
ci: update github actions (#85) (Amaresh S M)9ff004e
chore: add funding field (#84) (Amaresh S M)
v1.3.0 - May 20, 2022
aefa2a7
feat: update globals (#81) (Milos Djermanovic)
v1.2.3 - May 6, 2022
c9047b4
chore: Upgrade espree@9.3.2 (#80) (Milos Djermanovic)baf145f
chore: bump version of minimatch due to security issue PRISMA-2022-0039 (#76) (Jan Opravil)44415d3
chore: update license copyright (#79) (唯然)
v1.2.2 - April 22, 2022
18b15ac
fix: use custom Rollup plugin for import.meta.url
(#77) (Milos Djermanovic)a6e12e4
build: add node v18 (#78) (唯然)
v1.2.1 - March 11, 2022
98fb12d
chore: upgrade ignore
to v5.2.0
(#72) (Nitin Kumar)
v1.2.0 - February 25, 2022
9b71981
feat: Avoid dirname for built-in configs (#71) (DoZerg)
v1.1.0 - February 11, 2022
0f17fb1
chore: Upgrade to espree@9.3.1 (#69) (Milos Djermanovic)33b8ee7
feat: add esN envs for all post-es6 years (#68) (Jordan Harband)bc097b6
chore: upgrade espree@9.3.0 (#65) (Gustavo Santana)
v1.0.5 - December 3, 2021
870810a
chore: upgrade espree@9.2.0 (#64) (Milos Djermanovic)
v1.0.4 - November 5, 2021
f0b528b
build: upgrade eslint-release to v3.2.0 to support conventional commits (#62) (Milos Djermanovic)731fa49
chore: update js-yaml
dependency (#61) (Nitin Kumar)b657cea
Build: add node v17 (#58) (唯然)
v1.0.3 - October 13, 2021
6b5fc8b
Fix: add universal
export to root (#57) (Simen Bekkhus)
v1.0.2 - October 9, 2021
347fe40
Build: Don't freeze Rollup output (#56) (Nicholas C. Zakas)3b8ae43
Chore: ignore package manager lock files (#55) (Nitin Kumar)
v1.0.1 - September 10, 2021
f2e2c33
Upgrade: espree@9.0.0 (#54) (Milos Djermanovic)c5d4919
Fix: ConfigArrayFactory was ignoring the resolver option in some places (#53) (Stéphane Goetz)
v1.0.0 - August 6, 2021
aaf282e
Update: Add /universal entrypoint (fixes #50) (#51) (Nicholas C. Zakas)3c6cfe6
Upgrade: debug@4.3.2 (#52) (Milos Djermanovic)3983fde
Upgrade: Espree (fixes #41) (#49) (Nicholas C. Zakas)7e5e4e5
Update: Export environments (#46) (Nicholas C. Zakas)348e889
Chore: Use actions/setup-node@v2 (#47) (薛定谔的猫)bbcef88
Breaking: drop node v10/v13/v15 (refs eslint/eslint#14023) (#37) (薛定谔的猫)bdce01a
Breaking: Switch to ESM (fixes #35) (#39) (Brett Zamir)
v0.4.3 - July 17, 2021
ce78027
Fix: ensure config files are files (#42) (Tom Jenkinson)95b1c9b
Chore: pin fs-teardown@0.1.1 (#45) (Milos Djermanovic)593fbe3
Chore: fix failing test (#44) (Tom Jenkinson)
v0.4.2 - June 4, 2021
cc79a4d
Upgrade: update globals to version 13.6 (#32) (Rouven Weßling)
v0.4.1 - May 7, 2021
aa38ef4
Fix: Properly export module resolver (#34) (Richie Bendall)62ea4bd
Build: add node v16 (#33) (薛定谔的猫)7c43d77
Chore: add tests for built-in rules config schema validation (fixes #15) (#31) (Milos Djermanovic)d8ea601
Chore: Test on Node 15.x (#30) (Milos Djermanovic)0b2f80d
Chore: lint test files (#18) (Milos Djermanovic)
v0.4.0 - February 27, 2021
d9a527b
New: Implement DotCompat class (#20) (Nicholas C. Zakas)dac76c0
Chore: Replace usage of lodash with cache set (#29) (Tim van der Lippe)3ae2d77
Update: add AggregateError global to es2021 environment (#28) (Milos Djermanovic)
v0.3.0 - January 15, 2021
5184490
Upgrade: lodash@4.17.20 (#24) (Milos Djermanovic)f1179c5
Update: Implement missing functionality from ESLint port (fixes #12) (#23) (Nicholas C. Zakas)
v0.2.2 - December 5, 2020
1746840
Fix: include loadRules in internalSlotsMap cache (#19) (Henry Q. Dineen)f30bb49
Chore: Test fixes for CascadingConfigArrayFactory (#17) (Nicholas C. Zakas)4440df8
Chore: Fix config-array tests (#16) (Nicholas C. Zakas)7890e02
Chore: Test fixes for config-array-factory.js (#13) (Nicholas C. Zakas)
v0.2.1 - October 26, 2020
8b202ff
Fix: validate schema for built-in rules (#14) (Milos Djermanovic)04f3cae
Fix: cache compiled config schema (#9) (Milos Djermanovic)
v0.2.0 - October 16, 2020
cb12255
Update: Allow eslint:all and eslint:recommended paths to be passed in (#11) (Nicholas C. Zakas)a75bacd
Chore: use GitHub Actions (#10) (Milos Djermanovic)
v0.1.3 - September 1, 2020
8647a61
Fix: version number and eslint-release version (refs #6) (Nicholas C. Zakas)