Initial commit

This commit is contained in:
2025-03-07 19:22:02 +01:00
commit 4a98255d83
55743 changed files with 5280367 additions and 0 deletions
+100
View File
@@ -0,0 +1,100 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import assert from "assert";
import { describe, it } from "mocha";
import * as prettierLint from "../../src/lint";
describe("test cases", function () {
it("eslint and prettier commands", async function () {
const inputFile = "./test/cases/basic/functions.ts";
const lintExpectedCommand = "./test/cases/basic/functions.ts";
const lintFixExpectedCommand = "--fix ./test/cases/basic/functions.ts";
const prettierExpectedCommand = "--parser typescript --write ./test/cases/basic/functions.ts";
const lintExpectedTestConfig = "eslint.config.test.mjs";
const lintCheckCommand = prettierLint.getLintCheckCommand(inputFile);
assert.strictEqual(
lintCheckCommand.indexOf(lintExpectedCommand) > 0,
true,
"Lint command does not match expected value."
);
const lintCheckConfig = prettierLint.getLintCheckCommand(inputFile, true);
assert.strictEqual(
lintCheckConfig.indexOf(lintExpectedTestConfig) > 0,
true,
"Lint test command does not match expected value."
);
const lintFixCommand = prettierLint.getLintFixCommand(inputFile);
assert.strictEqual(
lintFixCommand.indexOf(lintFixExpectedCommand) > 0,
true,
"Lint fix command does not match expected value."
);
const prettierCommand = prettierLint.getPrettierCommand(inputFile);
assert.strictEqual(
prettierCommand.indexOf(prettierExpectedCommand) > 0,
true,
"Prettier command does not match expected value."
);
});
it("spaces in filename", async function () {
const inputFile = "./test/cases/basic/functions with space.ts";
const lintExpectedCommand = "./test/cases/basic/functions\\ with\\ space.ts";
const lintFixExpectedCommand = "--fix ./test/cases/basic/functions\\ with\\ space.ts";
const prettierExpectedCommand = "--parser typescript --write ./test/cases/basic/functions\\ with\\ space.ts";
const lintCheckCommand = prettierLint.getLintCheckCommand(inputFile);
assert.strictEqual(
lintCheckCommand.indexOf(lintExpectedCommand) > 0,
true,
"Lint command does not match expected value."
);
const lintFixCommand = prettierLint.getLintFixCommand(inputFile);
assert.strictEqual(
lintFixCommand.indexOf(lintFixExpectedCommand) > 0,
true,
"Lint fix command does not match expected value."
);
const prettierCommand = prettierLint.getPrettierCommand(inputFile);
assert.strictEqual(
prettierCommand.indexOf(prettierExpectedCommand) > 0,
true,
"Prettier command does not match expected value."
);
});
it("spaces in filepath", async function () {
const inputFile = "./test/cases/basic with space/functions.ts";
const lintExpectedCommand = "./test/cases/basic\\ with\\ space/functions.ts";
const lintFixExpectedCommand = "--fix ./test/cases/basic\\ with\\ space/functions.ts";
const prettierExpectedCommand = "--parser typescript --write ./test/cases/basic\\ with\\ space/functions.ts";
const lintCheckCommand = prettierLint.getLintCheckCommand(inputFile);
assert.strictEqual(
lintCheckCommand.indexOf(lintExpectedCommand) > 0,
true,
"Lint command does not match expected value."
);
const lintFixCommand = prettierLint.getLintFixCommand(inputFile);
assert.strictEqual(
lintFixCommand.indexOf(lintFixExpectedCommand) > 0,
true,
"Lint fix command does not match expected value."
);
const prettierCommand = prettierLint.getPrettierCommand(inputFile);
assert.strictEqual(
prettierCommand.indexOf(prettierExpectedCommand) > 0,
true,
"Prettier command does not match expected value."
);
});
});