mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
feat(linter): add schema for unicorn/prefer-object-from-entries (#23249)
issue #22955
This commit is contained in:
1 parent
f89b909351
commit
e77ff81a6b
5 files changed
+84
-6
No files matched your search
@@ -1487,7 +1487,10 @@ export interface DummyRuleMap {
|
||||
"unicorn/prefer-negative-index"?: RuleNoConfig;
|
||||
"unicorn/prefer-node-protocol"?: RuleNoConfig;
|
||||
"unicorn/prefer-number-properties"?: AllowWarnDeny | [AllowWarnDeny] | [AllowWarnDeny, PreferNumberPropertiesConfig];
|
||||
"unicorn/prefer-object-from-entries"?: DummyRule;
|
||||
"unicorn/prefer-object-from-entries"?:
|
||||
| AllowWarnDeny
|
||||
| [AllowWarnDeny]
|
||||
| [AllowWarnDeny, PreferObjectFromEntriesConfig];
|
||||
"unicorn/prefer-optional-catch-binding"?: RuleNoConfig;
|
||||
"unicorn/prefer-prototype-methods"?: RuleNoConfig;
|
||||
"unicorn/prefer-query-selector"?: RuleNoConfig;
|
||||
@@ -5116,6 +5119,12 @@ export interface PreferNumberPropertiesConfig {
|
||||
*/
|
||||
checkNaN?: boolean;
|
||||
}
|
||||
export interface PreferObjectFromEntriesConfig {
|
||||
/**
|
||||
* Additional functions to treat as equivalents to `Object.fromEntries`.
|
||||
*/
|
||||
functions?: string[];
|
||||
}
|
||||
export interface PreferStructuredCloneConfig {
|
||||
/**
|
||||
* List of functions that are allowed to be used for deep cloning instead of structuredClone.
|
||||
|
||||
@@ -26,7 +26,7 @@ fn prefer_object_from_entries_diagnostic(span: Span) -> OxcDiagnostic {
|
||||
pub struct PreferObjectFromEntries(Box<PreferObjectFromEntriesConfig>);
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, JsonSchema)]
|
||||
#[serde(rename_all = "camelCase", default)]
|
||||
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
|
||||
pub struct PreferObjectFromEntriesConfig {
|
||||
/// Additional functions to treat as equivalents to `Object.fromEntries`.
|
||||
functions: Vec<String>,
|
||||
|
||||
@@ -13,7 +13,7 @@ use crate::rules::RuleEnum;
|
||||
/// These should return the DummyRule struct/schema instead of the actual rule struct/schema,
|
||||
/// until we verify that the rule's schema is valid and can be generated by schemars.
|
||||
#[cfg(feature = "ruledocs")]
|
||||
const NO_VERIFIED_VALID_SCHEMA: [&str; 62] = [
|
||||
const NO_VERIFIED_VALID_SCHEMA: [&str; 61] = [
|
||||
"eslint/func-name-matching",
|
||||
"eslint/no-restricted-globals",
|
||||
"eslint/no-restricted-imports",
|
||||
@@ -68,7 +68,6 @@ const NO_VERIFIED_VALID_SCHEMA: [&str; 62] = [
|
||||
"unicorn/import-style",
|
||||
"unicorn/numeric-separators-style",
|
||||
"unicorn/prefer-at",
|
||||
"unicorn/prefer-object-from-entries",
|
||||
"vitest/consistent-each-for",
|
||||
"vitest/consistent-test-filename",
|
||||
"vitest/consistent-vitest-vi",
|
||||
|
||||
@@ -7282,7 +7282,24 @@
|
||||
]
|
||||
},
|
||||
"unicorn/prefer-object-from-entries": {
|
||||
"$ref": "#/definitions/DummyRule"
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/AllowWarnDeny"
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"items": [
|
||||
{
|
||||
"$ref": "#/definitions/AllowWarnDeny"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/PreferObjectFromEntriesConfig"
|
||||
}
|
||||
],
|
||||
"maxItems": 2,
|
||||
"minItems": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"unicorn/prefer-optional-catch-binding": {
|
||||
"$ref": "#/definitions/RuleNoConfig"
|
||||
@@ -13181,6 +13198,24 @@
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"PreferObjectFromEntriesConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"functions": {
|
||||
"description": "Additional functions to treat as equivalents to `Object.fromEntries`.",
|
||||
"default": [
|
||||
"_.fromPairs",
|
||||
"lodash.fromPairs"
|
||||
],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"markdownDescription": "Additional functions to treat as equivalents to `Object.fromEntries`."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"PreferOptionalChainConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -7286,7 +7286,24 @@ expression: json
|
||||
]
|
||||
},
|
||||
"unicorn/prefer-object-from-entries": {
|
||||
"$ref": "#/definitions/DummyRule"
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/AllowWarnDeny"
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"items": [
|
||||
{
|
||||
"$ref": "#/definitions/AllowWarnDeny"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/PreferObjectFromEntriesConfig"
|
||||
}
|
||||
],
|
||||
"maxItems": 2,
|
||||
"minItems": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"unicorn/prefer-optional-catch-binding": {
|
||||
"$ref": "#/definitions/RuleNoConfig"
|
||||
@@ -13185,6 +13202,24 @@ expression: json
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"PreferObjectFromEntriesConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"functions": {
|
||||
"description": "Additional functions to treat as equivalents to `Object.fromEntries`.",
|
||||
"default": [
|
||||
"_.fromPairs",
|
||||
"lodash.fromPairs"
|
||||
],
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"markdownDescription": "Additional functions to treat as equivalents to `Object.fromEntries`."
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"PreferOptionalChainConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
Reference in new issue
Block a user