Skip to content

[no-empty-group] [no-empty-capturing-group] detect inplace manipulation of arrays #852

@danielrentz

Description

@danielrentz

Description

The rules [no-empty-group] and [no-empty-capturing-group] trigger when the group has been filled from a joined array that has been filled dynamically using push.

const arr = [];
arr.push("a", "b"); // simplified; original code processes some other data
const rex = new RegExp("(" + arr.join("|") + ")");

This (simplified) example triggers because the rules seem to see only the initialization to an empty array. The rule could be improved by detecting inplace manipulations with push, unshift etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions