From 81c3748a2805f6b329911d61c7dc7755bc48758b Mon Sep 17 00:00:00 2001 From: Connor Shea Date: Sun, 26 Oct 2025 22:17:01 -0600 Subject: [PATCH] docs(linter): Add configuration option docs for import/no-anonymous-default-export rule. These already existed, but this allows us to autogenerate them. --- .../import/no_anonymous_default_export.rs | 37 ++++++------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/crates/oxc_linter/src/rules/import/no_anonymous_default_export.rs b/crates/oxc_linter/src/rules/import/no_anonymous_default_export.rs index 25ef44c92660b..3a368204bc74c 100644 --- a/crates/oxc_linter/src/rules/import/no_anonymous_default_export.rs +++ b/crates/oxc_linter/src/rules/import/no_anonymous_default_export.rs @@ -5,6 +5,7 @@ use oxc_ast::{ use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; use oxc_span::Span; +use schemars::JsonSchema; use serde_json::Value; use crate::{AstNode, context::LintContext, rule::Rule}; @@ -14,15 +15,24 @@ fn no_anonymous_default_export_diagnostic(span: Span, msg: &'static str) -> OxcD OxcDiagnostic::warn(msg).with_label(span) } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, JsonSchema)] +#[serde(rename_all = "camelCase", default)] pub struct NoAnonymousDefaultExport { + /// Allow anonymous array as default export. allow_array: bool, + /// Allow anonymous arrow function as default export. allow_arrow_function: bool, + /// Allow anonymous class as default export. allow_anonymous_class: bool, + /// Allow anonymous function as default export. allow_anonymous_function: bool, + /// Allow anonymous call expression as default export. allow_call_expression: bool, + /// Allow anonymous new expression as default export. allow_new: bool, + /// Allow anonymous literal as default export. allow_literal: bool, + /// Allow anonymous object as default export. allow_object: bool, } @@ -97,35 +107,12 @@ declare_oxc_lint!( /// export default foo(bar); /// ``` /// - /// ### Options - /// - /// This rule takes an object with the following properties: - /// - /// - `allowArray`: `boolean` (default: `false`) - Allow anonymous array as default export. - /// - `allowArrowFunction`: `boolean` (default: `false`) - Allow anonymous arrow function as default export. - /// - `allowAnonymousClass`: `boolean` (default: `false`) - Allow anonymous class as default export. - /// - `allowAnonymousFunction`: `boolean` (default: `false`) - Allow anonymous function as default export. - /// - `allowCallExpression`: `boolean` (default: `true`) - Allow anonymous call expression as default export. - /// - `allowNew`: `boolean` (default: `false`) - Allow anonymous new expression as default export. - /// - `allowLiteral`: `boolean` (default: `false`) - Allow anonymous literal as default export. - /// - `allowObject`: `boolean` (default: `false`) - Allow anonymous object as default export. - /// /// By default, all types of anonymous default exports are forbidden, /// but any types can be selectively allowed by toggling them on in the options. - /// ```json - /// "import/no-anonymous-default-export": ["error", { - /// "allowArray": false, - /// "allowArrowFunction": false, - /// "allowAnonymousClass": false, - /// "allowAnonymousFunction": false, - /// "allowCallExpression": true, - /// "allowNew": false, - /// "allowLiteral": false, - /// "allowObject": false - /// ``` NoAnonymousDefaultExport, import, style, + config = NoAnonymousDefaultExport, ); impl Rule for NoAnonymousDefaultExport {