{"record":{"id":"6164e4a00ab8045e","repo":"oxc-project/oxc","slug":"object-name-property-name-is-restricted-from","errorCode":null,"errorMessage":"'{object_name}.{property_name}' is restricted from being used.","messagePattern":"'(.+?)\\.(.+?)' is restricted from being used\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/no_restricted_properties.rs","lineNumber":60,"sourceCode":"    {\n        write!(\n            warn_text,\n            \" Property '{property_name}' is only allowed on these objects: {}.\",\n            allow_objects.iter().map(CompactStr::as_str).join(\", \")\n        )\n        .unwrap();\n    }\n\n    if let Some(allow_properties) = &property.allow_properties {\n        write!(\n            warn_text,\n            \" Only these properties are allowed: {}.\",\n            allow_properties.iter().map(CompactStr::as_str).join(\", \")\n        )\n        .unwrap();\n    }\n\n    let diagnostic = OxcDiagnostic::warn(warn_text).with_label(span);\n\n    if let Some(message) = &property.message {\n        diagnostic.with_help(message.as_str().to_string())\n    } else {\n        diagnostic\n    }\n}\n\n#[derive(Debug, Default, Clone, Deserialize, JsonSchema)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\nstruct PropertyDetails {\n    /// The object on which the property is being accessed.\n    object: Option<CompactStr>,\n    /// The property being accessed. If `object` is not specified, this applies to the named\n    /// property on all objects.\n    property: Option<CompactStr>,\n    /// A custom message to display.\n    message: Option<CompactStr>,","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/oxc-project/oxc/blob/1f902a69625cd14e6d8dc58feca94da099d2d251/crates/oxc_linter/src/rules/eslint/no_restricted_properties.rs#L42-L78","documentation":"oxlint's port of ESLint `no-restricted-properties`. It fires on member accesses (and calls) whose object/property pair is restricted by config. The base message names `'{object}.{property}'`; optional `restricted`/`allow` lists append detail, and an optional per-property `message` becomes the diagnostic help.","triggerScenarios":"`\"restrictedProperties\": { \"isFinite\": [\"*\"], \"_\": [\"map\", \"filter\"] }` in .oxlintrc, then `isFinite(x)`, `_.map(arr, fn)`, or `_.filter` anywhere in the file.","commonSituations":"Forcing `Number.isFinite` over the global coercing version; banning lodash prototype-style calls in favor of per-method lodash-es imports; forbidding `angular.element`, `moment.fn` mutations and similar legacy APIs.","solutions":["Use the sanctioned API: `Number.isFinite(x)`, or `import map from 'lodash-es/map';`.","If the object is a namespace, import the individual functions directly.","Adjust the config: move the property to `allowProperties`, or remove the entry."],"exampleFix":"// before\nimport _ from 'lodash';\nconst doubled = _.map(xs, x => x * 2);\n\n// after\nimport map from 'lodash-es/map';\nconst doubled = map(xs, x => x * 2);","handlingStrategy":"validation","validationCode":"// Detect restricted object.property usages\nconst RESTRICTED = { _: ['map', 'filter'], isFinite: ['*'] };\nfunction restrictedPropertyUse(src) {\n  const hits = [];\n  for (const [obj, props] of Object.entries(RESTRICTED)) {\n    for (const m of src.matchAll(new RegExp(`(?<![\\\\w$])${obj}\\\\s*\\\\.\\\\s*([\\\\w$]+)`, 'g'))) {\n      if (props.includes('*') || props.includes(m[1])) hits.push(`${obj}.${m[1]}`);\n    }\n  }\n  return hits;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Import lodash methods individually (`import map from 'lodash-es/map'`) so `_.x` never appears.","Prefer static methods on `Number`/`BigInt` over coercing globals.","Keep the `restrictedProperties` map in .oxlintrc in sync with your dependency policy."],"tags":["lint","eslint","no-restricted-properties","api-usage","configuration"],"backgroundTag":"restricted-property-access","analyzedSha":"1f902a69625cd14e6d8dc58feca94da099d2d251","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}