cordova-android icon indicating copy to clipboard operation
cordova-android copied to clipboard

chore: Add fmt script for fixing lint errors

Open jcesarmobile opened this issue 3 years ago • 4 comments

At the moment we have the lint script that tells you all the lint errors the code has, but you have to fix all the problems manually, which is tedious. Since we are already using eslint for the linting, we can use the --fix parameter to automatically fix the errors (or at least most of them).

With this PR users will be able to run npm run fmt (I'm open for using other name), and fix the lint errors without having to manually change the code.

We could probably add this to all repositories that are already using eslint.

jcesarmobile avatar Sep 19 '22 23:09 jcesarmobile

Codecov Report

Merging #1493 (d860bb7) into master (954d3e0) will not change coverage. The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #1493   +/-   ##
=======================================
  Coverage   72.13%   72.13%           
=======================================
  Files          21       21           
  Lines        1751     1751           
=======================================
  Hits         1263     1263           
  Misses        488      488           

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov-commenter avatar Sep 19 '22 23:09 codecov-commenter

npm run lint -- --fix is what I am using.

erisu avatar Sep 20 '22 02:09 erisu

If you must have a command added to package.json, then I suggest

"lint:fix": "npm run lint -- --fix",

So the command becomes npm run lint:fix.

erisu avatar Sep 20 '22 09:09 erisu

On windows command line / Powershell, you might have to encapsulate the intermediate -- with double quotations so it's npm run lint "--" --fix. I vaguely recall that being an issue for windows users trying to pass through the --packageType flag to the cordova build command.

Not sure if the same syntax works for bash shells, but if we do add a command, it probably should work in both windows cmd line as well as bash.

breautek avatar Sep 20 '22 12:09 breautek

tested the command erisu proposed and worked fine on macOS, windows CMD and windows powershell, the quotation might be needed for when you type the commands yourself, but seem to work fine if the command is in a npm script

jcesarmobile avatar Oct 27 '22 21:10 jcesarmobile