Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix biome fmt error case #772

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
19 changes: 18 additions & 1 deletion linters/biome/biome.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
import { linterCheckTest, linterFmtTest } from "tests";
import path from "path";
import { customLinterCheckTest, linterCheckTest, linterFmtTest } from "tests";
import { TrunkLintDriver } from "tests/driver";
import { TEST_DATA } from "tests/utils";

linterCheckTest({ linterName: "biome", namedTestPrefixes: ["basic_check"] });

linterFmtTest({ linterName: "biome", namedTestPrefixes: ["basic_fmt", "basic_json"] });

const preCheck = (driver: TrunkLintDriver) => {
// Write an invalid biome config and verify we surface an error for format.
// NOTE(Tyler): We should handle config errors better for 'lint' too, but the JSON
// output for biome is not stable and they don't support SARIF.
driver.writeFile("biome.json", JSON.stringify({ rules: { "no-foo": "error" } }));
};

customLinterCheckTest({
linterName: "biome",
testName: "error",
args: path.join(TEST_DATA, "basic_check.in.ts"),
preCheck,
});
2 changes: 1 addition & 1 deletion linters/biome/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ lint:
- name: fmt
output: rewrite
run: biome format --write "${target}"
success_codes: [0, 1]
success_codes: [0]
batch: true
cache_results: true
formatter: true
Expand Down
36 changes: 36 additions & 0 deletions linters/biome/test_data/biome_v1.4.1_error.check.shot
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Testing linter biome test error 1`] = `
{
"issues": [],
"lintActions": [
{
"command": "lint",
"fileGroupName": "typescript",
"linter": "biome",
"paths": [
"test_data/basic_check.in.ts",
],
"verb": "TRUNK_VERB_CHECK",
},
{
"command": "lint",
"fileGroupName": "typescript",
"linter": "biome",
"paths": [
"test_data/basic_check.in.ts",
],
"upstream": true,
"verb": "TRUNK_VERB_CHECK",
},
],
"taskFailures": [
{
"details": StringMatching /\\.\\*\\$/m,
"message": "test_data/basic_check.in.ts",
"name": "biome",
},
],
"unformattedFiles": [],
}
`;
36 changes: 36 additions & 0 deletions linters/biome/test_data/biome_v1.6.0_error.check.shot
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Testing linter biome test error 1`] = `
{
"issues": [],
"lintActions": [
{
"command": "lint",
"fileGroupName": "typescript",
"linter": "biome",
"paths": [
"test_data/basic_check.in.ts",
],
"verb": "TRUNK_VERB_CHECK",
},
{
"command": "lint",
"fileGroupName": "typescript",
"linter": "biome",
"paths": [
"test_data/basic_check.in.ts",
],
"upstream": true,
"verb": "TRUNK_VERB_CHECK",
},
],
"taskFailures": [
{
"details": StringMatching /\\.\\*\\$/m,
"message": "test_data/basic_check.in.ts",
"name": "biome",
},
],
"unformattedFiles": [],
}
`;
Loading