1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 05:42:25 -05:00

feat: fmt and lint respect .gitignore file (#26897)

Closes https://github.com/denoland/deno/issues/26573
This commit is contained in:
Bartek Iwańczuk 2024-11-18 22:54:28 +00:00 committed by GitHub
parent c36f877f8d
commit 106d47a013
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 55 additions and 0 deletions

View file

@ -228,6 +228,7 @@ fn collect_fmt_files(
})
.ignore_git_folder()
.ignore_node_modules()
.use_gitignore()
.set_vendor_folder(cli_options.vendor_dir_path().map(ToOwned::to_owned))
.collect_file_patterns(&deno_config::fs::RealDenoConfigFs, files)
}

View file

@ -436,6 +436,7 @@ fn collect_lint_files(
})
.ignore_git_folder()
.ignore_node_modules()
.use_gitignore()
.set_vendor_folder(cli_options.vendor_dir_path().map(ToOwned::to_owned))
.collect_file_patterns(&deno_config::fs::RealDenoConfigFs, files)
}

1
tests/specs/fmt/gitignore/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/dist/

View file

@ -0,0 +1,6 @@
{
"tempDir": true,
"args": "fmt --check",
"output": "expected.out",
"exitCode": 1
}

View file

@ -0,0 +1,6 @@
// This file is in `.gitignore` simulating that it's generated by a build tool
// and should not be linted
function foo( ) {
console.log( "hello")
}

View file

@ -0,0 +1,10 @@
from [WILDCARD]file2.ts:
1 | -function foo( ): any {
1 | +function foo(): any {
2 | - console.log( "hello")
2 | + console.log("hello");
3 | - }
3 | +}
error: Found 1 not formatted file in 1 file

View file

@ -0,0 +1,3 @@
function foo( ): any {
console.log( "hello")
}

1
tests/specs/lint/gitignore/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/dist/

View file

@ -0,0 +1,5 @@
{
"args": "lint",
"output": "expected.out",
"exitCode": 1
}

View file

@ -0,0 +1,3 @@
// This file is in `.gitignore` simulating that it's generated by a build tool
// and should not be linted
while (false) {}

View file

@ -0,0 +1,12 @@
error[no-empty]: Empty block statement
--> [WILDCARD]file2.ts:3:14
|
3 | } catch (_e) {}
| ^^
= hint: Add code or comment to the empty block
docs: https://lint.deno.land/rules/no-empty
Found 1 problem
Checked 1 file

View file

@ -0,0 +1,6 @@
try {
await Deno.open("./some/file.txt");
} catch (_e) {}
// deno-lint-ignore no-explicit-any
function _foo(): any {}