Skip to content

Commit af8bdae

Browse files
authored
docs(linter): Add configuration option docs for import/no-anonymous-default-export rule. (#14971)
These already existed, but this allows us to auto-generate them. Part of #14743. Generated docs: ```md ## Configuration This rule accepts a configuration object with the following properties: ### allowAnonymousClass type: `boolean` default: `false` Allow anonymous class as default export. ### allowAnonymousFunction type: `boolean` default: `false` Allow anonymous function as default export. ### allowArray type: `boolean` default: `false` Allow anonymous array as default export. ### allowArrowFunction type: `boolean` default: `false` Allow anonymous arrow function as default export. ### allowCallExpression type: `boolean` default: `true` Allow anonymous call expression as default export. ### allowLiteral type: `boolean` default: `false` Allow anonymous literal as default export. ### allowNew type: `boolean` default: `false` Allow anonymous new expression as default export. ### allowObject type: `boolean` default: `false` Allow anonymous object as default export. ```
1 parent 5a81953 commit af8bdae

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

crates/oxc_linter/src/rules/import/no_anonymous_default_export.rs

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use oxc_ast::{
55
use oxc_diagnostics::OxcDiagnostic;
66
use oxc_macros::declare_oxc_lint;
77
use oxc_span::Span;
8+
use schemars::JsonSchema;
89
use serde_json::Value;
910

1011
use crate::{AstNode, context::LintContext, rule::Rule};
@@ -14,15 +15,24 @@ fn no_anonymous_default_export_diagnostic(span: Span, msg: &'static str) -> OxcD
1415
OxcDiagnostic::warn(msg).with_label(span)
1516
}
1617

17-
#[derive(Debug, Clone)]
18+
#[derive(Debug, Clone, JsonSchema)]
19+
#[serde(rename_all = "camelCase", default)]
1820
pub struct NoAnonymousDefaultExport {
21+
/// Allow anonymous array as default export.
1922
allow_array: bool,
23+
/// Allow anonymous arrow function as default export.
2024
allow_arrow_function: bool,
25+
/// Allow anonymous class as default export.
2126
allow_anonymous_class: bool,
27+
/// Allow anonymous function as default export.
2228
allow_anonymous_function: bool,
29+
/// Allow anonymous call expression as default export.
2330
allow_call_expression: bool,
31+
/// Allow anonymous new expression as default export.
2432
allow_new: bool,
33+
/// Allow anonymous literal as default export.
2534
allow_literal: bool,
35+
/// Allow anonymous object as default export.
2636
allow_object: bool,
2737
}
2838

@@ -97,35 +107,12 @@ declare_oxc_lint!(
97107
/// export default foo(bar);
98108
/// ```
99109
///
100-
/// ### Options
101-
///
102-
/// This rule takes an object with the following properties:
103-
///
104-
/// - `allowArray`: `boolean` (default: `false`) - Allow anonymous array as default export.
105-
/// - `allowArrowFunction`: `boolean` (default: `false`) - Allow anonymous arrow function as default export.
106-
/// - `allowAnonymousClass`: `boolean` (default: `false`) - Allow anonymous class as default export.
107-
/// - `allowAnonymousFunction`: `boolean` (default: `false`) - Allow anonymous function as default export.
108-
/// - `allowCallExpression`: `boolean` (default: `true`) - Allow anonymous call expression as default export.
109-
/// - `allowNew`: `boolean` (default: `false`) - Allow anonymous new expression as default export.
110-
/// - `allowLiteral`: `boolean` (default: `false`) - Allow anonymous literal as default export.
111-
/// - `allowObject`: `boolean` (default: `false`) - Allow anonymous object as default export.
112-
///
113110
/// By default, all types of anonymous default exports are forbidden,
114111
/// but any types can be selectively allowed by toggling them on in the options.
115-
/// ```json
116-
/// "import/no-anonymous-default-export": ["error", {
117-
/// "allowArray": false,
118-
/// "allowArrowFunction": false,
119-
/// "allowAnonymousClass": false,
120-
/// "allowAnonymousFunction": false,
121-
/// "allowCallExpression": true,
122-
/// "allowNew": false,
123-
/// "allowLiteral": false,
124-
/// "allowObject": false
125-
/// ```
126112
NoAnonymousDefaultExport,
127113
import,
128114
style,
115+
config = NoAnonymousDefaultExport,
129116
);
130117

131118
impl Rule for NoAnonymousDefaultExport {

0 commit comments

Comments
 (0)