Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Js For of loop error in atom #596

Open
axe-z opened this issue Sep 16, 2018 · 5 comments
Open

Js For of loop error in atom #596

axe-z opened this issue Sep 16, 2018 · 5 comments

Comments

@axe-z
Copy link

axe-z commented Sep 16, 2018

Simple, latest version 1.30

for loop,
the for of autocompletes (without any added snippets) this:

for (variable of iterable) {

}

always f...s me up later.

should be
for (LET variable of iterable) {

}

@chfritz

This comment has been minimized.

@Arcanemagus

This comment has been minimized.

@axe-z
Copy link
Author

axe-z commented Sep 16, 2018

It's not a huge deal anyway, but the for IN is ok(var), regular for loop too :

for (var variable in object) {
if (object.hasOwnProperty(variable)) {

}
} && for (var i = 0; i < array.length; i++) {
array[i]
}

Might also be time to use the LET keyword !
I always, for no good reason mind you... , wake up and figure out the variable's missing after a few seconds of debugging.and YES, I've created my own snippet by now, but still, this should be an easy fix.

@fd-rey
Copy link
Contributor

fd-rey commented Nov 21, 2018

I've the same issue, for...of is creating code that produces ReferenceError.
I think that a possible solution could be modify this file:
https://github.com/atom/language-javascript/blob/master/snippets/language-javascript.cson

setting this line
'for of': 'prefix': 'forof' 'body': 'for (${1:variable} of ${2:iterable}) {\n\t$3\n}'

to this one (add var before the variable)
'for of': 'prefix': 'forof' 'body': 'for (var ${1:variable} of ${2:iterable}) {\n\t$3\n}'

@axe-z

This comment has been minimized.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants