Skip to content

eslint-plugin-prefer-let: Forbid to use const for non-primitive values #77

@vanyauhalin

Description

@vanyauhalin

Hi, thank you for the plugin. Can you please extend its functionality to forbid using const for non-primitive values? The idea is simple, I think the const keyword for evrething except primitive values is missliding, because you can in fact modify it.

const o = {}
o.value = "hello"

const a = []
a.push("gotch you")

Constants

const c0 = ""
const c1 = 0
const c2 = 0n
const c3 = false
const c4 = undefined
const c5 = Symbol("")
const c6 = null

Variables

let v0 = {}
let v1 = []
// etc

References

https://developer.mozilla.org/en-US/docs/Glossary/Primitive

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