Skip to content

Commit

Permalink
Merge tests for deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Dec 20, 2023
1 parent 8b30806 commit 265105f
Showing 1 changed file with 10 additions and 23 deletions.
33 changes: 10 additions & 23 deletions tests/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,15 @@ describe("cli", () => {
const originalEnv = process.env;
const originalCwd = process.cwd;

let processStub;

beforeEach(() => {
processStub = sinon.stub(process, "emitWarning");
process.env = { ...originalEnv };
});

afterEach(() => {
processStub.restore();
process.env = originalEnv;
process.cwd = originalCwd;
});
Expand All @@ -167,6 +171,12 @@ describe("cli", () => {
const exitCode = await cli.execute(`--no-ignore --ext .js ${getFixturePath("files")}`, null, useFlatConfig);

assert.strictEqual(exitCode, 0);


if (useFlatConfig) {
assert.strictEqual(processStub.callCount, 1, "calls `process.emitWarning()` once");
assert.strictEqual(processStub.getCall(0).args[1], "ESLintRCWarning");
}
});

it(`should use it when ESLINT_USE_FLAT_CONFIG=true and useFlatConfig is true even if an eslint.config.js is not present:${configType}`, async () => {
Expand Down Expand Up @@ -1597,29 +1607,6 @@ describe("cli", () => {
});
});

describe("when using an eslintrc config file", () => {

let processStub;

beforeEach(() => {
processStub = sinon.stub(process, "emitWarning");
});

afterEach(() => {
processStub.restore();
});

it("should emit deprecation warning", async () => {
const configPath = getFixturePath(".eslintrc");
const filePath = getFixturePath("passing.js");

await cli.execute(`--config ${configPath} ${filePath}`, null, false);

assert.strictEqual(processStub.callCount, 1, "calls `process.emitWarning()` once");
assert.strictEqual(processStub.getCall(0).args[1], "ESLintRCWarning");
});
});

describe("when executing without no-eslintrc flag", () => {
it("should load a local config file", async () => {
const filePath = getFixturePath("eslintrc", "quotes.js");
Expand Down

0 comments on commit 265105f

Please sign in to comment.