repo stringlengths 6 65 | file_url stringlengths 81 311 | file_path stringlengths 6 227 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:31:58 2026-01-04 20:25:31 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/classes/constructor_class_member.rs | crates/rome_js_formatter/src/js/classes/constructor_class_member.rs | use crate::prelude::*;
use crate::js::classes::method_class_member::FormatAnyJsMethodMember;
use rome_formatter::write;
use rome_js_syntax::JsConstructorClassMember;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatJsConstructorClassMember;
impl FormatNodeRule<JsConstructorClassMember> for FormatJsConstructorClassMember {
fn fmt_fields(&self, node: &JsConstructorClassMember, f: &mut JsFormatter) -> FormatResult<()> {
write![
f,
[
node.modifiers().format(),
space(),
FormatAnyJsMethodMember::from(node.clone())
]
]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/classes/static_initialization_block_class_member.rs | crates/rome_js_formatter/src/js/classes/static_initialization_block_class_member.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::JsStaticInitializationBlockClassMember;
use rome_js_syntax::JsStaticInitializationBlockClassMemberFields;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatJsStaticInitializationBlockClassMember;
impl FormatNodeRule<JsStaticInitializationBlockClassMember>
for FormatJsStaticInitializationBlockClassMember
{
fn fmt_fields(
&self,
node: &JsStaticInitializationBlockClassMember,
f: &mut JsFormatter,
) -> FormatResult<()> {
let JsStaticInitializationBlockClassMemberFields {
static_token,
l_curly_token,
statements,
r_curly_token,
} = node.as_fields();
write!(f, [static_token.format(), space(), l_curly_token.format()])?;
if statements.is_empty() {
write!(
f,
[format_dangling_comments(node.syntax()).with_block_indent()]
)?;
} else {
write!(f, [block_indent(&statements.format())])?;
}
write!(f, [r_curly_token.format()])
}
fn fmt_dangling_comments(
&self,
_: &JsStaticInitializationBlockClassMember,
_: &mut JsFormatter,
) -> FormatResult<()> {
// Formatted inside of `fmt_fields
Ok(())
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/for_initializer.rs | crates/rome_js_formatter/src/js/any/for_initializer.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsForInitializer;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsForInitializer;
impl FormatRule<AnyJsForInitializer> for FormatAnyJsForInitializer {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsForInitializer, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsForInitializer::JsVariableDeclaration(node) => node.format().fmt(f),
AnyJsForInitializer::AnyJsExpression(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/declaration.rs | crates/rome_js_formatter/src/js/any/declaration.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsDeclaration;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsDeclaration;
impl FormatRule<AnyJsDeclaration> for FormatAnyJsDeclaration {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsDeclaration, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsDeclaration::JsClassDeclaration(node) => node.format().fmt(f),
AnyJsDeclaration::JsFunctionDeclaration(node) => node.format().fmt(f),
AnyJsDeclaration::JsVariableDeclaration(node) => node.format().fmt(f),
AnyJsDeclaration::TsEnumDeclaration(node) => node.format().fmt(f),
AnyJsDeclaration::TsTypeAliasDeclaration(node) => node.format().fmt(f),
AnyJsDeclaration::TsInterfaceDeclaration(node) => node.format().fmt(f),
AnyJsDeclaration::TsDeclareFunctionDeclaration(node) => node.format().fmt(f),
AnyJsDeclaration::TsModuleDeclaration(node) => node.format().fmt(f),
AnyJsDeclaration::TsExternalModuleDeclaration(node) => node.format().fmt(f),
AnyJsDeclaration::TsGlobalDeclaration(node) => node.format().fmt(f),
AnyJsDeclaration::TsImportEqualsDeclaration(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/constructor_parameter.rs | crates/rome_js_formatter/src/js/any/constructor_parameter.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsConstructorParameter;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsConstructorParameter;
impl FormatRule<AnyJsConstructorParameter> for FormatAnyJsConstructorParameter {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsConstructorParameter, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsConstructorParameter::AnyJsFormalParameter(node) => node.format().fmt(f),
AnyJsConstructorParameter::JsRestParameter(node) => node.format().fmt(f),
AnyJsConstructorParameter::TsPropertyParameter(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/object_assignment_pattern_member.rs | crates/rome_js_formatter/src/js/any/object_assignment_pattern_member.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsObjectAssignmentPatternMember;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsObjectAssignmentPatternMember;
impl FormatRule<AnyJsObjectAssignmentPatternMember> for FormatAnyJsObjectAssignmentPatternMember {
type Context = JsFormatContext;
fn fmt(
&self,
node: &AnyJsObjectAssignmentPatternMember,
f: &mut JsFormatter,
) -> FormatResult<()> {
match node {
AnyJsObjectAssignmentPatternMember::JsObjectAssignmentPatternShorthandProperty(
node,
) => node.format().fmt(f),
AnyJsObjectAssignmentPatternMember::JsObjectAssignmentPatternProperty(node) => {
node.format().fmt(f)
}
AnyJsObjectAssignmentPatternMember::JsObjectAssignmentPatternRest(node) => {
node.format().fmt(f)
}
AnyJsObjectAssignmentPatternMember::JsBogusAssignment(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/array_element.rs | crates/rome_js_formatter/src/js/any/array_element.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsArrayElement;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsArrayElement;
impl FormatRule<AnyJsArrayElement> for FormatAnyJsArrayElement {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsArrayElement, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsArrayElement::AnyJsExpression(node) => node.format().fmt(f),
AnyJsArrayElement::JsSpread(node) => node.format().fmt(f),
AnyJsArrayElement::JsArrayHole(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/decorator.rs | crates/rome_js_formatter/src/js/any/decorator.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsDecorator;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsDecorator;
impl FormatRule<AnyJsDecorator> for FormatAnyJsDecorator {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsDecorator, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsDecorator::JsParenthesizedExpression(node) => node.format().fmt(f),
AnyJsDecorator::JsCallExpression(node) => node.format().fmt(f),
AnyJsDecorator::JsStaticMemberExpression(node) => node.format().fmt(f),
AnyJsDecorator::JsIdentifierExpression(node) => node.format().fmt(f),
AnyJsDecorator::JsBogusExpression(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/array_binding_pattern_element.rs | crates/rome_js_formatter/src/js/any/array_binding_pattern_element.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsArrayBindingPatternElement;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsArrayBindingPatternElement;
impl FormatRule<AnyJsArrayBindingPatternElement> for FormatAnyJsArrayBindingPatternElement {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsArrayBindingPatternElement, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsArrayBindingPatternElement::JsArrayHole(node) => node.format().fmt(f),
AnyJsArrayBindingPatternElement::AnyJsBindingPattern(node) => node.format().fmt(f),
AnyJsArrayBindingPatternElement::JsBindingPatternWithDefault(node) => {
node.format().fmt(f)
}
AnyJsArrayBindingPatternElement::JsArrayBindingPatternRestElement(node) => {
node.format().fmt(f)
}
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/arrow_function_parameters.rs | crates/rome_js_formatter/src/js/any/arrow_function_parameters.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsArrowFunctionParameters;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsArrowFunctionParameters;
impl FormatRule<AnyJsArrowFunctionParameters> for FormatAnyJsArrowFunctionParameters {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsArrowFunctionParameters, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsArrowFunctionParameters::JsParameters(node) => node.format().fmt(f),
AnyJsArrowFunctionParameters::AnyJsBinding(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/object_member.rs | crates/rome_js_formatter/src/js/any/object_member.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsObjectMember;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsObjectMember;
impl FormatRule<AnyJsObjectMember> for FormatAnyJsObjectMember {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsObjectMember, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsObjectMember::JsPropertyObjectMember(node) => node.format().fmt(f),
AnyJsObjectMember::JsMethodObjectMember(node) => node.format().fmt(f),
AnyJsObjectMember::JsGetterObjectMember(node) => node.format().fmt(f),
AnyJsObjectMember::JsSetterObjectMember(node) => node.format().fmt(f),
AnyJsObjectMember::JsShorthandPropertyObjectMember(node) => node.format().fmt(f),
AnyJsObjectMember::JsSpread(node) => node.format().fmt(f),
AnyJsObjectMember::JsBogusMember(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/named_import_specifier.rs | crates/rome_js_formatter/src/js/any/named_import_specifier.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsNamedImportSpecifier;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsNamedImportSpecifier;
impl FormatRule<AnyJsNamedImportSpecifier> for FormatAnyJsNamedImportSpecifier {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsNamedImportSpecifier, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsNamedImportSpecifier::JsShorthandNamedImportSpecifier(node) => {
node.format().fmt(f)
}
AnyJsNamedImportSpecifier::JsNamedImportSpecifier(node) => node.format().fmt(f),
AnyJsNamedImportSpecifier::JsBogusNamedImportSpecifier(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/class.rs | crates/rome_js_formatter/src/js/any/class.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsClass;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsClass;
impl FormatRule<AnyJsClass> for FormatAnyJsClass {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsClass, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsClass::JsClassDeclaration(node) => node.format().fmt(f),
AnyJsClass::JsClassExpression(node) => node.format().fmt(f),
AnyJsClass::JsClassExportDefaultDeclaration(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/method_modifier.rs | crates/rome_js_formatter/src/js/any/method_modifier.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsMethodModifier;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsMethodModifier;
impl FormatRule<AnyJsMethodModifier> for FormatAnyJsMethodModifier {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsMethodModifier, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsMethodModifier::TsAccessibilityModifier(node) => node.format().fmt(f),
AnyJsMethodModifier::JsStaticModifier(node) => node.format().fmt(f),
AnyJsMethodModifier::JsDecorator(node) => node.format().fmt(f),
AnyJsMethodModifier::TsOverrideModifier(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/root.rs | crates/rome_js_formatter/src/js/any/root.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsRoot;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsRoot;
impl FormatRule<AnyJsRoot> for FormatAnyJsRoot {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsRoot, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsRoot::JsScript(node) => node.format().fmt(f),
AnyJsRoot::JsModule(node) => node.format().fmt(f),
AnyJsRoot::JsExpressionSnipped(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/array_assignment_pattern_element.rs | crates/rome_js_formatter/src/js/any/array_assignment_pattern_element.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsArrayAssignmentPatternElement;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsArrayAssignmentPatternElement;
impl FormatRule<AnyJsArrayAssignmentPatternElement> for FormatAnyJsArrayAssignmentPatternElement {
type Context = JsFormatContext;
fn fmt(
&self,
node: &AnyJsArrayAssignmentPatternElement,
f: &mut JsFormatter,
) -> FormatResult<()> {
match node {
AnyJsArrayAssignmentPatternElement::JsAssignmentWithDefault(node) => {
node.format().fmt(f)
}
AnyJsArrayAssignmentPatternElement::AnyJsAssignmentPattern(node) => {
node.format().fmt(f)
}
AnyJsArrayAssignmentPatternElement::JsArrayAssignmentPatternRestElement(node) => {
node.format().fmt(f)
}
AnyJsArrayAssignmentPatternElement::JsArrayHole(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/export_named_specifier.rs | crates/rome_js_formatter/src/js/any/export_named_specifier.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsExportNamedSpecifier;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsExportNamedSpecifier;
impl FormatRule<AnyJsExportNamedSpecifier> for FormatAnyJsExportNamedSpecifier {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsExportNamedSpecifier, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsExportNamedSpecifier::JsExportNamedShorthandSpecifier(node) => {
node.format().fmt(f)
}
AnyJsExportNamedSpecifier::JsExportNamedSpecifier(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/template_element.rs | crates/rome_js_formatter/src/js/any/template_element.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsTemplateElement;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsTemplateElement;
impl FormatRule<AnyJsTemplateElement> for FormatAnyJsTemplateElement {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsTemplateElement, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsTemplateElement::JsTemplateChunkElement(node) => node.format().fmt(f),
AnyJsTemplateElement::JsTemplateElement(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/function.rs | crates/rome_js_formatter/src/js/any/function.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsFunction;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsFunction;
impl FormatRule<AnyJsFunction> for FormatAnyJsFunction {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsFunction, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsFunction::JsFunctionExpression(node) => node.format().fmt(f),
AnyJsFunction::JsFunctionDeclaration(node) => node.format().fmt(f),
AnyJsFunction::JsArrowFunctionExpression(node) => node.format().fmt(f),
AnyJsFunction::JsFunctionExportDefaultDeclaration(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/object_member_name.rs | crates/rome_js_formatter/src/js/any/object_member_name.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsObjectMemberName;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsObjectMemberName;
impl FormatRule<AnyJsObjectMemberName> for FormatAnyJsObjectMemberName {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsObjectMemberName, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsObjectMemberName::JsLiteralMemberName(node) => node.format().fmt(f),
AnyJsObjectMemberName::JsComputedMemberName(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/call_argument.rs | crates/rome_js_formatter/src/js/any/call_argument.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsCallArgument;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsCallArgument;
impl FormatRule<AnyJsCallArgument> for FormatAnyJsCallArgument {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsCallArgument, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsCallArgument::AnyJsExpression(node) => node.format().fmt(f),
AnyJsCallArgument::JsSpread(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/function_body.rs | crates/rome_js_formatter/src/js/any/function_body.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsFunctionBody;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsFunctionBody;
impl FormatRule<AnyJsFunctionBody> for FormatAnyJsFunctionBody {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsFunctionBody, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsFunctionBody::AnyJsExpression(node) => node.format().fmt(f),
AnyJsFunctionBody::JsFunctionBody(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/export_default_declaration.rs | crates/rome_js_formatter/src/js/any/export_default_declaration.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsExportDefaultDeclaration;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsExportDefaultDeclaration;
impl FormatRule<AnyJsExportDefaultDeclaration> for FormatAnyJsExportDefaultDeclaration {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsExportDefaultDeclaration, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsExportDefaultDeclaration::JsClassExportDefaultDeclaration(node) => {
node.format().fmt(f)
}
AnyJsExportDefaultDeclaration::JsFunctionExportDefaultDeclaration(node) => {
node.format().fmt(f)
}
AnyJsExportDefaultDeclaration::TsInterfaceDeclaration(node) => node.format().fmt(f),
AnyJsExportDefaultDeclaration::TsDeclareFunctionExportDefaultDeclaration(node) => {
node.format().fmt(f)
}
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/declaration_clause.rs | crates/rome_js_formatter/src/js/any/declaration_clause.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsDeclarationClause;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsDeclarationClause;
impl FormatRule<AnyJsDeclarationClause> for FormatAnyJsDeclarationClause {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsDeclarationClause, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsDeclarationClause::JsClassDeclaration(node) => node.format().fmt(f),
AnyJsDeclarationClause::JsFunctionDeclaration(node) => node.format().fmt(f),
AnyJsDeclarationClause::JsVariableDeclarationClause(node) => node.format().fmt(f),
AnyJsDeclarationClause::TsEnumDeclaration(node) => node.format().fmt(f),
AnyJsDeclarationClause::TsTypeAliasDeclaration(node) => node.format().fmt(f),
AnyJsDeclarationClause::TsInterfaceDeclaration(node) => node.format().fmt(f),
AnyJsDeclarationClause::TsDeclareFunctionDeclaration(node) => node.format().fmt(f),
AnyJsDeclarationClause::TsModuleDeclaration(node) => node.format().fmt(f),
AnyJsDeclarationClause::TsExternalModuleDeclaration(node) => node.format().fmt(f),
AnyJsDeclarationClause::TsGlobalDeclaration(node) => node.format().fmt(f),
AnyJsDeclarationClause::TsImportEqualsDeclaration(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/expression.rs | crates/rome_js_formatter/src/js/any/expression.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsExpression;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsExpression;
impl FormatRule<AnyJsExpression> for FormatAnyJsExpression {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsExpression, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsExpression::AnyJsLiteralExpression(node) => node.format().fmt(f),
AnyJsExpression::JsImportMetaExpression(node) => node.format().fmt(f),
AnyJsExpression::JsArrayExpression(node) => node.format().fmt(f),
AnyJsExpression::JsArrowFunctionExpression(node) => node.format().fmt(f),
AnyJsExpression::JsAssignmentExpression(node) => node.format().fmt(f),
AnyJsExpression::JsAwaitExpression(node) => node.format().fmt(f),
AnyJsExpression::JsBinaryExpression(node) => node.format().fmt(f),
AnyJsExpression::JsCallExpression(node) => node.format().fmt(f),
AnyJsExpression::JsClassExpression(node) => node.format().fmt(f),
AnyJsExpression::JsComputedMemberExpression(node) => node.format().fmt(f),
AnyJsExpression::JsConditionalExpression(node) => node.format().fmt(f),
AnyJsExpression::JsFunctionExpression(node) => node.format().fmt(f),
AnyJsExpression::JsIdentifierExpression(node) => node.format().fmt(f),
AnyJsExpression::JsImportCallExpression(node) => node.format().fmt(f),
AnyJsExpression::JsInExpression(node) => node.format().fmt(f),
AnyJsExpression::JsInstanceofExpression(node) => node.format().fmt(f),
AnyJsExpression::JsLogicalExpression(node) => node.format().fmt(f),
AnyJsExpression::JsNewExpression(node) => node.format().fmt(f),
AnyJsExpression::JsObjectExpression(node) => node.format().fmt(f),
AnyJsExpression::JsParenthesizedExpression(node) => node.format().fmt(f),
AnyJsExpression::JsPostUpdateExpression(node) => node.format().fmt(f),
AnyJsExpression::JsPreUpdateExpression(node) => node.format().fmt(f),
AnyJsExpression::JsSequenceExpression(node) => node.format().fmt(f),
AnyJsExpression::JsStaticMemberExpression(node) => node.format().fmt(f),
AnyJsExpression::JsSuperExpression(node) => node.format().fmt(f),
AnyJsExpression::JsThisExpression(node) => node.format().fmt(f),
AnyJsExpression::JsUnaryExpression(node) => node.format().fmt(f),
AnyJsExpression::JsBogusExpression(node) => node.format().fmt(f),
AnyJsExpression::JsYieldExpression(node) => node.format().fmt(f),
AnyJsExpression::JsNewTargetExpression(node) => node.format().fmt(f),
AnyJsExpression::JsTemplateExpression(node) => node.format().fmt(f),
AnyJsExpression::TsTypeAssertionExpression(node) => node.format().fmt(f),
AnyJsExpression::TsAsExpression(node) => node.format().fmt(f),
AnyJsExpression::TsSatisfiesExpression(node) => node.format().fmt(f),
AnyJsExpression::TsNonNullAssertionExpression(node) => node.format().fmt(f),
AnyJsExpression::TsInstantiationExpression(node) => node.format().fmt(f),
AnyJsExpression::JsxTagExpression(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/class_member_name.rs | crates/rome_js_formatter/src/js/any/class_member_name.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsClassMemberName;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsClassMemberName;
impl FormatRule<AnyJsClassMemberName> for FormatAnyJsClassMemberName {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsClassMemberName, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsClassMemberName::JsLiteralMemberName(node) => node.format().fmt(f),
AnyJsClassMemberName::JsComputedMemberName(node) => node.format().fmt(f),
AnyJsClassMemberName::JsPrivateClassMemberName(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/module_item.rs | crates/rome_js_formatter/src/js/any/module_item.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsModuleItem;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsModuleItem;
impl FormatRule<AnyJsModuleItem> for FormatAnyJsModuleItem {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsModuleItem, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsModuleItem::AnyJsStatement(node) => node.format().fmt(f),
AnyJsModuleItem::JsExport(node) => node.format().fmt(f),
AnyJsModuleItem::JsImport(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/for_in_or_of_initializer.rs | crates/rome_js_formatter/src/js/any/for_in_or_of_initializer.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsForInOrOfInitializer;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsForInOrOfInitializer;
impl FormatRule<AnyJsForInOrOfInitializer> for FormatAnyJsForInOrOfInitializer {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsForInOrOfInitializer, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsForInOrOfInitializer::AnyJsAssignmentPattern(node) => node.format().fmt(f),
AnyJsForInOrOfInitializer::JsForVariableDeclaration(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/in_property.rs | crates/rome_js_formatter/src/js/any/in_property.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsInProperty;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsInProperty;
impl FormatRule<AnyJsInProperty> for FormatAnyJsInProperty {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsInProperty, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsInProperty::JsPrivateName(node) => node.format().fmt(f),
AnyJsInProperty::AnyJsExpression(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/mod.rs | crates/rome_js_formatter/src/js/any/mod.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
pub(crate) mod array_assignment_pattern_element;
pub(crate) mod array_binding_pattern_element;
pub(crate) mod array_element;
pub(crate) mod arrow_function_parameters;
pub(crate) mod assignment;
pub(crate) mod assignment_pattern;
pub(crate) mod binding;
pub(crate) mod binding_pattern;
pub(crate) mod call_argument;
pub(crate) mod class;
pub(crate) mod class_member;
pub(crate) mod class_member_name;
pub(crate) mod constructor_parameter;
pub(crate) mod declaration;
pub(crate) mod declaration_clause;
pub(crate) mod decorator;
pub(crate) mod export_clause;
pub(crate) mod export_default_declaration;
pub(crate) mod export_named_specifier;
pub(crate) mod expression;
pub(crate) mod for_in_or_of_initializer;
pub(crate) mod for_initializer;
pub(crate) mod formal_parameter;
pub(crate) mod function;
pub(crate) mod function_body;
pub(crate) mod import_assertion_entry;
pub(crate) mod import_clause;
pub(crate) mod in_property;
pub(crate) mod literal_expression;
pub(crate) mod method_modifier;
pub(crate) mod module_item;
pub(crate) mod name;
pub(crate) mod named_import;
pub(crate) mod named_import_specifier;
pub(crate) mod object_assignment_pattern_member;
pub(crate) mod object_binding_pattern_member;
pub(crate) mod object_member;
pub(crate) mod object_member_name;
pub(crate) mod parameter;
pub(crate) mod property_modifier;
pub(crate) mod root;
pub(crate) mod statement;
pub(crate) mod switch_clause;
pub(crate) mod template_element;
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/import_clause.rs | crates/rome_js_formatter/src/js/any/import_clause.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsImportClause;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsImportClause;
impl FormatRule<AnyJsImportClause> for FormatAnyJsImportClause {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsImportClause, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsImportClause::JsImportBareClause(node) => node.format().fmt(f),
AnyJsImportClause::JsImportNamedClause(node) => node.format().fmt(f),
AnyJsImportClause::JsImportDefaultClause(node) => node.format().fmt(f),
AnyJsImportClause::JsImportNamespaceClause(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/statement.rs | crates/rome_js_formatter/src/js/any/statement.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsStatement;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsStatement;
impl FormatRule<AnyJsStatement> for FormatAnyJsStatement {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsStatement, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsStatement::JsBlockStatement(node) => node.format().fmt(f),
AnyJsStatement::JsBreakStatement(node) => node.format().fmt(f),
AnyJsStatement::JsClassDeclaration(node) => node.format().fmt(f),
AnyJsStatement::JsContinueStatement(node) => node.format().fmt(f),
AnyJsStatement::JsDebuggerStatement(node) => node.format().fmt(f),
AnyJsStatement::JsDoWhileStatement(node) => node.format().fmt(f),
AnyJsStatement::JsEmptyStatement(node) => node.format().fmt(f),
AnyJsStatement::JsExpressionStatement(node) => node.format().fmt(f),
AnyJsStatement::JsForInStatement(node) => node.format().fmt(f),
AnyJsStatement::JsForOfStatement(node) => node.format().fmt(f),
AnyJsStatement::JsForStatement(node) => node.format().fmt(f),
AnyJsStatement::JsIfStatement(node) => node.format().fmt(f),
AnyJsStatement::JsLabeledStatement(node) => node.format().fmt(f),
AnyJsStatement::JsReturnStatement(node) => node.format().fmt(f),
AnyJsStatement::JsSwitchStatement(node) => node.format().fmt(f),
AnyJsStatement::JsThrowStatement(node) => node.format().fmt(f),
AnyJsStatement::JsTryFinallyStatement(node) => node.format().fmt(f),
AnyJsStatement::JsTryStatement(node) => node.format().fmt(f),
AnyJsStatement::JsBogusStatement(node) => node.format().fmt(f),
AnyJsStatement::JsVariableStatement(node) => node.format().fmt(f),
AnyJsStatement::JsWhileStatement(node) => node.format().fmt(f),
AnyJsStatement::JsWithStatement(node) => node.format().fmt(f),
AnyJsStatement::JsFunctionDeclaration(node) => node.format().fmt(f),
AnyJsStatement::TsEnumDeclaration(node) => node.format().fmt(f),
AnyJsStatement::TsTypeAliasDeclaration(node) => node.format().fmt(f),
AnyJsStatement::TsInterfaceDeclaration(node) => node.format().fmt(f),
AnyJsStatement::TsDeclareFunctionDeclaration(node) => node.format().fmt(f),
AnyJsStatement::TsDeclareStatement(node) => node.format().fmt(f),
AnyJsStatement::TsModuleDeclaration(node) => node.format().fmt(f),
AnyJsStatement::TsExternalModuleDeclaration(node) => node.format().fmt(f),
AnyJsStatement::TsGlobalDeclaration(node) => node.format().fmt(f),
AnyJsStatement::TsImportEqualsDeclaration(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/switch_clause.rs | crates/rome_js_formatter/src/js/any/switch_clause.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsSwitchClause;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsSwitchClause;
impl FormatRule<AnyJsSwitchClause> for FormatAnyJsSwitchClause {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsSwitchClause, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsSwitchClause::JsCaseClause(node) => node.format().fmt(f),
AnyJsSwitchClause::JsDefaultClause(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/literal_expression.rs | crates/rome_js_formatter/src/js/any/literal_expression.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsLiteralExpression;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsLiteralExpression;
impl FormatRule<AnyJsLiteralExpression> for FormatAnyJsLiteralExpression {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsLiteralExpression, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsLiteralExpression::JsStringLiteralExpression(node) => node.format().fmt(f),
AnyJsLiteralExpression::JsNumberLiteralExpression(node) => node.format().fmt(f),
AnyJsLiteralExpression::JsBigintLiteralExpression(node) => node.format().fmt(f),
AnyJsLiteralExpression::JsBooleanLiteralExpression(node) => node.format().fmt(f),
AnyJsLiteralExpression::JsNullLiteralExpression(node) => node.format().fmt(f),
AnyJsLiteralExpression::JsRegexLiteralExpression(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/name.rs | crates/rome_js_formatter/src/js/any/name.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsName;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsName;
impl FormatRule<AnyJsName> for FormatAnyJsName {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsName, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsName::JsName(node) => node.format().fmt(f),
AnyJsName::JsPrivateName(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/formal_parameter.rs | crates/rome_js_formatter/src/js/any/formal_parameter.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsFormalParameter;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsFormalParameter;
impl FormatRule<AnyJsFormalParameter> for FormatAnyJsFormalParameter {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsFormalParameter, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsFormalParameter::JsFormalParameter(node) => node.format().fmt(f),
AnyJsFormalParameter::JsBogusParameter(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/class_member.rs | crates/rome_js_formatter/src/js/any/class_member.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsClassMember;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsClassMember;
impl FormatRule<AnyJsClassMember> for FormatAnyJsClassMember {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsClassMember, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsClassMember::JsConstructorClassMember(node) => node.format().fmt(f),
AnyJsClassMember::JsStaticInitializationBlockClassMember(node) => node.format().fmt(f),
AnyJsClassMember::JsPropertyClassMember(node) => node.format().fmt(f),
AnyJsClassMember::JsMethodClassMember(node) => node.format().fmt(f),
AnyJsClassMember::JsGetterClassMember(node) => node.format().fmt(f),
AnyJsClassMember::JsSetterClassMember(node) => node.format().fmt(f),
AnyJsClassMember::TsConstructorSignatureClassMember(node) => node.format().fmt(f),
AnyJsClassMember::TsPropertySignatureClassMember(node) => node.format().fmt(f),
AnyJsClassMember::TsInitializedPropertySignatureClassMember(node) => {
node.format().fmt(f)
}
AnyJsClassMember::TsMethodSignatureClassMember(node) => node.format().fmt(f),
AnyJsClassMember::TsGetterSignatureClassMember(node) => node.format().fmt(f),
AnyJsClassMember::TsSetterSignatureClassMember(node) => node.format().fmt(f),
AnyJsClassMember::TsIndexSignatureClassMember(node) => node.format().fmt(f),
AnyJsClassMember::JsEmptyClassMember(node) => node.format().fmt(f),
AnyJsClassMember::JsBogusMember(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/binding.rs | crates/rome_js_formatter/src/js/any/binding.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsBinding;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsBinding;
impl FormatRule<AnyJsBinding> for FormatAnyJsBinding {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsBinding, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsBinding::JsIdentifierBinding(node) => node.format().fmt(f),
AnyJsBinding::JsBogusBinding(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/binding_pattern.rs | crates/rome_js_formatter/src/js/any/binding_pattern.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsBindingPattern;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsBindingPattern;
impl FormatRule<AnyJsBindingPattern> for FormatAnyJsBindingPattern {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsBindingPattern, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsBindingPattern::AnyJsBinding(node) => node.format().fmt(f),
AnyJsBindingPattern::JsArrayBindingPattern(node) => node.format().fmt(f),
AnyJsBindingPattern::JsObjectBindingPattern(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/named_import.rs | crates/rome_js_formatter/src/js/any/named_import.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsNamedImport;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsNamedImport;
impl FormatRule<AnyJsNamedImport> for FormatAnyJsNamedImport {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsNamedImport, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsNamedImport::JsNamedImportSpecifiers(node) => node.format().fmt(f),
AnyJsNamedImport::JsNamespaceImportSpecifier(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/property_modifier.rs | crates/rome_js_formatter/src/js/any/property_modifier.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsPropertyModifier;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsPropertyModifier;
impl FormatRule<AnyJsPropertyModifier> for FormatAnyJsPropertyModifier {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsPropertyModifier, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsPropertyModifier::TsAccessibilityModifier(node) => node.format().fmt(f),
AnyJsPropertyModifier::JsStaticModifier(node) => node.format().fmt(f),
AnyJsPropertyModifier::JsAccessorModifier(node) => node.format().fmt(f),
AnyJsPropertyModifier::JsDecorator(node) => node.format().fmt(f),
AnyJsPropertyModifier::TsReadonlyModifier(node) => node.format().fmt(f),
AnyJsPropertyModifier::TsOverrideModifier(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/assignment_pattern.rs | crates/rome_js_formatter/src/js/any/assignment_pattern.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsAssignmentPattern;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsAssignmentPattern;
impl FormatRule<AnyJsAssignmentPattern> for FormatAnyJsAssignmentPattern {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsAssignmentPattern, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsAssignmentPattern::AnyJsAssignment(node) => node.format().fmt(f),
AnyJsAssignmentPattern::JsArrayAssignmentPattern(node) => node.format().fmt(f),
AnyJsAssignmentPattern::JsObjectAssignmentPattern(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/export_clause.rs | crates/rome_js_formatter/src/js/any/export_clause.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsExportClause;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsExportClause;
impl FormatRule<AnyJsExportClause> for FormatAnyJsExportClause {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsExportClause, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsExportClause::JsExportDefaultDeclarationClause(node) => node.format().fmt(f),
AnyJsExportClause::JsExportDefaultExpressionClause(node) => node.format().fmt(f),
AnyJsExportClause::JsExportNamedClause(node) => node.format().fmt(f),
AnyJsExportClause::JsExportFromClause(node) => node.format().fmt(f),
AnyJsExportClause::JsExportNamedFromClause(node) => node.format().fmt(f),
AnyJsExportClause::AnyJsDeclarationClause(node) => node.format().fmt(f),
AnyJsExportClause::TsExportAsNamespaceClause(node) => node.format().fmt(f),
AnyJsExportClause::TsExportAssignmentClause(node) => node.format().fmt(f),
AnyJsExportClause::TsExportDeclareClause(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/assignment.rs | crates/rome_js_formatter/src/js/any/assignment.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsAssignment;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsAssignment;
impl FormatRule<AnyJsAssignment> for FormatAnyJsAssignment {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsAssignment, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsAssignment::JsIdentifierAssignment(node) => node.format().fmt(f),
AnyJsAssignment::JsStaticMemberAssignment(node) => node.format().fmt(f),
AnyJsAssignment::JsComputedMemberAssignment(node) => node.format().fmt(f),
AnyJsAssignment::JsParenthesizedAssignment(node) => node.format().fmt(f),
AnyJsAssignment::TsNonNullAssertionAssignment(node) => node.format().fmt(f),
AnyJsAssignment::TsAsAssignment(node) => node.format().fmt(f),
AnyJsAssignment::TsSatisfiesAssignment(node) => node.format().fmt(f),
AnyJsAssignment::TsTypeAssertionAssignment(node) => node.format().fmt(f),
AnyJsAssignment::JsBogusAssignment(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/object_binding_pattern_member.rs | crates/rome_js_formatter/src/js/any/object_binding_pattern_member.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsObjectBindingPatternMember;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsObjectBindingPatternMember;
impl FormatRule<AnyJsObjectBindingPatternMember> for FormatAnyJsObjectBindingPatternMember {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsObjectBindingPatternMember, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsObjectBindingPatternMember::JsObjectBindingPatternProperty(node) => {
node.format().fmt(f)
}
AnyJsObjectBindingPatternMember::JsObjectBindingPatternRest(node) => {
node.format().fmt(f)
}
AnyJsObjectBindingPatternMember::JsObjectBindingPatternShorthandProperty(node) => {
node.format().fmt(f)
}
AnyJsObjectBindingPatternMember::JsBogusBinding(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/import_assertion_entry.rs | crates/rome_js_formatter/src/js/any/import_assertion_entry.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsImportAssertionEntry;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsImportAssertionEntry;
impl FormatRule<AnyJsImportAssertionEntry> for FormatAnyJsImportAssertionEntry {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsImportAssertionEntry, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsImportAssertionEntry::JsImportAssertionEntry(node) => node.format().fmt(f),
AnyJsImportAssertionEntry::JsBogusImportAssertionEntry(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/any/parameter.rs | crates/rome_js_formatter/src/js/any/parameter.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsParameter;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsParameter;
impl FormatRule<AnyJsParameter> for FormatAnyJsParameter {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyJsParameter, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyJsParameter::AnyJsFormalParameter(node) => node.format().fmt(f),
AnyJsParameter::JsRestParameter(node) => node.format().fmt(f),
AnyJsParameter::TsThisParameter(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/objects/literal_member_name.rs | crates/rome_js_formatter/src/js/objects/literal_member_name.rs | use crate::prelude::*;
use crate::utils::{FormatLiteralStringToken, StringLiteralParentKind};
use rome_formatter::write;
use rome_js_syntax::JsLiteralMemberNameFields;
use rome_js_syntax::{JsLiteralMemberName, JsSyntaxKind};
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatJsLiteralMemberName;
impl FormatNodeRule<JsLiteralMemberName> for FormatJsLiteralMemberName {
fn fmt_fields(&self, node: &JsLiteralMemberName, f: &mut JsFormatter) -> FormatResult<()> {
let JsLiteralMemberNameFields { value } = node.as_fields();
let value = value?;
match value.kind() {
JsSyntaxKind::JS_STRING_LITERAL => {
write![
f,
[FormatLiteralStringToken::new(
&value,
StringLiteralParentKind::Member
)]
]
}
_ => write![f, [value.format()]],
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/objects/property_object_member.rs | crates/rome_js_formatter/src/js/objects/property_object_member.rs | use crate::prelude::*;
use crate::utils::AnyJsAssignmentLike;
use rome_formatter::write;
use rome_js_syntax::JsPropertyObjectMember;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatJsPropertyObjectMember;
impl FormatNodeRule<JsPropertyObjectMember> for FormatJsPropertyObjectMember {
fn fmt_fields(&self, node: &JsPropertyObjectMember, f: &mut JsFormatter) -> FormatResult<()> {
write![f, [AnyJsAssignmentLike::from(node.clone())]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/objects/shorthand_property_object_member.rs | crates/rome_js_formatter/src/js/objects/shorthand_property_object_member.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::JsShorthandPropertyObjectMember;
use rome_js_syntax::JsShorthandPropertyObjectMemberFields;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatJsShorthandPropertyObjectMember;
impl FormatNodeRule<JsShorthandPropertyObjectMember> for FormatJsShorthandPropertyObjectMember {
fn fmt_fields(
&self,
node: &JsShorthandPropertyObjectMember,
f: &mut JsFormatter,
) -> FormatResult<()> {
let JsShorthandPropertyObjectMemberFields { name } = node.as_fields();
write![f, [name.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/objects/computed_member_name.rs | crates/rome_js_formatter/src/js/objects/computed_member_name.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::JsComputedMemberName;
use rome_js_syntax::JsComputedMemberNameFields;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatJsComputedMemberName;
impl FormatNodeRule<JsComputedMemberName> for FormatJsComputedMemberName {
fn fmt_fields(&self, node: &JsComputedMemberName, f: &mut JsFormatter) -> FormatResult<()> {
let JsComputedMemberNameFields {
l_brack_token,
expression,
r_brack_token,
} = node.as_fields();
write![
f,
[
l_brack_token.format(),
expression.format(),
r_brack_token.format(),
]
]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/objects/mod.rs | crates/rome_js_formatter/src/js/objects/mod.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
pub(crate) mod computed_member_name;
pub(crate) mod getter_object_member;
pub(crate) mod literal_member_name;
pub(crate) mod method_object_member;
pub(crate) mod private_class_member_name;
pub(crate) mod property_object_member;
pub(crate) mod setter_object_member;
pub(crate) mod shorthand_property_object_member;
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/objects/setter_object_member.rs | crates/rome_js_formatter/src/js/objects/setter_object_member.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::JsSetterObjectMember;
use rome_js_syntax::JsSetterObjectMemberFields;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatJsSetterObjectMember;
impl FormatNodeRule<JsSetterObjectMember> for FormatJsSetterObjectMember {
fn fmt_fields(&self, node: &JsSetterObjectMember, f: &mut JsFormatter) -> FormatResult<()> {
let JsSetterObjectMemberFields {
set_token,
name,
l_paren_token,
parameter,
r_paren_token,
body,
} = node.as_fields();
write![
f,
[
set_token.format(),
space(),
name.format(),
l_paren_token.format(),
parameter.format(),
r_paren_token.format(),
space(),
body.format(),
]
]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/objects/private_class_member_name.rs | crates/rome_js_formatter/src/js/objects/private_class_member_name.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::JsPrivateClassMemberName;
use rome_js_syntax::JsPrivateClassMemberNameFields;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatJsPrivateClassMemberName;
impl FormatNodeRule<JsPrivateClassMemberName> for FormatJsPrivateClassMemberName {
fn fmt_fields(&self, node: &JsPrivateClassMemberName, f: &mut JsFormatter) -> FormatResult<()> {
let JsPrivateClassMemberNameFields {
hash_token,
id_token,
} = node.as_fields();
write![f, [hash_token.format(), id_token.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/objects/method_object_member.rs | crates/rome_js_formatter/src/js/objects/method_object_member.rs | use crate::prelude::*;
use crate::js::classes::method_class_member::FormatAnyJsMethodMember;
use rome_js_syntax::JsMethodObjectMember;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatJsMethodObjectMember;
impl FormatNodeRule<JsMethodObjectMember> for FormatJsMethodObjectMember {
fn fmt_fields(&self, node: &JsMethodObjectMember, f: &mut JsFormatter) -> FormatResult<()> {
FormatAnyJsMethodMember::from(node.clone()).fmt(f)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/js/objects/getter_object_member.rs | crates/rome_js_formatter/src/js/objects/getter_object_member.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::JsGetterObjectMember;
use rome_js_syntax::JsGetterObjectMemberFields;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatJsGetterObjectMember;
impl FormatNodeRule<JsGetterObjectMember> for FormatJsGetterObjectMember {
fn fmt_fields(&self, node: &JsGetterObjectMember, f: &mut JsFormatter) -> FormatResult<()> {
let JsGetterObjectMemberFields {
get_token,
name,
l_paren_token,
r_paren_token,
return_type,
body,
} = node.as_fields();
write![
f,
[
get_token.format(),
space(),
name.format(),
l_paren_token.format(),
r_paren_token.format(),
return_type.format(),
space(),
body.format()
]
]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/mod.rs | crates/rome_js_formatter/src/ts/mod.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
pub(crate) mod any;
pub(crate) mod assignments;
pub(crate) mod auxiliary;
pub(crate) mod bindings;
pub(crate) mod bogus;
pub(crate) mod classes;
pub(crate) mod declarations;
pub(crate) mod expressions;
pub(crate) mod lists;
pub(crate) mod module;
pub(crate) mod statements;
pub(crate) mod types;
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/statements/declare_statement.rs | crates/rome_js_formatter/src/ts/statements/declare_statement.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsDeclareStatement;
use rome_js_syntax::TsDeclareStatementFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsDeclareStatement;
impl FormatNodeRule<TsDeclareStatement> for FormatTsDeclareStatement {
fn fmt_fields(&self, node: &TsDeclareStatement, f: &mut JsFormatter) -> FormatResult<()> {
let TsDeclareStatementFields {
declaration,
declare_token,
} = node.as_fields();
write![f, [declare_token.format(), space(), declaration.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/statements/mod.rs | crates/rome_js_formatter/src/ts/statements/mod.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
pub(crate) mod declare_statement;
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/lists/property_signature_modifier_list.rs | crates/rome_js_formatter/src/ts/lists/property_signature_modifier_list.rs | use crate::prelude::*;
use crate::utils::format_modifiers::FormatModifiers;
use rome_js_syntax::TsPropertySignatureModifierList;
#[derive(Debug, Clone, Default)]
pub struct FormatTsPropertySignatureModifierList;
impl FormatRule<TsPropertySignatureModifierList> for FormatTsPropertySignatureModifierList {
type Context = JsFormatContext;
fn fmt(&self, node: &TsPropertySignatureModifierList, f: &mut JsFormatter) -> FormatResult<()> {
FormatModifiers::from(node.clone()).fmt(f)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/lists/enum_member_list.rs | crates/rome_js_formatter/src/ts/lists/enum_member_list.rs | use crate::prelude::*;
use crate::context::trailing_comma::FormatTrailingComma;
use rome_js_syntax::TsEnumMemberList;
#[derive(Debug, Clone, Default)]
pub struct FormatTsEnumMemberList;
impl FormatRule<TsEnumMemberList> for FormatTsEnumMemberList {
type Context = JsFormatContext;
fn fmt(&self, node: &TsEnumMemberList, f: &mut JsFormatter) -> FormatResult<()> {
let trailing_separator = FormatTrailingComma::ES5.trailing_separator(f.options());
let mut joiner = f.join_nodes_with_soft_line();
for variant in node
.format_separated(",")
.with_trailing_separator(trailing_separator)
.nodes_grouped()
{
joiner.entry(variant.node()?.syntax(), &variant)
}
joiner.finish()
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/lists/type_parameter_list.rs | crates/rome_js_formatter/src/ts/lists/type_parameter_list.rs | use crate::context::trailing_comma::FormatTrailingComma;
use crate::prelude::*;
use rome_js_syntax::TsTypeParameterList;
use rome_rowan::AstSeparatedList;
#[derive(Debug, Clone, Default)]
pub struct FormatTsTypeParameterList;
impl FormatRule<TsTypeParameterList> for FormatTsTypeParameterList {
type Context = JsFormatContext;
fn fmt(&self, node: &TsTypeParameterList, f: &mut JsFormatter) -> FormatResult<()> {
// nodes and formatter are not aware of the source type (TSX vs TS), which means we can't
// exactly pin point the exact case.
//
// This is just an heuristic to avoid removing the trailing comma from a TSX grammar.
// This means that, if we are in a TS context and we have a trailing comma, the formatter won't remove it.
// It's an edge case, while waiting for a better solution,
let trailing_separator = if node.len() == 1 && node.trailing_separator().is_some() {
TrailingSeparator::Mandatory
} else {
FormatTrailingComma::All.trailing_separator(f.options())
};
f.join_with(&soft_line_break_or_space())
.entries(
node.format_separated(",")
.with_trailing_separator(trailing_separator),
)
.finish()
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/lists/intersection_type_element_list.rs | crates/rome_js_formatter/src/ts/lists/intersection_type_element_list.rs | use crate::{prelude::*, utils::is_object_like_type};
use rome_formatter::{format_args, write};
use rome_js_syntax::TsIntersectionTypeElementList;
use rome_rowan::AstSeparatedList;
#[derive(Debug, Clone, Default)]
pub struct FormatTsIntersectionTypeElementList;
impl FormatRule<TsIntersectionTypeElementList> for FormatTsIntersectionTypeElementList {
type Context = JsFormatContext;
// [Prettier applies]: https://github.com/prettier/prettier/blob/cd3e530c2e51fb8296c0fb7738a9afdd3a3a4410/src/language-js/print/type-annotation.js#L93-L120
fn fmt(&self, node: &TsIntersectionTypeElementList, f: &mut JsFormatter) -> FormatResult<()> {
let last_index = node.len().saturating_sub(1);
let mut is_prev_object_type_like = false;
let mut is_chain_indented = false;
for (index, element) in node.elements().enumerate() {
let node = element.node()?;
let is_object_type_like = is_object_like_type(node);
// always inline first element
if index == 0 {
write!(f, [node.format()])?;
} else {
// If no object is involved, go to the next line if it breaks
if !is_prev_object_type_like && !is_object_type_like {
write!(
f,
[indent(&format_args![
soft_line_break_or_space(),
node.format()
])]
)?;
} else {
write!(f, [space()])?;
if !is_prev_object_type_like || !is_object_type_like {
// indent if we move from object to non-object or vice versa, otherwise keep inline
is_chain_indented = index > 1;
}
if is_chain_indented {
write!(f, [indent(&node.format())])?;
} else {
write!(f, [node.format()])?;
}
}
}
let trailing_separator = element.trailing_separator()?;
if let Some(token) = trailing_separator {
if index == last_index {
write![f, [format_removed(token)]]?;
} else {
write![f, [space(), token.format()]]?;
}
}
is_prev_object_type_like = is_object_type_like;
}
Ok(())
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/lists/type_argument_list.rs | crates/rome_js_formatter/src/ts/lists/type_argument_list.rs | use crate::prelude::*;
use rome_js_syntax::TsTypeArgumentList;
#[derive(Debug, Clone, Default)]
pub struct FormatTsTypeArgumentList;
impl FormatRule<TsTypeArgumentList> for FormatTsTypeArgumentList {
type Context = JsFormatContext;
fn fmt(&self, node: &TsTypeArgumentList, f: &mut JsFormatter) -> FormatResult<()> {
f.join_with(&soft_line_break_or_space())
.entries(
node.format_separated(",")
.with_trailing_separator(TrailingSeparator::Disallowed),
)
.finish()
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/lists/index_signature_modifier_list.rs | crates/rome_js_formatter/src/ts/lists/index_signature_modifier_list.rs | use crate::prelude::*;
use crate::utils::sort_modifiers_by_precedence;
use rome_js_syntax::TsIndexSignatureModifierList;
#[derive(Debug, Clone, Default)]
pub struct FormatTsIndexSignatureModifierList;
impl FormatRule<TsIndexSignatureModifierList> for FormatTsIndexSignatureModifierList {
type Context = JsFormatContext;
fn fmt(&self, node: &TsIndexSignatureModifierList, f: &mut JsFormatter) -> FormatResult<()> {
f.join_with(&space())
.entries(sort_modifiers_by_precedence(node).into_iter().formatted())
.finish()
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/lists/property_parameter_modifier_list.rs | crates/rome_js_formatter/src/ts/lists/property_parameter_modifier_list.rs | use crate::prelude::*;
use crate::utils::sort_modifiers_by_precedence;
use rome_js_syntax::TsPropertyParameterModifierList;
#[derive(Debug, Clone, Default)]
pub struct FormatTsPropertyParameterModifierList;
impl FormatRule<TsPropertyParameterModifierList> for FormatTsPropertyParameterModifierList {
type Context = JsFormatContext;
fn fmt(&self, node: &TsPropertyParameterModifierList, f: &mut JsFormatter) -> FormatResult<()> {
f.join_with(&space())
.entries(sort_modifiers_by_precedence(node).into_iter().formatted())
.finish()
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/lists/mod.rs | crates/rome_js_formatter/src/ts/lists/mod.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
pub(crate) mod enum_member_list;
pub(crate) mod index_signature_modifier_list;
pub(crate) mod intersection_type_element_list;
pub(crate) mod method_signature_modifier_list;
pub(crate) mod property_parameter_modifier_list;
pub(crate) mod property_signature_modifier_list;
pub(crate) mod template_element_list;
pub(crate) mod tuple_type_element_list;
pub(crate) mod type_argument_list;
pub(crate) mod type_list;
pub(crate) mod type_member_list;
pub(crate) mod type_parameter_list;
pub(crate) mod type_parameter_modifier_list;
pub(crate) mod union_type_variant_list;
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/lists/type_parameter_modifier_list.rs | crates/rome_js_formatter/src/ts/lists/type_parameter_modifier_list.rs | use crate::prelude::*;
use rome_js_syntax::TsTypeParameterModifierList;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatTsTypeParameterModifierList;
impl FormatRule<TsTypeParameterModifierList> for FormatTsTypeParameterModifierList {
type Context = JsFormatContext;
fn fmt(&self, node: &TsTypeParameterModifierList, f: &mut JsFormatter) -> FormatResult<()> {
f.join_with(&space())
.entries(node.iter().formatted())
.finish()
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/lists/union_type_variant_list.rs | crates/rome_js_formatter/src/ts/lists/union_type_variant_list.rs | use crate::prelude::*;
use crate::ts::bogus::bogus_type::FormatTsBogusType;
use crate::ts::module::import_type::FormatTsImportType;
use crate::ts::types::any_type::FormatTsAnyType;
use crate::ts::types::array_type::FormatTsArrayType;
use crate::ts::types::bigint_literal_type::FormatTsBigintLiteralType;
use crate::ts::types::bigint_type::FormatTsBigintType;
use crate::ts::types::boolean_literal_type::FormatTsBooleanLiteralType;
use crate::ts::types::boolean_type::FormatTsBooleanType;
use crate::ts::types::conditional_type::FormatTsConditionalType;
use crate::ts::types::constructor_type::FormatTsConstructorType;
use crate::ts::types::function_type::FormatTsFunctionType;
use crate::ts::types::indexed_access_type::FormatTsIndexedAccessType;
use crate::ts::types::infer_type::FormatTsInferType;
use crate::ts::types::intersection_type::FormatTsIntersectionType;
use crate::ts::types::mapped_type::FormatTsMappedType;
use crate::ts::types::never_type::FormatTsNeverType;
use crate::ts::types::non_primitive_type::FormatTsNonPrimitiveType;
use crate::ts::types::null_literal_type::FormatTsNullLiteralType;
use crate::ts::types::number_literal_type::FormatTsNumberLiteralType;
use crate::ts::types::number_type::FormatTsNumberType;
use crate::ts::types::object_type::FormatTsObjectType;
use crate::ts::types::parenthesized_type::FormatTsParenthesizedType;
use crate::ts::types::reference_type::FormatTsReferenceType;
use crate::ts::types::string_literal_type::FormatTsStringLiteralType;
use crate::ts::types::string_type::FormatTsStringType;
use crate::ts::types::symbol_type::FormatTsSymbolType;
use crate::ts::types::template_literal_type::FormatTsTemplateLiteralType;
use crate::ts::types::this_type::FormatTsThisType;
use crate::ts::types::tuple_type::FormatTsTupleType;
use crate::ts::types::type_operator_type::FormatTsTypeOperatorType;
use crate::ts::types::typeof_type::FormatTsTypeofType;
use crate::ts::types::undefined_type::FormatTsUndefinedType;
use crate::ts::types::union_type::FormatTsUnionType;
use crate::ts::types::unknown_type::FormatTsUnknownType;
use crate::ts::types::void_type::FormatTsVoidType;
use crate::JsCommentStyle;
use rome_formatter::{comments::CommentStyle, write, FormatRuleWithOptions};
use rome_js_syntax::{AnyTsType, JsLanguage, TsUnionType, TsUnionTypeVariantList};
use rome_rowan::{AstSeparatedElement, AstSeparatedList};
#[derive(Debug, Clone, Default)]
pub struct FormatTsUnionTypeVariantList {
should_hug: bool,
}
impl FormatRuleWithOptions<TsUnionTypeVariantList> for FormatTsUnionTypeVariantList {
type Options = bool;
fn with_options(mut self, options: Self::Options) -> Self {
self.should_hug = options;
self
}
}
impl FormatRule<TsUnionTypeVariantList> for FormatTsUnionTypeVariantList {
type Context = JsFormatContext;
fn fmt(&self, node: &TsUnionTypeVariantList, f: &mut JsFormatter) -> FormatResult<()> {
let last_index = node.len().saturating_sub(1);
f.join_with(space())
.entries(
node.elements()
.enumerate()
.map(|(index, item)| FormatTypeVariant {
last: index == last_index,
list: node,
element: item,
should_hug: self.should_hug,
}),
)
.finish()
}
}
pub struct FormatTypeVariant<'a> {
last: bool,
should_hug: bool,
element: AstSeparatedElement<JsLanguage, AnyTsType>,
list: &'a TsUnionTypeVariantList,
}
impl Format<JsFormatContext> for FormatTypeVariant<'_> {
fn fmt(&self, f: &mut JsFormatter) -> FormatResult<()> {
let separator = self.element.trailing_separator()?;
let node = self.element.node()?;
let is_suppressed = is_type_suppressed(node, self.list, f.comments());
// This is a hack: It by passes the regular format node to only format the node without its comments.
let format_node = format_with(|f: &mut JsFormatter| {
if is_suppressed {
write!(f, [format_suppressed_node(node.syntax()).skip_comments()])
} else {
match node {
AnyTsType::TsAnyType(ty) => FormatTsAnyType::default().fmt_node(ty, f),
AnyTsType::TsArrayType(ty) => FormatTsArrayType::default().fmt_node(ty, f),
AnyTsType::TsBigintLiteralType(ty) => {
FormatTsBigintLiteralType::default().fmt_node(ty, f)
}
AnyTsType::TsBigintType(ty) => FormatTsBigintType::default().fmt_node(ty, f),
AnyTsType::TsBooleanLiteralType(ty) => {
FormatTsBooleanLiteralType::default().fmt_node(ty, f)
}
AnyTsType::TsBooleanType(ty) => FormatTsBooleanType::default().fmt_node(ty, f),
AnyTsType::TsConditionalType(ty) => {
FormatTsConditionalType::default().fmt_node(ty, f)
}
AnyTsType::TsConstructorType(ty) => {
FormatTsConstructorType::default().fmt_node(ty, f)
}
AnyTsType::TsFunctionType(ty) => {
FormatTsFunctionType::default().fmt_node(ty, f)
}
AnyTsType::TsImportType(ty) => FormatTsImportType::default().fmt_node(ty, f),
AnyTsType::TsIndexedAccessType(ty) => {
FormatTsIndexedAccessType::default().fmt_node(ty, f)
}
AnyTsType::TsInferType(ty) => FormatTsInferType::default().fmt_node(ty, f),
AnyTsType::TsIntersectionType(ty) => {
FormatTsIntersectionType::default().fmt_node(ty, f)
}
AnyTsType::TsMappedType(ty) => FormatTsMappedType::default().fmt_node(ty, f),
AnyTsType::TsNeverType(ty) => FormatTsNeverType::default().fmt_node(ty, f),
AnyTsType::TsNonPrimitiveType(ty) => {
FormatTsNonPrimitiveType::default().fmt_node(ty, f)
}
AnyTsType::TsNullLiteralType(ty) => {
FormatTsNullLiteralType::default().fmt_node(ty, f)
}
AnyTsType::TsNumberLiteralType(ty) => {
FormatTsNumberLiteralType::default().fmt_node(ty, f)
}
AnyTsType::TsNumberType(ty) => FormatTsNumberType::default().fmt_node(ty, f),
AnyTsType::TsObjectType(ty) => FormatTsObjectType::default().fmt_node(ty, f),
AnyTsType::TsParenthesizedType(ty) => {
FormatTsParenthesizedType::default().fmt_node(ty, f)
}
AnyTsType::TsReferenceType(ty) => {
FormatTsReferenceType::default().fmt_node(ty, f)
}
AnyTsType::TsStringLiteralType(ty) => {
FormatTsStringLiteralType::default().fmt_node(ty, f)
}
AnyTsType::TsStringType(ty) => FormatTsStringType::default().fmt_node(ty, f),
AnyTsType::TsSymbolType(ty) => FormatTsSymbolType::default().fmt_node(ty, f),
AnyTsType::TsTemplateLiteralType(ty) => {
FormatTsTemplateLiteralType::default().fmt_node(ty, f)
}
AnyTsType::TsThisType(ty) => FormatTsThisType::default().fmt_node(ty, f),
AnyTsType::TsTupleType(ty) => FormatTsTupleType::default().fmt_node(ty, f),
AnyTsType::TsTypeOperatorType(ty) => {
FormatTsTypeOperatorType::default().fmt_node(ty, f)
}
AnyTsType::TsTypeofType(ty) => FormatTsTypeofType::default().fmt_node(ty, f),
AnyTsType::TsUndefinedType(ty) => {
FormatTsUndefinedType::default().fmt_node(ty, f)
}
AnyTsType::TsUnionType(ty) => FormatTsUnionType::default().fmt_node(ty, f),
AnyTsType::TsUnknownType(ty) => FormatTsUnknownType::default().fmt_node(ty, f),
AnyTsType::TsVoidType(ty) => FormatTsVoidType::default().fmt_node(ty, f),
AnyTsType::TsBogusType(ty) => FormatTsBogusType::default().fmt(ty, f),
}
}
});
write!(f, [format_leading_comments(node.syntax())])?;
if self.should_hug {
write!(f, [format_node])?;
} else {
write!(f, [align(2, &format_node)])?;
}
if !is_suppressed {
write!(f, [format_dangling_comments(node.syntax())])?;
}
write!(f, [format_trailing_comments(node.syntax())])?;
if let Some(token) = separator {
if self.last {
write!(f, [format_removed(token)])?;
} else {
if self.should_hug {
write!(f, [space()])?;
} else {
write!(f, [soft_line_break_or_space()])?;
}
write![f, [token.format()]]?;
}
}
Ok(())
}
}
fn is_type_suppressed(
ty: &AnyTsType,
list: &TsUnionTypeVariantList,
comments: &JsComments,
) -> bool {
comments.mark_suppression_checked(ty.syntax());
if let AnyTsType::TsUnionType(union) = ty {
// If the union isn't empty, than the suppression applies to the first variant
if !union.types().is_empty() {
return false;
}
}
// Otherwise check if the node has a suppression in its leading or dangling comments
// before then checking the previous variants trailing "OwnLine" comments (comments that are on their own line)
let leading_dangling = comments
.leading_comments(ty.syntax())
.iter()
.chain(comments.dangling_comments(ty.syntax()));
for comment in leading_dangling {
if JsCommentStyle::is_suppression(comment.piece().text()) {
return true;
}
}
for comment in comments
.trailing_comments(ty.syntax())
.iter()
.take_while(|comment| comment.lines_before() == 0)
{
if JsCommentStyle::is_suppression(comment.piece().text()) {
return true;
}
}
// Test if the preceding node as a trailing own line comment that is a suppression
if let Some(preceding_variant) = ty.syntax().prev_sibling() {
comments
.trailing_comments(&preceding_variant)
.iter()
.skip_while(|comment| comment.lines_before() == 0)
.any(|comment| JsCommentStyle::is_suppression(comment.piece().text()))
}
// If this is the first variant, then see if the union has a leading suppression comment.
else if let Some(union) = list.parent::<TsUnionType>() {
comments
.leading_comments(union.syntax())
.iter()
.any(|comment| JsCommentStyle::is_suppression(comment.piece().text()))
} else {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/lists/tuple_type_element_list.rs | crates/rome_js_formatter/src/ts/lists/tuple_type_element_list.rs | use crate::context::trailing_comma::FormatTrailingComma;
use crate::prelude::*;
use rome_js_syntax::TsTupleTypeElementList;
#[derive(Debug, Clone, Default)]
pub struct FormatTsTupleTypeElementList;
impl FormatRule<TsTupleTypeElementList> for FormatTsTupleTypeElementList {
type Context = JsFormatContext;
fn fmt(&self, node: &TsTupleTypeElementList, f: &mut JsFormatter) -> FormatResult<()> {
let trailing_separator = FormatTrailingComma::All.trailing_separator(f.options());
f.join_with(&soft_line_break_or_space())
.entries(
node.format_separated(",")
.with_trailing_separator(trailing_separator)
.nodes_grouped(),
)
.finish()
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/lists/type_list.rs | crates/rome_js_formatter/src/ts/lists/type_list.rs | use crate::prelude::*;
use rome_js_syntax::TsTypeList;
#[derive(Debug, Clone, Default)]
pub struct FormatTsTypeList;
impl FormatRule<TsTypeList> for FormatTsTypeList {
type Context = JsFormatContext;
fn fmt(&self, node: &TsTypeList, f: &mut JsFormatter) -> FormatResult<()> {
// the grouping will be applied by the parent
f.join_with(&soft_line_break_or_space())
.entries(
node.format_separated(",")
.with_trailing_separator(TrailingSeparator::Disallowed),
)
.finish()
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/lists/template_element_list.rs | crates/rome_js_formatter/src/ts/lists/template_element_list.rs | use crate::js::lists::template_element_list::AnyTemplateElementList;
use crate::prelude::*;
use rome_js_syntax::TsTemplateElementList;
#[derive(Debug, Clone, Default)]
pub struct FormatTsTemplateElementList;
impl FormatRule<TsTemplateElementList> for FormatTsTemplateElementList {
type Context = JsFormatContext;
fn fmt(&self, node: &TsTemplateElementList, f: &mut JsFormatter) -> FormatResult<()> {
AnyTemplateElementList::TsTemplateElementList(node.clone()).fmt(f)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/lists/type_member_list.rs | crates/rome_js_formatter/src/ts/lists/type_member_list.rs | use crate::prelude::*;
use rome_formatter::{write, Buffer};
use rome_js_syntax::{AnyTsTypeMember, TsTypeMemberList};
use crate::context::Semicolons;
use rome_rowan::AstNodeList;
#[derive(Debug, Clone, Default)]
pub struct FormatTsTypeMemberList;
impl FormatRule<TsTypeMemberList> for FormatTsTypeMemberList {
type Context = JsFormatContext;
fn fmt(&self, node: &TsTypeMemberList, f: &mut JsFormatter) -> FormatResult<()> {
let items = node.iter();
let last_index = items.len().saturating_sub(1);
let mut joiner = f.join_nodes_with_soft_line();
for (index, member) in items.enumerate() {
joiner.entry(
member.syntax(),
&TsTypeMemberItem {
last: index == last_index,
member: &member,
},
)
}
joiner.finish()
}
}
struct TsTypeMemberItem<'a> {
last: bool,
member: &'a AnyTsTypeMember,
}
impl Format<JsFormatContext> for TsTypeMemberItem<'_> {
fn fmt(&self, f: &mut JsFormatter) -> FormatResult<()> {
let mut is_verbatim = false;
write!(
f,
[group(&format_once(|f| {
let mut recording = f.start_recording();
write!(recording, [self.member.format()])?;
is_verbatim = recording.stop().end_tag(TagKind::Verbatim).is_some();
Ok(())
}))]
)?;
if !is_verbatim {
// Children don't format the separator on purpose, so it's up to the parent - this node,
// to decide to print their separator
match f.options().semicolons() {
Semicolons::Always => {
if self.last {
write!(f, [if_group_breaks(&text(";"))])?;
} else {
text(";").fmt(f)?;
}
}
Semicolons::AsNeeded => {
if !self.last {
write!(f, [if_group_fits_on_line(&text(";"))])?;
}
}
}
}
Ok(())
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/lists/method_signature_modifier_list.rs | crates/rome_js_formatter/src/ts/lists/method_signature_modifier_list.rs | use crate::prelude::*;
use crate::utils::format_modifiers::FormatModifiers;
use rome_js_syntax::TsMethodSignatureModifierList;
#[derive(Debug, Clone, Default)]
pub struct FormatTsMethodSignatureModifierList;
impl FormatRule<TsMethodSignatureModifierList> for FormatTsMethodSignatureModifierList {
type Context = JsFormatContext;
fn fmt(&self, node: &TsMethodSignatureModifierList, f: &mut JsFormatter) -> FormatResult<()> {
FormatModifiers::from(node.clone()).fmt(f)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/assignments/type_assertion_assignment.rs | crates/rome_js_formatter/src/ts/assignments/type_assertion_assignment.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxKind, JsSyntaxNode, TsTypeAssertionAssignmentFields};
use crate::parentheses::NeedsParentheses;
use rome_js_syntax::TsTypeAssertionAssignment;
#[derive(Debug, Clone, Default)]
pub struct FormatTsTypeAssertionAssignment;
impl FormatNodeRule<TsTypeAssertionAssignment> for FormatTsTypeAssertionAssignment {
fn fmt_fields(
&self,
node: &TsTypeAssertionAssignment,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsTypeAssertionAssignmentFields {
l_angle_token,
ty,
r_angle_token,
assignment,
} = node.as_fields();
write![
f,
[
l_angle_token.format(),
group(&soft_block_indent(&ty.format())),
r_angle_token.format(),
assignment.format()
]
]
}
fn needs_parentheses(&self, item: &TsTypeAssertionAssignment) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsTypeAssertionAssignment {
fn needs_parentheses_with_parent(&self, parent: &JsSyntaxNode) -> bool {
matches!(
parent.kind(),
JsSyntaxKind::JS_ASSIGNMENT_EXPRESSION
| JsSyntaxKind::TS_TYPE_ASSERTION_ASSIGNMENT
| JsSyntaxKind::TS_NON_NULL_ASSERTION_ASSIGNMENT
| JsSyntaxKind::JS_PRE_UPDATE_EXPRESSION
| JsSyntaxKind::JS_POST_UPDATE_EXPRESSION
)
}
}
#[cfg(test)]
mod tests {
use crate::{assert_needs_parentheses, assert_not_needs_parentheses};
use rome_js_syntax::TsTypeAssertionAssignment;
#[test]
fn needs_parentheses() {
assert_needs_parentheses!("(<number>a) = 'test'", TsTypeAssertionAssignment);
assert_needs_parentheses!("(<number>a)! = 'test'", TsTypeAssertionAssignment);
assert_needs_parentheses!("(<number>(<any>a)) = 'test'", TsTypeAssertionAssignment[0]);
assert_needs_parentheses!("(<number>(<any>a)) = 'test'", TsTypeAssertionAssignment[1]);
assert_needs_parentheses!("++(<number>a)", TsTypeAssertionAssignment);
assert_needs_parentheses!("(<number>a)--", TsTypeAssertionAssignment);
assert_not_needs_parentheses!("({ a: <number>a } = { a: 5 })", TsTypeAssertionAssignment);
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/assignments/satisfies_assignment.rs | crates/rome_js_formatter/src/ts/assignments/satisfies_assignment.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use crate::ts::assignments::as_assignment::TsAsOrSatisfiesAssignment;
use rome_js_syntax::JsSyntaxNode;
use rome_js_syntax::TsSatisfiesAssignment;
#[derive(Debug, Clone, Default)]
pub struct FormatTsSatisfiesAssignment;
impl FormatNodeRule<TsSatisfiesAssignment> for FormatTsSatisfiesAssignment {
fn fmt_fields(&self, node: &TsSatisfiesAssignment, f: &mut JsFormatter) -> FormatResult<()> {
TsAsOrSatisfiesAssignment::from(node.clone()).fmt(f)
}
fn needs_parentheses(&self, item: &TsSatisfiesAssignment) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsSatisfiesAssignment {
fn needs_parentheses_with_parent(&self, parent: &JsSyntaxNode) -> bool {
TsAsOrSatisfiesAssignment::from(self.clone()).needs_parentheses_with_parent(parent)
}
}
#[cfg(test)]
mod tests {
use crate::assert_needs_parentheses;
use rome_js_syntax::TsSatisfiesAssignment;
#[test]
fn needs_parentheses() {
assert_needs_parentheses!("a satisfies number = 'test'", TsSatisfiesAssignment);
assert_needs_parentheses!("(a satisfies number)! = 'test'", TsSatisfiesAssignment);
assert_needs_parentheses!(
"(<number>(a satisfies number)) = 'test'",
TsSatisfiesAssignment
);
assert_needs_parentheses!("++(a satisfies number)", TsSatisfiesAssignment);
assert_needs_parentheses!("(a satisfies number)--", TsSatisfiesAssignment);
assert_needs_parentheses!(
"({ a: a satisfies number } = { a: 5 })",
TsSatisfiesAssignment
);
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/assignments/mod.rs | crates/rome_js_formatter/src/ts/assignments/mod.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
pub(crate) mod as_assignment;
pub(crate) mod non_null_assertion_assignment;
pub(crate) mod satisfies_assignment;
pub(crate) mod type_assertion_assignment;
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/assignments/non_null_assertion_assignment.rs | crates/rome_js_formatter/src/ts/assignments/non_null_assertion_assignment.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::TsNonNullAssertionAssignmentFields;
use rome_js_syntax::{JsSyntaxNode, TsNonNullAssertionAssignment};
#[derive(Debug, Clone, Default)]
pub struct FormatTsNonNullAssertionAssignment;
impl FormatNodeRule<TsNonNullAssertionAssignment> for FormatTsNonNullAssertionAssignment {
fn fmt_fields(
&self,
node: &TsNonNullAssertionAssignment,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsNonNullAssertionAssignmentFields {
assignment,
excl_token,
} = node.as_fields();
write![f, [assignment.format(), excl_token.format()]]
}
fn needs_parentheses(&self, item: &TsNonNullAssertionAssignment) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsNonNullAssertionAssignment {
#[inline]
fn needs_parentheses(&self) -> bool {
false
}
#[inline]
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/assignments/as_assignment.rs | crates/rome_js_formatter/src/ts/assignments/as_assignment.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::{format_args, write};
use rome_js_syntax::{AnyJsAssignment, AnyTsType, JsSyntaxKind, JsSyntaxNode, JsSyntaxToken};
use rome_js_syntax::{TsAsAssignment, TsSatisfiesAssignment};
use rome_rowan::{declare_node_union, SyntaxResult};
#[derive(Debug, Clone, Default)]
pub struct FormatTsAsAssignment;
impl FormatNodeRule<TsAsAssignment> for FormatTsAsAssignment {
fn fmt_fields(&self, node: &TsAsAssignment, f: &mut JsFormatter) -> FormatResult<()> {
TsAsOrSatisfiesAssignment::from(node.clone()).fmt(f)
}
fn needs_parentheses(&self, item: &TsAsAssignment) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsAsAssignment {
fn needs_parentheses_with_parent(&self, parent: &JsSyntaxNode) -> bool {
TsAsOrSatisfiesAssignment::from(self.clone()).needs_parentheses_with_parent(parent)
}
}
declare_node_union! {
pub(crate) TsAsOrSatisfiesAssignment = TsAsAssignment | TsSatisfiesAssignment
}
impl Format<JsFormatContext> for TsAsOrSatisfiesAssignment {
fn fmt(&self, f: &mut Formatter<JsFormatContext>) -> FormatResult<()> {
let assignment = self.assignment()?;
let operation_token = self.operation_token()?;
let ty = self.ty()?;
write![f, [assignment.format(), space(), operation_token.format()]]?;
if f.comments().has_leading_own_line_comment(ty.syntax()) {
write!(f, [indent(&format_args![hard_line_break(), ty.format()])])
} else {
write!(f, [space(), ty.format()])
}
}
}
impl NeedsParentheses for TsAsOrSatisfiesAssignment {
fn needs_parentheses_with_parent(&self, parent: &JsSyntaxNode) -> bool {
matches!(
parent.kind(),
JsSyntaxKind::JS_ASSIGNMENT_EXPRESSION
| JsSyntaxKind::TS_NON_NULL_ASSERTION_ASSIGNMENT
| JsSyntaxKind::TS_TYPE_ASSERTION_ASSIGNMENT
| JsSyntaxKind::JS_PRE_UPDATE_EXPRESSION
| JsSyntaxKind::JS_POST_UPDATE_EXPRESSION
| JsSyntaxKind::JS_OBJECT_ASSIGNMENT_PATTERN_PROPERTY
)
}
}
impl TsAsOrSatisfiesAssignment {
fn assignment(&self) -> SyntaxResult<AnyJsAssignment> {
match self {
TsAsOrSatisfiesAssignment::TsAsAssignment(assignment) => assignment.assignment(),
TsAsOrSatisfiesAssignment::TsSatisfiesAssignment(assignment) => assignment.assignment(),
}
}
fn operation_token(&self) -> SyntaxResult<JsSyntaxToken> {
match self {
TsAsOrSatisfiesAssignment::TsAsAssignment(assignment) => assignment.as_token(),
TsAsOrSatisfiesAssignment::TsSatisfiesAssignment(assignment) => {
assignment.satisfies_token()
}
}
}
fn ty(&self) -> SyntaxResult<AnyTsType> {
match self {
TsAsOrSatisfiesAssignment::TsAsAssignment(assignment) => assignment.ty(),
TsAsOrSatisfiesAssignment::TsSatisfiesAssignment(assignment) => assignment.ty(),
}
}
}
#[cfg(test)]
mod tests {
use crate::assert_needs_parentheses;
use rome_js_syntax::TsAsAssignment;
#[test]
fn needs_parentheses() {
assert_needs_parentheses!("a as number = 'test'", TsAsAssignment);
assert_needs_parentheses!("(a as number)! = 'test'", TsAsAssignment);
assert_needs_parentheses!("(<number>(a as number)) = 'test'", TsAsAssignment);
assert_needs_parentheses!("++(a as number)", TsAsAssignment);
assert_needs_parentheses!("(a as number)--", TsAsAssignment);
assert_needs_parentheses!("({ a: a as number } = { a: 5 })", TsAsAssignment);
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/bogus/bogus_type.rs | crates/rome_js_formatter/src/ts/bogus/bogus_type.rs | use crate::parentheses::NeedsParentheses;
use crate::FormatBogusNodeRule;
use rome_js_syntax::{JsSyntaxNode, TsBogusType};
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatTsBogusType;
impl FormatBogusNodeRule<TsBogusType> for FormatTsBogusType {}
impl NeedsParentheses for TsBogusType {
fn needs_parentheses(&self) -> bool {
false
}
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/bogus/mod.rs | crates/rome_js_formatter/src/ts/bogus/mod.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
pub(crate) mod bogus_type;
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/declarations/type_alias_declaration.rs | crates/rome_js_formatter/src/ts/declarations/type_alias_declaration.rs | use crate::prelude::*;
use crate::utils::{AnyJsAssignmentLike, FormatStatementSemicolon};
use rome_formatter::write;
use rome_js_syntax::TsTypeAliasDeclaration;
#[derive(Debug, Clone, Default)]
pub struct FormatTsTypeAliasDeclaration;
impl FormatNodeRule<TsTypeAliasDeclaration> for FormatTsTypeAliasDeclaration {
fn fmt_fields(&self, node: &TsTypeAliasDeclaration, f: &mut JsFormatter) -> FormatResult<()> {
let type_token = node.type_token()?;
let semicolon = node.semicolon_token();
let assignment_like = format_with(|f| write!(f, [AnyJsAssignmentLike::from(node.clone())]));
write!(
f,
[
type_token.format(),
space(),
group(&assignment_like),
FormatStatementSemicolon::new(semicolon.as_ref())
]
)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/declarations/declare_function_export_default_declaration.rs | crates/rome_js_formatter/src/ts/declarations/declare_function_export_default_declaration.rs | use crate::js::declarations::function_declaration::FormatFunction;
use crate::prelude::*;
use crate::utils::FormatStatementSemicolon;
use rome_formatter::write;
use rome_js_syntax::TsDeclareFunctionExportDefaultDeclaration;
#[derive(Debug, Clone, Default)]
pub struct FormatTsDeclareFunctionExportDefaultDeclaration;
impl FormatNodeRule<TsDeclareFunctionExportDefaultDeclaration>
for FormatTsDeclareFunctionExportDefaultDeclaration
{
fn fmt_fields(
&self,
node: &TsDeclareFunctionExportDefaultDeclaration,
f: &mut JsFormatter,
) -> FormatResult<()> {
write![
f,
[
FormatFunction::from(node.clone()),
FormatStatementSemicolon::new(node.semicolon_token().as_ref())
]
]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/declarations/import_equals_declaration.rs | crates/rome_js_formatter/src/ts/declarations/import_equals_declaration.rs | use crate::prelude::*;
use crate::utils::FormatStatementSemicolon;
use rome_formatter::write;
use rome_js_syntax::TsImportEqualsDeclaration;
use rome_js_syntax::TsImportEqualsDeclarationFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsImportEqualsDeclaration;
impl FormatNodeRule<TsImportEqualsDeclaration> for FormatTsImportEqualsDeclaration {
fn fmt_fields(
&self,
node: &TsImportEqualsDeclaration,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsImportEqualsDeclarationFields {
import_token,
type_token,
id,
eq_token,
module_reference,
semicolon_token,
} = node.as_fields();
write!(f, [import_token.format(), space(),])?;
if let Some(type_token) = type_token {
write!(f, [type_token.format(), space()])?;
}
write!(
f,
[
id.format(),
space(),
eq_token.format(),
space(),
module_reference.format(),
FormatStatementSemicolon::new(semicolon_token.as_ref())
]
)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/declarations/external_module_declaration.rs | crates/rome_js_formatter/src/ts/declarations/external_module_declaration.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsExternalModuleDeclarationFields;
use rome_js_syntax::{AnyTsExternalModuleDeclarationBody, TsExternalModuleDeclaration};
#[derive(Debug, Clone, Default)]
pub struct FormatTsExternalModuleDeclaration;
impl FormatNodeRule<TsExternalModuleDeclaration> for FormatTsExternalModuleDeclaration {
fn fmt_fields(
&self,
node: &TsExternalModuleDeclaration,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsExternalModuleDeclarationFields {
body,
module_token,
source,
} = node.as_fields();
write!(f, [module_token.format(), space(), source.format(),])?;
match body {
Some(AnyTsExternalModuleDeclarationBody::TsEmptyExternalModuleDeclarationBody(
body,
)) => {
body.format().fmt(f)?;
}
Some(AnyTsExternalModuleDeclarationBody::TsModuleBlock(body)) => {
write!(f, [space(), body.format()])?;
}
None if f.options().semicolons().is_always() => {
write!(f, [text(";")])?;
}
None => {}
}
Ok(())
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/declarations/interface_declaration.rs | crates/rome_js_formatter/src/ts/declarations/interface_declaration.rs | use crate::prelude::*;
use rome_formatter::{format_args, write};
use rome_js_syntax::{TsInterfaceDeclaration, TsInterfaceDeclarationFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsInterfaceDeclaration;
impl FormatNodeRule<TsInterfaceDeclaration> for FormatTsInterfaceDeclaration {
fn fmt_fields(&self, node: &TsInterfaceDeclaration, f: &mut JsFormatter) -> FormatResult<()> {
let TsInterfaceDeclarationFields {
interface_token,
id,
type_parameters,
extends_clause,
members,
l_curly_token,
r_curly_token,
} = node.as_fields();
let l_curly_token = l_curly_token?;
let r_curly_token = r_curly_token?;
let id = id?;
let type_parameters = type_parameters;
let should_indent_extends_only = type_parameters.as_ref().map_or(false, |params| {
!f.comments().has_trailing_line_comment(params.syntax())
});
let type_parameter_group = if should_indent_extends_only && extends_clause.is_some() {
Some(f.group_id("type_parameters"))
} else {
None
};
let format_id = format_with(|f| {
write!(f, [id.format(),])?;
if let Some(type_parameters) = &type_parameters {
write!(
f,
[type_parameters.format().with_options(type_parameter_group)]
)?;
}
Ok(())
});
let format_extends = format_with(|f| {
if let Some(extends_clause) = &extends_clause {
if should_indent_extends_only {
write!(
f,
[
if_group_breaks(&space()).with_group_id(type_parameter_group),
if_group_fits_on_line(&soft_line_break_or_space())
.with_group_id(type_parameter_group),
]
)?;
} else {
write!(f, [soft_line_break_or_space()])?;
}
write!(f, [extends_clause.format(), space()])?;
}
Ok(())
});
let content = format_with(|f| {
write![f, [interface_token.format(), space()]]?;
let id_has_trailing_comments = f.comments().has_trailing_comments(id.syntax());
if id_has_trailing_comments || extends_clause.is_some() {
if should_indent_extends_only {
write!(
f,
[group(&format_args!(format_id, indent(&format_extends)))]
)?;
} else {
write!(
f,
[group(&indent(&format_args!(format_id, format_extends)))]
)?;
}
} else {
write!(f, [format_id, format_extends])?;
}
write!(f, [space(), l_curly_token.format()])?;
if members.is_empty() {
write!(
f,
[format_dangling_comments(node.syntax()).with_block_indent()]
)?;
} else {
write!(f, [block_indent(&members.format())])?;
}
write!(f, [r_curly_token.format()])
});
write![f, [group(&content)]]
}
fn fmt_dangling_comments(
&self,
_: &TsInterfaceDeclaration,
_: &mut JsFormatter,
) -> FormatResult<()> {
// Handled inside of `fmt_fields`
Ok(())
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/declarations/mod.rs | crates/rome_js_formatter/src/ts/declarations/mod.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
pub(crate) mod declare_function_declaration;
pub(crate) mod declare_function_export_default_declaration;
pub(crate) mod enum_declaration;
pub(crate) mod external_module_declaration;
pub(crate) mod global_declaration;
pub(crate) mod import_equals_declaration;
pub(crate) mod interface_declaration;
pub(crate) mod module_declaration;
pub(crate) mod type_alias_declaration;
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/declarations/module_declaration.rs | crates/rome_js_formatter/src/ts/declarations/module_declaration.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsModuleDeclaration;
use rome_js_syntax::TsModuleDeclarationFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsModuleDeclaration;
impl FormatNodeRule<TsModuleDeclaration> for FormatTsModuleDeclaration {
fn fmt_fields(&self, node: &TsModuleDeclaration, f: &mut JsFormatter) -> FormatResult<()> {
let TsModuleDeclarationFields {
module_or_namespace,
name,
body,
} = node.as_fields();
write![
f,
[
module_or_namespace.format(),
space(),
name.format(),
space(),
body.format(),
]
]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/declarations/enum_declaration.rs | crates/rome_js_formatter/src/ts/declarations/enum_declaration.rs | use crate::prelude::*;
use rome_formatter::{format_args, write};
use rome_js_syntax::{TsEnumDeclaration, TsEnumDeclarationFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsEnumDeclaration;
impl FormatNodeRule<TsEnumDeclaration> for FormatTsEnumDeclaration {
fn fmt_fields(&self, node: &TsEnumDeclaration, f: &mut JsFormatter) -> FormatResult<()> {
let TsEnumDeclarationFields {
const_token,
enum_token,
id,
members,
l_curly_token,
r_curly_token,
} = node.as_fields();
if let Some(const_token) = const_token {
write!(f, [const_token.format(), space()])?;
}
write!(
f,
[
enum_token.format(),
space(),
id.format(),
space(),
l_curly_token.format(),
]
)?;
if members.is_empty() {
write!(
f,
[group(&format_args![
format_dangling_comments(node.syntax()),
soft_line_break()
])]
)?;
} else {
write!(f, [block_indent(&members.format())])?;
}
write!(f, [r_curly_token.format()])
}
fn fmt_dangling_comments(
&self,
_: &TsEnumDeclaration,
_: &mut JsFormatter,
) -> FormatResult<()> {
Ok(())
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/declarations/declare_function_declaration.rs | crates/rome_js_formatter/src/ts/declarations/declare_function_declaration.rs | use crate::prelude::*;
use crate::utils::FormatStatementSemicolon;
use crate::js::declarations::function_declaration::FormatFunction;
use rome_formatter::write;
use rome_js_syntax::TsDeclareFunctionDeclaration;
#[derive(Debug, Clone, Default)]
pub struct FormatTsDeclareFunctionDeclaration;
impl FormatNodeRule<TsDeclareFunctionDeclaration> for FormatTsDeclareFunctionDeclaration {
fn fmt_fields(
&self,
node: &TsDeclareFunctionDeclaration,
f: &mut JsFormatter,
) -> FormatResult<()> {
write!(
f,
[
FormatFunction::from(node.clone()),
FormatStatementSemicolon::new(node.semicolon_token().as_ref())
]
)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/declarations/global_declaration.rs | crates/rome_js_formatter/src/ts/declarations/global_declaration.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsGlobalDeclaration;
use rome_js_syntax::TsGlobalDeclarationFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsGlobalDeclaration;
impl FormatNodeRule<TsGlobalDeclaration> for FormatTsGlobalDeclaration {
fn fmt_fields(&self, node: &TsGlobalDeclaration, f: &mut JsFormatter) -> FormatResult<()> {
let TsGlobalDeclarationFields { global_token, body } = node.as_fields();
write![f, [global_token.format(), space(), body.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/string_literal_type.rs | crates/rome_js_formatter/src/ts/types/string_literal_type.rs | use crate::prelude::*;
use crate::utils::{FormatLiteralStringToken, StringLiteralParentKind};
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsStringLiteralType, TsStringLiteralTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsStringLiteralType;
impl FormatNodeRule<TsStringLiteralType> for FormatTsStringLiteralType {
fn fmt_fields(&self, node: &TsStringLiteralType, f: &mut JsFormatter) -> FormatResult<()> {
let TsStringLiteralTypeFields { literal_token } = node.as_fields();
write!(
f,
[FormatLiteralStringToken::new(
&literal_token?,
StringLiteralParentKind::Expression
)]
)
}
fn needs_parentheses(&self, item: &TsStringLiteralType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsStringLiteralType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/null_literal_type.rs | crates/rome_js_formatter/src/ts/types/null_literal_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsNullLiteralType, TsNullLiteralTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsNullLiteralType;
impl FormatNodeRule<TsNullLiteralType> for FormatTsNullLiteralType {
fn fmt_fields(&self, node: &TsNullLiteralType, f: &mut JsFormatter) -> FormatResult<()> {
let TsNullLiteralTypeFields { literal_token } = node.as_fields();
write![f, [literal_token.format()]]
}
fn needs_parentheses(&self, item: &TsNullLiteralType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsNullLiteralType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/typeof_type.rs | crates/rome_js_formatter/src/ts/types/typeof_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsTypeofType, TsTypeofTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsTypeofType;
impl FormatNodeRule<TsTypeofType> for FormatTsTypeofType {
fn fmt_fields(&self, node: &TsTypeofType, f: &mut JsFormatter) -> FormatResult<()> {
let TsTypeofTypeFields {
type_arguments,
typeof_token,
expression_name,
} = node.as_fields();
write![
f,
[
typeof_token.format(),
space(),
expression_name.format(),
type_arguments.format()
]
]
}
fn needs_parentheses(&self, item: &TsTypeofType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsTypeofType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/type_operator_type.rs | crates/rome_js_formatter/src/ts/types/type_operator_type.rs | use crate::prelude::*;
use crate::parentheses::{operator_type_or_higher_needs_parens, NeedsParentheses};
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsTypeOperatorType, TsTypeOperatorTypeFields};
use rome_rowan::AstNode;
#[derive(Debug, Clone, Default)]
pub struct FormatTsTypeOperatorType;
impl FormatNodeRule<TsTypeOperatorType> for FormatTsTypeOperatorType {
fn fmt_fields(&self, node: &TsTypeOperatorType, f: &mut JsFormatter) -> FormatResult<()> {
let TsTypeOperatorTypeFields { operator_token, ty } = node.as_fields();
write![f, [operator_token.format(), space(), ty.format()]]
}
fn needs_parentheses(&self, item: &TsTypeOperatorType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsTypeOperatorType {
fn needs_parentheses_with_parent(&self, parent: &JsSyntaxNode) -> bool {
operator_type_or_higher_needs_parens(self.syntax(), parent)
}
}
#[cfg(test)]
mod tests {
use crate::{assert_needs_parentheses, assert_not_needs_parentheses};
use rome_js_syntax::TsTypeOperatorType;
#[test]
fn needs_parentheses() {
assert_needs_parentheses!("let s: (unique symbol)[] = symbol();", TsTypeOperatorType);
assert_needs_parentheses!("let s: unique (unique symbol);", TsTypeOperatorType[1]);
assert_not_needs_parentheses!("let s: unique (unique symbol);", TsTypeOperatorType[0]);
assert_needs_parentheses!("let s: [number, ...(unique symbol)]", TsTypeOperatorType);
assert_needs_parentheses!("let s: [(unique symbol)?]", TsTypeOperatorType);
assert_needs_parentheses!("let s: (unique symbol)[a]", TsTypeOperatorType);
assert_not_needs_parentheses!("let s: a[(unique symbol)]", TsTypeOperatorType);
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/template_literal_type.rs | crates/rome_js_formatter/src/ts/types/template_literal_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::TsTemplateLiteralTypeFields;
use rome_js_syntax::{JsSyntaxNode, TsTemplateLiteralType};
#[derive(Debug, Clone, Default)]
pub struct FormatTsTemplateLiteralType;
impl FormatNodeRule<TsTemplateLiteralType> for FormatTsTemplateLiteralType {
fn fmt_fields(&self, node: &TsTemplateLiteralType, f: &mut JsFormatter) -> FormatResult<()> {
let TsTemplateLiteralTypeFields {
l_tick_token,
elements,
r_tick_token,
} = node.as_fields();
write![
f,
[
l_tick_token.format(),
elements.format(),
r_tick_token.format(),
]
]
}
fn needs_parentheses(&self, item: &TsTemplateLiteralType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsTemplateLiteralType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/asserts_return_type.rs | crates/rome_js_formatter/src/ts/types/asserts_return_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::TsAssertsReturnTypeFields;
use rome_js_syntax::{JsSyntaxNode, TsAssertsReturnType};
#[derive(Debug, Clone, Default)]
pub struct FormatTsAssertsReturnType;
impl FormatNodeRule<TsAssertsReturnType> for FormatTsAssertsReturnType {
fn fmt_fields(&self, node: &TsAssertsReturnType, f: &mut JsFormatter) -> FormatResult<()> {
let TsAssertsReturnTypeFields {
parameter_name,
asserts_token,
predicate,
} = node.as_fields();
write![
f,
[
asserts_token.format(),
space(),
parameter_name.format(),
space(),
predicate.format()
]
]
}
fn needs_parentheses(&self, item: &TsAssertsReturnType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsAssertsReturnType {
#[inline]
fn needs_parentheses_with_parent(&self, _: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/union_type.rs | crates/rome_js_formatter/src/ts/types/union_type.rs | use crate::parentheses::NeedsParentheses;
use crate::prelude::*;
use crate::utils::{
should_hug_type, union_or_intersection_type_needs_parentheses, FormatTypeMemberSeparator,
TsIntersectionOrUnionTypeList,
};
use rome_formatter::{format_args, write, Buffer};
use rome_js_syntax::{JsSyntaxKind, JsSyntaxToken, TsTupleTypeElementList, TsUnionType};
use rome_js_syntax::{JsSyntaxNode, TsUnionTypeFields};
use rome_rowan::SyntaxNodeOptionExt;
#[derive(Debug, Clone, Default)]
pub struct FormatTsUnionType;
impl FormatNodeRule<TsUnionType> for FormatTsUnionType {
// [Prettier applies]: https://github.com/prettier/prettier/blob/cd3e530c2e51fb8296c0fb7738a9afdd3a3a4410/src/language-js/print/type-annotation.js#L123-L202
fn fmt_fields(&self, node: &TsUnionType, f: &mut JsFormatter) -> FormatResult<()> {
let TsUnionTypeFields {
leading_separator_token,
types,
} = node.as_fields();
// ```ts
// {
// a: string
// } | null | void
// ```
// should be inlined and not be printed in the multi-line variant
let should_hug = should_hug_type(&node.clone().into());
if should_hug {
return write!(
f,
[
FormatTypeMemberSeparator::new(leading_separator_token.as_ref()),
types.format().with_options(should_hug)
]
);
}
let has_leading_comments = f.comments().has_leading_comments(node.syntax());
let should_indent = {
let parent_kind = node.syntax().parent().kind();
// These parents have indent for their content, so we don't need to indent here
!match parent_kind {
Some(JsSyntaxKind::TS_TYPE_ALIAS_DECLARATION) => has_leading_comments,
parent_kind => {
matches!(
parent_kind,
Some(
JsSyntaxKind::TS_TYPE_ASSERTION_EXPRESSION
| JsSyntaxKind::TS_TUPLE_TYPE_ELEMENT_LIST
| JsSyntaxKind::TS_TYPE_ASSERTION_ASSIGNMENT
| JsSyntaxKind::TS_TYPE_ARGUMENT_LIST
| JsSyntaxKind::TS_MAPPED_TYPE
)
)
}
}
};
let types = format_with(|f| {
if has_leading_comments {
write!(f, [soft_line_break()])?;
}
write!(
f,
[
FormatTypeSetLeadingSeparator {
separator: "|",
leading_separator: leading_separator_token.as_ref(),
leading_soft_line_break_or_space: should_indent && !has_leading_comments,
},
types.format()
]
)
});
let content = format_with(|f| {
// it is necessary to add parentheses for unions in intersections
// ```ts
// type Some = B & (C | A) & D
// ```
if node.needs_parentheses() {
return write!(f, [indent(&types), soft_line_break()]);
}
let is_inside_complex_tuple_type = node
.parent::<TsTupleTypeElementList>()
.map_or(false, |tuple| tuple.len() > 1);
if is_inside_complex_tuple_type {
write!(
f,
[
indent(&format_args![
if_group_breaks(&format_args![text("("), soft_line_break()]),
types
]),
soft_line_break(),
if_group_breaks(&text(")"))
]
)
} else if should_indent {
write!(f, [indent(&types)])
} else {
write!(f, [types])
}
});
write!(f, [group(&content)])
}
fn needs_parentheses(&self, item: &TsUnionType) -> bool {
item.needs_parentheses()
}
fn is_suppressed(&self, node: &TsUnionType, f: &JsFormatter) -> bool {
f.comments().mark_suppression_checked(node.syntax());
if node.types().is_empty() {
f.comments().is_suppressed(node.syntax())
} else {
// Suppression applies to first variant
false
}
}
}
impl NeedsParentheses for TsUnionType {
fn needs_parentheses_with_parent(&self, parent: &JsSyntaxNode) -> bool {
union_or_intersection_type_needs_parentheses(
self.syntax(),
parent,
&TsIntersectionOrUnionTypeList::TsUnionTypeVariantList(self.types()),
)
}
}
pub struct FormatTypeSetLeadingSeparator<'a> {
separator: &'static str,
leading_separator: Option<&'a JsSyntaxToken>,
leading_soft_line_break_or_space: bool,
}
impl Format<JsFormatContext> for FormatTypeSetLeadingSeparator<'_> {
fn fmt(&self, f: &mut JsFormatter) -> FormatResult<()> {
match &self.leading_separator {
Some(token) => {
let content = format_with(|f| {
if self.leading_soft_line_break_or_space {
write!(f, [soft_line_break_or_space()])?;
}
write!(f, [token.format(), space()])
});
format_only_if_breaks(token, &content).fmt(f)
}
None => {
let content = format_with(|f| {
if self.leading_soft_line_break_or_space {
write!(f, [soft_line_break_or_space()])?;
}
write!(f, [text(self.separator), space()])
});
write!(f, [if_group_breaks(&content)])
}
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/intersection_type.rs | crates/rome_js_formatter/src/ts/types/intersection_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use crate::utils::{
union_or_intersection_type_needs_parentheses, FormatTypeMemberSeparator,
TsIntersectionOrUnionTypeList,
};
use rome_formatter::{format_args, write};
use rome_js_syntax::{JsSyntaxNode, TsIntersectionType, TsIntersectionTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsIntersectionType;
impl FormatNodeRule<TsIntersectionType> for FormatTsIntersectionType {
fn fmt_fields(&self, node: &TsIntersectionType, f: &mut JsFormatter) -> FormatResult<()> {
let TsIntersectionTypeFields {
leading_separator_token,
types,
} = node.as_fields();
write!(
f,
[group(&format_args!(
FormatTypeMemberSeparator::new(leading_separator_token.as_ref()),
types.format()
))]
)
}
fn needs_parentheses(&self, item: &TsIntersectionType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsIntersectionType {
fn needs_parentheses_with_parent(&self, parent: &JsSyntaxNode) -> bool {
union_or_intersection_type_needs_parentheses(
self.syntax(),
parent,
&TsIntersectionOrUnionTypeList::TsIntersectionTypeElementList(self.types()),
)
}
}
#[cfg(test)]
mod tests {
use crate::{assert_needs_parentheses, assert_not_needs_parentheses};
use rome_js_syntax::TsIntersectionType;
#[test]
fn needs_parentheses() {
assert_needs_parentheses!("let s: (string & number)[] = symbol();", TsIntersectionType);
assert_needs_parentheses!("let s: unique (string & number);", TsIntersectionType);
assert_needs_parentheses!("let s: [number, ...(string & number)]", TsIntersectionType);
assert_needs_parentheses!("let s: [(string & number)?]", TsIntersectionType);
assert_needs_parentheses!("let s: (string & number)[a]", TsIntersectionType);
assert_not_needs_parentheses!("let s: a[(string & number)]", TsIntersectionType);
assert_not_needs_parentheses!("let s: (&a) & (&b)", TsIntersectionType[1]);
assert_not_needs_parentheses!("let s: (&a) & (&b)", TsIntersectionType[2]);
assert_needs_parentheses!("let s: (a & b) & (&c)", TsIntersectionType[1]);
assert_not_needs_parentheses!("let s: (a & b) & (&c)", TsIntersectionType[2]);
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/tuple_type.rs | crates/rome_js_formatter/src/ts/types/tuple_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsTupleType, TsTupleTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsTupleType;
impl FormatNodeRule<TsTupleType> for FormatTsTupleType {
fn fmt_fields(&self, node: &TsTupleType, f: &mut JsFormatter) -> FormatResult<()> {
let TsTupleTypeFields {
l_brack_token,
elements,
r_brack_token,
} = node.as_fields();
write!(f, [l_brack_token.format(),])?;
if elements.is_empty() {
write!(
f,
[format_dangling_comments(node.syntax()).with_soft_block_indent()]
)?;
} else {
write!(f, [group(&soft_block_indent(&elements.format())),])?;
}
write!(f, [r_brack_token.format(),])
}
fn needs_parentheses(&self, item: &TsTupleType) -> bool {
item.needs_parentheses()
}
fn fmt_dangling_comments(&self, _: &TsTupleType, _: &mut JsFormatter) -> FormatResult<()> {
// Handled inside of `fmt_fields`
Ok(())
}
}
impl NeedsParentheses for TsTupleType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.