diff --git a/docs/src/integrate/nodejs-api.md b/docs/src/integrate/nodejs-api.md index 89ac7e3f823..154f01fccd4 100644 --- a/docs/src/integrate/nodejs-api.md +++ b/docs/src/integrate/nodejs-api.md @@ -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" } @@ -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`)
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`)
- 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`)
+ Default is `null`. Ignore file patterns to use in addition to config ignores. These patterns are relative to `cwd`. +* `options.passOnNoPatterns` (`boolean`)
+ Default is `false`. When set to `true`, missing patterns cause the linting operation to short circuit and not report any failures. +* `options.warnIgnored` (`boolean`)
+ Default is `true`. Show warnings when the file list includes ignored files. ##### Linting @@ -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 | null`)
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`)
- 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`)
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. @@ -204,7 +206,7 @@ The second parameter `options` is omittable. * `options.filePath` (`string`)
Optional. The path to the file of the source code text. If omitted, the `result.filePath` becomes the string `""`. * `options.warnIgnored` (`boolean`)
- 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 diff --git a/lib/eslint/eslint-helpers.js b/lib/eslint/eslint-helpers.js index b199452774f..065a9e98c5c 100644 --- a/lib/eslint/eslint-helpers.js +++ b/lib/eslint/eslint-helpers.js @@ -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. diff --git a/lib/eslint/eslint.js b/lib/eslint/eslint.js index 566220c5b60..cc6d061def7 100644 --- a/lib/eslint/eslint.js +++ b/lib/eslint/eslint.js @@ -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([ @@ -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``. */ diff --git a/tests/_utils/test-lazy-loading-rules.js b/tests/_utils/test-lazy-loading-rules.js index 34e19869ac7..66a4a661376 100644 --- a/tests/_utils/test-lazy-loading-rules.js +++ b/tests/_utils/test-lazy-loading-rules.js @@ -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 }) => { diff --git a/tests/lib/eslint/legacy-eslint.js b/tests/lib/eslint/legacy-eslint.js index cdf1bba2a89..ffd0eaea8e9 100644 --- a/tests/lib/eslint/legacy-eslint.js +++ b/tests/lib/eslint/legacy-eslint.js @@ -986,7 +986,7 @@ describe("LegacyESLint", () => { describe("lintFiles()", () => { - /** @type {InstanceType} */ + /** @type {InstanceType} */ let eslint; it("should use correct parser when custom parser is specified", async () => { @@ -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");