<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Valeriy Stepanov</title>
    <description>The latest articles on DEV Community by Valeriy Stepanov (@bskydive).</description>
    <link>https://dev.to/bskydive</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F226447%2Ffca8175b-4209-4bbf-b6f2-5bea831e8b14.jpeg</url>
      <title>DEV Community: Valeriy Stepanov</title>
      <link>https://dev.to/bskydive</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bskydive"/>
    <language>en</language>
    <item>
      <title>JS code quality starter pack: linters, conventions, best practices</title>
      <dc:creator>Valeriy Stepanov</dc:creator>
      <pubDate>Mon, 17 May 2021 20:01:53 +0000</pubDate>
      <link>https://dev.to/bskydive/javascript-code-conventions-starter-pack-3jff</link>
      <guid>https://dev.to/bskydive/javascript-code-conventions-starter-pack-3jff</guid>
      <description>&lt;p&gt;This article is about my view to convention building. &lt;/p&gt;

&lt;p&gt;It includes some basic examples including linting tools setup. &lt;/p&gt;

&lt;p&gt;That can be interesting for developers who like to follow coding best practices and who want to improve their own or team code quality. &lt;/p&gt;

&lt;p&gt;As for me, I've explained and use those concepts many times. So, putting them into article will be handy.&lt;/p&gt;

&lt;p&gt;First of all you can look at my linting guide with the linter pack setup &lt;a href="https://github.com/bskydive/typescript-tspqwe-linters"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Also you can grab my article from git repo &lt;a href="https://gitlab.com/stepanovv/kbo/-/blob/master/public/kbo/kb/conventions/starter-conventions.md"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is it for
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Put and keep things in order together.&lt;/li&gt;
&lt;li&gt;To make productivity a little bit higher, and also reduce the volume of work.&lt;/li&gt;
&lt;li&gt;Conventions supports convenience of:

&lt;ul&gt;
&lt;li&gt;migration. Facilitate the process of transferring the code between an old and new design / framework.&lt;/li&gt;
&lt;li&gt;debugging. Look at debug/dev tools and understand from which file this piece of code is, and where it can be inside the file.&lt;/li&gt;
&lt;li&gt;reading. Reduce the time for searching and analyzing information. The code units naming should help to immediately understand what it should do.&lt;/li&gt;
&lt;li&gt;development. Use generally(framework) accepted patterns and practices.&lt;/li&gt;
&lt;li&gt;communication. Reduce the length/duration of actions chains and loops(ping-pong)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How to make it
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Conventions should respect team's/framework's abilities and limitations.&lt;/li&gt;
&lt;li&gt;Conventions is always a compromise. You should learn how to do that before doing conventions.&lt;/li&gt;
&lt;li&gt;Compromise is based on the trust, and that's based on the respect and responsibility.&lt;/li&gt;
&lt;li&gt;Respect yourself and others results of the work and time which has been spent.&lt;/li&gt;
&lt;li&gt;Prepare and make discussions well:

&lt;ul&gt;
&lt;li&gt;reduce the number of participants&lt;/li&gt;
&lt;li&gt;make and read agendas&lt;/li&gt;
&lt;li&gt;convert feelings into real facts and stories&lt;/li&gt;
&lt;li&gt;speak in plain English, avoid using &lt;a href="https://blog.juliobiason.me/thoughts/things-i-learnt-the-hard-way/#design-patterns-are-used-to-describe-solutions-not-to-find-them"&gt;abbreviations&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;draw trees with facts decomposition&lt;/li&gt;
&lt;li&gt;write a summary and apply the decisions&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Rules for the PR reviewer
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;reduce the number of reviewers

&lt;ul&gt;
&lt;li&gt;More than one can be the cause of duplicated work and time spending while one of them/you out of work or busy&lt;/li&gt;
&lt;li&gt;If more than one participants is necessary, you should divide the code for each reviewer&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;check all code at once, reduce review-fix(ping-pong) time spending&lt;/li&gt;
&lt;li&gt;actions:

&lt;ul&gt;
&lt;li&gt;switch into PR branch&lt;/li&gt;
&lt;li&gt;execute and test at least one main functionality of the PR, prevent moving PR to QA engineers with silly issues like "forgot to run &lt;code&gt;git add&lt;/code&gt;"&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;check the:

&lt;ul&gt;
&lt;li&gt;unit test code coverage&lt;/li&gt;
&lt;li&gt;code convention compliance&lt;/li&gt;
&lt;li&gt;code complexity&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Rules for the PR author
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Less code means less:

&lt;ul&gt;
&lt;li&gt;bugs&lt;/li&gt;
&lt;li&gt;merge conflicts&lt;/li&gt;
&lt;li&gt;reading time&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Do not shorten unit's names or line breaks:

&lt;ul&gt;
&lt;li&gt;Long names and line breaks reduce analysis time and bugs count.&lt;/li&gt;
&lt;li&gt;Minifier will remove them anyway.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;describe PR's scope in a task to help make the review and a test better:

&lt;ul&gt;
&lt;li&gt;modules/components or domain areas which have been modified&lt;/li&gt;
&lt;li&gt;new functionalities were added and where&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;reduce the PR's scope, make a new subtask/story for:

&lt;ul&gt;
&lt;li&gt;broken/disabled(xit/xdescribe) unit test&lt;/li&gt;
&lt;li&gt;optional parts of functionality/refactoring&lt;/li&gt;
&lt;li&gt;investigation and description(making notes/readmes) of how old code is working&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;execute before the pushing into repo:

&lt;ul&gt;
&lt;li&gt;reformat and autofix all code using prettier, eslint and stylelint rules&lt;/li&gt;
&lt;li&gt;git pull &amp;amp;&amp;amp; git merge origin master&lt;/li&gt;
&lt;li&gt;npm run lint&lt;/li&gt;
&lt;li&gt;npm run build&lt;/li&gt;
&lt;li&gt;npm run test&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Rules for code quality
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;make functions private as much as possible&lt;/li&gt;
&lt;li&gt;use camelCase&lt;/li&gt;
&lt;li&gt;remove an unused code&lt;/li&gt;
&lt;li&gt;reduce the &lt;a href="https://eslint.org/docs/rules/complexity"&gt;code complexity&lt;/a&gt;:

&lt;ul&gt;
&lt;li&gt;nested braces depth&lt;/li&gt;
&lt;li&gt;else blocks&lt;/li&gt;
&lt;li&gt;lines length&lt;/li&gt;
&lt;li&gt;lines per function&lt;/li&gt;
&lt;li&gt;params count&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;make names readable like:

&lt;ul&gt;
&lt;li&gt;isSomethingEnabled&lt;/li&gt;
&lt;li&gt;onEventHappens&lt;/li&gt;
&lt;li&gt;getSomeValue&lt;/li&gt;
&lt;li&gt;setSomeValue&lt;/li&gt;
&lt;li&gt;parseValues&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;put notes to share your &lt;a href="https://blog.juliobiason.me/thoughts/things-i-learnt-the-hard-way/#documentation-is-a-love-letter-to-your-future-self"&gt;knowledge&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;The code describes how things works, and your notes describes why or what for&lt;/li&gt;
&lt;li&gt;One short note can prevent hours of investigation or days of rewriting code back and forth&lt;/li&gt;
&lt;li&gt;Put comments in one line, after the code not to increase lines number&lt;/li&gt;
&lt;li&gt;Put jsdoc in one line not to increase lines number. In popovers they are automatically reformatted.&lt;/li&gt;
&lt;li&gt;Put long notes in readme files: usage examples&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;make separate unit test assertion for:

&lt;ul&gt;
&lt;li&gt;every input option&lt;/li&gt;
&lt;li&gt;every output value&lt;/li&gt;
&lt;li&gt;every possible state: init, loading, disabled, broken(reproduce exact issue), valid&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;add in every unit test not only the final state, but state transition: before/after loading, before/after issue fixing&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>javascript</category>
    </item>
  </channel>
</rss>
