Skip to content

Latest commit

 

History

History
20 lines (16 loc) · 837 Bytes

File metadata and controls

20 lines (16 loc) · 837 Bytes

Ignore errors for sloppy mode syntax (#11750 by @fisker, #11778 by @sosukesuzuki)

JavaScript’s strict mode adds several useful errors to prevent mistakes. Some of these errors are syntax errors that occur at parse time. Since Prettier’s goal is to format all syntactically valid JavaScript code regardless of whether it will actually run, we’ve opted to leave this error checking to linters, compilers, and the runtime.

// Input
function foo() { var bar = 1; delete bar; }

// Prettier stable
SyntaxError: Deleting local variable in strict mode. (1:31)
> 1 | function foo() { var bar = 1; delete bar; }
    |                               ^

// Prettier main
function foo() {
  var bar = 1;
  delete bar;
}