Skip to content

enabling eslint's prefer-const rule #3118

Closed
@misterdjules

Description

@misterdjules

This conversation started here: #3036 (comment).

It seems there's an implicit rule of preferring const over var for variables that hold values that never change, which makes sense. It's been mentioned in #1243, and seems to be enforced during code reviews.

However, it's not currently caught by our eslint setup. To paraphrase #3036 (comment), I'm not a big fan of having implicit coding style rules. It becomes frustrating for maintainers to enforce them every time, and for contributors because they don't have any tool to check that their code complies to the guidelines.

However, using the prefer-const rule does not apply to function-scoped variable declarations, so we would need to use the no-var eslint rule too and use let instead of var, which I assume would require a significant amount of work.

#1243 mentions that let's V8's implementation had performance at some point.

My question thus is: is moving from var to let and enforcing const with eslint worth investigating now?

/cc @nodejs/tsc

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussIssues opened for discussions and feedbacks.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions