Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion tasks/website_linter/src/rules/doc_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions tasks/website_linter/src/rules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
173 changes: 173 additions & 0 deletions tasks/website_linter/src/rules/snapshots/docs_rule_pages.snap
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,98 @@ oxlint --deny promise/no-callback-in-promise --promise-plugin
- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>


--- react/no-will-update-set-state.md ---
---
title: "react/no-will-update-set-state"
category: "Correctness"
default: false
type_aware: false
fix: "none"
---

<!-- This file is auto-generated by tasks/website_linter/src/rules/doc_page.rs. Do not edit it manually. -->

<script setup>
import { data } from '../version.data.js';
const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_linter/src/rules/react/no_will_update_set_state.rs`;
</script>

<RuleHeader />


### 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 <div>Hello {this.state.name}</div>;
}
});
```

Examples of **correct** code for this rule:
```jsx
var Hello = createReactClass({
componentWillUpdate: function() {
this.props.prepareHandler();
},
render: function() {
return <div>Hello {this.state.name}</div>;
}
});
```


## 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

- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>


--- typescript/no-floating-promises.md ---
---
title: "typescript/no-floating-promises"
Expand Down Expand Up @@ -1812,6 +1904,87 @@ oxlint --deny react/rules-of-hooks --react-plugin
:::


## References

- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>


--- typescript/class-literal-property-style.md ---
---
title: "typescript/class-literal-property-style"
category: "Style"
default: false
type_aware: false
fix: "pending"
---

<!-- This file is auto-generated by tasks/website_linter/src/rules/doc_page.rs. Do not edit it manually. -->

<script setup>
import { data } from '../version.data.js';
const source = `https://github.com/oxc-project/oxc/blob/${ data }/crates/oxc_linter/src/rules/typescript/class_literal_property_style.rs`;
</script>

<RuleHeader />


### 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

- <a v-bind:href="source" target="_blank" rel="noreferrer">Rule Source</a>
Loading