question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

space_after_named_function not working inside an ES6 class

See original GitHub issue

Description

space_after_named_function not working inside an ES6 class. I don’t know if this is the indented behaviour or not, but it was not what I was expecting

Input

The code looked like this before beautification:

class blah {
  constructor() {
    this.doStuff()
  }

  doStuff() {
    console.log("stuff")
  }
}

function test() {}

Expected Output

The code should have looked like this after beautification:

class blah {
  constructor () {
    this.doStuff()
  }

  doStuff () {
    console.log("stuff")
  }
}

function test () {}

Actual Output

The code actually looked like this after beautification:

class blah {
  constructor() {
    this.doStuff()
  }

  doStuff() {
    console.log("stuff")
  }
}

function test () {}

Steps to Reproduce

Run on https://beautifier.io/

Environment

https://beautifier.io/ Also, ubuntu 18.10

Settings

Example:

{
  "indent_size": "2",
  "indent_char": " ",
  "max_preserve_newlines": "5",
  "preserve_newlines": true,
  "keep_array_indentation": false,
  "break_chained_methods": false,
  "indent_scripts": "normal",
  "brace_style": "collapse",
  "space_before_conditional": true,
  "unescape_strings": false,
  "jslint_happy": false,
  "end_with_newline": false,
  "wrap_line_length": "0",
  "indent_inner_html": false,
  "comma_first": false,
  "e4x": true,
  "space_after_anon_function": true,
  "space_after_named_function": true
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bitwisemancommented, Jun 20, 2022

Turns out this was in the 1.14.4 - released today.

0reactions
bitwisemancommented, Jun 20, 2022

Yup, not fixed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Why is "this" in an ES6 class not implicit?
I know that ES6 solved a lot of problems that existed with the this keyword in ES5, such as arrow functions and classes....
Read more >
Classes - JavaScript - MDN Web Docs
Classes are a template for creating objects. They encapsulate data with code to work on that data. Classes in JS are built on...
Read more >
As a JS Developer, This Is What Keeps Me Up at Night
The answer here is there isn't one. These do effectively the same thing, it's only a question of whether ES6 class syntax was...
Read more >
15. Classes
Under the hood, ES6 classes are not something that is radically new: They mainly ... not become a variable outside of the class,...
Read more >
An Overview of ES6 Classes
In this article, I'll provide an overview of how classes work in ... TypeError: Class constructor MyClass cannot be invoked without 'new' ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found