<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Juro Uhlar on Medium]]></title>
        <description><![CDATA[Stories by Juro Uhlar on Medium]]></description>
        <link>https://medium.com/@jurouhlar?source=rss-ac650b30cf52------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nMb_omDDctdUVNp8RrYWWA.jpeg</url>
            <title>Stories by Juro Uhlar on Medium</title>
            <link>https://medium.com/@jurouhlar?source=rss-ac650b30cf52------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 20:20:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jurouhlar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Every bugfix should be a refactor]]></title>
            <link>https://medium.com/@jurouhlar/every-bugfix-should-be-a-refactor-7e667fceeb6d?source=rss-ac650b30cf52------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e667fceeb6d</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[bugs]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Juro Uhlar]]></dc:creator>
            <pubDate>Sun, 14 Sep 2025 17:22:27 GMT</pubDate>
            <atom:updated>2025-09-14T17:26:18.733Z</atom:updated>
            <content:encoded><![CDATA[<p>Someone reports a bug. You make a ticket. Dive into the code. After a while, you realize the bug is silly. You or your teammate called the wrong function, placed some operation in the wrong order, or forgot to check a condition somewhere.</p><p>You fix it in a single line and submit your PR within record time. Great job? No, most likely not a great job. A wasted opportunity!</p><p>Someone probably created that bug because the code was a mess. It’s hard to justify spending engineering time on fixing a messy code that works. But this mess just stopped working! A ticket was already created with loose expectations of how long it should take! What a gift!</p><p>If the bug is not critical, now is the time to take a couple of hours to ask <em>Why</em> several times in a row and address the root cause.</p><ul><li>Maybe you called the wrong function because there are multiple similarly badly-named functions. Rename them all!</li><li>Maybe you misordered an operation because the entire data flow was confusing. Rewrite it from scratch to make it clear!</li><li>Maybe you missed a condition because that piece of code is loosely typed. Type it correctly to make repeating the error impossible!</li><li>Why did no tests catch the bug? Can you add tests that would catch this class of bugs?</li></ul><p>Whatever confusion or obstacles you faced trying to understand and find the bug is probably what caused it in the first place.</p><p>To fix just the bug itself is to waste it. Fix the root cause.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e667fceeb6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solving the link icon wrapping problem with React and CSS]]></title>
            <link>https://medium.com/@jurouhlar/solving-the-link-icon-wrapping-problem-with-react-and-css-490b3316d513?source=rss-ac650b30cf52------2</link>
            <guid isPermaLink="false">https://medium.com/p/490b3316d513</guid>
            <category><![CDATA[icons]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[white-space]]></category>
            <category><![CDATA[wrapping]]></category>
            <dc:creator><![CDATA[Juro Uhlar]]></dc:creator>
            <pubDate>Sun, 26 May 2024 17:08:44 GMT</pubDate>
            <atom:updated>2024-05-26T17:08:44.613Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*3GEEqCzHuCa5nvrTQ3TJIA.png" /></figure><p>So I have a special kind of &lt;Link&gt; component in a table that adds an external link icon (↗)️ to the link text and animates it.</p><p>The problem is sometimes the icon doesn’t fit and only the icon ends up wrapping to the new line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*3pubKw7X8ISC9mB2FaGWjA.png" /></figure><p>In those cases, you want the last word of the link to also be on the second line.</p><p>You might resort to adding a &lt;br /&gt; element. But it depends on the available width and text length, so you need to place it there manually. Or use some gnarly JavaScript to calculate when you need the &lt;br /&gt; element.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*RoBdp2667P0oJ4L4ihc3zg.png" /></figure><p>Here is a simple way:</p><ol><li>Split the text link into leading words and the last word.</li><li>Put the last word together with the icon inside &lt;span style=”white-space: nowrap”&gt;.</li></ol><p>Now the icon never ends up on a new line all alone. Here is a React example but you can use the same principle anywhere.</p><pre>const DocsLink: FunctionComponent&lt;{ children: string; href: string; style?: React.CSSProperties }&gt; = ({<br>  children,<br>  href,<br>}) =&gt; {<br>  const lastWord = children.split(&#39; &#39;).pop();<br>  const leadingWords = children.split(&#39; &#39;).slice(0, -1).join(&#39; &#39;);<br>  return (<br>    &lt;Link href={href} target=&#39;_blank&#39;&gt;<br>      {leadingWords}{&#39; &#39;}<br>      &lt;span style={{ whiteSpace: &#39;nowrap&#39; }}&gt;<br>        {lastWord}<br>        &lt;Image src={externalLinkArrow} alt=&#39;&#39; /&gt;<br>      &lt;/span&gt;<br>    &lt;/Link&gt;<br>  );<br>};</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=490b3316d513" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple text-reveal CSS effect using Clip-path and Framer Motion]]></title>
            <link>https://medium.com/@jurouhlar/simple-text-reveal-css-effect-using-clip-path-and-framer-motion-4d0866b1d949?source=rss-ac650b30cf52------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d0866b1d949</guid>
            <category><![CDATA[framer-motion]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-animation]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Juro Uhlar]]></dc:creator>
            <pubDate>Fri, 02 Feb 2024 12:42:11 GMT</pubDate>
            <atom:updated>2024-02-02T12:42:11.786Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rjdBkKKgTpYNlwmhGHVmtA.png" /></figure><p>I was working on a <a href="https://demo.fingerprint.com/">use case demo</a> the other day, and it required this “Note” UI element:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZhjEPuNDxMG0TRgHUjHItQ.png" /></figure><p>It’s pretty small to avoid distracting from the meat of the demo but we wanted to draw the user’s attention to it when they first saw it.</p><blockquote>What if when the user gets to this viewpoint, we animate this hand making it fade in from the left and wave, and then the text also appears or types in?</blockquote><p>I usually stick to CSS for simple animations but animating on enter requires some JavaScript. At that point, it was better to reach for <a href="https://www.framer.com/motion/">Framer Motion</a> and get to work.</p><p>The waving hand is straightforward:</p><ul><li>Use the whileInView to define the animation that happens when the user scrolls to the element.</li><li>You can pass an array to rotate to wave the hand back on forth a few times before returning to 0.</li></ul><pre>import { motion } from &#39;framer-motion&#39;;<br><br>const Wave = () =&gt; (<br>  &lt;motion.div<br>    initial={{ rotate: 0 }}<br>    whileInView={{ rotate: [30, -30, 30, -30, 30, -30, 30, -30, 30, -30, 0] }}<br>    transition={{ duration: 1.5 }}<br>    viewport={{ once: true }}<br>  &gt;<br>    &lt;Image src={WaveIcon} alt=&quot;&quot; /&gt;<br>  &lt;/motion.div&gt;<br>);</pre><p>The typing-style text reveal is harder. There are many <a href="https://www.freecodecamp.org/news/reveal-on-scroll-in-react-using-the-intersection-observer-api/">complicated ways to do it</a>, especially if you need the full typewriter effect including the cursor. But if you just want the text to appear from left to right, you can achieve that using a single CSS property: <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/clip-path">clip-path</a>. It allows you to define what part of the element is shown, using a variety of shapes.</p><pre>const InstructionPrompt = ({ children }) =&gt; (<br>    &lt;motion.div<br>      // reveals content from left to right<br>      initial={{ clipPath: &#39;polygon(0 0, 0 0, 0 100%, 0% 100%)&#39; }}<br>      whileInView={{ clipPath: &#39;polygon(0 0, 100% 0, 100% 100%, 0 100%)&#39; }}<br>      viewport={{ once: true }}<br>      transition={{ duration: 1.5 }}<br>    &gt;<br>      {children}<br>    &lt;/motion.div&gt;<br>);</pre><p>You can use one of many online <a href="https://bennettfeely.com/clippy/">clip path generators</a> to get your shape values. Here is the final result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*fv3BAfKaHBTyOt3tZ0Xsmg.gif" /></figure><p>I am just writing down this small anecdote just to remember how to do it next time. It also illustrates avoiding a pitfall I sometimes fall into. You have a nice-to-have requirement like an animation. But many ways of achieving that requirement are too have-handed for the limited benefit. Some things are only worth doing if you can do them simply.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d0866b1d949" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Hitchhiking Developer’s Guide to Writing Documentation]]></title>
            <link>https://medium.com/@jurouhlar/the-hitchhiking-developers-guide-to-writing-documentation-cccb85987992?source=rss-ac650b30cf52------2</link>
            <guid isPermaLink="false">https://medium.com/p/cccb85987992</guid>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[manuals]]></category>
            <category><![CDATA[technical-writing]]></category>
            <category><![CDATA[documentation]]></category>
            <dc:creator><![CDATA[Juro Uhlar]]></dc:creator>
            <pubDate>Fri, 13 May 2022 13:59:17 GMT</pubDate>
            <atom:updated>2022-05-13T13:59:17.275Z</atom:updated>
            <content:encoded><![CDATA[<p>So you are a rock-star developer, but now you need to write documentation. Life can be hard that way. What’s worse, the way you have been taught to write in school does not apply here. In fact, it will make your docs suck.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ip2p-h0UocSm_BBE" /><figcaption>Photo by <a href="https://unsplash.com/@jamie452?utm_source=medium&amp;utm_medium=referral">Jamie Street</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The goal [of a lot of] academic writing is to sound smart. The goal of technical writing is to be easily understood. Those are opposite goals. To learn human writing, you must unlearn school writing. The Holy Grail is having docs that a child with only basic English and technical skills can use.</p><p>Some general principles to follow are <strong>simplicity</strong>, <strong>brevity</strong>, <strong>directness</strong>, <strong>consistency</strong>, <strong>structure,</strong> and <strong>empathy</strong> (yes, the same ones as for writing code).</p><h3>1. Keep it Simple</h3><ul><li>Write like a human (similar to the way you speak).</li><li>Don’t be clever, be understood.</li><li>Avoid unnecessary technical jargon and complex sentence structures.</li><li>As with code, only use the minimum amount of (linguistic) complexity required to get the job done (get the information across).</li></ul><p>❌ Users section is the next step where a selection of users for whom the preset is going to be installed takes place.<br>✅ Select which users the preset will be applied to.</p><p>❌ This selection is populated in accordance with the content of the Category selection. The user may select the data endpoints available for the respective category.<br>✅ The drop-down options are based on the Category selection above.</p><h3>2. Keep it Short</h3><ul><li>Remove useless words.</li><li>Less is more.</li></ul><p>❌ Clicking the report name in the table redirects the user to the report detail.<br>✅ Click the report name to open it.</p><p>❌ After clicking the <em>More actions icon</em>, the user can perform basic actions, using the options <em>Duplicate</em>, <em>Edit</em> and <em>Delete</em>.<br>✅ Click <em>More actions</em> to duplicate, edit, or delete a schedule.</p><h3>3. Keep it Direct</h3><ul><li>Just tell people what to do (use imperative form).</li><li>Write “you” instead of “the user”.</li><li>Avoid passive voice “reports are generated” (who generates them?).</li><li>Avoid “it is possible to”, “the user has the ability to”, “please note that”.</li></ul><p>❌ The user may filter the reports using the left sidebar.<br>✅ Use the left sidebar to filter the reports.</p><p>❌ User can either create an empty dashboard or create a ready-to-use dashboard from the list of predefined dashboards.<br>✅ Create an empty dashboard or use one of the predefined dashboards.</p><h3>4. Keep it Consistent</h3><ul><li>One name for one thing, synonyms are a source of confusion.</li><li>If you are referring the same feature/concept/element, use the same word every time, even if it sounds repetitive.</li><li>Docs must be consistent with the user interface and easily searchable.</li></ul><p>❌ New task can be added by clicking the New schedule button.<br>✅ Click New schedule to create a schedule.</p><p><strong>Bonus points</strong>: Use the same conventions for common patterns, such as:</p><ul><li>Referring to buttons: “Click <em>Create</em>” vs “Click the ‘Create’ button”.</li><li>Referring to icons: “Click Edit” vs “Click the ✎ icon”.</li><li>Referring to check-boxes: “Uncheck <em>Active</em>” vs “Disable the ‘Active’ checkbox”.</li><li>Linking to other pages: “See [Reports] for more details” vs “Find more details on [Reports] page”.</li><li>etc…</li></ul><h3>5. Keep it Structured</h3><ul><li>Break it up. Avoid long walls of text.</li><li>Docs are scanned more often than read.</li><li>Short sentences, short paragraphs, sections, lists, bullet points.</li><li>One idea per sentence, one concept per paragraph.</li></ul><p>❌ <br>New report can be added by clicking the <strong>New report</strong> button. Insert a <strong>Name</strong> of the report, <strong>Location</strong> and <strong>Device</strong> name. <strong>Location</strong> and <strong>Device</strong> name can be modified by clicking the <strong>Edit</strong> button. List of all available chapters is located at the bottom of the form. Requested chapters can be added into a report by checking them in the list and by clicking the <strong>Add chapters</strong> button. Once the chapter is added, its parameters can be modified by clicking the pencil icon on the right side of the list. Chapters can be reordered by dragging and dropping. The next step is either to <strong>Create report</strong>, or to <strong>Create and schedule</strong> the report.</p><p>✅<strong><br></strong>Click <strong>New report</strong> to create a report:</p><ol><li>Enter the report name.</li><li>Click <strong>Edit</strong> to change the <strong>Location</strong> or the <strong>Device</strong> of the report.</li><li>Click <strong>Add chapter</strong> to add one or more chapters to the report. Once added, you can reorder the chapters by dragging and dropping.</li><li>Click the <strong>Pencil icon</strong> to edit the chapter name, description, and visualization settings.</li><li>Click <strong>Create report</strong> to finish or <strong>Create and schedule</strong> to schedule the new report right away.</li></ol><h3>6. Empathize</h3><ul><li>How would you like this explained to you if you didn’t know what you know?</li><li>What did you struggle with when you were first doing the task?</li><li>Leave out “simply”, “easily”, “doing X is straightforward”, even if the action is simple. It adds no useful information and it sounds mean if the reader struggled with the step for whatever reason.</li></ul><p>❌ To sort the table, simply click on one of the column headers.<br>✅ Click the column header to sort the table by that column.</p><h3>Linters for Docs</h3><p>There are tools that will help you avoid the most common mistakes:</p><ul><li><a href="https://app.grammarly.com/">Grammarly</a> detects misspellings and bad grammar.</li><li><a href="https://hemingwayapp.com/">Hemingway</a> editor highlights convoluted paragraphs and needlessly fancy words. It gives you a readability score.</li></ul><h3>Reading about Writing</h3><p>There are professional, comprehensive style guides that inspired this humble write-up. Go straight to the source:</p><ul><li><a href="https://docs.microsoft.com/en-us/style-guide/welcome/">Microsoft Style Guide</a></li><li><a href="https://developers.google.com/style/highlights">Google Documentation Style Guide</a></li></ul><p><em>Thanks for reading! What did I miss? Argue with me in the comments! The list is by no means comprehensive. It reflects the most common problems I encountered when I went from a technical writer to a developer on a more technical product where documentation was written primarily by developers.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cccb85987992" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debug FreeCodeCamp Challenges Faster With This Bookmarklet]]></title>
            <link>https://medium.com/@jurouhlar/debug-freecodecamp-challenges-faster-with-this-bookmarklet-3b06a0dc2c47?source=rss-ac650b30cf52------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b06a0dc2c47</guid>
            <category><![CDATA[freecodecamp]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[bookmarks]]></category>
            <category><![CDATA[test-case]]></category>
            <category><![CDATA[bookmarklet]]></category>
            <dc:creator><![CDATA[Juro Uhlar]]></dc:creator>
            <pubDate>Tue, 25 Jan 2022 08:01:11 GMT</pubDate>
            <atom:updated>2022-01-25T08:01:11.780Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-ZVUgR6Nsx7GUmI4" /><figcaption>Photo by <a href="https://unsplash.com/@anniespratt?utm_source=medium&amp;utm_medium=referral">Annie Spratt</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><a href="https://www.freecodecamp.org/">FreeCodeCamp</a> is a fantastic non-profit platform for learning and improving your coding skills. They break things down into individual challenges that are covered by automatic tests. Clear the tests, pass the challenge. The one thing that used to bug me is that sometimes they don’t describe their test cases very well.</p><p>For simpler challenges, they are usually specific and useful:</p><blockquote>pairwise([1, 4, 2, 3, 0, 5], 7) should return 11.</blockquote><p>Excellent test description right there! But for the more complex challenges, they can get pretty abstract:</p><blockquote>“The remove method should remove leaf nodes from the tree.”</blockquote><p>If this test is failing and you don’t know why, it sure would be useful to see the testing data and the expected result. But you can’t access these anywhere inside the interface, so your debugging options are limited. You can look at the solution or give up and have a beer. I was already reaching for the bottle opener when I thought of the third, retrospectively super-obvious option:</p><blockquote>“FreeCodeCamp must be open-source! I can dig up the test cases somewhere on GitHub!”</blockquote><p>And sure enough, you can just go over to <a href="https://github.com/freeCodeCamp/freeCodeCamp/tree/main/curriculum/challenges/english">their repository</a> and view the source code for all the challenges in a <a href="https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/10-coding-interview-prep/data-structures/delete-a-node-with-two-children-in-a-binary-search-tree.md">human-readable markdown</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VfTEQMssi7gK-Bol48Km9w.png" /></figure><p>I also wanted to save myself the 5 seconds of digging through folder structure every time I want to debug a test. So I made a bookmarklet that opens the source code of the currently open challenge.</p><h3>Make a bookmarklet</h3><p><a href="https://www.freecodecamp.org/news/what-are-bookmarklets/">Bookmarklets</a> are browser bookmarks that run JavaScript instead of going to a page. To make a bookmarklet:</p><ol><li>Click “Add new bookmark” in your browser’s bookmark manager.</li><li>In the “URL” field, paste the JavaScript you want to run in the following format:</li></ol><pre>javascript: (() =&gt; {<br>  // Your code<br>})();</pre><p>Our script is very simple. We need to:</p><ul><li>Read the current URL and check that we are on FreeCodeCamp</li><li>Parse the curriculum, section, and challenge from the URL</li><li>Open a new tab with the corresponding markdown file on GitHub</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eecea8299a74a168ba827a5d483548a2/href">https://medium.com/media/eecea8299a74a168ba827a5d483548a2/href</a></iframe><p>If your bookmarklet is longer than a line, it’s a good idea to write it in a code editor. Then you can use a tool like <a href="https://caiorss.github.io/bookmarklet-maker/">Bookmarklet Maker</a> to wrap it inside a javascript: function call and escape any invalid characters. Here is the result, which you can take a turn into a bookmark:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a661e45f8ecc8527b409510be4ebea40/href">https://medium.com/media/a661e45f8ecc8527b409510be4ebea40/href</a></iframe><p>And that’s it! Test cases of any* FreeCodeCamp challenge are now always just one click away (instead of, like, five).</p><p>Of all the code I write, it’s silly things like these that spark the most joy sometimes ¯\_(ツ)_/¯</p><p><em>* Actually, a few challenges (irritatingly) split words in the URL differently than their markdown files. So you might rarely get a 404, but most of the time it works fine.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b06a0dc2c47" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Driving TypeScript Adoption With Automated Reports]]></title>
            <link>https://medium.com/better-programming/driving-typescript-adoption-with-automated-reports-dee725298302?source=rss-ac650b30cf52------2</link>
            <guid isPermaLink="false">https://medium.com/p/dee725298302</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Juro Uhlar]]></dc:creator>
            <pubDate>Sun, 09 Jan 2022 13:14:22 GMT</pubDate>
            <atom:updated>2022-01-21T08:02:41.566Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to prioritize cleaning up your codebase</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SNpUA355r1M8pV6G" /><figcaption>Photo by <a href="https://unsplash.com/@landall?utm_source=medium&amp;utm_medium=referral">lan deng</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>First, TypeScript is good. But that’s not what the article is about. It’s about what to do if the codebase at your job doesn’t have enough of it.</p><blockquote>“Do you use TypeScript in your React codebase?” I asked my future boss in a job interview.</blockquote><blockquote>“Yes.” was the answer.</blockquote><blockquote>“Great!”</blockquote><p>But alas, it was not great. I should have asked, “How [much] are you using TypeScript?”. TypeScript adoption is not a binary state, but a spectrum.</p><p>Like many older React projects, the codebase was being rewritten to TypeScript in a “write new stuff in TypeScript, fix old stuff when you have time” kind of way. But without a set goal and a measure of progress, the incentive is always on delivering new features rather than solving technical debt.</p><p>Several months after the switch, most of the code was still untyped, and progress was slow. We knew rewriting to TypeScript was valuable in the long run. But to justify spending development time on it, we wanted to track and visualize our progress.</p><h3><strong>Gamify the End Goal</strong></h3><ol><li>Explain to your decision-makers that enabling TypeScript everywhere will help you ship faster and sleep better.</li><li>Build them a progress bar to look at.</li></ol><p>That&#39;s it. <a href="https://dl.acm.org/doi/10.1145/317456.317459">Progress bars are magic</a>. They are stupidly simple, but they work. RPG players will grind for hours to get their Elder Paladin to Level 75 or whatever. Goal clarity drives motivation. People do things to see numbers go up. Developers will fix TypeScript errors for the same reason. You can buy them pizza for each big milestone.</p><p>Don’t get me wrong, developers are and should be intrinsically motivated to improve code quality. But then this happens:</p><blockquote>“Why is that task taking so long?” — PM</blockquote><blockquote>“Well, there was a lot of TypeScript to add and fix.” — Dev</blockquote><blockquote>“Uh, okay, sounds like an excuse, but whatever, can we focus on delivering customer value here, please?” — PM (in his head , probably)</blockquote><p>Maybe next time you leave the code just as messy as you found it to get ahead on your next task. Your work fixing technical debt is invisible and only gets in the way. Or the conversation can go like this:</p><blockquote>“Why is that task taking so long?” — PM</blockquote><blockquote>“Well, there was a lot of TypeScript to add and fix, so I fixed it. See the progress bar? We went from 54% to 60% TypeScript coverage this sprint. The closer we are to a 100, the more our long-term velocity as a team increases.” — Dev</blockquote><blockquote>“I see, good work.” — PM</blockquote><p>Your work is not invisible anymore. It moved the team towards an established goal <strong>by a specific amount</strong>. “What gets measured, gets done”<strong> </strong>applies well here.</p><h3>Measure the Right Thing</h3><p>Measuring TypeScript adaption depends on your flavor of not actually adopting TypeScript.</p><p>Maybe you have .js(x) and .ts(x) files living side by side. This is the cleanest alternative. You can count them up with a little bash magic:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb6a864346008badf483f54441dc103c/href">https://medium.com/media/eb6a864346008badf483f54441dc103c/href</a></iframe><p>In fact, both GitHub and GitLab display language statistics of your repositories automatically.</p><p>Maybe all your files are .ts but you typed everything as any. Best to use a tool that analyses your any usage and spits out a report:</p><ul><li><a href="https://github.com/plantain-00/type-coverage">type-coverage</a></li><li><a href="https://github.com/alexcanessa/typescript-coverage-report">typescript-coverage-report</a></li></ul><p>Maybe your situation is messy. Your files are .ts and contain some types, but most of them have @ts-nocheck flags right on top. Then you need to count the offending files:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed70b4f417b35950514a74d79a343a04/href">https://medium.com/media/ed70b4f417b35950514a74d79a343a04/href</a></iframe><p>You can do a similar thing for @ts-ignore. Whatever the problem is, you need to adjust your measurement accordingly.</p><h3>Build the Report</h3><p>Percentages are fine, but you really want a nice fat colorful progress bar. Red is bad, green is good. Crucially, it helps to see the progress in time, to see the green slowly defeating the red, inching its way toward victory. A time chart can help too.</p><p>Our report — smashed together during a one-day hackathon — looked like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8OCNXGBPa_E3dhRT8aei3Q.png" /></figure><p>We used a bash script to count the files and generate an HTML file with a table and a <a href="https://gionkunz.github.io/chartist-js/">Chartist.js</a> chart. But you can use anything.</p><h3>Automate the Report</h3><p>A progress bar is no good if no one looks at it. It’s important to put the numbers in front of people so they don’t have to dig for them. Remove as much friction as possible. In our case, that meant a weekly scheduled GitLab pipeline that:</p><ol><li>Runs the ts-report bash script on our repository and generates the report.</li><li>Uploads the report to <a href="https://docs.gitlab.com/ee/user/project/pages/#how-it-works">GitLab Pages</a>.</li><li><a href="https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook">Sends a message to a Teams channel</a> with the link to the report.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8c5a094ea0496cfc8bc9ff6f1092c2d/href">https://medium.com/media/e8c5a094ea0496cfc8bc9ff6f1092c2d/href</a></iframe><p>Then once a week, we get this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cr3Zi96YYAZwcAfJZ22z5A.png" /></figure><p>It would be better to put the report directly in the message, but this is fine for now. A Slack notification or an email works too. Pick whatever communication tool your team uses the most.</p><h3>Hold Yourself Accountable</h3><p>The last step is to share your progress. Our sprint reviews have a dedicated slide for updates on technical debt, so we talk about our TypeScript coverage there. The progress bar can be effective, even if only used internally within your team. But it’s much better to commit publicly to a goal and give stakeholders regular updates.</p><p>Since building the report, our TypeScript adoption speed has notably increased. (Other factors like new team members also helped.)</p><p>This time it was TypeScript coverage, but you can apply the same idea to different types of long-term technical debt:</p><p><em>Make invisible work not just visible but </em><strong><em>easy to see regularly</em></strong><em> — and it will get done faster.</em></p><p>Thank you for reading! Do you know a better way?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dee725298302" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/driving-typescript-adoption-with-automated-reports-dee725298302">Driving TypeScript Adoption With Automated Reports</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quick DevNotes: XSS vulnerabilities in React]]></title>
            <link>https://medium.com/@jurouhlar/quick-devnotes-xss-vulnerabilities-in-react-45d9f683a7d2?source=rss-ac650b30cf52------2</link>
            <guid isPermaLink="false">https://medium.com/p/45d9f683a7d2</guid>
            <category><![CDATA[xss-vulnerability]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[xss-attack]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Juro Uhlar]]></dc:creator>
            <pubDate>Tue, 28 Sep 2021 09:51:01 GMT</pubDate>
            <atom:updated>2021-09-28T09:51:01.541Z</atom:updated>
            <content:encoded><![CDATA[<p>There are a couple of dangerous methods you should know about when writing React/JavaScript code to prevent <a href="https://developer.mozilla.org/en-US/docs/Web/Security/Types_of_attacks#cross-site_scripting_xss">XSS (cross-site scripting) attacks.</a></p><p>In general, these are methods that <strong>inject their input as raw HTML </strong>into the page or <strong>evaluate their input as JavaScript</strong> code.</p><p>The most common ones are:</p><ul><li>dangerouslySetInnerHTML={{__html: &quot;userDefinedString&quot;}}</li><li>innerHTML=&quot;userDefinedString&quot;</li><li>&lt;a href=&quot;userDefinedString&quot;&gt;</li><li>location.href = &quot;userDefinedString&quot;</li><li>new Function(&quot;userDefinedString&quot;)</li><li>eval(&quot;userDefinedString&quot;)</li><li>user-defined props: &lt;div {...userDefinedPropsObject} /&gt;</li></ul><p>If <strong>the user</strong> defines the input of the method (for example, text coming from an &lt;input&gt; element), an attacker can inject and run their malicious code on the page.</p><p>If <strong>you</strong> control the input (it comes from your code or your API), the method is generally safe to use. But still:</p><ul><li>Consider if you can achieve the desired result without using the dangerous method.</li><li>If not, mark the method with a comment explaining why it is safe (if it’s not clear that the input can’t be user-generated). It should prevent your teammates from using your code in an unsafe way in the future without considering the security implications.</li></ul><p>A little playground for demonstration:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2F8rcj0&amp;display_name=CodeSandbox&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2F8rcj0&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/942317057455531296e45139f60b7172/href">https://medium.com/media/942317057455531296e45139f60b7172/href</a></iframe><p>Read more about XSS in React:</p><ul><li>StackOverflow: <a href="https://stackoverflow.com/questions/33644499/what-does-it-mean-when-they-say-react-is-xss-protected">What does it mean when they say React is XSS protected?</a></li><li><a href="https://medium.com/dailyjs/exploiting-script-injection-flaws-in-reactjs-883fb1fe36c1">Exploiting script injection flaws in ReactJS apps</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45d9f683a7d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>