oxc-project/oxc · warning · OxcDiagnostic
'{object_name}.{property_name}' is restricted from being use
Error message
'{object_name}.{property_name}' is restricted from being used. What it means
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.
Source
Thrown at crates/oxc_linter/src/rules/eslint/no_restricted_properties.rs:56
{
write!(
warn_text,
" Property '{property_name}' is only allowed on these objects: {}.",
allow_objects.iter().map(CompactStr::as_str).join(", ")
)
.unwrap();
}
if let Some(allow_properties) = &property.allow_properties {
write!(
warn_text,
" Only these properties are allowed: {}.",
allow_properties.iter().map(CompactStr::as_str).join(", ")
)
.unwrap();
}
let diagnostic = OxcDiagnostic::warn(warn_text).with_label(span);
if let Some(message) = &property.message {
diagnostic.with_help(message.as_str().to_string())
} else {
diagnostic
}
}
#[derive(Debug, Default, Clone, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
struct PropertyDetails {
/// The object on which the property is being accessed.
object: Option<CompactStr>,
/// The property being accessed. If `object` is not specified, this applies to the named
/// property on all objects.
property: Option<CompactStr>,
/// A custom message to display.
message: Option<CompactStr>,View on GitHub (pinned to e1e7af627c)
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.
Example fix
// before import _ from 'lodash'; const doubled = _.map(xs, x => x * 2); // after import map from 'lodash-es/map'; const doubled = map(xs, x => x * 2);
Defensive patterns
Strategy: validation
Validate before calling
// Detect restricted object.property usages
const RESTRICTED = { _: ['map', 'filter'], isFinite: ['*'] };
function restrictedPropertyUse(src) {
const hits = [];
for (const [obj, props] of Object.entries(RESTRICTED)) {
for (const m of src.matchAll(new RegExp(`(?<![\\w$])${obj}\\s*\\.\\s*([\\w$]+)`, 'g'))) {
if (props.includes('*') || props.includes(m[1])) hits.push(`${obj}.${m[1]}`);
}
}
return hits;
} Prevention
- 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.
When it happens
Trigger: `"restrictedProperties": { "isFinite": ["*"], "_": ["map", "filter"] }` in .oxlintrc, then `isFinite(x)`, `_.map(arr, fn)`, or `_.filter` anywhere in the file.
Common situations: 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.
Related errors
- '{name}' is already defined as a built-in global variable.
- Reexporting 'default' export is restricted.
- Exporting 'default' is restricted.
- Exporting named value as default is restricted.
- Reexporting named export as default is restricted.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/6164e4a00ab8045e.
Report an issue: GitHub.