source: imaps-frontend/node_modules/@eslint/eslintrc/README.md

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 2.9 KB
Line 
1# ESLintRC Library
2
3This 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.
4
5**Note:** This package is frozen except for critical bug fixes as ESLint moves to a new config system.
6
7## Installation
8
9You can install the package as follows:
10
11```
12npm install @eslint/eslintrc --save-dev
13
14# or
15
16yarn add @eslint/eslintrc -D
17```
18
19## Usage (ESM)
20
21The 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:
22
23```js
24import { FlatCompat } from "@eslint/eslintrc";
25import js from "@eslint/js";
26import path from "path";
27import { fileURLToPath } from "url";
28
29// mimic CommonJS variables -- not needed if using CommonJS
30const __filename = fileURLToPath(import.meta.url);
31const __dirname = path.dirname(__filename);
32
33const compat = new FlatCompat({
34 baseDirectory: __dirname, // optional; default: process.cwd()
35 resolvePluginsRelativeTo: __dirname, // optional
36 recommendedConfig: js.configs.recommended, // optional
37 allConfig: js.configs.all, // optional
38});
39
40export default [
41
42 // mimic ESLintRC-style extends
43 ...compat.extends("standard", "example"),
44
45 // mimic environments
46 ...compat.env({
47 es2020: true,
48 node: true
49 }),
50
51 // mimic plugins
52 ...compat.plugins("airbnb", "react"),
53
54 // translate an entire config
55 ...compat.config({
56 plugins: ["airbnb", "react"],
57 extends: "standard",
58 env: {
59 es2020: true,
60 node: true
61 },
62 rules: {
63 semi: "error"
64 }
65 })
66];
67```
68
69## Usage (CommonJS)
70
71Using `FlatCompat` in CommonJS files is similar to ESM, but you'll use `require()` and `module.exports` instead of `import` and `export`. Here's how you use it inside of your `eslint.config.js` CommonJS file:
72
73```js
74const { FlatCompat } = require("@eslint/eslintrc");
75const js = require("@eslint/js");
76
77const compat = new FlatCompat({
78 baseDirectory: __dirname, // optional; default: process.cwd()
79 resolvePluginsRelativeTo: __dirname, // optional
80 recommendedConfig: js.configs.recommended, // optional
81 allConfig: js.configs.all, // optional
82});
83
84module.exports = [
85
86 // mimic ESLintRC-style extends
87 ...compat.extends("standard", "example"),
88
89 // mimic environments
90 ...compat.env({
91 es2020: true,
92 node: true
93 }),
94
95 // mimic plugins
96 ...compat.plugins("airbnb", "react"),
97
98 // translate an entire config
99 ...compat.config({
100 plugins: ["airbnb", "react"],
101 extends: "standard",
102 env: {
103 es2020: true,
104 node: true
105 },
106 rules: {
107 semi: "error"
108 }
109 })
110];
111```
112
113## License
114
115MIT License
Note: See TracBrowser for help on using the repository browser.