版博士V2.0程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

README.md 1.8 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # ESLintRC Library
  2. 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.
  3. **Note:** This package is frozen except for critical bug fixes as ESLint moves to a new config system.
  4. ## Installation
  5. You can install the package as follows:
  6. ```
  7. npm install @eslint/eslintrc --save-dev
  8. # or
  9. yarn add @eslint/eslintrc -D
  10. ```
  11. ## Usage
  12. 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:
  13. ```js
  14. import { FlatCompat } from "@eslint/eslintrc";
  15. import js from "@eslint/js";
  16. import path from "path";
  17. import { fileURLToPath } from "url";
  18. // mimic CommonJS variables -- not needed if using CommonJS
  19. const __filename = fileURLToPath(import.meta.url);
  20. const __dirname = path.dirname(__filename);
  21. const compat = new FlatCompat({
  22. baseDirectory: __dirname, // optional; default: process.cwd()
  23. resolvePluginsRelativeTo: __dirname, // optional
  24. recommendedConfig: js.configs.recommended, // optional
  25. allConfig: js.configs.all, // optional
  26. });
  27. export default [
  28. // mimic ESLintRC-style extends
  29. ...compat.extends("standard", "example"),
  30. // mimic environments
  31. ...compat.env({
  32. es2020: true,
  33. node: true
  34. }),
  35. // mimic plugins
  36. ...compat.plugins("airbnb", "react"),
  37. // translate an entire config
  38. ...compat.config({
  39. plugins: ["airbnb", "react"],
  40. extends: "standard",
  41. env: {
  42. es2020: true,
  43. node: true
  44. },
  45. rules: {
  46. semi: "error"
  47. }
  48. })
  49. ];
  50. ```
  51. ## License
  52. MIT License