| Summary: | Reduce "'console' is undefined" severity to warning? | ||
|---|---|---|---|
| Product: | [ECD] Orion | Reporter: | Mark Macdonald <mamacdon> |
| Component: | JS Tools | Assignee: | Project Inbox <orion.client-inbox> |
| Status: | RESOLVED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | mamacdon, Michael_Rennie, simon_kaegi |
| Version: | 6.0 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
(In reply to Mark Macdonald from comment #0) > 1. Paste this code into a .js file: > /*eslint-env browser*/ > console.log("sup"); > > 2. You will see an error saying "'console' is undefined." > > > The error can be resolved by adding console to your globals: > /*global console*/ You can also suppress it using: /*eslint-env node*/ > > It's been argued that console should be part of the browser environment to > avoid the hassle of adding an explicit global. This was suggested in > upstream ESLint, but they decided against it: > https://github.com/eslint/eslint/issues/1074 > > I'm inclined to follow the upstream behavior. So am I, and in a dream world when we can some day simply use the rules from upstream eslint, 'console' would just come back as an error / warning (unless we modified the rule, which would be a pain). I'm going to mark this wontfix. If there is a strong push to allow users to do bad things we can reopen. |
1. Paste this code into a .js file: /*eslint-env browser*/ console.log("sup"); 2. You will see an error saying "'console' is undefined." The error can be resolved by adding console to your globals: /*global console*/ It's been argued that console should be part of the browser environment to avoid the hassle of adding an explicit global. This was suggested in upstream ESLint, but they decided against it: https://github.com/eslint/eslint/issues/1074 I'm inclined to follow the upstream behavior. But we could consider reducing the severity to a warning (for 'console' only, and only when the 'browser' eslint-env is enabled). While 'console' is not recommended in production code, it's unlikely to cause a runtime error in a modern web browser**. ** Older browsers are a different story: Firefox 3.6 and IE8 do not have 'console' at all, so you will get a runtime error trying to call it. IE9 is similar -- except if you open the Developer Tools window, it causes 'console' to become defined (!)