-9

The Stack Snippets editor includes a "Tidy" button. This button uses a outdated version of js-beautify which does not include support for syntax changes in ECMAScript 2020 and newer. Running it with code that uses such syntax can result in the code being broken and producing syntax errors. This has been reported on MSE and MSO several times over the last four years, such as here, with requests to update js-beautify to fix it, such as here, but it hasn't been fixed. There are probably going to be more syntax changes in the future, so this will continue to get more broken unless it's regularly updated.

Since that doesn't seem likely, I suggest the easier solution of just removing it instead.

In theory, a code formatting capability could be useful for any code block on Stack Overflow, but one was never implemented and I don't think there's ever been much demand for it. There's no strong reason that Stack Snippets needs it when the rest of the site does without.

As currently implemented, the feature is arguably harmful, since it can cause otherwise-valid code to become broken, perhaps without the author realizing. (I generally assume that formatting my code doesn't affect behavior, so I wouldn't necessarily feel a need to re-test after formatting it.)

8
  • 3
    @Cerbrus same problem, but advocating for a different “solution” Commented Dec 2 at 18:28
  • 2
    So suggest that in an answer, there. No point spreading out the discussion. And seeing as how that question is tagged status-review, it's in SE's backlog... Somewhere.
    – Cerbrus
    Commented Dec 2 at 18:30
  • Also, just removing the functionality isn't a solution.
    – Cerbrus
    Commented Dec 2 at 18:30
  • 4
    @Cerbrus sure it is. Removing the “break my code” button solves the problem of “there’s a button that’s breaking people’s code”. Commented Dec 2 at 18:33
  • 3
    Calling it a "break my code" button is a gross overstatement to me. It works 100% for HTML and CSS, and only breaks on a few new syntax features in JS. What you want to be advocating for is for the fix to be implemented. Not for the feature to be removed. If they're going to have a look at this, at all, removing the feature altogether shouldn't be the priority.
    – Cerbrus
    Commented Dec 2 at 18:35
  • Everyone clearly disagrees with this, but it’s obviously not a duplicate. Don’t abuse your close votes to signal disagreement. Just downvote and move on. Commented Dec 3 at 16:11
  • Jeremy, you're free to disagree with the close-votes, but please don't accuse people of abuse just because you disagree with their actions. That's rather hostile and unproductive. I don't think it's "obviously" not a duplicate. You're asking about the same issue, but you're just suggesting a different, rather drastic solution. That suggestion, as I stated before, can just be made on the dupe target.
    – Cerbrus
    Commented Dec 3 at 16:54
  • "Everyone clearly disagrees with this" is also misrepresenting the current state. Your question has four upvotes at the moment.
    – Cerbrus
    Commented Dec 3 at 16:55

1 Answer 1

9

I don't think just removing the functionality is a solution.

The "Tidy" feature does still work for a lot of JS, and it also processes the CSS and HTML fields.

You'd be removing a significant piece of functionality to prevent a less significant bug.

Alternatively, you could skip the JS field, but that'd make the "Tidy" button a lot less intuitive... "Why didn't it tidy my code?"

Not the answer you're looking for? Browse other questions tagged .