{"action":"created","issue":{"url":"https://api.github.com/repos/eslint/eslint/issues/6298","repository_url":"https://api.github.com/repos/eslint/eslint","labels_url":"https://api.github.com/repos/eslint/eslint/issues/6298/labels{/name}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/6298/comments","events_url":"https://api.github.com/repos/eslint/eslint/issues/6298/events","html_url":"https://github.com/eslint/eslint/issues/6298","id":157712771,"number":6298,"title":" \"Repository settings\" as a way to share configuration between rules without creating rule-to-rule dependencies?","user":{"login":"platinumazure","id":284282,"avatar_url":"https://avatars.githubusercontent.com/u/284282?v=3","gravatar_id":"","url":"https://api.github.com/users/platinumazure","html_url":"https://github.com/platinumazure","followers_url":"https://api.github.com/users/platinumazure/followers","following_url":"https://api.github.com/users/platinumazure/following{/other_user}","gists_url":"https://api.github.com/users/platinumazure/gists{/gist_id}","starred_url":"https://api.github.com/users/platinumazure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/platinumazure/subscriptions","organizations_url":"https://api.github.com/users/platinumazure/orgs","repos_url":"https://api.github.com/users/platinumazure/repos","events_url":"https://api.github.com/users/platinumazure/events{/privacy}","received_events_url":"https://api.github.com/users/platinumazure/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/eslint/eslint/labels/core","name":"core","color":"c7def8"},{"url":"https://api.github.com/repos/eslint/eslint/labels/evaluating","name":"evaluating","color":"fef2c0"},{"url":"https://api.github.com/repos/eslint/eslint/labels/feature","name":"feature","color":"bfd4f2"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-05-31T16:20:18Z","updated_at":"2016-05-31T20:36:56Z","closed_at":null,"body":"We continue to run into questions about how best to auto-fix rules that appear to have a dependency on other rules.\r\n\r\nFor example, `lines-around-comment` and `newline-before-return` may introduce blank lines as part of its auto-fix, but it has no way of knowing the correct line break sequence to use (which may be configured in `linebreak-style`).\r\n\r\nNow that we have multi-pass autofixing available, a common response is that we can let multi-pass autofix take care of it. For example, `lines-around-comment` can arbitrarily choose `\\n` (without loss of generality) and that will be applied in the first pass, and then the second pass of autofix can fix the line break issues. However, the problem with this reasoning is that not everyone will use those rules that apply second-pass fixes.\r\n\r\nNoting that [no rule can be deemed \"too important to turn off\"](http://eslint.org/docs/about/#philosophy) (meaning we really shouldn't be recommending the use of other rules that users might not want to use), I think we need to consider a different approach.\r\n\r\nBelow is a proposal for how we can better handle this. In terms of scope, I think we can start with something simple, like line breaks; later on, we can augment this proposal to include other repository style elements as needed.\r\n\r\nIn configuration:\r\n\r\n```json\r\n{\r\n    \"rules\": {\r\n        \"linebreak-style\": \"error\",\r\n        \"lines-around-comment\": \"error\",\r\n        \"newline-before-return\": \"error\"\r\n    },\r\n    \"repositorySettings\": {\r\n        \"lineBreak\": \"unix\"\r\n    }\r\n}\r\n```\r\n\r\nChanges to how the affected rules would work:\r\n\r\n* Repository settings becomes available in RuleContext object\r\n* `linebreak-style` rule uses repository setting lineBreak property if specified\r\n  * Backward compatibility: can still accept inline config for backward compatibility until next major version.\r\n  * If lineBreak is specified, then the goal of this rule is *solely* to enforce the style specified in repositorySettings.\r\n* `lines-around-comment` uses repository setting lineBreak property if specified when autofixing\r\n  * Backward compatibility: Could fallback to arbitrary line termination sequence such as `\\n` if needed\r\n* `newline-before-return` uses repository setting lineBreak property if specified when autofixing\r\n  * Backward compatibility: Could fallback to arbitrary line termination sequence such as `\\n` if needed\r\n* I haven't accounted for other rules that may need this information, but my assumption is they can migrate toward using repositorySettings in minor version bumps.\r\n\r\nOther thoughts:\r\n\r\n* Repository settings probably deserve their own JSON Schema\r\n* Rule metadata could be used to specify dependencies on repository settings, and ESLint could error out if repository setting not specified, similar to errors we emit for mis-configurations\r\n  * Needless to say, for existing rules to actually *use* these dependencies and error out, that would have to wait for a major version bump\r\n\r\n(N.B. I had created an issue with a similar title in the past, but the discussion there was focused around plugin processors and was correctly closed. I hope the team can agree that this issue is sufficiently different from the old issue and that the motivation for discussion is highly relevant now as we try to avoid over-reliance on multi-pass autofix.)"},"comment":{"url":"https://api.github.com/repos/eslint/eslint/issues/comments/222812289","html_url":"https://github.com/eslint/eslint/issues/6298#issuecomment-222812289","issue_url":"https://api.github.com/repos/eslint/eslint/issues/6298","id":222812289,"user":{"login":"ilyavolodin","id":1380062,"avatar_url":"https://avatars.githubusercontent.com/u/1380062?v=3","gravatar_id":"","url":"https://api.github.com/users/ilyavolodin","html_url":"https://github.com/ilyavolodin","followers_url":"https://api.github.com/users/ilyavolodin/followers","following_url":"https://api.github.com/users/ilyavolodin/following{/other_user}","gists_url":"https://api.github.com/users/ilyavolodin/gists{/gist_id}","starred_url":"https://api.github.com/users/ilyavolodin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilyavolodin/subscriptions","organizations_url":"https://api.github.com/users/ilyavolodin/orgs","repos_url":"https://api.github.com/users/ilyavolodin/repos","events_url":"https://api.github.com/users/ilyavolodin/events{/privacy}","received_events_url":"https://api.github.com/users/ilyavolodin/received_events","type":"User","site_admin":false},"created_at":"2016-05-31T20:36:56Z","updated_at":"2016-05-31T20:36:56Z","body":"Ah, OK, now I think I got where you are going with this. So you expect every used to configure every single possible option of `repositorySettings`? What if I really don't care about what type of linebreaks my code uses and don't want to waist my time creating a style guide?"}}
{"actor":{"display_login":"ilyavolodin"}}