diff --git a/.editorconfig b/.editorconfig index e38fe5895c9..115b0ff1dc1 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,7 +10,7 @@ indent_size = 2 # YAML doesn't support hard tabs 🙃 # Templates that will be weird with hard tabs in the website editor -[{**.yml, **.md, **.rs, **.mdx}] +[{**.yml, **.md, **.rs, **.mdx, justfile}] indent_style = space [*.rs] diff --git a/crates/rome_cli/src/vcs.rs b/crates/rome_cli/src/vcs.rs index 32f46047d5c..da00d9fc97e 100644 --- a/crates/rome_cli/src/vcs.rs +++ b/crates/rome_cli/src/vcs.rs @@ -1,10 +1,9 @@ use crate::diagnostics::{DisabledVcs, NoVcsFolderFound}; use crate::{CliDiagnostic, CliSession}; -use indexmap::IndexSet; use rome_console::{markup, ConsoleExt}; use rome_diagnostics::PrintDiagnostic; use rome_service::configuration::vcs::{VcsClientKind, VcsConfiguration}; -use rome_service::configuration::FilesConfiguration; +use rome_service::configuration::{FilesConfiguration, StringSet}; use rome_service::{Configuration, WorkspaceError}; use std::path::PathBuf; @@ -40,7 +39,7 @@ pub(crate) fn store_path_to_ignore_from_vcs( let files = configuration .files .get_or_insert_with(FilesConfiguration::default); - let ignored_files = files.ignore.get_or_insert_with(IndexSet::new); + let ignored_files = files.ignore.get_or_insert_with(StringSet::default); ignored_files.extend(files_to_ignore.into_iter()); } } diff --git a/crates/rome_service/src/configuration/formatter.rs b/crates/rome_service/src/configuration/formatter.rs index 7dc4e66788a..032cc9125f0 100644 --- a/crates/rome_service/src/configuration/formatter.rs +++ b/crates/rome_service/src/configuration/formatter.rs @@ -1,6 +1,6 @@ +use crate::configuration::string_set::StringSet; use crate::settings::FormatSettings; use crate::{ConfigurationDiagnostic, MatchOptions, Matcher, WorkspaceError}; -use indexmap::IndexSet; use rome_formatter::{IndentStyle, LineWidth}; use serde::{Deserialize, Serialize}; @@ -30,12 +30,8 @@ pub struct FormatterConfiguration { /// A list of Unix shell style patterns. The formatter will ignore files/folders that will /// match these patterns. - #[serde( - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::deserialize_set_of_strings", - serialize_with = "crate::serialize_set_of_strings" - )] - pub ignore: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub ignore: Option, } impl FormatterConfiguration { @@ -76,8 +72,8 @@ impl TryFrom for FormatSettings { require_literal_separator: false, }); if let Some(ignore) = conf.ignore { - for pattern in ignore { - matcher.add_pattern(&pattern).map_err(|err| { + for pattern in ignore.index_set() { + matcher.add_pattern(pattern).map_err(|err| { WorkspaceError::Configuration( ConfigurationDiagnostic::new_invalid_ignore_pattern( pattern.to_string(), diff --git a/crates/rome_service/src/configuration/javascript.rs b/crates/rome_service/src/configuration/javascript.rs index 0e84d144df5..e8388e34d22 100644 --- a/crates/rome_service/src/configuration/javascript.rs +++ b/crates/rome_service/src/configuration/javascript.rs @@ -1,4 +1,4 @@ -use indexmap::IndexSet; +use crate::configuration::string_set::StringSet; use rome_js_formatter::context::{ trailing_comma::TrailingComma, QuoteProperties, QuoteStyle, Semicolons, }; @@ -14,12 +14,8 @@ pub struct JavascriptConfiguration { /// A list of global bindings that should be ignored by the analyzers /// /// If defined here, they should not emit diagnostics. - #[serde( - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::deserialize_set_of_strings", - serialize_with = "crate::serialize_set_of_strings" - )] - pub globals: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub globals: Option, #[serde(skip_serializing_if = "Option::is_none")] pub organize_imports: Option, diff --git a/crates/rome_service/src/configuration/linter/mod.rs b/crates/rome_service/src/configuration/linter/mod.rs index a9317967a1d..9a5fe080645 100644 --- a/crates/rome_service/src/configuration/linter/mod.rs +++ b/crates/rome_service/src/configuration/linter/mod.rs @@ -2,9 +2,9 @@ mod rules; pub use crate::configuration::linter::rules::Rules; +use crate::configuration::string_set::StringSet; use crate::settings::LinterSettings; use crate::{ConfigurationDiagnostic, MatchOptions, Matcher, WorkspaceError}; -use indexmap::IndexSet; use rome_diagnostics::Severity; pub use rules::*; #[cfg(feature = "schemars")] @@ -24,12 +24,8 @@ pub struct LinterConfiguration { /// A list of Unix shell style patterns. The formatter will ignore files/folders that will /// match these patterns. - #[serde( - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::deserialize_set_of_strings", - serialize_with = "crate::serialize_set_of_strings" - )] - pub ignore: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub ignore: Option, } impl LinterConfiguration { @@ -56,8 +52,8 @@ impl TryFrom for LinterSettings { require_literal_separator: false, }); if let Some(ignore) = conf.ignore { - for pattern in ignore { - matcher.add_pattern(&pattern).map_err(|err| { + for pattern in ignore.index_set() { + matcher.add_pattern(pattern).map_err(|err| { WorkspaceError::Configuration( ConfigurationDiagnostic::new_invalid_ignore_pattern( pattern.to_string(), diff --git a/crates/rome_service/src/configuration/mod.rs b/crates/rome_service/src/configuration/mod.rs index b3d3eaff3b9..1beb7873f39 100644 --- a/crates/rome_service/src/configuration/mod.rs +++ b/crates/rome_service/src/configuration/mod.rs @@ -4,14 +4,10 @@ //! by language. The language might further options divided by tool. use crate::{DynRef, WorkspaceError}; -use indexmap::IndexSet; use rome_fs::{FileSystem, OpenOptions}; -use serde::de::{SeqAccess, Visitor}; -use serde::ser::SerializeSeq; use serde::{Deserialize, Serialize}; use std::fmt::Debug; use std::io::ErrorKind; -use std::marker::PhantomData; use std::num::NonZeroU64; use std::path::{Path, PathBuf}; @@ -22,11 +18,13 @@ mod javascript; pub mod linter; pub mod organize_imports; mod parse; +pub mod string_set; pub mod vcs; pub use crate::configuration::diagnostics::ConfigurationDiagnostic; use crate::configuration::generated::push_to_analyzer_rules; use crate::configuration::organize_imports::OrganizeImports; +pub use crate::configuration::string_set::StringSet; use crate::configuration::vcs::VcsConfiguration; use crate::settings::{LanguagesSettings, LinterSettings}; pub use formatter::{FormatterConfiguration, PlainIndentStyle}; @@ -135,12 +133,8 @@ pub struct FilesConfiguration { /// A list of Unix shell style patterns. Rome tools will ignore files/folders that will /// match these patterns. - #[serde( - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::deserialize_set_of_strings", - serialize_with = "crate::serialize_set_of_strings" - )] - pub ignore: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub ignore: Option, } impl FilesConfiguration { @@ -257,70 +251,6 @@ pub fn create_config( Ok(()) } -/// Some documentation -pub fn deserialize_set_of_strings<'de, D>( - deserializer: D, -) -> Result>, D::Error> -where - D: serde::de::Deserializer<'de>, -{ - struct IndexVisitor { - marker: PhantomData Option>>, - } - - impl IndexVisitor { - fn new() -> Self { - IndexVisitor { - marker: PhantomData, - } - } - } - - impl<'de> Visitor<'de> for IndexVisitor { - type Value = Option>; - - // Format a message stating what data this Visitor expects to receive. - fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { - formatter.write_str("expecting a sequence") - } - - fn visit_seq(self, mut seq: A) -> Result - where - A: SeqAccess<'de>, - { - let mut index_set = IndexSet::with_capacity(seq.size_hint().unwrap_or(0)); - - while let Some(value) = seq.next_element()? { - index_set.insert(value); - } - - Ok(Some(index_set)) - } - } - - deserializer.deserialize_seq(IndexVisitor::new()) -} - -pub fn serialize_set_of_strings( - set_of_strings: &Option>, - s: S, -) -> Result -where - S: serde::ser::Serializer, -{ - if let Some(set_of_strings) = set_of_strings { - let mut sequence = s.serialize_seq(Some(set_of_strings.len()))?; - let iter = set_of_strings.into_iter(); - for global in iter { - sequence.serialize_element(global)?; - } - - sequence.end() - } else { - s.serialize_none() - } -} - /// Converts a [WorkspaceSettings] into a suited [configuration for the analyzer]. /// /// The function needs access to a filter, in order to have an easy access to the [metadata] of the diff --git a/crates/rome_service/src/configuration/organize_imports.rs b/crates/rome_service/src/configuration/organize_imports.rs index 653cfd8820a..da7d571d135 100644 --- a/crates/rome_service/src/configuration/organize_imports.rs +++ b/crates/rome_service/src/configuration/organize_imports.rs @@ -1,6 +1,6 @@ +use crate::configuration::string_set::StringSet; use crate::settings::OrganizeImportsSettings; use crate::{ConfigurationDiagnostic, MatchOptions, Matcher, WorkspaceError}; -use indexmap::IndexSet; use serde::{Deserialize, Serialize}; #[derive(Debug, Default, Serialize, Deserialize, Eq, PartialEq)] @@ -12,12 +12,8 @@ pub struct OrganizeImports { /// A list of Unix shell style patterns. The formatter will ignore files/folders that will /// match these patterns. - #[serde( - skip_serializing_if = "Option::is_none", - deserialize_with = "crate::deserialize_set_of_strings", - serialize_with = "crate::serialize_set_of_strings" - )] - pub ignore: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub ignore: Option, } impl TryFrom for OrganizeImportsSettings { @@ -30,8 +26,8 @@ impl TryFrom for OrganizeImportsSettings { require_literal_separator: false, }); if let Some(ignore) = organize_imports.ignore { - for pattern in ignore { - matcher.add_pattern(&pattern).map_err(|err| { + for pattern in ignore.index_set() { + matcher.add_pattern(pattern).map_err(|err| { WorkspaceError::Configuration( ConfigurationDiagnostic::new_invalid_ignore_pattern( pattern.to_string(), diff --git a/crates/rome_service/src/configuration/parse/json/files.rs b/crates/rome_service/src/configuration/parse/json/files.rs index 03beb4774e5..460b3c981aa 100644 --- a/crates/rome_service/src/configuration/parse/json/files.rs +++ b/crates/rome_service/src/configuration/parse/json/files.rs @@ -1,3 +1,4 @@ +use crate::configuration::string_set::StringSet; use crate::configuration::FilesConfiguration; use rome_deserialize::json::{has_only_known_keys, VisitJsonNode}; use rome_deserialize::{DeserializationDiagnostic, VisitNode}; @@ -30,7 +31,9 @@ impl VisitNode for FilesConfiguration { NonZeroU64::new(self.map_to_u64(&value, name_text, u64::MAX, diagnostics)?); } "ignore" => { - self.ignore = self.map_to_index_set_string(&value, name_text, diagnostics); + self.ignore = self + .map_to_index_set_string(&value, name_text, diagnostics) + .map(StringSet::new); } _ => {} } diff --git a/crates/rome_service/src/configuration/parse/json/formatter.rs b/crates/rome_service/src/configuration/parse/json/formatter.rs index fe2dd9008fc..66b293cf81a 100644 --- a/crates/rome_service/src/configuration/parse/json/formatter.rs +++ b/crates/rome_service/src/configuration/parse/json/formatter.rs @@ -1,3 +1,4 @@ +use crate::configuration::string_set::StringSet; use crate::configuration::{FormatterConfiguration, PlainIndentStyle}; use rome_console::markup; use rome_deserialize::json::{has_only_known_keys, with_only_known_variants, VisitJsonNode}; @@ -33,7 +34,9 @@ impl VisitNode for FormatterConfiguration { self.enabled = self.map_to_boolean(&value, name_text, diagnostics)?; } "ignore" => { - self.ignore = self.map_to_index_set_string(&value, name_text, diagnostics); + self.ignore = self + .map_to_index_set_string(&value, name_text, diagnostics) + .map(StringSet::new); } "indentStyle" => { let mut indent_style = PlainIndentStyle::default(); diff --git a/crates/rome_service/src/configuration/parse/json/javascript.rs b/crates/rome_service/src/configuration/parse/json/javascript.rs index 63e8a4fa163..f6642aca85b 100644 --- a/crates/rome_service/src/configuration/parse/json/javascript.rs +++ b/crates/rome_service/src/configuration/parse/json/javascript.rs @@ -1,4 +1,5 @@ use crate::configuration::javascript::JavascriptOrganizeImports; +use crate::configuration::string_set::StringSet; use crate::configuration::{JavascriptConfiguration, JavascriptFormatter}; use rome_deserialize::json::{has_only_known_keys, VisitJsonNode}; use rome_deserialize::{DeserializationDiagnostic, VisitNode}; @@ -34,7 +35,9 @@ impl VisitNode for JavascriptConfiguration { self.formatter = Some(javascript_formatter); } "globals" => { - self.globals = self.map_to_index_set_string(&value, name_text, diagnostics); + self.globals = self + .map_to_index_set_string(&value, name_text, diagnostics) + .map(StringSet::new); } "organizeImports" => { let mut javascript_organize_imports = JavascriptOrganizeImports::default(); diff --git a/crates/rome_service/src/configuration/parse/json/linter.rs b/crates/rome_service/src/configuration/parse/json/linter.rs index 386119e10bb..5722da4d649 100644 --- a/crates/rome_service/src/configuration/parse/json/linter.rs +++ b/crates/rome_service/src/configuration/parse/json/linter.rs @@ -1,4 +1,5 @@ use crate::configuration::linter::{RulePlainConfiguration, RuleWithOptions}; +use crate::configuration::string_set::StringSet; use crate::configuration::LinterConfiguration; use crate::{RuleConfiguration, Rules}; use rome_console::markup; @@ -28,7 +29,9 @@ impl VisitNode for LinterConfiguration { let name_text = name.text(); match name_text { "ignore" => { - self.ignore = self.map_to_index_set_string(&value, name_text, diagnostics); + self.ignore = self + .map_to_index_set_string(&value, name_text, diagnostics) + .map(StringSet::new); } "enabled" => { self.enabled = self.map_to_boolean(&value, name_text, diagnostics)?; diff --git a/crates/rome_service/src/configuration/parse/json/organize_imports.rs b/crates/rome_service/src/configuration/parse/json/organize_imports.rs index 6e378f14bab..6273a003938 100644 --- a/crates/rome_service/src/configuration/parse/json/organize_imports.rs +++ b/crates/rome_service/src/configuration/parse/json/organize_imports.rs @@ -1,4 +1,5 @@ use crate::configuration::organize_imports::OrganizeImports; +use crate::configuration::string_set::StringSet; use rome_deserialize::json::{has_only_known_keys, VisitJsonNode}; use rome_deserialize::{DeserializationDiagnostic, VisitNode}; use rome_json_syntax::{JsonLanguage, JsonSyntaxNode}; @@ -28,7 +29,9 @@ impl VisitNode for OrganizeImports { self.enabled = self.map_to_boolean(&value, name_text, diagnostics)?; } "ignore" => { - self.ignore = self.map_to_index_set_string(&value, name_text, diagnostics); + self.ignore = self + .map_to_index_set_string(&value, name_text, diagnostics) + .map(StringSet::new); } _ => {} } diff --git a/crates/rome_service/src/configuration/string_set.rs b/crates/rome_service/src/configuration/string_set.rs new file mode 100644 index 00000000000..59f25c5e1ca --- /dev/null +++ b/crates/rome_service/src/configuration/string_set.rs @@ -0,0 +1,97 @@ +use indexmap::IndexSet; +use serde::de::{SeqAccess, Visitor}; +use serde::ser::SerializeSeq; +use serde::{Deserialize, Serialize}; +use std::marker::PhantomData; + +#[derive(Default, Debug, Deserialize, Serialize, Eq, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct StringSet( + #[serde( + deserialize_with = "crate::deserialize_string_set", + serialize_with = "crate::serialize_string_set" + )] + IndexSet, +); + +impl StringSet { + pub fn new(index_set: IndexSet) -> Self { + Self(index_set) + } + + pub fn len(&self) -> usize { + self.0.len() + } + + pub fn is_empty(&self) -> bool { + self.0.len() == 0 + } + + pub fn index_set(&self) -> &IndexSet { + &self.0 + } + + pub fn into_index_set(self) -> IndexSet { + self.0 + } + + pub fn extend(&mut self, entries: impl IntoIterator) { + self.0.extend(entries); + } +} + +/// Some documentation +pub fn deserialize_string_set<'de, D>(deserializer: D) -> Result, D::Error> +where + D: serde::de::Deserializer<'de>, +{ + struct IndexVisitor { + marker: PhantomData IndexSet>, + } + + impl IndexVisitor { + fn new() -> Self { + IndexVisitor { + marker: PhantomData, + } + } + } + + impl<'de> Visitor<'de> for IndexVisitor { + type Value = IndexSet; + + // Format a message stating what data this Visitor expects to receive. + fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { + formatter.write_str("expecting a sequence") + } + + fn visit_seq(self, mut seq: A) -> Result + where + A: SeqAccess<'de>, + { + let mut index_set = IndexSet::with_capacity(seq.size_hint().unwrap_or(0)); + + while let Some(value) = seq.next_element()? { + index_set.insert(value); + } + + Ok(index_set) + } + } + + deserializer.deserialize_seq(IndexVisitor::new()) +} + +pub fn serialize_string_set(string_set: &IndexSet, s: S) -> Result +where + S: serde::ser::Serializer, +{ + let mut sequence = s.serialize_seq(Some(string_set.len()))?; + let iter = string_set.into_iter(); + for global in iter { + sequence.serialize_element(&global)?; + } + + sequence.end() +} diff --git a/crates/rome_service/src/lib.rs b/crates/rome_service/src/lib.rs index e4b2256a80f..e864fa43c06 100644 --- a/crates/rome_service/src/lib.rs +++ b/crates/rome_service/src/lib.rs @@ -14,13 +14,13 @@ mod diagnostics; pub mod workspace_types; pub use crate::configuration::{ - create_config, load_config, Configuration, ConfigurationBasePath, ConfigurationDiagnostic, - RuleConfiguration, Rules, + create_config, load_config, + string_set::{deserialize_string_set, serialize_string_set}, + Configuration, ConfigurationBasePath, ConfigurationDiagnostic, RuleConfiguration, Rules, }; pub use crate::matcher::{MatchOptions, Matcher, Pattern}; /// Exports only for this crate -pub(crate) use crate::configuration::{deserialize_set_of_strings, serialize_set_of_strings}; pub use crate::file_handlers::JsFormatterSettings; pub use crate::workspace::Workspace; diff --git a/crates/rome_service/src/settings.rs b/crates/rome_service/src/settings.rs index 778bb9be79d..887e37668cf 100644 --- a/crates/rome_service/src/settings.rs +++ b/crates/rome_service/src/settings.rs @@ -72,7 +72,7 @@ impl WorkspaceSettings { // javascript settings let javascript = configuration.javascript; if let Some(javascript) = javascript { - self.languages.javascript.globals = javascript.globals; + self.languages.javascript.globals = javascript.globals.map(|g| g.into_index_set()); let formatter = javascript.formatter; if let Some(formatter) = formatter { self.languages.javascript.formatter.quote_style = Some(formatter.quote_style); @@ -272,8 +272,8 @@ impl TryFrom for FilesSettings { require_literal_separator: false, }); if let Some(ignore) = config.ignore { - for pattern in ignore { - matcher.add_pattern(&pattern).map_err(|err| { + for pattern in ignore.index_set() { + matcher.add_pattern(pattern).map_err(|err| { WorkspaceError::Configuration( ConfigurationDiagnostic::new_invalid_ignore_pattern( pattern.to_string(), diff --git a/editors/vscode/configuration_schema.json b/editors/vscode/configuration_schema.json index 9dce3677a0c..5fb4035e49e 100644 --- a/editors/vscode/configuration_schema.json +++ b/editors/vscode/configuration_schema.json @@ -350,9 +350,7 @@ "properties": { "ignore": { "description": "A list of Unix shell style patterns. Rome tools will ignore files/folders that will match these patterns.", - "type": ["array", "null"], - "items": { "type": "string" }, - "uniqueItems": true + "anyOf": [{ "$ref": "#/definitions/StringSet" }, { "type": "null" }] }, "maxSize": { "description": "The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reason. Defaults to 1 MiB", @@ -375,9 +373,7 @@ }, "ignore": { "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", - "type": ["array", "null"], - "items": { "type": "string" }, - "uniqueItems": true + "anyOf": [{ "$ref": "#/definitions/StringSet" }, { "type": "null" }] }, "indentSize": { "description": "The size of the indentation, 2 by default", @@ -410,9 +406,7 @@ }, "globals": { "description": "A list of global bindings that should be ignored by the analyzers\n\nIf defined here, they should not emit diagnostics.", - "type": ["array", "null"], - "items": { "type": "string" }, - "uniqueItems": true + "anyOf": [{ "$ref": "#/definitions/StringSet" }, { "type": "null" }] }, "organize_imports": { "anyOf": [ @@ -469,9 +463,7 @@ }, "ignore": { "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", - "type": ["array", "null"], - "items": { "type": "string" }, - "uniqueItems": true + "anyOf": [{ "$ref": "#/definitions/StringSet" }, { "type": "null" }] }, "rules": { "description": "List of rules", @@ -883,9 +875,7 @@ }, "ignore": { "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", - "type": ["array", "null"], - "items": { "type": "string" }, - "uniqueItems": true + "anyOf": [{ "$ref": "#/definitions/StringSet" }, { "type": "null" }] } }, "additionalProperties": false @@ -1005,6 +995,11 @@ } }, "Semicolons": { "type": "string", "enum": ["always", "asNeeded"] }, + "StringSet": { + "type": "array", + "items": { "type": "string" }, + "uniqueItems": true + }, "Style": { "description": "A list of rules that belong to this group", "type": "object", diff --git a/justfile b/justfile index 30e2d23008e..5bfaa84c5a6 100644 --- a/justfile +++ b/justfile @@ -4,6 +4,9 @@ _default: codegen: cargo codegen all cargo codegen-configuration + just codegen-bindings + +codegen-bindings: cargo codegen-schema cargo codegen-bindings @@ -11,8 +14,7 @@ codegen: codegen-linter: cargo codegen analyzer cargo codegen-configuration - cargo codegen-schema - cargo codegen-bindings + just codegen-bindings cargo lintdoc # Generates the documentation diff --git a/npm/backend-jsonrpc/src/workspace.ts b/npm/backend-jsonrpc/src/workspace.ts index 74c3a74a8d7..8192728c009 100644 --- a/npm/backend-jsonrpc/src/workspace.ts +++ b/npm/backend-jsonrpc/src/workspace.ts @@ -58,7 +58,7 @@ export interface FilesConfiguration { /** * A list of Unix shell style patterns. Rome tools will ignore files/folders that will match these patterns. */ - ignore?: string[]; + ignore?: StringSet; /** * The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reason. Defaults to 1 MiB */ @@ -73,7 +73,7 @@ export interface FormatterConfiguration { /** * A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns. */ - ignore?: string[]; + ignore?: StringSet; /** * The size of the indentation, 2 by default */ @@ -94,7 +94,7 @@ export interface JavascriptConfiguration { If defined here, they should not emit diagnostics. */ - globals?: string[]; + globals?: StringSet; organize_imports?: JavascriptOrganizeImports; } export interface LinterConfiguration { @@ -105,7 +105,7 @@ export interface LinterConfiguration { /** * A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns. */ - ignore?: string[]; + ignore?: StringSet; /** * List of rules */ @@ -119,7 +119,7 @@ export interface OrganizeImports { /** * A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns. */ - ignore?: string[]; + ignore?: StringSet; } /** * Set @@ -144,6 +144,7 @@ If Rome can't fine the configuration, it will attempt to use the current working */ useIgnoreFile?: boolean; } +export type StringSet = string[]; export type PlainIndentStyle = "tab" | "space"; /** * Validated value for the `line_width` formatter options diff --git a/npm/rome/configuration_schema.json b/npm/rome/configuration_schema.json index 9dce3677a0c..5fb4035e49e 100644 --- a/npm/rome/configuration_schema.json +++ b/npm/rome/configuration_schema.json @@ -350,9 +350,7 @@ "properties": { "ignore": { "description": "A list of Unix shell style patterns. Rome tools will ignore files/folders that will match these patterns.", - "type": ["array", "null"], - "items": { "type": "string" }, - "uniqueItems": true + "anyOf": [{ "$ref": "#/definitions/StringSet" }, { "type": "null" }] }, "maxSize": { "description": "The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reason. Defaults to 1 MiB", @@ -375,9 +373,7 @@ }, "ignore": { "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", - "type": ["array", "null"], - "items": { "type": "string" }, - "uniqueItems": true + "anyOf": [{ "$ref": "#/definitions/StringSet" }, { "type": "null" }] }, "indentSize": { "description": "The size of the indentation, 2 by default", @@ -410,9 +406,7 @@ }, "globals": { "description": "A list of global bindings that should be ignored by the analyzers\n\nIf defined here, they should not emit diagnostics.", - "type": ["array", "null"], - "items": { "type": "string" }, - "uniqueItems": true + "anyOf": [{ "$ref": "#/definitions/StringSet" }, { "type": "null" }] }, "organize_imports": { "anyOf": [ @@ -469,9 +463,7 @@ }, "ignore": { "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", - "type": ["array", "null"], - "items": { "type": "string" }, - "uniqueItems": true + "anyOf": [{ "$ref": "#/definitions/StringSet" }, { "type": "null" }] }, "rules": { "description": "List of rules", @@ -883,9 +875,7 @@ }, "ignore": { "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", - "type": ["array", "null"], - "items": { "type": "string" }, - "uniqueItems": true + "anyOf": [{ "$ref": "#/definitions/StringSet" }, { "type": "null" }] } }, "additionalProperties": false @@ -1005,6 +995,11 @@ } }, "Semicolons": { "type": "string", "enum": ["always", "asNeeded"] }, + "StringSet": { + "type": "array", + "items": { "type": "string" }, + "uniqueItems": true + }, "Style": { "description": "A list of rules that belong to this group", "type": "object",