Skip to content

Fix Regexes for JavaScript objects #1

@baseplate-admin

Description

@baseplate-admin

Currently the regex can't add comma to JavaScript objects which has more than 2 variables

For example :

{
    hello: 'world',
    foo: 'bar'
};

This will turn into :

{
    hello: 'world',
    foo: 'bar'; // Notice the line break? 🤔
};

Now the python regex that i am using is :

NEW_LINE_REPLACE_PATTERN: Pattern = re.compile(
    r"(?!^)(?<![\s{,\"\`;])\n(?!^(\s\S*($|[\"\`)$]|)}))(?![\w\s]*[\)])"
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions