diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2021-09-13 20:19:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-13 20:19:10 +0200 |
commit | 0dbeb774ba9ea618ff1e92b63ab31e5caf3003dd (patch) | |
tree | 592244102cf046716acbb144233586c312ee7a7e /cli/tests/integration/fmt_tests.rs | |
parent | a655a0f3e4201840eda94938fc8d6222c2b94a99 (diff) |
feat(fmt): add support for configuration file (#11944)
This commit adds support for configuration file for "deno fmt"
subcommand. It is also respected by LSP when formatting
files.
Example configuration:
{
"fmt": {
"files": {
"include": ["src/"],
"exclude": ["src/testdata/"]
},
"options": {
"useTabs": true,
"lineWidth": 80,
"indentWidth": 4,
"singleQuote": true,
"textWrap": "preserve"
}
}
}
Diffstat (limited to 'cli/tests/integration/fmt_tests.rs')
-rw-r--r-- | cli/tests/integration/fmt_tests.rs | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/cli/tests/integration/fmt_tests.rs b/cli/tests/integration/fmt_tests.rs index 00565a5d0..2d7451694 100644 --- a/cli/tests/integration/fmt_tests.rs +++ b/cli/tests/integration/fmt_tests.rs @@ -129,25 +129,25 @@ fn fmt_ignore_unexplicit_files() { } itest!(fmt_check_tests_dir { - args: "fmt --check ./ --ignore=.test_coverage", + args: "fmt --check ./ --ignore=.test_coverage,fmt/fmt_with_config/", output: "fmt/expected_fmt_check_tests_dir.out", exit_code: 1, }); itest!(fmt_quiet_check_fmt_dir { - args: "fmt --check --quiet fmt/", + args: "fmt --check --quiet fmt/regular/", output_str: Some(""), exit_code: 0, }); itest!(fmt_check_formatted_files { - args: "fmt --check fmt/formatted1.js fmt/formatted2.ts fmt/formatted3.md fmt/formatted4.jsonc", + args: "fmt --check fmt/regular/formatted1.js fmt/regular/formatted2.ts fmt/regular/formatted3.md fmt/regular/formatted4.jsonc", output: "fmt/expected_fmt_check_formatted_files.out", exit_code: 0, }); itest!(fmt_check_ignore { - args: "fmt --check --ignore=fmt/formatted1.js fmt/", + args: "fmt --check --ignore=fmt/regular/formatted1.js fmt/regular/", output: "fmt/expected_fmt_check_ignore.out", exit_code: 0, }); @@ -181,3 +181,26 @@ itest!(fmt_stdin_check_not_formatted { input: Some("const a = 1\n"), output_str: Some("Not formatted stdin\n"), }); + +itest!(fmt_with_config { + args: "fmt --config fmt/deno.jsonc fmt/fmt_with_config/", + output: "fmt/fmt_with_config.out", +}); + +// Check if CLI flags take precedence +itest!(fmt_with_config_and_flags { + args: "fmt --config fmt/deno.jsonc --ignore=fmt/fmt_with_config/a.ts,fmt/fmt_with_config/b.ts", + output: "fmt/fmt_with_config_and_flags.out", +}); + +itest!(fmt_with_malformed_config { + args: "fmt --config fmt/deno.malformed.jsonc", + output: "fmt/fmt_with_malformed_config.out", + exit_code: 1, +}); + +itest!(fmt_with_malformed_config2 { + args: "fmt --config fmt/deno.malformed2.jsonc", + output: "fmt/fmt_with_malformed_config2.out", + exit_code: 1, +}); |