Skip to content

Commit 31543ed

Browse files
committed
feat(linter): add schema for vue/define-props-destructuring (#23252)
1 parent 21b6c3d commit 31543ed

4 files changed

Lines changed: 133 additions & 5 deletions

File tree

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ export type SwitchCaseBracesConfig = "always" | "avoid";
236236
export type CaseType = "PascalCase" | "kebab-case";
237237
export type DeclarationStyle = "type-based" | "type-literal" | "runtime";
238238
export type DeclarationStyle2 = "type-based" | "runtime";
239+
export type Destructure = "only-when-assigned" | "always" | "never";
239240
export type NextTickOption = "promise" | "callback";
240241
export type CaseType2 = "camelCase" | "snake_case";
241242
export type AllowYoda = "never" | "always";
@@ -1606,7 +1607,7 @@ export interface DummyRuleMap {
16061607
"vue/component-definition-name-casing"?: AllowWarnDeny | [AllowWarnDeny] | [AllowWarnDeny, CaseType];
16071608
"vue/define-emits-declaration"?: AllowWarnDeny | [AllowWarnDeny] | [AllowWarnDeny, DeclarationStyle];
16081609
"vue/define-props-declaration"?: AllowWarnDeny | [AllowWarnDeny] | [AllowWarnDeny, DeclarationStyle2];
1609-
"vue/define-props-destructuring"?: DummyRule;
1610+
"vue/define-props-destructuring"?: AllowWarnDeny | [AllowWarnDeny] | [AllowWarnDeny, DefinePropsDestructuring];
16101611
"vue/max-props"?: AllowWarnDeny | [AllowWarnDeny] | [AllowWarnDeny, MaxProps];
16111612
"vue/next-tick-style"?: AllowWarnDeny | [AllowWarnDeny] | [AllowWarnDeny, NextTickOption];
16121613
"vue/no-arrow-functions-in-watch"?: RuleNoConfig;
@@ -5185,6 +5186,12 @@ export interface RequireMockTypeParametersConfig {
51855186
*/
51865187
checkImportFunctions?: boolean;
51875188
}
5189+
export interface DefinePropsDestructuring {
5190+
/**
5191+
* Require or prohibit destructuring.
5192+
*/
5193+
destructure?: Destructure;
5194+
}
51885195
export interface MaxProps {
51895196
/**
51905197
* The maximum number of props allowed in a Vue SFC.

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; 60] = [
16+
const NO_VERIFIED_VALID_SCHEMA: [&str; 59] = [
1717
"eslint/func-name-matching",
1818
"eslint/no-restricted-globals",
1919
"eslint/no-restricted-imports",
@@ -73,7 +73,6 @@ const NO_VERIFIED_VALID_SCHEMA: [&str; 60] = [
7373
"vitest/prefer-import-in-mock",
7474
"vitest/prefer-lowercase-title",
7575
"vitest/valid-title",
76-
"vue/define-props-destructuring",
7776
];
7877

7978
/// Should this rule be skipped for config schema generation?

npm/oxlint/configuration_schema.json

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,50 @@
12461246
},
12471247
"additionalProperties": false
12481248
},
1249+
"DefinePropsDestructuring": {
1250+
"type": "object",
1251+
"properties": {
1252+
"destructure": {
1253+
"description": "Require or prohibit destructuring.",
1254+
"default": "only-when-assigned",
1255+
"allOf": [
1256+
{
1257+
"$ref": "#/definitions/Destructure"
1258+
}
1259+
],
1260+
"markdownDescription": "Require or prohibit destructuring."
1261+
}
1262+
},
1263+
"additionalProperties": false
1264+
},
1265+
"Destructure": {
1266+
"oneOf": [
1267+
{
1268+
"description": "Requires destructuring when `defineProps` is assigned to a variable and warns against using `withDefaults` with destructuring",
1269+
"type": "string",
1270+
"enum": [
1271+
"only-when-assigned"
1272+
],
1273+
"markdownDescription": "Requires destructuring when `defineProps` is assigned to a variable and warns against using `withDefaults` with destructuring"
1274+
},
1275+
{
1276+
"description": "Requires destructuring when using `defineProps` and warns against using `withDefaults` with destructuring",
1277+
"type": "string",
1278+
"enum": [
1279+
"always"
1280+
],
1281+
"markdownDescription": "Requires destructuring when using `defineProps` and warns against using `withDefaults` with destructuring"
1282+
},
1283+
{
1284+
"description": "Requires using a variable to store props and prohibits destructuring",
1285+
"type": "string",
1286+
"enum": [
1287+
"never"
1288+
],
1289+
"markdownDescription": "Requires using a variable to store props and prohibits destructuring"
1290+
}
1291+
]
1292+
},
12491293
"Destructuring": {
12501294
"oneOf": [
12511295
{
@@ -8062,7 +8106,24 @@
80628106
]
80638107
},
80648108
"vue/define-props-destructuring": {
8065-
"$ref": "#/definitions/DummyRule"
8109+
"anyOf": [
8110+
{
8111+
"$ref": "#/definitions/AllowWarnDeny"
8112+
},
8113+
{
8114+
"type": "array",
8115+
"items": [
8116+
{
8117+
"$ref": "#/definitions/AllowWarnDeny"
8118+
},
8119+
{
8120+
"$ref": "#/definitions/DefinePropsDestructuring"
8121+
}
8122+
],
8123+
"maxItems": 2,
8124+
"minItems": 1
8125+
}
8126+
]
80668127
},
80678128
"vue/max-props": {
80688129
"anyOf": [

tasks/website_linter/src/snapshots/schema_json.snap

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,50 @@ expression: json
12501250
},
12511251
"additionalProperties": false
12521252
},
1253+
"DefinePropsDestructuring": {
1254+
"type": "object",
1255+
"properties": {
1256+
"destructure": {
1257+
"description": "Require or prohibit destructuring.",
1258+
"default": "only-when-assigned",
1259+
"allOf": [
1260+
{
1261+
"$ref": "#/definitions/Destructure"
1262+
}
1263+
],
1264+
"markdownDescription": "Require or prohibit destructuring."
1265+
}
1266+
},
1267+
"additionalProperties": false
1268+
},
1269+
"Destructure": {
1270+
"oneOf": [
1271+
{
1272+
"description": "Requires destructuring when `defineProps` is assigned to a variable and warns against using `withDefaults` with destructuring",
1273+
"type": "string",
1274+
"enum": [
1275+
"only-when-assigned"
1276+
],
1277+
"markdownDescription": "Requires destructuring when `defineProps` is assigned to a variable and warns against using `withDefaults` with destructuring"
1278+
},
1279+
{
1280+
"description": "Requires destructuring when using `defineProps` and warns against using `withDefaults` with destructuring",
1281+
"type": "string",
1282+
"enum": [
1283+
"always"
1284+
],
1285+
"markdownDescription": "Requires destructuring when using `defineProps` and warns against using `withDefaults` with destructuring"
1286+
},
1287+
{
1288+
"description": "Requires using a variable to store props and prohibits destructuring",
1289+
"type": "string",
1290+
"enum": [
1291+
"never"
1292+
],
1293+
"markdownDescription": "Requires using a variable to store props and prohibits destructuring"
1294+
}
1295+
]
1296+
},
12531297
"Destructuring": {
12541298
"oneOf": [
12551299
{
@@ -8066,7 +8110,24 @@ expression: json
80668110
]
80678111
},
80688112
"vue/define-props-destructuring": {
8069-
"$ref": "#/definitions/DummyRule"
8113+
"anyOf": [
8114+
{
8115+
"$ref": "#/definitions/AllowWarnDeny"
8116+
},
8117+
{
8118+
"type": "array",
8119+
"items": [
8120+
{
8121+
"$ref": "#/definitions/AllowWarnDeny"
8122+
},
8123+
{
8124+
"$ref": "#/definitions/DefinePropsDestructuring"
8125+
}
8126+
],
8127+
"maxItems": 2,
8128+
"minItems": 1
8129+
}
8130+
]
80708131
},
80718132
"vue/max-props": {
80728133
"anyOf": [

0 commit comments

Comments
 (0)