Open Bug 1252174 Opened 10 years ago Updated 3 years ago

We should choose either functions or ES6 method definitions in eslint

Categories

(DevTools :: General, defect, P3)

defect

Tracking

(Not tracked)

People

(Reporter: miker, Unassigned)

Details

(Whiteboard: [btpp-backlog])

Should we use Method Definitions in our code i.e. not using the function keyword? { doit() { ... }, function nonES6Doit() { ... } } We could use eslint to automate this and add a rule so it wouldn't be too much work to switch.
I use them regularly in new code and see no real issue with them. Is this bug suggesting they be allowed or blocked? The summary and first comment seem to say opposite things.
Flags: needinfo?(mratcliffe)
Flags: needinfo?(mratcliffe)
Summary: Should we disallow ES6 method definitions in eslint → We should choose either functions or ES6 method definitions in eslint
(In reply to J. Ryan Stinnett [:jryans] (use ni?) from comment #1) > I use them regularly in new code and see no real issue with them. Is this > bug suggesting they be allowed or blocked? The summary and first comment > seem to say opposite things. I think we should use either one or the other but I am more than happy to be convinced otherwise. My point is that we can easily automate conversions like this using eslint so it is almost no work to switch everything to use Method Definitions where we can. Also happy to have both in our codebase... I like the idea that Method Definitions (concise functions) cannot be used as constructors. On the other hand I don't like the idea that concise functions have no lexical identifier binding so they show up in a stack case as: Object.<anonymous> Which is not as useful as the display of a normal function in a stack trace: Object.foo()
It is the stack trace issue that concerns me the most.
(In reply to Michael Ratcliffe [:miker] [:mratcliffe] from comment #3) > It is the stack trace issue that concerns me the most. I agree. I think best would be to (try to) fix this, and make switching to method style depend on that being successfully completed.
Priority: -- → P3
Whiteboard: [btpp-backlog]
Product: Firefox → DevTools
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.