dodona icon indicating copy to clipboard operation
dodona copied to clipboard

Add formatter for JavaScript/TypeScript

Open niknetniko opened this issue 3 years ago • 8 comments
trafficstars

This was recently mentioned in #3597, and I have also thought this a few times already.

Some well-known ones are:

  • https://standardjs.com/ (this would also replace eslint)
  • https://prettier.io/

niknetniko avatar May 13 '22 13:05 niknetniko

What is the advantage of standardjs? Since we're already using eslint can't we just use that for formatting? In fact, that's what I'm doing in vscode.

bmesuere avatar May 15 '22 09:05 bmesuere

What is the advantage of standardjs? Since we're already using eslint can't we just use that for formatting? In fact, that's what I'm doing in vscode.

If ESLint is able to do formatter tasks, then there is no advantage for us I think, then it's probably enough to enable more rules.

niknetniko avatar May 15 '22 17:05 niknetniko

The strange thing is that many of the small style issues mentioned in #3597 are reported (and fixed) in my editor: image

As far as I know, this uses the .eslintrc file in the repo. Maybe these smaller things are reported as warnings instead of errors (which is why linting doesn't fail) and @jorg-vr hasn't enabled eslint in his editor.

bmesuere avatar May 16 '22 06:05 bmesuere

Does yarn run lint --fix fix these issues? (@jorg-vr Do you run that command to fix simple issues?)

chvp avatar May 16 '22 07:05 chvp

yarn run lint --fix does not fix anything in #3597 It reports 0 errors and 737 warnings

Mostly max-len and no-jquery errors

jorg-vr avatar May 16 '22 07:05 jorg-vr

I lists no warnings for the edits @chvp made Warnings are highlighted in my editor (Rubymine)

jorg-vr avatar May 16 '22 07:05 jorg-vr

ESLint does seem to have rules for those things, e.g. https://eslint.org/docs/rules/space-infix-ops and https://eslint.org/docs/rules/space-in-parens. Maybe it's as simple as enabling more rules then?

niknetniko avatar May 17 '22 11:05 niknetniko

Relevant: https://eslint.org/blog/2023/10/deprecating-formatting-rules/

niknetniko avatar Oct 28 '23 08:10 niknetniko