max-mapper / standard-format

converts your code into Standard JavaScript Format
264 stars 59 forks source link

Code is being changed by the standard-format #182

Closed alexsorokoletov closed 7 years ago

alexsorokoletov commented 7 years ago

Hi! I initially found it as a problem with vscode-standard-format but then decided to check the standard-format and standard tools as well. We have code

function NodeListToArray(nl) {
    for(var a=[], l=nl.length; l--; a[l]=nl[l]);
    return a;
}

Running standard-format over it produces incorrect code:

$ standard-format 1.js         
function NodeListToArray (nl) {
  for (var a = [], l = nl.length; l--; a[l] = nl[l])
    return a
}

Tried same code with standard 1.js --fix, produces just formatted code (no semantic change).

Please advise.

feross commented 7 years ago

standard-format is deprecated, so you should use standard --fix instead. This command fixes a lot, but not all errors. Fortunately, more errors become fixable with each release.

Flet commented 7 years ago

@alexsorokoletov: Sam Chen's vscode-standardjs plugin includes a command to fix errors using --fix:

screen shot 2016-12-04 at 10 35 33 pm
alexsorokoletov commented 7 years ago

Thank you, guys.