diff --git a/tests/lib/cli-engine/file-enumerator.js b/tests/lib/cli-engine/file-enumerator.js index a1de4cd2161..2ccf15e73d1 100644 --- a/tests/lib/cli-engine/file-enumerator.js +++ b/tests/lib/cli-engine/file-enumerator.js @@ -550,7 +550,7 @@ describe("FileEnumerator", () => { const files = { "file.js": "", ".eslintrc.json": JSON.stringify({ - extends: ["eslint:recommended"] + extends: ["eslint:recommended", "eslint:all"] }) }; const { prepare, cleanup, getPath } = createCustomTeardown({ cwd: root, files }); diff --git a/tests/lib/eslint/eslint.js b/tests/lib/eslint/eslint.js index cc150b34961..29c5fa164f5 100644 --- a/tests/lib/eslint/eslint.js +++ b/tests/lib/eslint/eslint.js @@ -413,6 +413,55 @@ describe("ESLint", () => { ]); }); + it("should use eslint:recommended rules when eslint:recommended configuration is specified", async () => { + eslint = new ESLint({ + useEslintrc: false, + overrideConfig: { + extends: ["eslint:recommended"] + }, + ignore: false, + cwd: getFixturePath() + }); + const options = { filePath: "file.js" }; + const results = await eslint.lintText("foo ()", options); + + assert.strictEqual(results.length, 1); + assert.strictEqual(results[0].messages.length, 1); + assert.strictEqual(results[0].messages[0].ruleId, "no-undef"); + assert.strictEqual(results[0].messages[0].severity, 2); + }); + + it("should use eslint:all rules when eslint:all configuration is specified", async () => { + eslint = new ESLint({ + useEslintrc: false, + overrideConfig: { + extends: ["eslint:all"] + }, + ignore: false, + cwd: getFixturePath() + }); + const options = { filePath: "file.js" }; + const results = await eslint.lintText("foo ()", options); + + assert.strictEqual(results.length, 1); + + const { messages } = results[0]; + + // Some rules that should report errors in the given code. Not all, as we don't want to update this test when we add new rules. + const expectedRules = ["no-undef", "semi", "func-call-spacing"]; + + expectedRules.forEach(ruleId => { + const messageFromRule = messages.find(message => message.ruleId === ruleId); + + assert.ok( + typeof messageFromRule === "object" && messageFromRule !== null, // LintMessage object + `Expected a message from rule '${ruleId}'` + ); + assert.strictEqual(messageFromRule.severity, 2); + }); + + }); + it("correctly autofixes semicolon-conflicting-fixes", async () => { eslint = new ESLint({ cwd: path.join(fixtureDir, ".."),