From 75521f7d2e4aac9e77310803e7569d9d5b39869c Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Thu, 30 May 2024 16:36:56 -0400 Subject: [PATCH] fix: Update and standardize READMEs (#33) --- packages/compat/README.md | 2 ++ packages/config-array/README.md | 40 ++++++++++++++++++-------------- packages/object-schema/README.md | 26 ++++++++++++++------- 3 files changed, 42 insertions(+), 26 deletions(-) diff --git a/packages/compat/README.md b/packages/compat/README.md index f39d7aed..5b96734c 100644 --- a/packages/compat/README.md +++ b/packages/compat/README.md @@ -4,6 +4,8 @@ This packages contains functions that allow you to wrap existing ESLint rules, plugins, and configurations that were intended for use with ESLint v8.x to allow them to work as-is in ESLint v9.x. +**Note:** All plugins are not guaranteed to work in ESLint v9.x. This package fixes the most common issues but can't fix everything. + ## Installation For Node.js and compatible runtimes: diff --git a/packages/config-array/README.md b/packages/config-array/README.md index d6c40ccc..4b1bea26 100644 --- a/packages/config-array/README.md +++ b/packages/config-array/README.md @@ -1,16 +1,32 @@ # Config Array -by [Nicholas C. Zakas](https://humanwhocodes.com) - -If you find this useful, please consider supporting my work with a [donation](https://humanwhocodes.com/donate). - ## Description A config array is a way of managing configurations that are based on glob pattern matching of filenames. Each config array contains the information needed to determine the correct configuration for any file based on the filename. -## Background +**Note:** This is a generic package that can be used outside of ESLint. It contains no ESLint-specific functionality. -In 2019, I submitted an [ESLint RFC](https://github.com/eslint/rfcs/pull/9) proposing a new way of configuring ESLint. The goal was to streamline what had become an increasingly complicated configuration process. Over several iterations, this proposal was eventually born. +## Installation + +For Node.js and compatible runtimes: + +```shell +npm install @eslint/config-array +# or +yarn add @eslint/config-array +# or +pnpm install @eslint/config-array +# or +bun install @eslint/config-array +``` + +For Deno: + +```shell +deno add @eslint/config-array +``` + +## Background The basic idea is that all configuration, including overrides, can be represented by a single array where each item in the array is a config object. Config objects appearing later in the array override config objects appearing earlier in the array. You can calculate a config for a given file by traversing all config objects in the array to find the ones that match the filename. Matching is done by specifying glob patterns in `files` and `ignores` properties on each config object. Here's an example: @@ -34,18 +50,6 @@ export default [ In this example, there are two config objects: the first matches all JSON files in all directories and the second matches just `package.json` in the base path directory (all the globs are evaluated as relative to a base path that can be specified). When you retrieve a configuration for `foo.json`, only the first config object matches so `handler` is equal to `jsonHandler`; when you retrieve a configuration for `package.json`, `handler` is equal to `packageJsonHandler` (because both config objects match, the second one wins). -## Installation - -You can install the package using npm or Yarn: - -```bash -npm install @eslint/config-array --save - -# or - -yarn add @eslint/config-array -``` - ## Usage First, import the `ConfigArray` constructor: diff --git a/packages/object-schema/README.md b/packages/object-schema/README.md index eccb73e0..0f8cdde1 100644 --- a/packages/object-schema/README.md +++ b/packages/object-schema/README.md @@ -1,28 +1,38 @@ -# ESLint ObjectSchema Package +# ObjectSchema Package ## Overview -A JavaScript object merge/validation utility where you can define a different merge and validation strategy for each key. This is helpful when you need to validate complex data structures and then merge them in a way that is more complex than `Object.assign()`. +A JavaScript object merge/validation utility where you can define a different merge and validation strategy for each key. This is helpful when you need to validate complex data structures and then merge them in a way that is more complex than `Object.assign()`. This is used in the [`@eslint/config-array`](https://npmjs.com/package/@eslint/config-array) package but can also be used on its own. ## Installation -You can install using either npm: +For Node.js and compatible runtimes: -``` +```shell npm install @eslint/object-schema +# or +yarn add @eslint/object-schema +# or +pnpm install @eslint/object-schema +# or +bun install @eslint/object-schema ``` -Or Yarn: +For Deno: -``` -yarn add @eslint/object-schema +```shell +deno add @eslint/object-schema ``` ## Usage -Use CommonJS to get access to the `ObjectSchema` constructor: +Import the `ObjectSchema` constructor: ```js +// using ESM +import { ObjectSchema } from "@eslint/object-schema"; + +// using CommonJS const { ObjectSchema } = require("@eslint/object-schema"); const schema = new ObjectSchema({