diff --git a/package.json b/package.json index a2db1dd8338..a87680b713f 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@eslint-community/regexpp": "^4.6.1", "@eslint/eslintrc": "^2.1.4", "@eslint/js": "8.56.0", - "@humanwhocodes/config-array": "^0.11.13", + "@humanwhocodes/config-array": "^0.11.14", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", "@ungap/structured-clone": "^1.2.0", diff --git a/tests/bin/eslint.js b/tests/bin/eslint.js index 0622d48e973..ac4e5c9cde3 100644 --- a/tests/bin/eslint.js +++ b/tests/bin/eslint.js @@ -440,6 +440,21 @@ describe("bin/eslint.js", () => { }); }); + // https://github.com/eslint/eslint/issues/17960 + it("should include key information in the error message when there is an invalid config", () => { + + // The error message should include the key name + const config = path.join(__dirname, "../fixtures/bin/eslint.config-invalid-key.js"); + const child = runESLint(["--config", config, "conf", "tools"]); + const exitCodeAssertion = assertExitCode(child, 2); + const outputAssertion = getOutput(child).then(output => { + assert.include(output.stderr, "Key \"linterOptions\": Key \"reportUnusedDisableDirectives\""); + }); + + return Promise.all([exitCodeAssertion, outputAssertion]); + + }); + it("prints the error message pointing to line of code", () => { const invalidConfig = path.join(__dirname, "../fixtures/bin/eslint.config.js"); const child = runESLint(["--no-ignore", "-c", invalidConfig]); diff --git a/tests/fixtures/bin/eslint.config-invalid-key.js b/tests/fixtures/bin/eslint.config-invalid-key.js new file mode 100644 index 00000000000..d7840c15304 --- /dev/null +++ b/tests/fixtures/bin/eslint.config-invalid-key.js @@ -0,0 +1,5 @@ +module.exports = [{ + linterOptions: { + reportUnusedDisableDirectives: "banana" + } +}]; diff --git a/tests/lib/config/flat-config-array.js b/tests/lib/config/flat-config-array.js index 79f80bce425..c38f099a318 100644 --- a/tests/lib/config/flat-config-array.js +++ b/tests/lib/config/flat-config-array.js @@ -1039,7 +1039,7 @@ describe("FlatConfigArray", () => { reportUnusedDisableDirectives: {} } } - ], /Expected one of: "error", "warn", "off", 0, 1, 2, or a boolean./u); + ], /Key "linterOptions": Key "reportUnusedDisableDirectives": Expected one of: "error", "warn", "off", 0, 1, 2, or a boolean./u); }); it("should merge two objects when second object has overrides", () => assertMergedResult([ @@ -2054,4 +2054,5 @@ describe("FlatConfigArray", () => { }); }); + });