12/31/2023 0 Comments Annotate gem![]() ![]() You’ll then see something like “51 files inspected, 255 offenses detected, 183 offenses corrected, 57 more offenses can be corrected with `rubocop -A`” This will “clean up” a lot of default Rails files and anything we may have written sub-optimally along the way ourselves. So when you first run Rubocop on a project it will complain about lots of things. Most libraries/gems out there - such as Rails - don’t obey Rubocop all the time (their performance and readability would likely increase if they did!). You’ll see something like “51 files inspected, 238 offenses detected, 222 offenses auto-correctable”. Now, to get a sense for how rubocop works across the board, let’s go ahead and run:Īll this does is tell you how many “offenses” there are in your code. In your terminal at the quotesapp root, run: To do so, open up Gemfile and at the bottom add: gem 'rubocop', require: false So, to get started let’s install Rubocop. In fact, I've been writing code for decades and still learn new and helpful things with linters (along with corrections for all my bad code style habits, of course!). Since this is a training course for new developers, leveraging Rubocop, ESLint, and Prettier will help tremendously. For a full explanation, see this article, but the short version is that it speeds up development time for teams and helps beginners learn how to write better JavaScript. There are many great reasons to use both a style editor like Prettier alongside a more classic linter like ESLint. ![]() In addition, since JavaScript can be written a zillion different ways, we’ll start cleaning up our code first with Prettier before we run ESLint. For our JavaScript, we’ll leverage ESLint. Since we’ll be using Ruby for our primary “back-end” language (server side), our linter of choice there will be Rubocop. A linter is “a tool that analyzes source code to flag programming errors, bugs, stylistic errors, and suspicious constructs.” This helps tremendously to not only write better code faster, but it makes life easier for teams to stay on the same page and commit readable/reliable code. Here we’ll dive into the topics of automated code formatting and linting to maintain consistent code styles and help us catch bugs before they get committed to our code repository. This post is part 9 of a 10-part series within a series that is designed to teach full-stack web development for entrepreneurs.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |