Repository: swc-project/swc
File: crates/swc_ecma_parser/src/syntax.rs (Rust)

Code before:
        if self.dts {
            flags |= SyntaxFlags::DTS;
        }
        if self.no_early_errors {
            flags |= SyntaxFlags::NO_EARLY_ERRORS;
        }
        if self.disallow_ambiguous_jsx_like {
            flags |= SyntaxFlags::DISALLOW_AMBIGUOUS_JSX_LIKE;
        }
        flags
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EsSyntax {
    #[serde(default)]
    pub jsx: bool,

    /// Support function bind expression.
    #[serde(rename = "functionBind")]
    #[serde(default)]
    pub fn_bind: bool,

    #[serde(default)]
    /// Unwrap parenthesized expression in parser
    pub no_paren: bool,

    /// Enable decorators.
    #[serde(default)]
    pub decorators: bool,

    /// babel: `decorators.decoratorsBeforeExport`
    ///
    /// Effective only if `decorator` is true.
    #[serde(rename = "decoratorsBeforeExport")]
    #[serde(default)]
    pub decorators_before_export: bool,

    #[serde(default)]
    pub export_default_from: bool,

    /// Stage 4
    /// Always true in swc
    #[serde(default, alias = "importAssertions")]
    pub import_attributes: bool,

    #[serde(default, rename = "allowSuperOutsideMethod")]
    pub allow_super_outside_method: bool,

    #[serde(default, rename = "allowReturnOutsideFunction")]

Review comment (suggestion):
[nitpick] The documentation comment could be more descriptive. Consider expanding it to clarify the behavior and relationship to the ESTree spec, for example: "When enabled, the parser will not create ParenExpr nodes for parenthesized expressions. Instead, it returns the inner expression directly. This aligns with the ESTree spec which does not have a ParenthesizedExpression type."
```suggestion
    /// When enabled, the parser will not create ParenExpr nodes for parenthesized expressions.
    /// Instead, it returns the inner expression directly. This aligns with the ESTree spec,
    /// which does not have a ParenthesizedExpression type.
```

Code after:
        if self.no_paren {
            flags |= SyntaxFlags::NO_PAREN;
        }
        if self.dts {
            flags |= SyntaxFlags::DTS;
        }
        if self.no_early_errors {
            flags |= SyntaxFlags::NO_EARLY_ERRORS;
        }
        if self.disallow_ambiguous_jsx_like {
            flags |= SyntaxFlags::DISALLOW_AMBIGUOUS_JSX_LIKE;
        }
        flags
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EsSyntax {
    #[serde(default)]
    pub jsx: bool,

    /// Support function bind expression.
    #[serde(rename = "functionBind")]
    #[serde(default)]
    pub fn_bind: bool,

    #[serde(default)]
    /// When enabled, the parser will not create ParenExpr nodes for
    /// parenthesized expressions. Instead, it returns the inner expression
    /// directly. This aligns with the ESTree spec, which does not have a
    /// ParenthesizedExpression type.
    pub no_paren: bool,

    /// Enable decorators.
    #[serde(default)]
    pub decorators: bool,

    /// babel: `decorators.decoratorsBeforeExport`
    ///
    /// Effective only if `decorator` is true.
    #[serde(rename = "decoratorsBeforeExport")]
    #[serde(default)]
    pub decorators_before_export: bool,

    #[serde(default)]
    pub export_default_from: bool,

    /// Stage 4
    /// Always true in swc
    #[serde(default, alias = "importAssertions")]