Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add lint:fix script for fixing lint errors #1493

Merged
merged 2 commits into from Jan 11, 2023
Merged

chore: Add lint:fix script for fixing lint errors #1493

merged 2 commits into from Jan 11, 2023

Conversation

jcesarmobile
Copy link
Member

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-commenter
Copy link

codecov-commenter commented Sep 19, 2022

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           

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

@jcesarmobile jcesarmobile changed the title chore: Add fmt command for fixing lint errors chore: Add fmt script for fixing lint errors Sep 19, 2022
@erisu
Copy link
Member

erisu commented Sep 20, 2022

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

@erisu
Copy link
Member

erisu commented Sep 20, 2022

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.

@breautek
Copy link
Contributor

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.

@jcesarmobile jcesarmobile changed the title chore: Add fmt script for fixing lint errors chore: Add lint:fix script for fixing lint errors Oct 27, 2022
@jcesarmobile
Copy link
Member Author

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

@erisu erisu merged commit ce19a3b into master Jan 11, 2023
@erisu erisu deleted the fmt branch January 11, 2023 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants