diff --git a/tasks/website_linter/src/rules/doc_page.rs b/tasks/website_linter/src/rules/doc_page.rs index 45b288cf8a232..251155865e9ef 100644 --- a/tasks/website_linter/src/rules/doc_page.rs +++ b/tasks/website_linter/src/rules/doc_page.rs @@ -188,7 +188,21 @@ const source = `{}`;{} } let mut rendered = section.to_md(&self.renderer); if rendered.trim().is_empty() { - return rendered; + // For primitive types (e.g. a single string argument) with no child + // sections, render the section's own type and default info directly. + let mut parts = String::new(); + if let Some(ref instance_type) = section.instance_type + && !instance_type.is_empty() + { + write!(parts, "\ntype: `{instance_type}`\n").unwrap(); + } + if let Some(ref default) = section.default { + write!(parts, "\ndefault: `{default}`\n").unwrap(); + } + if parts.trim().is_empty() { + return rendered; + } + rendered = parts; } // Check if this is an enum-based config (oneOf with single-value enums) diff --git a/tasks/website_linter/src/rules/mod.rs b/tasks/website_linter/src/rules/mod.rs index 968262936c5ce..0716f837f78fb 100644 --- a/tasks/website_linter/src/rules/mod.rs +++ b/tasks/website_linter/src/rules/mod.rs @@ -148,7 +148,9 @@ mod tests { | "nextjs/no-duplicate-head" | "oxc/no-barrel-file" | "promise/no-callback-in-promise" + | "react/no-will-update-set-state" | "react/rules-of-hooks" + | "typescript/class-literal-property-style" | "typescript/no-floating-promises" | "typescript/no-explicit-any" | "unicorn/prefer-array-find" diff --git a/tasks/website_linter/src/rules/snapshots/docs_rule_pages.snap b/tasks/website_linter/src/rules/snapshots/docs_rule_pages.snap index aaa918c839d20..3128f1d572a88 100644 --- a/tasks/website_linter/src/rules/snapshots/docs_rule_pages.snap +++ b/tasks/website_linter/src/rules/snapshots/docs_rule_pages.snap @@ -984,6 +984,98 @@ oxlint --deny promise/no-callback-in-promise --promise-plugin - Rule Source +--- react/no-will-update-set-state.md --- +--- +title: "react/no-will-update-set-state" +category: "Correctness" +default: false +type_aware: false +fix: "none" +--- + + + + + + + + +### What it does + +Disallows using `setState` in the `componentWillUpdate` lifecycle method. + +### Why is this bad? + +Updating the state during the component update step can lead to indeterminate component state and is not allowed. +This can cause unexpected behavior and bugs in your React application. + +### Examples + +Examples of **incorrect** code for this rule: +```jsx +var Hello = createReactClass({ + componentWillUpdate: function() { + this.setState({ + name: this.props.name.toUpperCase() + }); + }, + render: function() { + return
Hello {this.state.name}
; + } +}); +``` + +Examples of **correct** code for this rule: +```jsx +var Hello = createReactClass({ + componentWillUpdate: function() { + this.props.prepareHandler(); + }, + render: function() { + return
Hello {this.state.name}
; + } +}); +``` + + +## Configuration + +This rule accepts one of the following string values: + +type: `"allowed" | "disallow-in-func"` + + + +## How to use + +To **enable** this rule using the config file or in the CLI, you can use: + +::: code-group + +```json [Config (.oxlintrc.json)] +{ + "plugins": ["react"], + "rules": { + "react/no-will-update-set-state": "error" + } +} +``` + +```bash [CLI] +oxlint --deny react/no-will-update-set-state --react-plugin +``` + +::: + + +## References + +- Rule Source + + --- typescript/no-floating-promises.md --- --- title: "typescript/no-floating-promises" @@ -1812,6 +1904,87 @@ oxlint --deny react/rules-of-hooks --react-plugin ::: +## References + +- Rule Source + + +--- typescript/class-literal-property-style.md --- +--- +title: "typescript/class-literal-property-style" +category: "Style" +default: false +type_aware: false +fix: "pending" +--- + + + + + + + + +### What it does + +Enforces a consistent style for exposing literal values on classes. + +### Why is this bad? + +Mixing readonly fields and trivial literal getters for the same kind of value +makes class APIs inconsistent and harder to scan. + +### Examples + +Examples of **incorrect** code for this rule (default `"fields"`): +```ts +class C { + get name() { + return "oxc"; + } +} +``` + +Examples of **correct** code for this rule: +```ts +class C { + readonly name = "oxc"; +} +``` + + +## Configuration + +This rule accepts one of the following string values: + +type: `"fields" | "getters"` + + + +## How to use + +To **enable** this rule using the config file or in the CLI, you can use: + +::: code-group + +```json [Config (.oxlintrc.json)] +{ + "rules": { + "typescript/class-literal-property-style": "error" + } +} +``` + +```bash [CLI] +oxlint --deny typescript/class-literal-property-style +``` + +::: + + ## References - Rule Source