summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorscarf <greenscarf005@gmail.com>2023-04-27 12:02:36 +0900
committerGitHub <noreply@github.com>2023-04-26 23:02:36 -0400
commit90a5ef5e343bedc0f6f5326b14b6851b71733bea (patch)
tree4c53261235e3d8720cad99341ee1eac31a92fa3e
parent4192978c3afc943b93d9fae0f65822a2c4edfa62 (diff)
feat(cli): flatten deno.json configuaration (#17799)
-rw-r--r--cli/args/config_file.rs406
-rw-r--r--cli/schemas/config-file.v1.json90
-rw-r--r--cli/tests/integration/fmt_tests.rs6
-rw-r--r--cli/tests/integration/test_tests.rs6
-rw-r--r--cli/tests/testdata/bench/collect/deno.jsonc8
-rw-r--r--cli/tests/testdata/bench/collect/deno.malformed.jsonc6
-rw-r--r--cli/tests/testdata/bench/collect/deno2.jsonc10
-rw-r--r--cli/tests/testdata/bench/collect_with_malformed_config.out2
-rw-r--r--cli/tests/testdata/fmt/deno.malformed.jsonc6
-rw-r--r--cli/tests/testdata/fmt/deno.malformed2.jsonc8
-rw-r--r--cli/tests/testdata/fmt/fmt_with_deprecated_config.out3
-rw-r--r--cli/tests/testdata/fmt/fmt_with_malformed_config.out2
-rw-r--r--cli/tests/testdata/fmt/fmt_with_malformed_config2.out2
-rw-r--r--cli/tests/testdata/fmt/with_config/deno.deprecated.jsonc20
-rw-r--r--cli/tests/testdata/fmt/with_config/deno.jsonc28
-rw-r--r--cli/tests/testdata/lint/Deno.compact.format.jsonc6
-rw-r--r--cli/tests/testdata/lint/Deno.jsonc6
-rw-r--r--cli/tests/testdata/lint/Deno.malformed.jsonc6
-rw-r--r--cli/tests/testdata/lint/Deno.malformed2.jsonc8
-rw-r--r--cli/tests/testdata/lint/Deno.no_tags.jsonc14
-rw-r--r--cli/tests/testdata/lint/with_malformed_config.out2
-rw-r--r--cli/tests/testdata/lint/with_malformed_config2.out2
-rw-r--r--cli/tests/testdata/lsp/deno.lint.exclude.jsonc8
-rw-r--r--cli/tests/testdata/test/collect.deprecated.out10
-rw-r--r--cli/tests/testdata/test/collect/deno.deprecated.jsonc7
-rw-r--r--cli/tests/testdata/test/collect/deno.jsonc4
-rw-r--r--cli/tests/testdata/test/collect/deno2.jsonc6
-rw-r--r--cli/tests/testdata/test/collect_with_malformed_config.out2
28 files changed, 535 insertions, 149 deletions
diff --git a/cli/args/config_file.rs b/cli/args/config_file.rs
index 0dda0db7d..2855199b9 100644
--- a/cli/args/config_file.rs
+++ b/cli/args/config_file.rs
@@ -279,7 +279,7 @@ impl Serialize for TsConfig {
}
}
-#[derive(Clone, Debug, Default, Deserialize)]
+#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[serde(default, deny_unknown_fields)]
pub struct LintRulesConfig {
pub tags: Option<Vec<String>>,
@@ -287,7 +287,7 @@ pub struct LintRulesConfig {
pub exclude: Option<Vec<String>>,
}
-#[derive(Clone, Debug, Default, Deserialize)]
+#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[serde(default, deny_unknown_fields)]
struct SerializedFilesConfig {
pub include: Vec<String>,
@@ -319,6 +319,10 @@ impl SerializedFilesConfig {
.collect::<Result<Vec<_>, _>>()?,
})
}
+
+ pub fn is_empty(&self) -> bool {
+ self.include.is_empty() && self.exclude.is_empty()
+ }
}
#[derive(Clone, Debug, Default, Eq, PartialEq)]
@@ -346,11 +350,57 @@ impl FilesConfig {
}
}
-#[derive(Clone, Debug, Default, Deserialize)]
+/// Choose between flat and nested files configuration.
+///
+/// `files` has precedence over `deprecated_files`.
+/// when `deprecated_files` is present, a warning is logged.
+///
+/// caveat: due to default values, it's not possible to distinguish between
+/// an empty configuration and a configuration with default values.
+/// `{ "files": {} }` is equivalent to `{ "files": { "include": [], "exclude": [] } }`
+/// and it wouldn't be able to emit warning for `{ "files": {}, "exclude": [] }`.
+///
+/// # Arguments
+///
+/// * `files` - Flat configuration.
+/// * `deprecated_files` - Nested configuration. ("Files")
+fn choose_files(
+ files: SerializedFilesConfig,
+ deprecated_files: SerializedFilesConfig,
+) -> SerializedFilesConfig {
+ const DEPRECATED_FILES: &str =
+ "Warning: \"files\" configuration is deprecated";
+ const FLAT_CONFIG: &str = "\"include\" and \"exclude\"";
+
+ let (files_nonempty, deprecated_files_nonempty) =
+ (!files.is_empty(), !deprecated_files.is_empty());
+
+ match (files_nonempty, deprecated_files_nonempty) {
+ (true, true) => {
+ log::warn!("{DEPRECATED_FILES} and ignored by {FLAT_CONFIG}.");
+ files
+ }
+ (true, false) => files,
+ (false, true) => {
+ log::warn!("{DEPRECATED_FILES}. Please use {FLAT_CONFIG} instead.");
+ deprecated_files
+ }
+ (false, false) => SerializedFilesConfig::default(),
+ }
+}
+
+/// `lint` config representation for serde
+///
+/// fields `include` and `exclude` are expanded from [SerializedFilesConfig].
+#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[serde(default, deny_unknown_fields)]
struct SerializedLintConfig {
pub rules: LintRulesConfig,
- pub files: SerializedFilesConfig,
+ pub include: Vec<String>,
+ pub exclude: Vec<String>,
+
+ #[serde(rename = "files")]
+ pub deprecated_files: SerializedFilesConfig,
pub report: Option<String>,
}
@@ -359,22 +409,26 @@ impl SerializedLintConfig {
self,
config_file_specifier: &ModuleSpecifier,
) -> Result<LintConfig, AnyError> {
+ let (include, exclude) = (self.include, self.exclude);
+ let files = SerializedFilesConfig { include, exclude };
+
Ok(LintConfig {
rules: self.rules,
- files: self.files.into_resolved(config_file_specifier)?,
+ files: choose_files(files, self.deprecated_files)
+ .into_resolved(config_file_specifier)?,
report: self.report,
})
}
}
-#[derive(Clone, Debug, Default)]
+#[derive(Clone, Debug, Default, PartialEq)]
pub struct LintConfig {
pub rules: LintRulesConfig,
pub files: FilesConfig,
pub report: Option<String>,
}
-#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
+#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)]
#[serde(deny_unknown_fields, rename_all = "camelCase")]
pub enum ProseWrap {
Always,
@@ -382,7 +436,7 @@ pub enum ProseWrap {
Preserve,
}
-#[derive(Clone, Debug, Default, Serialize, Deserialize)]
+#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)]
#[serde(default, deny_unknown_fields, rename_all = "camelCase")]
pub struct FmtOptionsConfig {
pub use_tabs: Option<bool>,
@@ -393,11 +447,75 @@ pub struct FmtOptionsConfig {
pub semi_colons: Option<bool>,
}
-#[derive(Clone, Debug, Default, Deserialize)]
-#[serde(default, deny_unknown_fields)]
+impl FmtOptionsConfig {
+ pub fn is_empty(&self) -> bool {
+ self.use_tabs.is_none()
+ && self.line_width.is_none()
+ && self.indent_width.is_none()
+ && self.single_quote.is_none()
+ && self.prose_wrap.is_none()
+ && self.semi_colons.is_none()
+ }
+}
+
+/// Choose between flat and nested fmt options.
+///
+/// `options` has precedence over `deprecated_options`.
+/// when `deprecated_options` is present, a warning is logged.
+///
+/// caveat: due to default values, it's not possible to distinguish between
+/// an empty configuration and a configuration with default values.
+/// `{ "fmt": {} } is equivalent to `{ "fmt": { "options": {} } }`
+/// and it wouldn't be able to emit warning for `{ "fmt": { "options": {}, "semiColons": "false" } }`.
+///
+/// # Arguments
+///
+/// * `options` - Flat options.
+/// * `deprecated_options` - Nested files configuration ("option").
+fn choose_fmt_options(
+ options: FmtOptionsConfig,
+ deprecated_options: FmtOptionsConfig,
+) -> FmtOptionsConfig {
+ const DEPRECATED_OPTIONS: &str =
+ "Warning: \"options\" configuration is deprecated";
+ const FLAT_OPTION: &str = "\"flat\" options";
+
+ let (options_nonempty, deprecated_options_nonempty) =
+ (!options.is_empty(), !deprecated_options.is_empty());
+
+ match (options_nonempty, deprecated_options_nonempty) {
+ (true, true) => {
+ log::warn!("{DEPRECATED_OPTIONS} and ignored by {FLAT_OPTION}.");
+ options
+ }
+ (true, false) => options,
+ (false, true) => {
+ log::warn!("{DEPRECATED_OPTIONS}. Please use {FLAT_OPTION} instead.");
+ deprecated_options
+ }
+ (false, false) => FmtOptionsConfig::default(),
+ }
+}
+
+/// `fmt` config representation for serde
+///
+/// fields from `use_tabs`..`semi_colons` are expanded from [FmtOptionsConfig].
+/// fields `include` and `exclude` are expanded from [SerializedFilesConfig].
+#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
+#[serde(default, deny_unknown_fields, rename_all = "camelCase")]
struct SerializedFmtConfig {
- pub options: FmtOptionsConfig,
- pub files: SerializedFilesConfig,
+ pub use_tabs: Option<bool>,
+ pub line_width: Option<u32>,
+ pub indent_width: Option<u8>,
+ pub single_quote: Option<bool>,
+ pub prose_wrap: Option<ProseWrap>,
+ pub semi_colons: Option<bool>,
+ #[serde(rename = "options")]
+ pub deprecated_options: FmtOptionsConfig,
+ pub include: Vec<String>,
+ pub exclude: Vec<String>,
+ #[serde(rename = "files")]
+ pub deprecated_files: SerializedFilesConfig,
}
impl SerializedFmtConfig {
@@ -405,23 +523,41 @@ impl SerializedFmtConfig {
self,
config_file_specifier: &ModuleSpecifier,
) -> Result<FmtConfig, AnyError> {
+ let (include, exclude) = (self.include, self.exclude);
+ let files = SerializedFilesConfig { include, exclude };
+ let options = FmtOptionsConfig {
+ use_tabs: self.use_tabs,
+ line_width: self.line_width,
+ indent_width: self.indent_width,
+ single_quote: self.single_quote,
+ prose_wrap: self.prose_wrap,
+ semi_colons: self.semi_colons,
+ };
+
Ok(FmtConfig {
- options: self.options,
- files: self.files.into_resolved(config_file_specifier)?,
+ options: choose_fmt_options(options, self.deprecated_options),
+ files: choose_files(files, self.deprecated_files)
+ .into_resolved(config_file_specifier)?,
})
}
}
-#[derive(Clone, Debug, Default)]
+#[derive(Clone, Debug, Default, PartialEq)]
pub struct FmtConfig {
pub options: FmtOptionsConfig,
pub files: FilesConfig,
}
-#[derive(Clone, Debug, Default, Deserialize)]
+/// `test` config representation for serde
+///
+/// fields `include` and `exclude` are expanded from [SerializedFilesConfig].
+#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[serde(default, deny_unknown_fields)]
struct SerializedTestConfig {
- pub files: SerializedFilesConfig,
+ pub include: Vec<String>,
+ pub exclude: Vec<String>,
+ #[serde(rename = "files")]
+ pub deprecated_files: SerializedFilesConfig,
}
impl SerializedTestConfig {
@@ -429,21 +565,31 @@ impl SerializedTestConfig {
self,
config_file_specifier: &ModuleSpecifier,
) -> Result<TestConfig, AnyError> {
+ let (include, exclude) = (self.include, self.exclude);
+ let files = SerializedFilesConfig { include, exclude };
+
Ok(TestConfig {
- files: self.files.into_resolved(config_file_specifier)?,
+ files: choose_files(files, self.deprecated_files)
+ .into_resolved(config_file_specifier)?,
})
}
}
-#[derive(Clone, Debug, Default)]
+#[derive(Clone, Debug, Default, PartialEq)]
pub struct TestConfig {
pub files: FilesConfig,
}
-#[derive(Clone, Debug, Default, Deserialize)]
+/// `bench` config representation for serde
+///
+/// fields `include` and `exclude` are expanded from [SerializedFilesConfig].
+#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[serde(default, deny_unknown_fields)]
struct SerializedBenchConfig {
- pub files: SerializedFilesConfig,
+ pub include: Vec<String>,
+ pub exclude: Vec<String>,
+ #[serde(rename = "files")]
+ pub deprecated_files: SerializedFilesConfig,
}
impl SerializedBenchConfig {
@@ -451,18 +597,22 @@ impl SerializedBenchConfig {
self,
config_file_specifier: &ModuleSpecifier,
) -> Result<BenchConfig, AnyError> {
+ let (include, exclude) = (self.include, self.exclude);
+ let files = SerializedFilesConfig { include, exclude };
+
Ok(BenchConfig {
- files: self.files.into_resolved(config_file_specifier)?,
+ files: choose_files(files, self.deprecated_files)
+ .into_resolved(config_file_specifier)?,
})
}
}
-#[derive(Clone, Debug, Default)]
+#[derive(Clone, Debug, Default, PartialEq)]
pub struct BenchConfig {
pub files: FilesConfig,
}
-#[derive(Clone, Debug, Deserialize)]
+#[derive(Clone, Debug, Deserialize, PartialEq)]
#[serde(untagged)]
pub enum LockConfig {
Bool(bool),
@@ -999,6 +1149,12 @@ mod tests {
use deno_core::serde_json::json;
use pretty_assertions::assert_eq;
+ fn unpack_object<T>(result: Result<Option<T>, AnyError>, name: &str) -> T {
+ result
+ .unwrap_or_else(|err| panic!("error parsing {name} object but got {err}"))
+ .unwrap_or_else(|| panic!("{name} object should be defined"))
+ }
+
#[test]
fn read_config_file_absolute() {
let path = test_util::testdata_path().join("module_graph/tsconfig.json");
@@ -1043,27 +1199,21 @@ mod tests {
"strict": true
},
"lint": {
- "files": {
- "include": ["src/"],
- "exclude": ["src/testdata/"]
- },
+ "include": ["src/"],
+ "exclude": ["src/testdata/"],
"rules": {
"tags": ["recommended"],
"include": ["ban-untagged-todo"]
}
},
"fmt": {
- "files": {
- "include": ["src/"],
- "exclude": ["src/testdata/"]
- },
- "options": {
- "useTabs": true,
- "lineWidth": 80,
- "indentWidth": 4,
- "singleQuote": true,
- "proseWrap": "preserve"
- }
+ "include": ["src/"],
+ "exclude": ["src/testdata/"],
+ "useTabs": true,
+ "lineWidth": 80,
+ "indentWidth": 4,
+ "singleQuote": true,
+ "proseWrap": "preserve"
},
"tasks": {
"build": "deno run --allow-read --allow-write build.ts",
@@ -1087,38 +1237,38 @@ mod tests {
}),
);
- let lint_config = config_file
- .to_lint_config()
- .expect("error parsing lint object")
- .expect("lint object should be defined");
- assert_eq!(lint_config.files.include, vec![PathBuf::from("/deno/src/")]);
assert_eq!(
- lint_config.files.exclude,
- vec![PathBuf::from("/deno/src/testdata/")]
- );
- assert_eq!(
- lint_config.rules.include,
- Some(vec!["ban-untagged-todo".to_string()])
- );
- assert_eq!(
- lint_config.rules.tags,
- Some(vec!["recommended".to_string()])
+ unpack_object(config_file.to_lint_config(), "lint"),
+ LintConfig {
+ files: FilesConfig {
+ include: vec![PathBuf::from("/deno/src/")],
+ exclude: vec![PathBuf::from("/deno/src/testdata/")],
+ },
+ rules: LintRulesConfig {
+ include: Some(vec!["ban-untagged-todo".to_string()]),
+ exclude: None,
+ tags: Some(vec!["recommended".to_string()]),
+ },
+ ..Default::default()
+ }
);
- assert!(lint_config.rules.exclude.is_none());
-
- let fmt_config = config_file
- .to_fmt_config()
- .expect("error parsing fmt object")
- .expect("fmt object should be defined");
- assert_eq!(fmt_config.files.include, vec![PathBuf::from("/deno/src/")]);
assert_eq!(
- fmt_config.files.exclude,
- vec![PathBuf::from("/deno/src/testdata/")],
+ unpack_object(config_file.to_fmt_config(), "fmt"),
+ FmtConfig {
+ files: FilesConfig {
+ include: vec![PathBuf::from("/deno/src/")],
+ exclude: vec![PathBuf::from("/deno/src/testdata/")],
+ },
+ options: FmtOptionsConfig {
+ use_tabs: Some(true),
+ line_width: Some(80),
+ indent_width: Some(4),
+ single_quote: Some(true),
+ prose_wrap: Some(ProseWrap::Preserve),
+ ..Default::default()
+ },
+ }
);
- assert_eq!(fmt_config.options.use_tabs, Some(true));
- assert_eq!(fmt_config.options.line_width, Some(80));
- assert_eq!(fmt_config.options.indent_width, Some(4));
- assert_eq!(fmt_config.options.single_quote, Some(true));
let tasks_config = config_file.to_tasks_config().unwrap().unwrap();
assert_eq!(
@@ -1131,6 +1281,128 @@ mod tests {
);
}
+ /// if either "include" or "exclude" is specified, "files" is ignored
+ #[test]
+ fn test_parse_config_with_deprecated_files_field() {
+ let config_text = r#"{
+ "lint": {
+ "files": { "include": ["foo/"], "exclude": ["bar/"] },
+ "include": ["src/"]
+ },
+ "fmt": {
+ "files": { "include": ["foo/"], "exclude": ["bar/"] },
+ "exclude": ["dist/"]
+ },
+ "bench": {
+ "files": { "include": ["foo/"] },
+ "include": ["src/"]
+ },
+ "test": {
+ "files": { "include": ["foo/"] },
+ "include": ["src/"]
+ }
+ }"#;
+ let config_dir = ModuleSpecifier::parse("file:///deno/").unwrap();
+ let config_specifier = config_dir.join("tsconfig.json").unwrap();
+ let config_file = ConfigFile::new(config_text, &config_specifier).unwrap();
+
+ let lint_files = unpack_object(config_file.to_lint_config(), "lint").files;
+ assert_eq!(
+ lint_files,
+ FilesConfig {
+ include: vec![PathBuf::from("/deno/src/")],
+ exclude: vec![],
+ }
+ );
+
+ let fmt_files = unpack_object(config_file.to_fmt_config(), "fmt").files;
+ assert_eq!(
+ fmt_files,
+ FilesConfig {
+ exclude: vec![PathBuf::from("/deno/dist/")],
+ include: vec![],
+ }
+ );
+
+ let test_include = unpack_object(config_file.to_test_config(), "test")
+ .files
+ .include;
+ assert_eq!(test_include, vec![PathBuf::from("/deno/src/")]);
+
+ let bench_include = unpack_object(config_file.to_bench_config(), "bench")
+ .files
+ .include;
+ assert_eq!(bench_include, vec![PathBuf::from("/deno/src/")]);
+ }
+
+ #[test]
+ fn test_parse_config_with_deprecated_files_field_only() {
+ let config_text = r#"{
+ "lint": { "files": { "include": ["src/"] } },
+ "fmt": { "files": { "include": ["src/"] } },
+ "test": { "files": { "exclude": ["dist/"] } },
+ "bench": { "files": { "exclude": ["dist/"] } }
+ }"#;
+ let config_dir = ModuleSpecifier::parse("file:///deno/").unwrap();
+ let config_specifier = config_dir.join("tsconfig.json").unwrap();
+ let config_file = ConfigFile::new(config_text, &config_specifier).unwrap();
+
+ let lint_include = unpack_object(config_file.to_lint_config(), "lint")
+ .files
+ .include;
+ assert_eq!(lint_include, vec![PathBuf::from("/deno/src/")]);
+
+ let fmt_include = unpack_object(config_file.to_fmt_config(), "fmt")
+ .files
+ .include;
+ assert_eq!(fmt_include, vec![PathBuf::from("/deno/src/")]);
+
+ let test_exclude = unpack_object(config_file.to_test_config(), "test")
+ .files
+ .exclude;
+ assert_eq!(test_exclude, vec![PathBuf::from("/deno/dist/")]);
+
+ let bench_exclude = unpack_object(config_file.to_bench_config(), "bench")
+ .files
+ .exclude;
+ assert_eq!(bench_exclude, vec![PathBuf::from("/deno/dist/")]);
+ }
+
+ #[test]
+ fn test_parse_config_with_deprecated_fmt_options() {
+ let config_text_both = r#"{
+ "fmt": {
+ "options": {
+ "semiColons": true
+ },
+ "semiColons": false
+ }
+ }"#;
+ let config_text_deprecated = r#"{
+ "fmt": {
+ "options": {
+ "semiColons": true
+ }
+ }
+ }"#;
+ let config_specifier =
+ ModuleSpecifier::parse("file:///deno/tsconfig.json").unwrap();
+ let config_file_both =
+ ConfigFile::new(config_text_both, &config_specifier).unwrap();
+ let config_file_deprecated =
+ ConfigFile::new(config_text_deprecated, &config_specifier).unwrap();
+
+ fn unpack_options(config_file: ConfigFile) -> FmtOptionsConfig {
+ unpack_object(config_file.to_fmt_config(), "fmt").options
+ }
+
+ let fmt_options_both = unpack_options(config_file_both);
+ assert_eq!(fmt_options_both.semi_colons, Some(false));
+
+ let fmt_options_deprecated = unpack_options(config_file_deprecated);
+ assert_eq!(fmt_options_deprecated.semi_colons, Some(true));
+ }
+
#[test]
fn test_parse_config_with_empty_file() {
let config_text = "";
diff --git a/cli/schemas/config-file.v1.json b/cli/schemas/config-file.v1.json
index f0b496720..7978a2597 100644
--- a/cli/schemas/config-file.v1.json
+++ b/cli/schemas/config-file.v1.json
@@ -227,6 +227,20 @@
"description": "Configuration for linter",
"type": "object",
"properties": {
+ "include": {
+ "type": "array",
+ "description": "List of files or directories that will be linted.",
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude": {
+ "type": "array",
+ "description": "List of files or directories that will not be linted.",
+ "items": {
+ "type": "string"
+ }
+ },
"files": {
"type": "object",
"properties": {
@@ -293,6 +307,20 @@
"description": "Configuration for formatter",
"type": "object",
"properties": {
+ "include": {
+ "type": "array",
+ "description": "List of files or directories that will be formatted.",
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude": {
+ "type": "array",
+ "description": "List of files or directories that will not be formatted.",
+ "items": {
+ "type": "string"
+ }
+ },
"files": {
"type": "object",
"properties": {
@@ -312,6 +340,40 @@
}
}
},
+ "useTabs": {
+ "description": "Whether to use tabs (true) or spaces (false) for indentation.",
+ "type": "boolean",
+ "default": false
+ },
+ "lineWidth": {
+ "description": "The width of a line the printer will try to stay under. Note that the printer may exceed this width in certain cases.",
+ "type": "number",
+ "default": 80
+ },
+ "indentWidth": {
+ "description": "The number of characters for an indent.",
+ "type": "number",
+ "default": 2
+ },
+ "singleQuote": {
+ "type": "boolean",
+ "description": "Whether to use single quote (true) or double quote (false) for quotation.",
+ "default": false
+ },
+ "proseWrap": {
+ "description": "Define how prose should be wrapped in Markdown files.",
+ "default": "always",
+ "enum": [
+ "always",
+ "never",
+ "preserve"
+ ]
+ },
+ "semiColons": {
+ "description": "Whether to prefer using semicolons.",
+ "type": "boolean",
+ "default": true
+ },
"options": {
"type": "object",
"properties": {
@@ -368,6 +430,20 @@
"description": "Configuration for deno test",
"type": "object",
"properties": {
+ "include": {
+ "type": "array",
+ "description": "List of files or directories that will be searched for tests.",
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude": {
+ "type": "array",
+ "description": "List of files or directories that will not be searched for tests.",
+ "items": {
+ "type": "string"
+ }
+ },
"files": {
"type": "object",
"properties": {
@@ -393,6 +469,20 @@
"description": "Configuration for deno bench",
"type": "object",
"properties": {
+ "include": {
+ "type": "array",
+ "description": "List of files or directories that will be searched for benchmarks.",
+ "items": {
+ "type": "string"
+ }
+ },
+ "exclude": {
+ "type": "array",
+ "description": "List of files or directories that will not be searched for benchmarks.",
+ "items": {
+ "type": "string"
+ }
+ },
"files": {
"type": "object",
"properties": {
diff --git a/cli/tests/integration/fmt_tests.rs b/cli/tests/integration/fmt_tests.rs
index 7812175a7..e47311cf0 100644
--- a/cli/tests/integration/fmt_tests.rs
+++ b/cli/tests/integration/fmt_tests.rs
@@ -229,6 +229,12 @@ itest!(fmt_with_config {
output: "fmt/fmt_with_config.out",
});
+itest!(fmt_with_deprecated_config {
+ args:
+ "fmt --config fmt/with_config/deno.deprecated.jsonc fmt/with_config/subdir",
+ output: "fmt/fmt_with_deprecated_config.out",
+});
+
itest!(fmt_with_config_default {
args: "fmt fmt/with_config/subdir",
output: "fmt/fmt_with_config.out",
diff --git a/cli/tests/integration/test_tests.rs b/cli/tests/integration/test_tests.rs
index cf1665289..0e1a39deb 100644
--- a/cli/tests/integration/test_tests.rs
+++ b/cli/tests/integration/test_tests.rs
@@ -77,6 +77,12 @@ itest!(test_with_config2 {
output: "test/collect2.out",
});
+itest!(test_with_deprecated_config {
+ args: "test --config test/collect/deno.deprecated.jsonc test/collect",
+ exit_code: 0,
+ output: "test/collect.deprecated.out",
+});
+
itest!(test_with_malformed_config {
args: "test --config test/collect/deno.malformed.jsonc",
exit_code: 1,
diff --git a/cli/tests/testdata/bench/collect/deno.jsonc b/cli/tests/testdata/bench/collect/deno.jsonc
index f88d13778..7f8f190d3 100644
--- a/cli/tests/testdata/bench/collect/deno.jsonc
+++ b/cli/tests/testdata/bench/collect/deno.jsonc
@@ -1,7 +1,5 @@
{
- "bench": {
- "files": {
- "exclude": ["./ignore"]
- }
- }
+ "bench": {
+ "exclude": ["./ignore"]
+ }
}
diff --git a/cli/tests/testdata/bench/collect/deno.malformed.jsonc b/cli/tests/testdata/bench/collect/deno.malformed.jsonc
index 02744bc11..8e558fbcf 100644
--- a/cli/tests/testdata/bench/collect/deno.malformed.jsonc
+++ b/cli/tests/testdata/bench/collect/deno.malformed.jsonc
@@ -1,5 +1,5 @@
{
- "bench": {
- "dont_know_this_field": {}
- }
+ "bench": {
+ "dont_know_this_field": {}
+ }
}
diff --git a/cli/tests/testdata/bench/collect/deno2.jsonc b/cli/tests/testdata/bench/collect/deno2.jsonc
index f24da5049..653ab1e31 100644
--- a/cli/tests/testdata/bench/collect/deno2.jsonc
+++ b/cli/tests/testdata/bench/collect/deno2.jsonc
@@ -1,8 +1,6 @@
{
- "bench": {
- "files": {
- "include": ["./include/"],
- "exclude": ["./ignore", "./include/2_bench.ts"]
- }
- }
+ "bench": {
+ "include": ["./include/"],
+ "exclude": ["./ignore", "./include/2_bench.ts"]
+ }
}
diff --git a/cli/tests/testdata/bench/collect_with_malformed_config.out b/cli/tests/testdata/bench/collect_with_malformed_config.out
index 10e64707c..92e5e29d2 100644
--- a/cli/tests/testdata/bench/collect_with_malformed_config.out
+++ b/cli/tests/testdata/bench/collect_with_malformed_config.out
@@ -1,4 +1,4 @@
error: Failed to parse "bench" configuration
Caused by:
- unknown field `dont_know_this_field`, expected `files`
+ unknown field `dont_know_this_field`, expected one of `include`, `exclude`, `files`
diff --git a/cli/tests/testdata/fmt/deno.malformed.jsonc b/cli/tests/testdata/fmt/deno.malformed.jsonc
index c6200c4ee..e326edb1f 100644
--- a/cli/tests/testdata/fmt/deno.malformed.jsonc
+++ b/cli/tests/testdata/fmt/deno.malformed.jsonc
@@ -1,9 +1,7 @@
{
"fmt": {
- "files": {
- "include": ["fmt_with_config/"],
- "exclude": ["fmt_with_config/b.ts"]
- },
+ "include": ["fmt_with_config/"],
+ "exclude": ["fmt_with_config/b.ts"],
"dont_know_this_field": {},
"options": {
"useTabs": true
diff --git a/cli/tests/testdata/fmt/deno.malformed2.jsonc b/cli/tests/testdata/fmt/deno.malformed2.jsonc
index 4d6e99ae2..e326edb1f 100644
--- a/cli/tests/testdata/fmt/deno.malformed2.jsonc
+++ b/cli/tests/testdata/fmt/deno.malformed2.jsonc
@@ -1,10 +1,8 @@
{
"fmt": {
- "files": {
- "include": ["fmt_with_config/"],
- "exclude": ["fmt_with_config/b.ts"],
- "dont_know_this_field": {}
- },
+ "include": ["fmt_with_config/"],
+ "exclude": ["fmt_with_config/b.ts"],
+ "dont_know_this_field": {},
"options": {
"useTabs": true
}
diff --git a/cli/tests/testdata/fmt/fmt_with_deprecated_config.out b/cli/tests/testdata/fmt/fmt_with_deprecated_config.out
new file mode 100644
index 000000000..793fac1bc
--- /dev/null
+++ b/cli/tests/testdata/fmt/fmt_with_deprecated_config.out
@@ -0,0 +1,3 @@
+Warning: "options" configuration is deprecated. Please use "flat" options instead.
+Warning: "files" configuration is deprecated. Please use "include" and "exclude" instead.
+Checked 2 files
diff --git a/cli/tests/testdata/fmt/fmt_with_malformed_config.out b/cli/tests/testdata/fmt/fmt_with_malformed_config.out
index 1a55613ef..c269053a6 100644
--- a/cli/tests/testdata/fmt/fmt_with_malformed_config.out
+++ b/cli/tests/testdata/fmt/fmt_with_malformed_config.out
@@ -1,4 +1,4 @@
error: Failed to parse "fmt" configuration
Caused by:
- unknown field `dont_know_this_field`, expected `options` or `files`
+ unknown field `dont_know_this_field`, expected one of `useTabs`, `lineWidth`, `indentWidth`, `singleQuote`, `proseWrap`, `semiColons`, `options`, `include`, `exclude`, `files`
diff --git a/cli/tests/testdata/fmt/fmt_with_malformed_config2.out b/cli/tests/testdata/fmt/fmt_with_malformed_config2.out
index 948b6b5b8..c269053a6 100644
--- a/cli/tests/testdata/fmt/fmt_with_malformed_config2.out
+++ b/cli/tests/testdata/fmt/fmt_with_malformed_config2.out
@@ -1,4 +1,4 @@
error: Failed to parse "fmt" configuration
Caused by:
- unknown field `dont_know_this_field`, expected `include` or `exclude`
+ unknown field `dont_know_this_field`, expected one of `useTabs`, `lineWidth`, `indentWidth`, `singleQuote`, `proseWrap`, `semiColons`, `options`, `include`, `exclude`, `files`
diff --git a/cli/tests/testdata/fmt/with_config/deno.deprecated.jsonc b/cli/tests/testdata/fmt/with_config/deno.deprecated.jsonc
new file mode 100644
index 000000000..e053233fd
--- /dev/null
+++ b/cli/tests/testdata/fmt/with_config/deno.deprecated.jsonc
@@ -0,0 +1,20 @@
+{
+ "fmt": {
+ "files": {
+ "include": [
+ "./subdir/"
+ ],
+ "exclude": [
+ "./subdir/b.ts"
+ ]
+ },
+ "options": {
+ "useTabs": true,
+ "lineWidth": 40,
+ "indentWidth": 8,
+ "singleQuote": true,
+ "proseWrap": "always",
+ "semiColons": false
+ }
+ }
+}
diff --git a/cli/tests/testdata/fmt/with_config/deno.jsonc b/cli/tests/testdata/fmt/with_config/deno.jsonc
index 44e3f9a99..ffd265dcd 100644
--- a/cli/tests/testdata/fmt/with_config/deno.jsonc
+++ b/cli/tests/testdata/fmt/with_config/deno.jsonc
@@ -1,20 +1,16 @@
{
"fmt": {
- "files": {
- "include": [
- "./subdir/"
- ],
- "exclude": [
- "./subdir/b.ts"
- ]
- },
- "options": {
- "useTabs": true,
- "lineWidth": 40,
- "indentWidth": 8,
- "singleQuote": true,
- "proseWrap": "always",
- "semiColons": false
- }
+ "include": [
+ "./subdir/"
+ ],
+ "exclude": [
+ "./subdir/b.ts"
+ ],
+ "useTabs": true,
+ "lineWidth": 40,
+ "indentWidth": 8,
+ "singleQuote": true,
+ "proseWrap": "always",
+ "semiColons": false
}
}
diff --git a/cli/tests/testdata/lint/Deno.compact.format.jsonc b/cli/tests/testdata/lint/Deno.compact.format.jsonc
index 24b159ca6..f3487501a 100644
--- a/cli/tests/testdata/lint/Deno.compact.format.jsonc
+++ b/cli/tests/testdata/lint/Deno.compact.format.jsonc
@@ -1,9 +1,7 @@
{
"lint": {
- "files": {
- "include": ["with_config/"],
- "exclude": ["with_config/b.ts"]
- },
+ "include": ["with_config/"],
+ "exclude": ["with_config/b.ts"],
"rules": {
"tags": ["recommended"],
"include": ["ban-untagged-todo"]
diff --git a/cli/tests/testdata/lint/Deno.jsonc b/cli/tests/testdata/lint/Deno.jsonc
index 24db221a7..e9c03cca4 100644
--- a/cli/tests/testdata/lint/Deno.jsonc
+++ b/cli/tests/testdata/lint/Deno.jsonc
@@ -1,9 +1,7 @@
{
"lint": {
- "files": {
- "include": ["with_config/"],
- "exclude": ["with_config/b.ts"]
- },
+ "include": ["with_config/"],
+ "exclude": ["with_config/b.ts"],
"rules": {
"tags": ["recommended"],
"include": ["ban-untagged-todo"]
diff --git a/cli/tests/testdata/lint/Deno.malformed.jsonc b/cli/tests/testdata/lint/Deno.malformed.jsonc
index 4534a1fe8..fa71cd851 100644
--- a/cli/tests/testdata/lint/Deno.malformed.jsonc
+++ b/cli/tests/testdata/lint/Deno.malformed.jsonc
@@ -1,9 +1,7 @@
{
"lint": {
- "files": {
- "include": ["with_config/"],
- "exclude": ["with_config/b.ts"]
- },
+ "include": ["with_config/"],
+ "exclude": ["with_config/b.ts"],
"dont_know_this_field": {},
"rules": {
"tags": ["recommended"],
diff --git a/cli/tests/testdata/lint/Deno.malformed2.jsonc b/cli/tests/testdata/lint/Deno.malformed2.jsonc
index 335fcdc23..fa71cd851 100644
--- a/cli/tests/testdata/lint/Deno.malformed2.jsonc
+++ b/cli/tests/testdata/lint/Deno.malformed2.jsonc
@@ -1,10 +1,8 @@
{
"lint": {
- "files": {
- "include": ["with_config/"],
- "exclude": ["with_config/b.ts"],
- "dont_know_this_field": {}
- },
+ "include": ["with_config/"],
+ "exclude": ["with_config/b.ts"],
+ "dont_know_this_field": {},
"rules": {
"tags": ["recommended"],
"include": ["ban-untagged-todo"]
diff --git a/cli/tests/testdata/lint/Deno.no_tags.jsonc b/cli/tests/testdata/lint/Deno.no_tags.jsonc
index 4771b0b73..b63600a90 100644
--- a/cli/tests/testdata/lint/Deno.no_tags.jsonc
+++ b/cli/tests/testdata/lint/Deno.no_tags.jsonc
@@ -1,13 +1,11 @@
{
"lint": {
- "files": {
- "include": [
- "with_config/"
- ],
- "exclude": [
- "with_config/b.ts"
- ]
- },
+ "include": [
+ "with_config/"
+ ],
+ "exclude": [
+ "with_config/b.ts"
+ ],
"rules": {
"include": [
"ban-untagged-todo"
diff --git a/cli/tests/testdata/lint/with_malformed_config.out b/cli/tests/testdata/lint/with_malformed_config.out
index 3aa491065..1c0f0fff6 100644
--- a/cli/tests/testdata/lint/with_malformed_config.out
+++ b/cli/tests/testdata/lint/with_malformed_config.out
@@ -1,4 +1,4 @@
error: Failed to parse "lint" configuration
Caused by:
- unknown field `dont_know_this_field`, expected one of `rules`, `files`, `report`
+ unknown field `dont_know_this_field`, expected one of `rules`, `include`, `exclude`, `files`, `report`
diff --git a/cli/tests/testdata/lint/with_malformed_config2.out b/cli/tests/testdata/lint/with_malformed_config2.out
index 11e878f00..1c0f0fff6 100644
--- a/cli/tests/testdata/lint/with_malformed_config2.out
+++ b/cli/tests/testdata/lint/with_malformed_config2.out
@@ -1,4 +1,4 @@
error: Failed to parse "lint" configuration
Caused by:
- unknown field `dont_know_this_field`, expected `include` or `exclude`
+ unknown field `dont_know_this_field`, expected one of `rules`, `include`, `exclude`, `files`, `report`
diff --git a/cli/tests/testdata/lsp/deno.lint.exclude.jsonc b/cli/tests/testdata/lsp/deno.lint.exclude.jsonc
index 89f6108ec..9d4ba52ad 100644
--- a/cli/tests/testdata/lsp/deno.lint.exclude.jsonc
+++ b/cli/tests/testdata/lsp/deno.lint.exclude.jsonc
@@ -1,10 +1,8 @@
{
"lint": {
- "files": {
- "exclude": [
- "ignored.ts"
- ]
- },
+ "exclude": [
+ "ignored.ts"
+ ],
"rules": {
"exclude": [
"camelcase"
diff --git a/cli/tests/testdata/test/collect.deprecated.out b/cli/tests/testdata/test/collect.deprecated.out
new file mode 100644
index 000000000..9bf68807c
--- /dev/null
+++ b/cli/tests/testdata/test/collect.deprecated.out
@@ -0,0 +1,10 @@
+Warning: "files" configuration is deprecated. Please use "include" and "exclude" instead.
+Check [WILDCARD]/test/collect/include/2_test.ts
+Check [WILDCARD]/test/collect/include/test.ts
+Check [WILDCARD]/test/collect/test.ts
+running 0 tests from ./test/collect/include/2_test.ts
+running 0 tests from ./test/collect/include/test.ts
+running 0 tests from ./test/collect/test.ts
+
+ok | 0 passed | 0 failed ([WILDCARD])
+
diff --git a/cli/tests/testdata/test/collect/deno.deprecated.jsonc b/cli/tests/testdata/test/collect/deno.deprecated.jsonc
new file mode 100644
index 000000000..b8acda27d
--- /dev/null
+++ b/cli/tests/testdata/test/collect/deno.deprecated.jsonc
@@ -0,0 +1,7 @@
+{
+ "test": {
+ "files": {
+ "exclude": ["./ignore"]
+ }
+ }
+}
diff --git a/cli/tests/testdata/test/collect/deno.jsonc b/cli/tests/testdata/test/collect/deno.jsonc
index b8acda27d..e14ce86da 100644
--- a/cli/tests/testdata/test/collect/deno.jsonc
+++ b/cli/tests/testdata/test/collect/deno.jsonc
@@ -1,7 +1,5 @@
{
"test": {
- "files": {
- "exclude": ["./ignore"]
- }
+ "exclude": ["./ignore"]
}
}
diff --git a/cli/tests/testdata/test/collect/deno2.jsonc b/cli/tests/testdata/test/collect/deno2.jsonc
index a4d244e31..b7af09d1c 100644
--- a/cli/tests/testdata/test/collect/deno2.jsonc
+++ b/cli/tests/testdata/test/collect/deno2.jsonc
@@ -1,8 +1,6 @@
{
"test": {
- "files": {
- "include": ["./include/"],
- "exclude": ["./ignore", "./include/2_test.ts"]
- }
+ "include": ["./include/"],
+ "exclude": ["./ignore", "./include/2_test.ts"]
}
}
diff --git a/cli/tests/testdata/test/collect_with_malformed_config.out b/cli/tests/testdata/test/collect_with_malformed_config.out
index 25c34406f..b31b18e6a 100644
--- a/cli/tests/testdata/test/collect_with_malformed_config.out
+++ b/cli/tests/testdata/test/collect_with_malformed_config.out
@@ -1,4 +1,4 @@
error: Failed to parse "test" configuration
Caused by:
- unknown field `dont_know_this_field`, expected `files`
+ unknown field `dont_know_this_field`, expected one of `include`, `exclude`, `files`