{"action":"created","issue":{"url":"https://api.github.com/repos/eslint/eslint/issues/3593","labels_url":"https://api.github.com/repos/eslint/eslint/issues/3593/labels{/name}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/3593/comments","events_url":"https://api.github.com/repos/eslint/eslint/issues/3593/events","html_url":"https://github.com/eslint/eslint/issues/3593","id":103917827,"number":3593,"title":"prefer-const add option onlyPrimitive","user":{"login":"Moeriki","id":38758,"avatar_url":"https://avatars.githubusercontent.com/u/38758?v=3","gravatar_id":"","url":"https://api.github.com/users/Moeriki","html_url":"https://github.com/Moeriki","followers_url":"https://api.github.com/users/Moeriki/followers","following_url":"https://api.github.com/users/Moeriki/following{/other_user}","gists_url":"https://api.github.com/users/Moeriki/gists{/gist_id}","starred_url":"https://api.github.com/users/Moeriki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Moeriki/subscriptions","organizations_url":"https://api.github.com/users/Moeriki/orgs","repos_url":"https://api.github.com/users/Moeriki/repos","events_url":"https://api.github.com/users/Moeriki/events{/privacy}","received_events_url":"https://api.github.com/users/Moeriki/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/eslint/eslint/labels/triage","name":"triage","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-30T10:55:34Z","updated_at":"2015-08-31T00:37:51Z","closed_at":null,"body":"Dear all,\r\n\r\nI'd like to propose an option for the *prefer-const* rule.\r\n\r\nI really like enforcing const on unchanged primitives. Not so much on unchanged objects. Because const doesn't protect object members I find this an illogical thing to do.\r\n\r\nProposed option: *onlyPrimitive*. This would allow the following code\r\n\r\n```json\r\n{\r\n    \"rules\": {\r\n        \"prefer-const\": [1, { \"onlyPrimitive\": true }]\r\n    }\r\n}\r\n```\r\n\r\n```javascript\r\nlet x = {};\r\n```\r\n\r\nI'd like to hear your thoughts on this.\r\nI already made an attempt to implement this change: #3578\r\n\r\nCC @mysticatea"},"comment":{"url":"https://api.github.com/repos/eslint/eslint/issues/comments/136222924","html_url":"https://github.com/eslint/eslint/issues/3593#issuecomment-136222924","issue_url":"https://api.github.com/repos/eslint/eslint/issues/3593","id":136222924,"user":{"login":"nzakas","id":38546,"avatar_url":"https://avatars.githubusercontent.com/u/38546?v=3","gravatar_id":"","url":"https://api.github.com/users/nzakas","html_url":"https://github.com/nzakas","followers_url":"https://api.github.com/users/nzakas/followers","following_url":"https://api.github.com/users/nzakas/following{/other_user}","gists_url":"https://api.github.com/users/nzakas/gists{/gist_id}","starred_url":"https://api.github.com/users/nzakas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nzakas/subscriptions","organizations_url":"https://api.github.com/users/nzakas/orgs","repos_url":"https://api.github.com/users/nzakas/repos","events_url":"https://api.github.com/users/nzakas/events{/privacy}","received_events_url":"https://api.github.com/users/nzakas/received_events","type":"User","site_admin":false},"created_at":"2015-08-31T00:37:51Z","updated_at":"2015-08-31T00:37:51Z","body":"I'm not quite agreeing with the rationale for such a change. `const` is about freezing identifier bindings, not about freezing values. In that vein, this suggestion draws an arbitrary distinction that I'm worried would be confusing for others.\r\n\r\nAlso, we can't staticly determine primitives unless you're just talking about literals, which would make it more arbitrary.\r\n\r\nUnless I'm missing something (feel free to let me know), I'm :-1: on this."}}