![]() Sublime Text JavaScript Standard Style linter Lines with errors are marked red, on the bottom you can see the error message. I highly recommend to install standard extension for Sublime Text, it will help a lot by pointing things to fix: The rest of warnings I need to fix manually, so I’m opening code editor, Sublime Text 3 in this scenario. JavaScript Standard Style after automatic fix Good first step of improving quality of the code is to let JavaScript Standard Style fix the code by itself, to do that you need to use –fix parameter: standard "src/js/modules/*.js" – fixĪs you can see, after the fix I have only 30 issues to fix: In my case, there were about 300 issues found □ JavaScript Standard Style first usage about 300 issues found Ok so we have JavaScript Standard Style installed, let’s check our code with the linter: standard "src/js/modules/*.js" If you want to have this installed locally (recommended) use –global parameter: npm install standard – global ![]() Okay and now we can install JavaScript Standard Style: npm install standard – save-dev ![]() Always use = instead of = – but obj = null is allowed to check null || undefined.Įnabling JavaScript Standard Style in the projectĪs always when you are doing some major change it’s good to start with creating a new branch: git checkout -b 'feature/standard-js'.This is the only gotcha with omitting semicolons – automatically checked for you!.No unused variables – this one catches tons of bugs!.Single quotes for strings – except to avoid escaping.That’s why JavaScript Standard Style is pretty interesting to me. Using ES Lint was very fun and easy, but when we finally found a “trendy” linter we had to start looking for a good configuration for it. A long time ago frontend developers have been using JS Lint, but after few months, we’ve been using JS Hint, and about one year ago we’ve switched to ES Lint.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |