Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions linters/pre-commit-hooks/pre_commit_hooks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { linterFmtTest, TestCallback } from "tests";
const fmtCallbacks: TestCallback = (driver) => {
const trunkYamlPath = ".trunk/trunk.yaml";
const currentContents = driver.readFile(trunkYamlPath);
const sqlfluffRegex = /- pre-commit-hooks@(.+)\n/;
const enableRegex = /- pre-commit-hooks@(.+)\n/;
const newContents = currentContents.replace(
sqlfluffRegex,
enableRegex,
"- pre-commit-hooks@$1:\n commands: [end-of-file-fixer]\n",
);
driver.writeFile(trunkYamlPath, newContents);
Expand Down
4 changes: 2 additions & 2 deletions linters/ruff/ruff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ linterCheckTest({
const preCheck = (driver: TrunkLintDriver) => {
const trunkYamlPath = ".trunk/trunk.yaml";
const currentContents = driver.readFile(trunkYamlPath);
const sqlfluffRegex = /- ruff@(.+)\n/;
const enableRegex = /- ruff@(.+)\n/;
const newContents = currentContents.replace(
sqlfluffRegex,
enableRegex,
"- ruff@$1:\n commands: [format]\n",
);
driver.writeFile(trunkYamlPath, newContents);
Expand Down
6 changes: 3 additions & 3 deletions linters/sqlfluff/sqlfluff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ linterCheckTest({ linterName: "sqlfluff", namedTestPrefixes: ["basic_check"] });
const fmtCallbacks: TestCallback = (driver) => {
const trunkYamlPath = ".trunk/trunk.yaml";
const currentContents = driver.readFile(trunkYamlPath);
const sqlfluffRegex = /- sqlfluff@(.+)\n/;
const enableRegex = /- sqlfluff@(.+)\n/;
const newContents = currentContents.replace(
sqlfluffRegex,
"- sqlfluff@$1:\n commands: [lint, fix]\n"
enableRegex,
"- sqlfluff@$1:\n commands: [lint, fix]\n",
);
driver.writeFile(trunkYamlPath, newContents);
};
Expand Down
4 changes: 2 additions & 2 deletions linters/stylelint/stylelint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const preCheck = (driver: TrunkLintDriver) => {
: "stylelint-config-standard@25.0.0";
const trunkYamlPath = ".trunk/trunk.yaml";
const currentContents = driver.readFile(trunkYamlPath);
const sqlfluffRegex = /- stylelint@(.+)\n/;
const enableRegex = /- stylelint@(.+)\n/;
const newContents = currentContents.replace(
sqlfluffRegex,
enableRegex,
`- stylelint@$1:\n packages: [${configVersion}]\n`,
);
driver.writeFile(trunkYamlPath, newContents);
Expand Down
6 changes: 3 additions & 3 deletions linters/terraform/terraform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { TrunkLintDriver } from "tests/driver";
const preCheck = (driver: TrunkLintDriver) => {
const trunkYamlPath = ".trunk/trunk.yaml";
const currentContents = driver.readFile(trunkYamlPath);
const sqlfluffRegex = /- terraform@(.+)\n/;
const enableRegex = /- terraform@(.+)\n/;
const newContents = currentContents.replace(
sqlfluffRegex,
"- terraform@$1:\n commands: [validate, fmt]\n"
enableRegex,
"- terraform@$1:\n commands: [validate, fmt]\n",
);
driver.writeFile(trunkYamlPath, newContents);
};
Expand Down
18 changes: 18 additions & 0 deletions linters/tofu/terraform.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { linterCheckTest, linterFmtTest } from "tests";
import { TrunkLintDriver } from "tests/driver";

// Due to terraform's validate subcommand being disabled by default, we need to manually enable it in our test's trunk.yaml.
const preCheck = (driver: TrunkLintDriver) => {
const trunkYamlPath = ".trunk/trunk.yaml";
const currentContents = driver.readFile(trunkYamlPath);
const enableRegex = /- terraform@(.+)\n/;
const newContents = currentContents.replace(
enableRegex,
"- terraform@$1:\n commands: [validate, fmt]\n",
);
driver.writeFile(trunkYamlPath, newContents);
};

linterCheckTest({ linterName: "terraform", preCheck });

linterFmtTest({ linterName: "terraform" });
4 changes: 2 additions & 2 deletions linters/tofu/tofu.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { TrunkLintDriver } from "tests/driver";
const preCheck = (driver: TrunkLintDriver) => {
const trunkYamlPath = ".trunk/trunk.yaml";
const currentContents = driver.readFile(trunkYamlPath);
const sqlfluffRegex = /- tofu@(.+)\n/;
const enableRegex = /- tofu@(.+)\n/;
const newContents = currentContents.replace(
sqlfluffRegex,
enableRegex,
"- tofu@$1:\n commands: [validate, fmt]\n",
);
driver.writeFile(trunkYamlPath, newContents);
Expand Down