Skip to content

Naming conventions #419

Closed
Closed
@Rich-Harris

Description

@Rich-Harris

This is just me being a bit anal, and it's entirely my fault in the first place, but I think the internal naming conventions in the generated code could be nicer. In this example...

screen shot 2017-03-28 at 3 36 18 pm

...there's all sorts going on — renderMainFragment, text$1, eachBlock_anchor, eachBlock_iterations, cat__index and so on.

I propose that we use snake_case for all generated identifiers, use a convention of adding _1, _2 and so on to identifiers that need to be deconflicted, and avoid __ double underscores. This would be more consistent, a bit easier (everything is lowercase, no worrying about capitalising things or whatever), and would make it easy to distinguish between generated code and helpers.

So the examples above would become render_main_fragment, text_1, eachblock_anchor, eachblock_iterations and cat_index.

Relatedly, it would be a tiny bit neater if we knew in advance that a particular name was going to be reused, so we could have div_0, div_1 instead of div, div_1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions