Skip to content

Commit

Permalink
docs: update API docs (#17919)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic committed Dec 29, 2023
1 parent baff28c commit 037abfc
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
16 changes: 9 additions & 7 deletions docs/src/integrate/nodejs-api.md
Expand Up @@ -83,9 +83,9 @@ const testCode = `
(async function main() {
// 1. Create an instance
const eslint = new ESLint({
useEslintrc: false,
overrideConfigFile: true,
overrideConfig: {
parserOptions: {
languageOptions: {
ecmaVersion: 2018,
sourceType: "commonjs"
}
Expand Down Expand Up @@ -129,8 +129,12 @@ The `ESLint` constructor takes an `options` object. If you omit the `options` ob
Default is `true`. If `false` is present, the [`eslint.lintFiles()`][eslint-lintfiles] method doesn't interpret glob patterns.
* `options.ignore` (`boolean`)<br>
Default is `true`. If `false` is present, the [`eslint.lintFiles()`][eslint-lintfiles] method doesn't respect `.eslintignore` files or `ignorePatterns` in your configuration.
* `options.ignorePath` (`string | null`)<br>
Default is `null`. The path to a file ESLint uses instead of `$CWD/.eslintignore`. If a path is present and the file doesn't exist, this constructor will throw an error.
* `options.ignorePatterns` (`string[] | null`)<br>
Default is `null`. Ignore file patterns to use in addition to config ignores. These patterns are relative to `cwd`.
* `options.passOnNoPatterns` (`boolean`)<br>
Default is `false`. When set to `true`, missing patterns cause the linting operation to short circuit and not report any failures.
* `options.warnIgnored` (`boolean`)<br>
Default is `true`. Show warnings when the file list includes ignored files.

##### Linting

Expand All @@ -144,8 +148,6 @@ The `ESLint` constructor takes an `options` object. If you omit the `options` ob
Default is `false`. The path to a configuration file, overrides all configurations used with this instance. The `options.overrideConfig` option is applied after this option is applied.
* `options.plugins` (`Record<string, Plugin> | null`)<br>
Default is `null`. The plugin implementations that ESLint uses for the `plugins` setting of your configuration. This is a map-like object. Those keys are plugin IDs and each value is implementation.
* `options.reportUnusedDisableDirectives` (`"error" | "warn" | "off" | null`)<br>
Default is `null`. The severity to report unused eslint-disable and eslint-enable directives. If this option is a severity, it overrides the `reportUnusedDisableDirectives` setting in your configurations.
* `options.ruleFilter` (`({ruleId: string, severity: number}) => boolean`)<br>
Default is `() => true`. A predicate function that filters rules to be run. This function is called with an object containing `ruleId` and `severity`, and returns `true` if the rule should be run.

Expand Down Expand Up @@ -204,7 +206,7 @@ The second parameter `options` is omittable.
* `options.filePath` (`string`)<br>
Optional. The path to the file of the source code text. If omitted, the `result.filePath` becomes the string `"<text>"`.
* `options.warnIgnored` (`boolean`)<br>
Optional. If `true` is present and the `options.filePath` is a file ESLint should ignore, this method returns a lint result contains a warning message.
Optional, defaults to `options.warnIgnored` passed to the constructor. If `true` is present and the `options.filePath` is a file ESLint should ignore, this method returns a lint result contains a warning message.

#### Return Value

Expand Down
4 changes: 2 additions & 2 deletions lib/eslint/eslint-helpers.js
Expand Up @@ -665,9 +665,9 @@ class ESLintInvalidOptionsError extends Error {

/**
* Validates and normalizes options for the wrapped CLIEngine instance.
* @param {FlatESLintOptions} options The options to process.
* @param {ESLintOptions} options The options to process.
* @throws {ESLintInvalidOptionsError} If of any of a variety of type errors.
* @returns {FlatESLintOptions} The normalized options.
* @returns {ESLintOptions} The normalized options.
*/
function processOptions({
allowInlineConfig = true, // ← we cannot use `overrideConfig.noInlineConfig` instead because `allowInlineConfig` has side-effect that suppress warnings that show inline configs are ignored.
Expand Down
4 changes: 2 additions & 2 deletions lib/eslint/eslint.js
Expand Up @@ -98,7 +98,7 @@ const FLAT_CONFIG_FILENAMES = [
"eslint.config.mjs",
"eslint.config.cjs"
];
const debug = require("debug")("eslint:flat-eslint");
const debug = require("debug")("eslint:eslint");
const privateMembers = new WeakMap();
const importedConfigFileModificationTime = new Map();
const removedFormatters = new Set([
Expand Down Expand Up @@ -360,7 +360,7 @@ async function locateConfigFileToUse({ configFile, cwd }) {

/**
* Calculates the config array for this run based on inputs.
* @param {FlatESLint} eslint The instance to create the config array for.
* @param {ESLint} eslint The instance to create the config array for.
* @param {import("./eslint").ESLintOptions} options The ESLint instance options.
* @returns {FlatConfigArray} The config array for `eslint``.
*/
Expand Down
4 changes: 2 additions & 2 deletions tests/_utils/test-lazy-loading-rules.js
Expand Up @@ -56,8 +56,8 @@ addHook(
* Everything related to loading any ESLint modules should be in this IIFE
*/
(async () => {
const { ESLint } = require("../..");
const eslint = new ESLint({ cwd });
const { LegacyESLint } = require("../../lib/unsupported-api");
const eslint = new LegacyESLint({ cwd });

await eslint.lintFiles([pattern]);
})().catch(({ message, stack }) => {
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/eslint/legacy-eslint.js
Expand Up @@ -986,7 +986,7 @@ describe("LegacyESLint", () => {

describe("lintFiles()", () => {

/** @type {InstanceType<import("../../../lib/eslint").ESLint>} */
/** @type {InstanceType<import("../../../lib/eslint/legacy-eslint").LegacyESLint>} */
let eslint;

it("should use correct parser when custom parser is specified", async () => {
Expand Down Expand Up @@ -5981,7 +5981,7 @@ describe("LegacyESLint", () => {

describe("when retrieving version number", () => {
it("should return current version number", () => {
const eslintCLI = require("../../../lib/eslint").ESLint;
const eslintCLI = require("../../../lib/eslint").LegacyESLint;
const version = eslintCLI.version;

assert.strictEqual(typeof version, "string");
Expand Down

0 comments on commit 037abfc

Please sign in to comment.