A few problems with js beautifier

Hi,

I’m a new Komodo IDE 12 user and I mostly like it so far, although I’ve encountered a few issues that could well be my fault so I’d thought I try asking here:

  • I couldn’t get ‘format code before saving’ working properly. I wrote a userscript to call ‘cmd_format’ (as found in a blog post) before saving, and it sort of works, the document does get formatted but it remains ‘modified’ and doesn’t end up getting saved. The userscript just does:

ko.commands.doCommandAsync(‘cmd_format’)

I tried ‘Sync’ instead of ‘Async’, various return values etc. but nothing worked. It does work when bound to a key so I can use that but would prefer on save.

  • The js beautifier formatter wants to insert a space into all my arrow operator arrows, so ‘=>’ becomes ‘= >’ which of course breaks at runtime. There doesn’t seem to be any relevant option for this in the IDE, is there another beautifier I can install? How?

  • Is there a list of userscript ‘ko.commands’ somewhere? I could fix my arrow operator problem if I could do a search replace after the cmd_format, but I don’t know how. I can’t find one at https://docs.activestate.com/komodo/12/.

Bye!
Mark

Ok, I eventually solved the js-beautifier problem simply by installing a command line ‘js-beautifier’ and selecting that instead of the built-in one. The built-in one appears to be a wee bit broken AFAICT.

New problem though, I tried to get eslint working instead of jshint but with no luck. Whenever I select it in the preferences page and go back to the editor to test it, nothing happens, and then when I go back to the preferences page it’s de-selected itself. Couldn’t find anything interesting in the help/log log either.

Eslint is working fine from the commandline OK. I’m not totally sure where to place the .eslintrc.json file, I’ve currently got it in the main project dir but I’ve tried it in file subdir too but it doesn’t fix anything.

A last question: is the ‘komodo edit’ at github the same as the ‘komodo ide’ one?

Bye!
Mark

Hi @blitz-research,

To set format on save using this toolbar button:

To change what the formatter does use the respective formatting tools config file options.

For a list of available cmd_*s press Ctrl+shift+O and open the Commands option. I don’t think we list it anywhere else.

Re ESlint: Looks like I patched this a while ago but it never made it into a release unfortunately. There hasn’t been a Komodo release in some time and there are no plans for one coming any time soon: [Bugs] Resets the selection of ESLint as a Linter · Issue #3833 · Komodo/KomodoEdit (github.com)

The KomodoEdit github account is where we accept bug reports for both KomodoIDE and KomodoEdit. The code base in that repo is KomodoEdit though. KomodoIDE is in a private ActiveState Repo.

  • Carey

Sweet, thanks a lot for the info, beautify on save does indeed work using that button, just not using a userscript.

Sad to hear there are no more updates planned for Komodo, it’s a very nice self contained package that just needs a few rough edges smoothed off IMO.

I can get by with JSHint vs ESLint so that’s not a biggy (yet).

Bye,
Mark

1 Like