cordova-android
cordova-android copied to clipboard
chore: Add fmt script for fixing lint errors
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.
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
npm run lint -- --fix is what I am using.
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.
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.
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