mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 20:38:55 +00:00
feat: fmt and lint respect .gitignore file (#26897)
Closes https://github.com/denoland/deno/issues/26573
This commit is contained in:
parent
c36f877f8d
commit
106d47a013
@ -228,6 +228,7 @@ fn collect_fmt_files(
|
|||||||
})
|
})
|
||||||
.ignore_git_folder()
|
.ignore_git_folder()
|
||||||
.ignore_node_modules()
|
.ignore_node_modules()
|
||||||
|
.use_gitignore()
|
||||||
.set_vendor_folder(cli_options.vendor_dir_path().map(ToOwned::to_owned))
|
.set_vendor_folder(cli_options.vendor_dir_path().map(ToOwned::to_owned))
|
||||||
.collect_file_patterns(&deno_config::fs::RealDenoConfigFs, files)
|
.collect_file_patterns(&deno_config::fs::RealDenoConfigFs, files)
|
||||||
}
|
}
|
||||||
|
@ -436,6 +436,7 @@ fn collect_lint_files(
|
|||||||
})
|
})
|
||||||
.ignore_git_folder()
|
.ignore_git_folder()
|
||||||
.ignore_node_modules()
|
.ignore_node_modules()
|
||||||
|
.use_gitignore()
|
||||||
.set_vendor_folder(cli_options.vendor_dir_path().map(ToOwned::to_owned))
|
.set_vendor_folder(cli_options.vendor_dir_path().map(ToOwned::to_owned))
|
||||||
.collect_file_patterns(&deno_config::fs::RealDenoConfigFs, files)
|
.collect_file_patterns(&deno_config::fs::RealDenoConfigFs, files)
|
||||||
}
|
}
|
||||||
|
1
tests/specs/fmt/gitignore/.gitignore
vendored
Normal file
1
tests/specs/fmt/gitignore/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/dist/
|
6
tests/specs/fmt/gitignore/__test__.jsonc
Normal file
6
tests/specs/fmt/gitignore/__test__.jsonc
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"tempDir": true,
|
||||||
|
"args": "fmt --check",
|
||||||
|
"output": "expected.out",
|
||||||
|
"exitCode": 1
|
||||||
|
}
|
6
tests/specs/fmt/gitignore/dist/file1.js
vendored
Normal file
6
tests/specs/fmt/gitignore/dist/file1.js
vendored
Normal 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")
|
||||||
|
}
|
||||||
|
|
10
tests/specs/fmt/gitignore/expected.out
Normal file
10
tests/specs/fmt/gitignore/expected.out
Normal 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
|
3
tests/specs/fmt/gitignore/file2.ts
Normal file
3
tests/specs/fmt/gitignore/file2.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
function foo( ): any {
|
||||||
|
console.log( "hello")
|
||||||
|
}
|
1
tests/specs/lint/gitignore/.gitignore
vendored
Normal file
1
tests/specs/lint/gitignore/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/dist/
|
5
tests/specs/lint/gitignore/__test__.jsonc
Normal file
5
tests/specs/lint/gitignore/__test__.jsonc
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"args": "lint",
|
||||||
|
"output": "expected.out",
|
||||||
|
"exitCode": 1
|
||||||
|
}
|
3
tests/specs/lint/gitignore/dist/file1.js
vendored
Normal file
3
tests/specs/lint/gitignore/dist/file1.js
vendored
Normal 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) {}
|
12
tests/specs/lint/gitignore/expected.out
Normal file
12
tests/specs/lint/gitignore/expected.out
Normal 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
|
6
tests/specs/lint/gitignore/file2.ts
Normal file
6
tests/specs/lint/gitignore/file2.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
try {
|
||||||
|
await Deno.open("./some/file.txt");
|
||||||
|
} catch (_e) {}
|
||||||
|
|
||||||
|
// deno-lint-ignore no-explicit-any
|
||||||
|
function _foo(): any {}
|
Loading…
Reference in New Issue
Block a user