Skip to content

linter: support eslint/no-restricted-globals new option enum #23617

Description

@Sysix

The upstream rules added a new object beside the already supported string | { name: string, message: string } option.
See the implementation here: eslint/eslint#19939

Our current oxlint rules does not support this new option:

fn from_configuration(value: serde_json::Value) -> Result<Self, serde_json::error::Error> {
let list = match value {
Value::Array(arr) => arr.iter().fold(FxHashMap::default(), |mut acc, v| match v {
// "no-restricted-globals": ["error", "event"]
Value::String(name) => {
acc.insert(name.clone(), String::new());
acc
}
// "no-restricted-globals": ["error", { "name": "event", "message": "Use local parameter instead." }]
Value::Object(obj) => {
let name = obj.get("name").and_then(Value::as_str).unwrap_or_default();
let message = obj.get("message").and_then(Value::as_str).unwrap_or_default();
acc.insert(name.to_string(), message.to_string());
acc
}
_ => acc,
}),
_ => FxHashMap::default(),
};
Ok(Self { restricted_globals: Box::new(list) })
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fields

    Priority

    None yet

    Start date

    None yet

    Target date

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions