{"action":"created","issue":{"url":"https://api.github.com/repos/eslint/eslint/issues/6377","repository_url":"https://api.github.com/repos/eslint/eslint","labels_url":"https://api.github.com/repos/eslint/eslint/issues/6377/labels{/name}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/6377/comments","events_url":"https://api.github.com/repos/eslint/eslint/issues/6377/events","html_url":"https://github.com/eslint/eslint/issues/6377","id":159766648,"number":6377,"title":"Rule Proposal: no-strict-with-complex-params","user":{"login":"mysticatea","id":1937871,"avatar_url":"https://avatars.githubusercontent.com/u/1937871?v=3","gravatar_id":"","url":"https://api.github.com/users/mysticatea","html_url":"https://github.com/mysticatea","followers_url":"https://api.github.com/users/mysticatea/followers","following_url":"https://api.github.com/users/mysticatea/following{/other_user}","gists_url":"https://api.github.com/users/mysticatea/gists{/gist_id}","starred_url":"https://api.github.com/users/mysticatea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mysticatea/subscriptions","organizations_url":"https://api.github.com/users/mysticatea/orgs","repos_url":"https://api.github.com/users/mysticatea/repos","events_url":"https://api.github.com/users/mysticatea/events{/privacy}","received_events_url":"https://api.github.com/users/mysticatea/received_events","type":"User","site_admin":false},"labels":[{"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"},{"url":"https://api.github.com/repos/eslint/eslint/labels/rule","name":"rule","color":"fbca04"}],"state":"open","locked":false,"assignee":{"login":"mysticatea","id":1937871,"avatar_url":"https://avatars.githubusercontent.com/u/1937871?v=3","gravatar_id":"","url":"https://api.github.com/users/mysticatea","html_url":"https://github.com/mysticatea","followers_url":"https://api.github.com/users/mysticatea/followers","following_url":"https://api.github.com/users/mysticatea/following{/other_user}","gists_url":"https://api.github.com/users/mysticatea/gists{/gist_id}","starred_url":"https://api.github.com/users/mysticatea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mysticatea/subscriptions","organizations_url":"https://api.github.com/users/mysticatea/orgs","repos_url":"https://api.github.com/users/mysticatea/repos","events_url":"https://api.github.com/users/mysticatea/events{/privacy}","received_events_url":"https://api.github.com/users/mysticatea/received_events","type":"User","site_admin":false},"milestone":null,"comments":38,"created_at":"2016-06-11T10:13:56Z","updated_at":"2016-06-16T03:44:48Z","closed_at":null,"body":"```js\r\nfunction foo(a = 1) {\r\n    \"use strict\"\r\n}\r\n```\r\n\r\nThis is a valid code in ES2015, but this is an invalid code (syntax error) in ES2016.\r\n\r\n> It is a Syntax Error if ContainsUseStrict of FunctionBody is true and IsSimpleParameterList of FormalParameters is false.\r\n> https://tc39.github.io/ecma262/2016/#sec-function-definitions-static-semantics-early-errors\r\n\r\nSo a combination of a non-simple parameter list and a `\"use strict\"` directive is going to break the software in future.\r\n\r\nThe purpose of this rule is that it protects software from the break.\r\n\r\n```js\r\n/*eslint no-strict-with-complex-params: error*/\r\n\r\n// ✘ BAD\r\nfunction foo(a = 1) {\r\n    \"use strict\"\r\n}\r\nfunction foo({a, b}) {\r\n    \"use strict\"\r\n}\r\n\r\n// ✔ GOOD\r\nfunction foo(a, b, c) {\r\n    \"use strict\"\r\n}\r\nfunction foo(a = 1) {\r\n}\r\nfunction foo({a, b}) {\r\n}\r\n```\r\n\r\nI think this is a good rule for `eslint:recommended`, so I separated this rule proposal from `strict` rule.\r\nI'm happy to work on this if accepted."},"comment":{"url":"https://api.github.com/repos/eslint/eslint/issues/comments/226381114","html_url":"https://github.com/eslint/eslint/issues/6377#issuecomment-226381114","issue_url":"https://api.github.com/repos/eslint/eslint/issues/6377","id":226381114,"user":{"login":"mysticatea","id":1937871,"avatar_url":"https://avatars.githubusercontent.com/u/1937871?v=3","gravatar_id":"","url":"https://api.github.com/users/mysticatea","html_url":"https://github.com/mysticatea","followers_url":"https://api.github.com/users/mysticatea/followers","following_url":"https://api.github.com/users/mysticatea/following{/other_user}","gists_url":"https://api.github.com/users/mysticatea/gists{/gist_id}","starred_url":"https://api.github.com/users/mysticatea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mysticatea/subscriptions","organizations_url":"https://api.github.com/users/mysticatea/orgs","repos_url":"https://api.github.com/users/mysticatea/repos","events_url":"https://api.github.com/users/mysticatea/events{/privacy}","received_events_url":"https://api.github.com/users/mysticatea/received_events","type":"User","site_admin":false},"created_at":"2016-06-16T03:44:48Z","updated_at":"2016-06-16T03:44:48Z","body":"@alberto there are 2 matters here:\r\n\r\n1. `strict` rule with `function` option is warning `function foo(a = 1) {}`, this would lead people to a syntax error, so I think this is a bug (refs #6405) and it's a `\"semver: patch\"` matter.\r\n2. `strict` rule should warn `function foo(a = 1) { \"use strict\" }` since it's going to be broken. This is an enhancement. My question is which is better that this is the default behavior or this is hidden behind an option. I think changing the default behavior is proper since the warning is critical.\r\n\r\n@pedrottimark Sounds good. Indeed, if `strict` rule with `function` option does not warn `function foo(a = 1) {}`, people can't get warnings for non-strict mode functions. We can keep the warning and add a more specific message."}}
{"actor":{"display_login":"mysticatea"}}