Skip to content

Commit 3d782b7

Browse files
authored
feat(linter): add schema for react/no-unstable-nested-components (#23287)
issue #22955
1 parent e63a139 commit 3d782b7

4 files changed

Lines changed: 109 additions & 5 deletions

File tree

apps/oxlint/src-js/package/config.generated.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,10 @@ export interface DummyRuleMap {
12031203
"react/no-unescaped-entities"?: RuleNoConfig;
12041204
"react/no-unknown-property"?: AllowWarnDeny | [AllowWarnDeny] | [AllowWarnDeny, NoUnknownPropertyConfig];
12051205
"react/no-unsafe"?: AllowWarnDeny | [AllowWarnDeny] | [AllowWarnDeny, NoUnsafeConfig];
1206-
"react/no-unstable-nested-components"?: DummyRule;
1206+
"react/no-unstable-nested-components"?:
1207+
| AllowWarnDeny
1208+
| [AllowWarnDeny]
1209+
| [AllowWarnDeny, NoUnstableNestedComponentsConfig];
12071210
"react/no-will-update-set-state"?: AllowWarnDeny | [AllowWarnDeny] | [AllowWarnDeny, NoWillUpdateSetStateConfig];
12081211
"react/only-export-components"?: AllowWarnDeny | [AllowWarnDeny] | [AllowWarnDeny, OnlyExportComponentsConfig];
12091212
"react/prefer-es6-class"?: AllowWarnDeny | [AllowWarnDeny] | [AllowWarnDeny, AlwaysNever];
@@ -4231,6 +4234,20 @@ export interface NoUnsafeConfig {
42314234
*/
42324235
checkAliases?: boolean;
42334236
}
4237+
export interface NoUnstableNestedComponentsConfig {
4238+
/**
4239+
* Allow component definitions in props.
4240+
*/
4241+
allowAsProps?: boolean;
4242+
/**
4243+
* Optional custom propTypes validators accepted for eslint-plugin-react compatibility.
4244+
*/
4245+
customValidators?: string[];
4246+
/**
4247+
* Glob pattern for render-prop names that may receive inline component definitions.
4248+
*/
4249+
propNamePattern?: string;
4250+
}
42344251
export interface OnlyExportComponentsConfig {
42354252
/**
42364253
* Allow exporting primitive constants (string/number/boolean/template literal)

crates/oxc_linter/src/utils/schemars.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::rules::RuleEnum;
1313
/// These should return the DummyRule struct/schema instead of the actual rule struct/schema,
1414
/// until we verify that the rule's schema is valid and can be generated by schemars.
1515
#[cfg(feature = "ruledocs")]
16-
const NO_VERIFIED_VALID_SCHEMA: [&str; 57] = [
16+
const NO_VERIFIED_VALID_SCHEMA: [&str; 56] = [
1717
"eslint/func-name-matching",
1818
"eslint/no-restricted-globals",
1919
"eslint/no-restricted-imports",
@@ -44,7 +44,6 @@ const NO_VERIFIED_VALID_SCHEMA: [&str; 57] = [
4444
"react/jsx-no-script-url",
4545
"react/jsx-no-target-blank",
4646
"react/no-did-update-set-state",
47-
"react/no-unstable-nested-components",
4847
"react_perf/jsx-no-new-object-as-prop",
4948
"typescript/array-type",
5049
"typescript/ban-ts-comment",

npm/oxlint/configuration_schema.json

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5576,7 +5576,24 @@
55765576
]
55775577
},
55785578
"react/no-unstable-nested-components": {
5579-
"$ref": "#/definitions/DummyRule"
5579+
"anyOf": [
5580+
{
5581+
"$ref": "#/definitions/AllowWarnDeny"
5582+
},
5583+
{
5584+
"type": "array",
5585+
"items": [
5586+
{
5587+
"$ref": "#/definitions/AllowWarnDeny"
5588+
},
5589+
{
5590+
"$ref": "#/definitions/NoUnstableNestedComponentsConfig"
5591+
}
5592+
],
5593+
"maxItems": 2,
5594+
"minItems": 1
5595+
}
5596+
]
55805597
},
55815598
"react/no-will-update-set-state": {
55825599
"anyOf": [
@@ -12405,6 +12422,33 @@
1240512422
},
1240612423
"additionalProperties": false
1240712424
},
12425+
"NoUnstableNestedComponentsConfig": {
12426+
"type": "object",
12427+
"properties": {
12428+
"allowAsProps": {
12429+
"description": "Allow component definitions in props.",
12430+
"default": false,
12431+
"type": "boolean",
12432+
"markdownDescription": "Allow component definitions in props."
12433+
},
12434+
"customValidators": {
12435+
"description": "Optional custom propTypes validators accepted for eslint-plugin-react compatibility.",
12436+
"default": [],
12437+
"type": "array",
12438+
"items": {
12439+
"type": "string"
12440+
},
12441+
"markdownDescription": "Optional custom propTypes validators accepted for eslint-plugin-react compatibility."
12442+
},
12443+
"propNamePattern": {
12444+
"description": "Glob pattern for render-prop names that may receive inline component definitions.",
12445+
"default": "render*",
12446+
"type": "string",
12447+
"markdownDescription": "Glob pattern for render-prop names that may receive inline component definitions."
12448+
}
12449+
},
12450+
"additionalProperties": false
12451+
},
1240812452
"NoUnusedExpressionsConfig": {
1240912453
"type": "object",
1241012454
"properties": {

tasks/website_linter/src/snapshots/schema_json.snap

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5580,7 +5580,24 @@ expression: json
55805580
]
55815581
},
55825582
"react/no-unstable-nested-components": {
5583-
"$ref": "#/definitions/DummyRule"
5583+
"anyOf": [
5584+
{
5585+
"$ref": "#/definitions/AllowWarnDeny"
5586+
},
5587+
{
5588+
"type": "array",
5589+
"items": [
5590+
{
5591+
"$ref": "#/definitions/AllowWarnDeny"
5592+
},
5593+
{
5594+
"$ref": "#/definitions/NoUnstableNestedComponentsConfig"
5595+
}
5596+
],
5597+
"maxItems": 2,
5598+
"minItems": 1
5599+
}
5600+
]
55845601
},
55855602
"react/no-will-update-set-state": {
55865603
"anyOf": [
@@ -12409,6 +12426,33 @@ expression: json
1240912426
},
1241012427
"additionalProperties": false
1241112428
},
12429+
"NoUnstableNestedComponentsConfig": {
12430+
"type": "object",
12431+
"properties": {
12432+
"allowAsProps": {
12433+
"description": "Allow component definitions in props.",
12434+
"default": false,
12435+
"type": "boolean",
12436+
"markdownDescription": "Allow component definitions in props."
12437+
},
12438+
"customValidators": {
12439+
"description": "Optional custom propTypes validators accepted for eslint-plugin-react compatibility.",
12440+
"default": [],
12441+
"type": "array",
12442+
"items": {
12443+
"type": "string"
12444+
},
12445+
"markdownDescription": "Optional custom propTypes validators accepted for eslint-plugin-react compatibility."
12446+
},
12447+
"propNamePattern": {
12448+
"description": "Glob pattern for render-prop names that may receive inline component definitions.",
12449+
"default": "render*",
12450+
"type": "string",
12451+
"markdownDescription": "Glob pattern for render-prop names that may receive inline component definitions."
12452+
}
12453+
},
12454+
"additionalProperties": false
12455+
},
1241212456
"NoUnusedExpressionsConfig": {
1241312457
"type": "object",
1241412458
"properties": {

0 commit comments

Comments
 (0)