<?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>Forem: Radharadhya Dasa</title>
    <description>The latest articles on Forem by Radharadhya Dasa (@rrd).</description>
    <link>https://forem.com/rrd</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%2F1597660%2F761da8ef-e898-4c13-925a-91f0ca9182cd.jpg</url>
      <title>Forem: Radharadhya Dasa</title>
      <link>https://forem.com/rrd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/rrd"/>
    <language>en</language>
    <item>
      <title>Taming the Mega-Component: My Vue.js Refactoring Adventure</title>
      <dc:creator>Radharadhya Dasa</dc:creator>
      <pubDate>Sat, 07 Sep 2024 16:48:24 +0000</pubDate>
      <link>https://forem.com/rrd/taming-the-mega-component-my-vuejs-refactoring-adventure-5a3</link>
      <guid>https://forem.com/rrd/taming-the-mega-component-my-vuejs-refactoring-adventure-5a3</guid>
      <description>&lt;p&gt;We’ve all been there: opening a codebase only to find a massive component, packed with hundreds of lines of code, where bugs seem to hide in every corner. Recently, I found myself staring down this exact challenge in a Vue.js project. A bug report had led me to this hulking component, and it became obvious—this beast needed taming.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq90ri8r4nm77bf4n8cob.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq90ri8r4nm77bf4n8cob.jpg" alt="Image description" width="600" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As it happens, I was the one who originally wrote this monstrosity, so there was no one to blame but myself.&lt;/p&gt;

&lt;p&gt;Although tools like the Vue mess detector provided some insights, the first step was a simple one: breaking the component into smaller, more manageable pieces. In this post, I’ll walk you through how I conquered this enormous component, and how the end result was a codebase that’s cleaner, more maintainable, and far easier to test.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Divide and Conquer
&lt;/h2&gt;

&lt;p&gt;The first task was to break the component into smaller, logical parts. I started by examining the template to identify distinct functionalities. I quickly found a few key candidates for extraction: a menu, a search form, a list display, and three tables that were nearly identical. These distinct elements would become separate, dedicated components.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Slicing Up the Script
&lt;/h2&gt;

&lt;p&gt;Once the template was divided, the next step was to do the same with the script. I extracted the logic related to each piece of the template and moved it into its own component file. This not only made the code easier to read but also set the stage for independent testing.&lt;/p&gt;

&lt;p&gt;During this process, I noticed some utility functions and a new composable that needed to be extracted. This refactoring pushed me to create reusable logic, which further enhanced the modularity and maintainability of the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Establishing Communication
&lt;/h2&gt;

&lt;p&gt;The next hurdle was to figure out how these new components would talk to each other. I had to carefully identify the props each sub-component needed and decide which actions should stay internal and which should be communicated back to the parent component. This balance helped keep each sub-component focused on its responsibilities while still ensuring smooth communication with the parent.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Syncing the Styles
&lt;/h2&gt;

&lt;p&gt;The refactor didn’t stop at logic; the styles had to be split as well. I moved the CSS previously bundled in the mega-component into the appropriate sub-components. This kept the styles close to the elements they were affecting, ensuring that everything stayed organized and localized.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Testing the Pieces
&lt;/h2&gt;

&lt;p&gt;Ensuring that everything still worked after the refactor was essential. As I pulled each sub-component out, I immediately wrote component tests and unit tests to verify that it behaved as expected. This "test-as-you-go" method gave me confidence that the refactoring wasn’t introducing new bugs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: Rinse and Repeat
&lt;/h2&gt;

&lt;p&gt;Once I found a rhythm, the process became almost mechanical—identify a section in the template, extract the script and logic, set up communication channels, move the styles, and write tests. With each iteration, the once-monolithic component transformed into a well-organized system of smaller, more manageable pieces.&lt;/p&gt;

&lt;h2&gt;
  
  
  Additional Thoughts
&lt;/h2&gt;

&lt;p&gt;In some cases, you might start by grouping similar elements into a single component. However, if differences between them start to complicate the logic, it might be worth splitting them further. For example, in my case, I initially created a single component for the three similar tables. But eventually, I realized that the slight differences (like one table having four columns while the others had five) justified splitting them into separate components to keep things clean and focused.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Results
&lt;/h2&gt;

&lt;p&gt;The refactor was a success. What was once an overwhelming, bug-prone component was now a collection of well-defined, well-tested sub-components. The original component was reduced to less than 400 lines, and I created six new sub-components, one composable, and one utility. The total lines of code is only a 100 lines smaller, but the clarity, maintainability, and testability improved dramatically.&lt;/p&gt;

&lt;p&gt;This experience reminded me of the importance of breaking down complex structures into smaller, more digestible pieces. Not only does this make the code easier to maintain, but it also sets the stage for better testing and future development.&lt;/p&gt;

&lt;p&gt;So, if you ever find yourself facing a Vue.js component that seems to have ballooned out of control, remember that with a thoughtful approach and some strategic refactoring, you can transform that monster into a clean, well-structured part of your application—one that’s a pleasure to work with.&lt;/p&gt;

</description>
      <category>vue</category>
      <category>nuxt</category>
      <category>refactoring</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Elevate Your Vue and Nuxt Code Quality with Vue Mess Detector</title>
      <dc:creator>Radharadhya Dasa</dc:creator>
      <pubDate>Sat, 24 Aug 2024 14:02:24 +0000</pubDate>
      <link>https://forem.com/rrd/elevate-your-vue-and-nuxt-code-quality-with-vue-mess-detector-4lm3</link>
      <guid>https://forem.com/rrd/elevate-your-vue-and-nuxt-code-quality-with-vue-mess-detector-4lm3</guid>
      <description>&lt;p&gt;Is code quality really that important? For computers, not so much—but for us, the developers, it absolutely is. Neglecting to maintain &lt;strong&gt;clean code&lt;/strong&gt; not only hampers our efficiency but also risks becoming a habit that could degrade project performance over time.&lt;/p&gt;

&lt;p&gt;Whether you're flying solo, working in a tight-knit team, or part of a larger organization, investing in code quality will pay dividends in the long run.&lt;/p&gt;

&lt;p&gt;Even though writing pristine code on the first go is tough, seasoned developers still sometimes create code that's less than perfect. They might notice the mess and leave a &lt;strong&gt;"TODO: clean this up later"&lt;/strong&gt; comment, but let’s be honest, that often ends up getting pushed to the bottom of the priority list.&lt;/p&gt;

&lt;p&gt;In reality, many of us jump into projects with extensive, existing codebases. And even if you’re the original author, it’s surprisingly easy to lose track of the finer details after a few weeks. That’s where a tool like &lt;a href="https://vue-mess-detector.webmania.cc/" rel="noopener noreferrer"&gt;Vue Mess Detector&lt;/a&gt; becomes invaluable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo42pu4wfo2y8h2c81t6c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo42pu4wfo2y8h2c81t6c.png" alt="Image description" width="800" height="576"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Vue Mess Detector Stands Out
&lt;/h2&gt;

&lt;p&gt;If &lt;strong&gt;Vue&lt;/strong&gt; or &lt;strong&gt;Nuxt&lt;/strong&gt; is your framework of choice, you’re already set up for success with their strong architecture. However, you can take it a step further by utilizing tools that enhance your coding practices.&lt;/p&gt;

&lt;p&gt;Vue Mess Detector is a &lt;strong&gt;static analysis&lt;/strong&gt; tool crafted specifically for Vue and Nuxt projects. It scans your code for potential issues—like code smells or best practice violations—and even provides suggestions on how to address them.&lt;/p&gt;

&lt;p&gt;As a static code analysis tool, Vue Mess Detector evaluates your code without executing it. It focuses on identifying patterns that could lead to problems down the road.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjs4oc7x3b3781pj5ty1q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjs4oc7x3b3781pj5ty1q.png" alt="Image description" width="606" height="130"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One of the most useful aspects of Vue Mess Detector is that it can assess the &lt;strong&gt;"health"&lt;/strong&gt; of your codebase. Whether you’re performing self-checks or assessing legacy code, this tool offers a snapshot of your code’s overall condition. It’s particularly handy for tracking improvements as you refactor, allowing you to see the tangible benefits of your efforts over time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why You Should Give It a Go
&lt;/h2&gt;

&lt;p&gt;Vue Mess Detector isn’t just another utility—it’s a stepping stone toward writing better code. If maintaining clean, scalable code is important to you, this tool is a must-try. It’s easy to set up, straightforward to use, and provides instant feedback on your code quality.&lt;/p&gt;

&lt;p&gt;Regardless of your experience level, Vue Mess Detector is designed to be helpful. Junior developers can use it to learn best practices, while more seasoned pros will appreciate its ability to spot tricky issues in complex codebases.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flr054ukuc6cu6wktnh73.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flr054ukuc6cu6wktnh73.png" alt="Image description" width="800" height="442"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Incorporating Vue Mess Detector into your routine helps you catch potential problems early on, before they escalate. Whether you’re refining your code or tackling a legacy system, this tool provides a clear path to improvement.&lt;/p&gt;

&lt;p&gt;Since Vue Mess Detector runs manually, it won’t &lt;strong&gt;disrupt your workflow&lt;/strong&gt;. You can decide when to analyze your code, allowing you to stay focused while you work and run checks when it's most convenient.&lt;/p&gt;

&lt;p&gt;So why not test it out? A quick scan with Vue Mess Detector might reveal insights that save you time and effort in the long run.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Get Started
&lt;/h2&gt;

&lt;p&gt;Getting Vue Mess Detector up and running is a breeze. Install it as a development dependency, then analyze your code with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx vue-mess-detector analyze src
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will scan your src directory (or another directory of your choosing) against &lt;strong&gt;over 30 different rules&lt;/strong&gt;. The results can be sorted by file or rule, with detailed explanations and links to the Vue Mess Detector &lt;a href="https://vue-mess-detector.webmania.cc/" rel="noopener noreferrer"&gt;documentation&lt;/a&gt; to help you fix any issues. The documentation is comprehensive, so you can dig deeper if you need more guidance.&lt;/p&gt;

&lt;p&gt;You can also customize the rulesets to focus on specific areas of your code, which is particularly useful if you're dealing with a large number of warnings. Start with the essential rules, and gradually work your way through the rest, such as the strongly recommended rules, and eventually to the more opinionated ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Contributing Matters
&lt;/h2&gt;

&lt;p&gt;Vue Mess Detector is powered by the community, and like most open-source projects, it thrives on contributions. Whether you can improve documentation, add new rules, or fine-tune existing ones, your contributions can make a significant impact.&lt;/p&gt;

&lt;p&gt;If Vue Mess Detector has been beneficial for you, consider giving back by contributing. It’s a great way to help fellow developers and sharpen your skills in the process. Plus, contributing to open-source projects is an excellent way to increase your visibility in the developer community. To make it easier for newcomers, we’ve labeled some issues as &lt;strong&gt;"good first issue"&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Clean code isn’t just about making your current project more manageable—it’s about cultivating a habit that will serve you throughout your career. Vue Mess Detector is a valuable tool that can assist you in achieving this goal within Vue and Nuxt projects. Try it out, observe how it enhances your codebase, and if possible, contribute to make it even better for everyone.&lt;/p&gt;

</description>
      <category>vue</category>
      <category>nuxt</category>
      <category>devtools</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Refactoring Nuxt Token Authentication Module to Use Nitro's Default db0 Layer</title>
      <dc:creator>Radharadhya Dasa</dc:creator>
      <pubDate>Sat, 29 Jun 2024 16:31:22 +0000</pubDate>
      <link>https://forem.com/rrd/refactoring-nuxt-token-authentication-module-to-use-nitros-default-db0-layer-18fd</link>
      <guid>https://forem.com/rrd/refactoring-nuxt-token-authentication-module-to-use-nitros-default-db0-layer-18fd</guid>
      <description>&lt;p&gt;Recently, I refactored my &lt;a href="https://github.com/rrd108/nuxt-token-authentication"&gt;Nuxt Token Authentication&lt;/a&gt; module to utilize Nitro's default &lt;code&gt;db0&lt;/code&gt; layer instead of Prisma. The transition was relatively smooth, though I encountered a few undocumented or not clearly documented aspects along the way. Here's a rundown of my experience to hopefully save you some time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Initial Struggle
&lt;/h2&gt;

&lt;p&gt;According to the Nitro documentation, you can use an object for the &lt;code&gt;database&lt;/code&gt; in the &lt;code&gt;nuxt.config.ts&lt;/code&gt; file. However, at the time of writing, this is not fully supported. Only a boolean value is accepted, which took some troubleshooting to uncover.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuration Example
&lt;/h3&gt;

&lt;p&gt;Instead of this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;defineNuxtConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;nitro&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;experimental&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;database&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sqlite&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="c1"&gt;// name: 'something', path: '/some/path'&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;defineNuxtConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;nitro&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;experimantal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;database&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="c1"&gt;// this is the correct setup currently&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Database Connection Issues
&lt;/h2&gt;

&lt;p&gt;I initially faced issues with my app not being able to communicate with the prepared database. The error messages were misleading, complaining about a missing &lt;code&gt;users&lt;/code&gt; table, what I already created. After some digging, I discovered that if the database does not exist at the default path &lt;code&gt;/.data/db.sqlite3&lt;/code&gt;, Nitro &lt;em&gt;silently&lt;/em&gt; creates it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error: SQLITE_ERROR: no such table: users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This error suggests a missing table, but the root cause was I tried to use a database in a non default path and name.&lt;/p&gt;

&lt;h2&gt;
  
  
  Auto-import Issues
&lt;/h2&gt;

&lt;p&gt;Another hiccup I encountered was with &lt;code&gt;useDatabase()&lt;/code&gt;. While it worked at runtime without issues, TypeScript could not find it, causing type errors. This auto-import problem can be a bit annoying during development.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// UseDatabase usage&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useDatabase&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TypeScript error: Cannot find name 'useDatabase'.ts(2304)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I did not found a solution yet to this problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Known Issue with Table Names and Fields
&lt;/h2&gt;

&lt;p&gt;A known issue with &lt;code&gt;db0&lt;/code&gt; is that table names and fields cannot be used without curly braces {}. This is tracked in &lt;a href="https://github.com/unjs/db0/issues/77"&gt;GitHub issue #77&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// incorrect, errors out&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;rows&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
      &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sql&lt;/span&gt;&lt;span class="s2"&gt;`SELECT * FROM &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;authTable&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; WHERE &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tokenField&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; = &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;strippedToken&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; LIMIT 1`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// correct&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;rows&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
      &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sql&lt;/span&gt;&lt;span class="s2"&gt;`SELECT * FROM {&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;authTable&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;} WHERE {&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tokenField&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;} = &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;strippedToken&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; LIMIT 1`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Switching to Nitro's &lt;code&gt;db0&lt;/code&gt; layer was a valuable learning experience. Despite the challenges with documentation and some minor bugs, the process was fairly straightforward. I hope sharing these insights can help other developers transition smoothly and avoid some of the pitfalls I encountered.&lt;/p&gt;

&lt;p&gt;Feel free to leave comments or ask questions if you run into any issues or have further tips to share!&lt;/p&gt;

&lt;p&gt;Let's slap into the code!&lt;/p&gt;

</description>
      <category>nuxt</category>
      <category>nitro</category>
    </item>
    <item>
      <title>Defending the Script Length Rule in vue-mess-detector</title>
      <dc:creator>Radharadhya Dasa</dc:creator>
      <pubDate>Mon, 10 Jun 2024 18:11:08 +0000</pubDate>
      <link>https://forem.com/rrd/defending-the-script-length-rule-in-vue-mess-detector-12hp</link>
      <guid>https://forem.com/rrd/defending-the-script-length-rule-in-vue-mess-detector-12hp</guid>
      <description>&lt;p&gt;Hey everyone,&lt;/p&gt;

&lt;p&gt;I've been receiving a lot of feedback on vue-mess-detector, particularly concerning the rule for script length. I understand this rule is a bit controversial, but I wanted to take a moment to explain why I believe it’s not just valid, but essential for writing maintainable code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Script Length Matters
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Readability&lt;/strong&gt;: Long scripts can be difficult to navigate. When scripts are too lengthy, it becomes harder to find specific pieces of code, understand their context, and figure out how different parts interact. Keeping scripts shorter enhances readability and makes life easier for developers, especially those who are new to the project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Maintainability&lt;/strong&gt;: A shorter script is easier to maintain. Changes are less likely to introduce bugs when the codebase is segmented into smaller, more manageable chunks. This is especially important for large projects where multiple developers might be working on different parts of the same file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Testing&lt;/strong&gt;: Smaller scripts are easier to test. When functions and components are more concise, unit tests can be more targeted and effective. This leads to more reliable code and a smoother development process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Separation of Concerns&lt;/strong&gt;: Enforcing a script length limit encourages developers to break their code into smaller, more focused modules. This aligns with the principle of separation of concerns, making the codebase more modular and reusable. For me &lt;em&gt;this&lt;/em&gt; is the main reason.&lt;/p&gt;

&lt;h2&gt;
  
  
  Addressing the Controversy
&lt;/h2&gt;

&lt;p&gt;I understand that some developers feel restricted by this rule. It can seem like an unnecessary limitation, especially when dealing with complex features that naturally require more lines of code. However, I believe that this rule pushes us to think critically about our code structure and encourages best practices in software development.&lt;/p&gt;

&lt;p&gt;Rather than viewing the script length rule as a constraint, I see it as a guideline that promotes better coding habits. It’s about finding the balance between flexibility and structure, ensuring that our projects remain clean, efficient, and easy to work with over time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;While the script length rule in vue-mess-detector might spark debate, I stand by its validity. It's a tool designed to foster maintainable and readable code, which ultimately benefits all developers involved in a project.&lt;/p&gt;

&lt;p&gt;I’m always open to feedback and discussions, so feel free to share your thoughts on this. Let's keep improving our code together!&lt;/p&gt;

&lt;p&gt;Slap into the code!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>vue</category>
    </item>
    <item>
      <title>vue mess detector</title>
      <dc:creator>Radharadhya Dasa</dc:creator>
      <pubDate>Sun, 09 Jun 2024 18:12:34 +0000</pubDate>
      <link>https://forem.com/rrd/vue-mess-detector-34cp</link>
      <guid>https://forem.com/rrd/vue-mess-detector-34cp</guid>
      <description>&lt;p&gt;I started to put together a static code analysis tool for detecting code smells and best practice violations in Vue.js and Nuxt.js projects.&lt;/p&gt;

&lt;p&gt;Vscode extension is coming soon.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/rrd108/vue-mess-detector"&gt;https://github.com/rrd108/vue-mess-detector&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vue</category>
      <category>nuxt</category>
    </item>
  </channel>
</rss>
