{"action":"created","issue":{"url":"https://api.github.com/repos/eslint/eslint/issues/4697","labels_url":"https://api.github.com/repos/eslint/eslint/issues/4697/labels{/name}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/4697/comments","events_url":"https://api.github.com/repos/eslint/eslint/issues/4697/events","html_url":"https://github.com/eslint/eslint/issues/4697","id":122102601,"number":4697,"title":"key-spacing for one-liner object literals","user":{"login":"neverfox","id":3344033,"avatar_url":"https://avatars.githubusercontent.com/u/3344033?v=3","gravatar_id":"","url":"https://api.github.com/users/neverfox","html_url":"https://github.com/neverfox","followers_url":"https://api.github.com/users/neverfox/followers","following_url":"https://api.github.com/users/neverfox/following{/other_user}","gists_url":"https://api.github.com/users/neverfox/gists{/gist_id}","starred_url":"https://api.github.com/users/neverfox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neverfox/subscriptions","organizations_url":"https://api.github.com/users/neverfox/orgs","repos_url":"https://api.github.com/users/neverfox/repos","events_url":"https://api.github.com/users/neverfox/events{/privacy}","received_events_url":"https://api.github.com/users/neverfox/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/eslint/eslint/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/eslint/eslint/labels/proposal","name":"proposal","color":"fef2c0"},{"url":"https://api.github.com/repos/eslint/eslint/labels/rule","name":"rule","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-12-14T18:33:35Z","updated_at":"2015-12-17T16:06:31Z","closed_at":null,"body":"Would it be possible to have a way to enforce different key-spacing rules depending on whether or not the object is specified on one line or multiple lines? A style we use is something like this:\r\n\r\n\r\n```\r\n// [2, { \"align\": \"colon\", \"beforeColon\": true, \"afterColon\": true }]\r\nconst obj1 = {\r\n  key1     : 'val1',\r\n  longKey2 : 'val2'\r\n}\r\n```\r\nBut for one-liners, we don't want `beforeColon: true`:\r\n```\r\nconst obj2 = { key1: 'val1', key2: 'val2' }\r\n```\r\n\r\nThe reason for this style choice is that we prefer no space before colons *unless* the colons can align, which is only relevant in multi-line situations. Right now, there doesn't seem to be a way to achieve this with a set of rules.\r\n\r\n<bountysource-plugin>\r\n---\r\nWant to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/29116177-key-spacing-for-one-liner-object-literals?utm_campaign=plugin&utm_content=tracker%2F282608&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F282608&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"},"comment":{"url":"https://api.github.com/repos/eslint/eslint/issues/comments/165495487","html_url":"https://github.com/eslint/eslint/issues/4697#issuecomment-165495487","issue_url":"https://api.github.com/repos/eslint/eslint/issues/4697","id":165495487,"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-12-17T16:06:31Z","updated_at":"2015-12-17T16:06:31Z","body":"Got it. Should we instead create two core rules?"}}