<?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 Marcin Skorek on Medium]]></title>
        <description><![CDATA[Stories by Marcin Skorek on Medium]]></description>
        <link>https://medium.com/@SkorekM?source=rss-cc1ca7435010------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Bp2pPUSAT2ei5sxOMnjBaw.jpeg</url>
            <title>Stories by Marcin Skorek on Medium</title>
            <link>https://medium.com/@SkorekM?source=rss-cc1ca7435010------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 05:39:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@SkorekM/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[From Theory to Automation: WCAG compliance using axe-core, next.js, and GitHub actions]]></title>
            <link>https://medium.com/@SkorekM/from-theory-to-automation-wcag-compliance-using-axe-core-next-js-and-github-actions-b9f63af8e155?source=rss-cc1ca7435010------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9f63af8e155</guid>
            <category><![CDATA[wcag]]></category>
            <category><![CDATA[a11y]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[github-actions]]></category>
            <dc:creator><![CDATA[Marcin Skorek]]></dc:creator>
            <pubDate>Mon, 07 Apr 2025 04:55:38 GMT</pubDate>
            <atom:updated>2025-04-07T04:55:38.493Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*erY8GAqehIvm7dzj" /><figcaption>Photo by <a href="https://unsplash.com/@goian?utm_source=medium&amp;utm_medium=referral">Ian Schneider</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction: Why Accessibility Matters</h3><p>Accessibility in web development is not just a nice-to-have, it should be a must-have. Whether it’s a personal blog or an extensive application, making sure that the site is accessible means creating and caring for the inclusive experience for all users.</p><p>Some time ago, I launched my website. I treat it as a playground for different integrations and as a side project that is also a home for my articles (<a href="https://www.skorekm.dev/">skorekm.dev</a> if you are interested). One Friday evening, I thought: “Let’s hook up some accessibility checks into my website.”. Naturally, I dove back into my <a href="https://medium.com/@SkorekM/guide-to-building-accessible-web-applications-35ee5afd313f">old article</a> about the WCAG, did more digging on the subject, and realized something. The practical guides, especially for newer versions of React (<strong>axe-core/react</strong> does not support React 18+) or automating the accessibility testing, are hard to find.</p><p>That’s what this article is all about. We are shifting from theory and outdated guides toward automation. We’ll explore how to automate the accessibility testing using axe-core library, GitHub Actions, and Next.js.</p><h3>Why axe-core? Choosing the right tool for the job</h3><p>When I decided to integrate accessibility checks into my website, I went down the rabbit hole of testing. From my previous research about the WCAG, I already knew about tools such as Pa11y, Lighthouse, and, of course, axe-core. The latter stood out the most for a number of reasons:</p><p><strong>Company backing</strong> — Deque, the company backing axe-core is known for its presence in the accessibility field.</p><p><strong>Effect</strong> — during my tests, axe-core consistently found more errors. I know it’s not always the benchmark, but in that case, those were meaningful, adequate tests.</p><p><strong>Lighthouse</strong> — While doing the research, I checked how Lighthouse is built, and they do, in fact, have the axe core in their <strong>package.json</strong> file. That’s some big endorsement for the library, if you ask me.</p><p>With that being said, Pa11y and Lighthouse are also great options. Lighthouse even has the check actions in their documentation. So if you feel like that’s a better choice, you can go ahead and use theirs to plug into your CI. My inner nerd just wanted to poke around with axe core. Me likey some challenge.</p><h3>Automation, my good old friend</h3><p>Automation can be a lifesaver (or production saver) if set up correctly.<br>In terms of my accessibility checks, the idea is pretty simple: Whenever I create the pull request to mydevelop or master branch, I want the GitHub Actions to run the accessibility checks. How to do that? Well, here’s a rough idea I had in mind when starting:</p><ul><li>Generate the sitemap for the available pages,</li><li>Parse the XML file with sitemaps to a list of strings,</li><li>Run accessibility checks on each URL</li></ul><h4>Sitemaps: The Guide That Knows It All</h4><p>A sitemap is essentially a list of all the pages on your website. It’s usually used by search engines to index your website. For accessibility testing, it’s a good idea, as sitemaps provide a reliable source of truth for all the pages.</p><p>In the next.js apps, it may be like looking for a needle in a haystack. Pages may be scattered all around, and some of them might be dynamic. A sitemap allows us to make sure that no page is left behind untested.</p><h3>Step-by-step implementation</h3><p>Okay, so buckle up. It’s time for the ride of code walkthroughs.</p><h4>Generating the sitemap</h4><pre>// src/app/sitemap.ts<br>export default function sitemap() {<br>  const baseUrl = process.env.NEXT_PUBLIC_BASE_URL;<br>  const postsSlugs = getPostsSlugs();  // Gets all my blog posts<br><br>  const postsUrls = postsSlugs.map((post) =&gt; (<br>    {<br>      url: `${baseUrl}/blog/${post}`,<br>      lastModified,<br>    }<br>  ));<br><br>  return [<br>    { url: `${baseUrl}/` },        // Home page<br>    { url: `${baseUrl}/about` },   // About page<br>    ...postsUrls,                  // Posts urls<br>  ]<br>}</pre><h4>Parsing the sitemap</h4><p>After the application is built, what is orchestrated in the workflow, I know the output will be in the XML format. Here’s the script I have written to get the sitemap file and parse URLs. It then saves it in the .txt file, and the final script iterates over it.</p><p>Side note: This step is opinionated, and it can be approached in a myriad of different ways.</p><pre>// ops/extract-sitemap-url.js<br>import fs from &#39;fs&#39;;<br>import path from &#39;path&#39;;<br><br>// After build, sitemap is in the .next directory<br>const sitemapPath = path.resolve(<br>  import.meta.dirname,<br>  &#39;../.next/server/app/sitemap.xml.body&#39;<br>);<br><br>try {<br>  // Make sure sitemap exists<br>  if (!fs.existsSync(sitemapPath)) {<br>    console.error(`Sitemap file not found at: ${sitemapPath}`);<br>    process.exit(1);<br>  }<br><br>  // Read and parse the sitemap<br>  const sitemapContent = fs.readFileSync(sitemapPath, &#39;utf8&#39;);<br>  const urlRegex = /&lt;loc&gt;(.*?)&lt;\/loc&gt;/g;<br>  const matches = [...sitemapContent.matchAll(urlRegex)];<br>  <br>  const urls = matches.map(match =&gt; match[1]);<br>  <br>  if (urls.length === 0) {<br>    console.warn(&#39;No URLs found in the sitemap.xml file.&#39;);<br>    process.exit(1);<br>  }<br>  <br>  // Convert URLs to paths for testing<br>  const paths = urls.map(url =&gt; {<br>    try {<br>      // Ensure proper URL parsing<br>      let processableUrl = url;<br>      if (!url.startsWith(&#39;http&#39;)) {<br>        processableUrl = &#39;http://&#39; + url;<br>      }<br>      const urlObj = new URL(processableUrl);<br>      return urlObj.pathname;<br>    } catch (err) {<br>      return url.startsWith(&#39;/&#39;) ? url : `/${url}`;<br>    }<br>  });<br>  <br>  // Save paths for the testing script<br>  const outputPath = path.resolve(process.cwd(), &#39;./ops/urls.txt&#39;);<br>  fs.writeFileSync(outputPath, paths.join(&#39;\n&#39;));<br>  <br>  console.log(`Found ${paths.length} URLs to test:`);<br>  paths.forEach(path =&gt; console.log(`  ${path}`));<br>} catch (error) {<br>  console.error(&#39;Error processing sitemap:&#39;, error);<br>  process.exit(1);<br>}</pre><h4>The accessibility test runner</h4><p>Now that we do have the URLs parsed, it’s time to run the axe-core against all of our paths. This is the final script that tests all the URLs and throws an error if accessibility issues are found.</p><pre>// ops/run-a11y-tests.js<br>import fs from &#39;fs&#39;;<br>import { execSync } from &#39;child_process&#39;;<br><br>try {<br>  // Read the URLs we found earlier<br>  const urls = fs.readFileSync(&#39;./ops/urls.txt&#39;, &#39;utf8&#39;)<br>    .split(&#39;\n&#39;)<br>    .filter(path =&gt; path.trim() !== &#39;&#39;);<br><br>  // we&#39;ll need it in the end<br>  let hasFailures = false;<br><br>  // Test each URL<br>  for (const url of urls) {    <br>    console.log(&#39;====================================================&#39;);<br>    console.log(`Testing: ${url}`);<br>    console.log(&#39;====================================================&#39;);<br>    <br>    try {<br>      // Run axe-core accessibility tests<br>      execSync(`axe &quot;${url}&quot; --exit`, { stdio: &#39;inherit&#39; });<br>    } catch (error) {<br>      console.log(&#39;Accessibility issues found on this page&#39;);<br>      hasFailures = true;<br>    }<br>  }<br><br>  // Final report<br>  console.log(&#39;====================================================&#39;);<br>  console.log(&#39;Accessibility testing complete.&#39;);<br>  console.log(&#39;====================================================&#39;);<br><br>  // Exit with error if we found any issues<br>  process.exit(hasFailures ? 1 : 0);<br>} catch (error) {<br>  console.error(&#39;Error during accessibility testing:&#39;, error);<br>  process.exit(1);<br>}</pre><h4>The workflow</h4><p>Lastly, it’s time to orchestrate all of those scripts around. I am not going to dive into too much detail on how the workflows work, but rather the main idea of how it’s set up. Firstly, we prepare the environment, then build the application (so that next.js build the sitemap file), we extract URLs, run the next.js app (so that the URLs are accessible by the axe-core), and lastly run accessibility tests.</p><pre>name: Accessibility Tests<br>on:<br>  push:<br>    branches: [main, develop]<br>  pull_request:<br>    branches: [main, develop]<br>  workflow_dispatch:<br><br>jobs:<br>  axe:<br>    name: Axe Accessibility Tests<br>    runs-on: ubuntu-22.04  # Using a specific version for consistency<br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v4<br><br>      - name: Setup Node.js<br>        uses: actions/setup-node@v4<br>        with:<br>          node-version: &#39;22&#39;<br>          cache: &#39;npm&#39;  # Built-in npm caching<br>      <br>      # Smart caching for faster builds<br>      - name: Cache Next.js build<br>        uses: actions/cache@v4<br>        with:<br>          path: ${{ github.workspace }}/.next/cache<br>          key: |<br>            ${{ runner.os }}-nextjs-v1-${{ <br>              hashFiles(&#39;**/package-lock.json&#39;) <br>            }}-${{ <br>              hashFiles(&#39;next.config.js&#39;) <br>            }}<br>          restore-keys: |<br>            ${{ runner.os }}-nextjs-v1-${{ <br>              hashFiles(&#39;**/package-lock.json&#39;) <br>            }}<br>            ${{ runner.os }}-nextjs-v1-<br><br>      - name: Install dependencies<br>        run: npm ci<br><br>      - name: Install axe-core CLI<br>        run: |<br>          npm install -g @axe-core/cli<br>          npx browser-driver-manager install chrome<br><br>      - name: Build Next.js app<br>        run: npm run build<br>        env:<br>          NEXT_PUBLIC_BASE_URL: http://localhost:3000<br><br>      - name: Extract sitemap URL<br>        run: node ops/extract-sitemap-url.js<br><br>      - name: Start Next.js app<br>        run: npm run start &amp;<br>        timeout-minutes: 2  # Prevents hanging builds<br><br>      - name: Run accessibility tests<br>        run: |<br>          echo &quot;Running accessibility tests...&quot;<br>          node ops/run-a11y-tests.js<br>          echo &quot;Accessibility tests finished.&quot;</pre><p>So this is it. That’s how I approached setting everything up. There are some improvements I could make, but I believe it can serve as a good base. Feel free to take whatever pieces may fit your workflow.</p><h4>Additional Tooling (Optional):</h4><p><strong>Linting with a11y<br></strong>Think of it as an extension to what we are doing here with the CI checks and, overall the axe core. The plugin does the static analysis of your JSX and can catch accessibility issues right in the code editor before committing the changes. Duh, you can even configure your workflow so it does not allow you to commit the code if those errors are caught (that’s a topic for another article).</p><p><a href="https://github.com/jsx-eslint/eslint-plugin-jsx-a11y">eslint-</a><a href="https://github.com/jsx-eslint/eslint-plugin-jsx-a11y">plugin</a>-<a href="https://github.com/jsx-eslint/eslint-plugin-jsx-a11y">jsx-a11y</a></p><p><strong>DevTools Axe<br></strong>Dequeue, the company behind the Axe, has built some awesome dev tools for accessibility testing. The tool is very useful, and I highly encourage you to check it out.</p><p><a href="https://www.deque.com/axe/devtools/">DevTools</a></p><h4>Sustaining accessibility beyond automation</h4><p>It’s important to note that automation is powerful, but it’s not a silver bullet. It works like a charm at catching issues like missing alt text or improper heading structures, but they are no replacement for people.</p><p>Automation tools will not tell you whether the alt text makes sense in the given context. So, while our digital assistants are helpful, we still need human insight to catch issues.</p><p>Lastly, accessibility is not about running tests and making sure that the tool does not fail the build. It’s about fostering inclusive mindsets throughout the development process. It’s easier to think about whether the color contrast is sufficient. We can prevent the issues rather than fix them later.</p><h4>Wrapping up</h4><p>This research and article were not planned at all. I just had a random thought along the lines of “Hey, let’s plug accessibility tools into my website”. Then, the inner nerd took over, and instead of taking the easy route, I made myself another cup of coffee and dug in. I hope that this comes useful, either by the idea of how I approached the problem, or overall solution. Nevertheless, before diving head first into automation, remember that accessibility is not just a checkbox.</p><p>In the meantime, thanks for reading, and till next time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9f63af8e155" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handling Asynchronous JavaScript: From callbacks to async/await]]></title>
            <link>https://medium.com/@SkorekM/handling-asynchronous-javascript-from-callbacks-to-async-await-a1fc6ad60d81?source=rss-cc1ca7435010------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1fc6ad60d81</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Marcin Skorek]]></dc:creator>
            <pubDate>Fri, 21 Mar 2025 07:15:26 GMT</pubDate>
            <atom:updated>2025-03-21T07:15:26.512Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1L9eXz_bmO_EXkCD" /><figcaption>Photo by <a href="https://unsplash.com/@glenncarstenspeters?utm_source=medium&amp;utm_medium=referral">Glenn Carstens-Peters</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Have you ever found yourself cooking dinner after a brutal day? Nope, not the Instagram-ready, can’t-eat-before-you-take-a-photo kind of meal. I’m talking about the “I am very hungry. I need food right now” kind.</p><p>Imagine this: you put the pot to boil and move to the cutting board, which is full of veggies that need chopping. You notice that the chicken breast sizzling in the pan is one step away from turning into charcoal.</p><p>This is similar to what JavaScript tries to do with asynchronous actions. It manages several tasks in the background while keeping the main thread free to take on a new task.</p><h3>How does JavaScript manage all of the tasks?</h3><p>JavaScript is single-threaded. It means that it can do only one thing at a time. But here’s the thing, it doesn’t just stop to process the task before it moves to another. If it were, web apps would be… annoyingly blocked most of the time. Gladly, it uses something called event-loop. I am not going to dive deep into how the event loop works, but think of it as a well-organized waiter in a fancy restaurant. They take your order (task), pass it to the kitchen (background work), and move on to serve another table.</p><h4>Callbacks</h4><p>This is the original way to manage asynchronous actions in JavaScript. A callback is just a function that is passed as an argument to another function to be executed later. Imagine we would like to check if we have the “Defence Against the Dark Arts” class today<strong>.</strong> Let’s be real — it’s one of the best classes.</p><pre>getWizard((wizard) =&gt; {<br>  getAcademicCalendar(wizard.id, (calendar) =&gt; {<br>    checkForDarkArtsClass(calendar);<br>  });<br>});</pre><p>Callbacks got dunked on really hard for what we call callback hell. This infamous phrase describes a situation when we pass a function&#39;s result to another function... and another function, and so on. Keep in mind though, it does not mean that callbacks are bad. Just try to avoid the callback hell, okay?</p><h4>Promises to the rescue</h4><p>Promises entered the scene to prevent the callback hell. A Promise represents the value that will be available in the future. It might either be resolved (success) or rejected (failure). With Promises, you can chain actions using .then() or .catch(), which eliminates the callback hell. The same example looks like this:</p><pre>getWizard()<br>  .then((wizard) =&gt; getAcademicCalendar(wizard.id))<br>  .then((calendar) =&gt; checkForDarkArtsClass(calendar))<br>  .catch((error) =&gt; console.log(&#39;handle me instead of logging...&#39;, error))</pre><p><strong>Good to know: </strong>The Promises cannot be canceled. Once it is created, it’s either resolved or rejected. No takesies backsies. However, we can use the AbortController to well.. abort the operation that Promise represents (like fetch), but not the Promise itself. Think of it as hanging up while talking to someone. The call (operation) breaks, but the phone (Promise) still exists, it just knows the call ended.</p><h4>Async/Await: Syntactic Sugar for Promises</h4><p>Okay, so Promises is not the only step up from the callbacks. We also have the async await, which is Promises in a tuxedo. It allows you to write your asynchronous code, which looks a lot like synchronous.</p><pre>async function fetchData() {<br>  try {<br>    const wizard = await getWizard();<br>    const calendar = await getAcademicCalendar(wizard.id);<br>    const isDarkArtsClass = await checkForDarkArtsClass(calendar);<br>  } catch (error) {<br>    console.log(&#39;Handle me instead of logging...&#39;, error);<br>  }<br>}</pre><p>This pattern goes hand in hand with the try catch blocks. It makes handling errors feel more natural. Overall, it’s opinionated - some people love it, some people hate it. Personally, I think it helps with readability, but it’s definitely not a magic fix for everything. The biggest downside? It’s easy to fall into the trap of awaiting every single action, which is like baking cookies… but instead of using a full tray, you’re putting one cookie in the oven at a time. Not exactly efficient.</p><h3>Common challenges</h3><p>Okay, it’s cool that we went through a bit of history and how handling asynchronous actions evolved over the years. But for now, it’s like integrals in math. Cool to know, but not really useful in life.</p><h4>When order matters</h4><p>We sort of already presented how this works, but let’s actually stick to the real-life scenario where this might come in handy. Let’s imagine the user signup flow:</p><pre>async function userSignUp(email, password) {  <br>  try {  <br>    // Check if email exists<br>    const emailExists = await checkEmailInDatabase(email);  <br>    if (emailExists) {<br>      throw new Error(&quot;Email already registered&quot;);<br>    };<br><br>    // Email is unique, let&#39;s create a user<br>    const user = await createUser(email, password);  <br><br>    // Send the welcome email, we don&#39;t need to await it<br>    await sendWelcomeEmail(user.id);<br><br>    return user;<br>  } catch (error) {<br>    console.log(&#39;Handle me instead of logging!&#39;, error);<br>  }  <br>}  </pre><p>This flow makes sense as those tasks need to happen in a particular order. Notice that not all of the tasks need to necessarily be awaited. Sending the welcome email might not be critical to finishing the signup process.</p><h4>Parallel Execution: Multiple Chefs in the Kitchen</h4><p>Sometimes, you might want to run some calls simultaneously. Just like multiple chefs working on different dishes all at once. This might be useful in a number of scenarios. Let’s imagine we would like to fetch some data for the dashboard:</p><pre>async function fetchDashboardData(userId) {  <br>  try {  <br>    // Fetch all independent data at once  <br>    const [notifications, activity, latestPosts] = await Promise.all([<br>      fetchNotifications(userId),<br>      fetchActivity(userId),<br>      fetchLatestPosts(userId),<br>    ]);  <br><br>    return {<br>      notifications,<br>      activity,<br>      latestPosts,<br>    };<br>  } catch (error) {<br>    console.log(&#39;Still logging errors, huh...&#39;, error);<br>  }  <br>} </pre><p>Using Promise.all speeds things up, but there’s a catch. Do you know what happens if one promise fails? All of them fail. Sometimes it’s exactly what you need, your choice. Or break the production, up to you.</p><p>Okay, let’s assume we are good to display the available data even if one promise fails (it’s almost always good to display it). Let’s use Promise.allSettled to get more resilience:</p><pre>export async function fetchDashboardData(userId) {<br>  try {<br>    const results = await Promise.allSettled([<br>      fetchNotifications(userId),<br>      fetchActivity(userId),<br>      fetchLatestPosts(userId),<br>    ]);<br><br>    const [notifications, activity, latestPosts] = results.map(result =&gt; <br>      result.status === &#39;fulfilled&#39; ? result.value : []<br>    );<br><br>    return {<br>      notifications,<br>      activity,<br>      latestPosts,<br>    };<br>  } catch (error) {<br>    console.log(&#39;Nope, still not handling errors&#39;, error);<br>  }<br>}</pre><p>This way, even if one API call decides to take a last-minute sick day, you will still get whatever data is available.</p><h4>Asynchronous Iteration</h4><p>Have you ever needed to process data from an asynchronous source? I did when I needed to generate some PDFs. Anyway, meet generators:</p><pre>async function* fetchTransactions(ids) {<br>  for (const id of ids) {<br>    yield fetchTransactionById(id); // fetch function<br>  }<br>}<br><br>async function generateTransactionReport(pdfDoc, transactionIds) {<br>  try {<br>    for await (const transaction of fetchTransactions(transactionIds)) {<br>      pdfDoc.addTransaction(transaction);<br>    }<br>  } catch (error) {<br>    console.error(&#39;Error generating report:&#39;, error);<br>  }<br>}</pre><p>This approach is perfect for scenarios where you don’t want to wait for all data upfront.</p><h4>Handling API Limits: The Cost of Parallelism (Don’t Be Greedy!)</h4><p>Ever hit a “429 Too Many Requests” error? That happens when the client floods the API with requests. If you ever come across this, try batching your calls:</p><pre>async function createUsersAndSendEmails(users, batchSize = 5) {<br>  const results = [];<br>  <br>  // Process users<br>  for (let i = 0; i &lt; users.length; i += batchSize) {<br>    const batch = users.slice(i, i + batchSize);<br>    <br>    // using Promise.allSettled process the batch<br>    const batchResults = await Promise.allSettled(<br>      batch.map(async (userData) =&gt; {<br>        try {<br>          // Create a new user<br>          const newUser = await createUser(userData);<br>          // Send a welcome email<br>          await sendWelcomeEmail(newUser.email);<br>        } catch (error) {<br>          // Log the error and return a standardized error object<br>          console.log(&#39;This logging needs to stop...&#39;, error);<br>        }<br>      })<br>    );<br>    <br>    results.push(...batchResults);<br>  }<br>  <br>  return results;<br>}</pre><p>This prevents overwhelming the server. In your implementation, you might also want to consider retry mechanisms. Nevertheless, batching is like pacing yourself at the all-you-can-eat buffet.</p><h3>Wrapping up</h3><p>Handling asynchronous operations has already been a long road. It all started with callbacks, and then Promises stepped into the game. Async Await is another chapter. Among all of them, it’s important to know that each method has its trade-offs. The key takeaway should be that there is not one fit-it-all solution. Whether the task needs to be written sequentially or in parallel, understanding those patterns and deciding when to use them is crucial.</p><p>Anyway, that’s it. Thanks for reading, and happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1fc6ad60d81" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Type coercion in JavaScript: That one quirky friend you never knew you had]]></title>
            <link>https://medium.com/@SkorekM/type-coercion-in-javascript-that-one-quirky-friend-you-never-knew-you-had-f1b2c00c3905?source=rss-cc1ca7435010------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1b2c00c3905</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[fundamentals]]></category>
            <dc:creator><![CDATA[Marcin Skorek]]></dc:creator>
            <pubDate>Thu, 27 Feb 2025 06:56:06 GMT</pubDate>
            <atom:updated>2025-03-02T08:37:49.059Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h9gNTcBhlJmzz3mE" /><figcaption>Photo by <a href="https://unsplash.com/@ar1991?utm_source=medium&amp;utm_medium=referral">Ayesh Rathnayake</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Picture this: it&#39;s Friday afternoon, and I am hunched over my laptop making a production release (because that&#39;s when it&#39;s supposed to happen, duh). I can almost taste the weekend — a cozy evening binging my favorite TV show. My code? Flawless. Or so I thought. But there it is, JavaScript starting a party I was not invited to:</p><pre>const myAge = &quot;28&quot;;<br>const currentYear = &quot;2025&quot;;<br>const iWannaRetireAt = 50;<br>const expectedRetirementYear = currentYear + (iWannaRetireAt - myAge);  <br>console.log(expectedRetirementYear); // &quot;202522&quot; !?  </pre><p>My face goes stone cold, and my only thought is<strong>, </strong>&quot;You serious!?&quot; (I wanna retire at 50. Leave me alone).</p><p>If this sounds familiar, this article might be for you. Well, not the production release on a Friday bit. We all know it&#39;s forbidden. I meant the super realistic coercion example, which was definitely not made up for the purpose of the introduction. So, as you might have already guessed, we will dive into the secret sauce of JavaScript that made a lot of memes across the internet — Type coercion.</p><h3>JavaScript: Misunderstood Genius or Mad Scientist?</h3><p>JavaScript type coercion is its way of transforming values from one type to another. Sometimes it&#39;s helpful. Sometimes, it makes you question your life choices. But understanding it can save you hours of debugging.</p><p>There are two main types: <strong>implicit</strong> coercion, where JavaScript does the magic for you, and <strong>explicit</strong> coercion, where you take the reins.</p><p>Okay, let&#39;s break this down.</p><h4>Implicit Coercion</h4><p>It&#39;s JS&#39;s way of saying, &quot;Don&#39;t worry, my friend. I have your back.&quot; It&#39;s with you for better or worse. It happens in arithmetic operations, logical contexts, and comparisons. Let&#39;s explore some examples.</p><p><strong>Arithmetic Operations</strong></p><p>Have you ever wondered why &quot;5&quot; + 2 gives 52 ? Well, I am gonna spill the tea: in the early days, devs concatenated text more often than they did math. Therefore, + became a dual-purpose operator, and it can perform string concatenation and arithmetic additions.</p><p>Okay, in such a case, why does — act normal? Because subtraction makes sense with numbers, not strings.</p><pre>&quot;5&quot; - 2;   // 3 (string → number)  <br>&quot;5&quot; + 2;   // &quot;52&quot; (number → string)<br>[] + 5;    // &quot;5&quot; (array → string)</pre><p><strong>Logical Contexts</strong></p><p>In logical contexts, values become true or false. For instance, a non-empty string equals to true, while 0 is false. But what about &quot;0&quot;? Yep, it&#39;s true too!</p><pre>if (&quot;hello&quot;) { /* runs */ }  // non-empty string =&gt; truthy <br>if (0) { /* does not run */ }     // 0 =&gt; falsy<br>if (&quot;0&quot;) { /* runs! */ } // &quot;0&quot; is a string, party time!</pre><p><strong>Loose Equality (</strong><strong>==)</strong></p><p>If the values have different types, JavaScript attempts to mediate by converting them to a common type before making the comparison. To be more precise, it tries to cast the values into a number.</p><pre>&quot;5&quot; == 5;       // true (string =&gt; number)<br>[] == 0;        // true (array =&gt; &quot;&quot; =&gt; 0)<br>&quot;0&quot; == false;   // true (&quot;0&quot; =&gt; 0, false =&gt; 0)</pre><p>Extra note about null and undefined, they are equal, let&#39;s leave it like that.</p><pre>null == undefined; // true (this one is special case)</pre><h4>Objects: Let&#39;s party!</h4><p>When comparing objects to other values, JavaScript does not throw the towel but tries actually to figure this out. It goes through this routine:</p><ul><li>It tries calling this particular method on the object valueOf() . This essentially asks, &quot;Hey, what&#39;s your value?&quot;. If it returns a primitive (number, string, etc.), calm — all great.</li><li>Although, if valueOf() does not return a primitive (or a method does not exist), JavaScript tries a toString() method. It&#39;s a plan B called &quot;Got it, how about you tell me what you look like as a string?&quot;</li><li>But what happens if neither works? Well, the comparison fails.</li></ul><p>Let&#39;s see some examples:</p><pre>const coolWord = {<br>  value: &quot;Bazinga&quot;,<br>  toString() {<br>    return this.value;<br>  }<br>};<br><br>console.log(coolWord == &quot;Bazinga&quot;); // true</pre><pre>const someCounter = {<br>  count: 2020,<br>  valueOf() {<br>    return this.count;<br>  }<br>};<br><br>console.log(someCounter == 2020); // true</pre><p>So, what happens when the object does not have those methods? Well, JavaScript cannot parse it to primitive, so it&#39;s always false.</p><pre>const someObject = {};<br>console.log(someObject.toString()) // &quot;[object Object]&quot;<br>console.log(someObject.valueOf()) // {}<br>console.log(someObject == &#39;something&#39;) // false</pre><p>And what about arrays? They are objects under the hood, so the above rules apply. Quick examples:</p><pre>console.log([1, 2, 3] == &quot;1,2,3&quot;); // true [1, 2, 3].toString() =&gt; &quot;1,2,3&quot;<br>console.log([42] == 42); // true [42].toString() =&gt; &quot;42&quot; =&gt; 42<br>console.log([] == 0); // true [].toString() =&gt; &quot;&quot; =&gt; 0</pre><h4>Explicit Coercion</h4><p>Now that you have seen how JavaScript attempts to be helpful (like that one friend who swears they know a shortcut), let&#39;s talk about explicit coercion—when you grab the wheel and say, &quot;Alright, I got this.&quot;. You can convert types using functions like Number(), String(), and Boolean(). Check this out.</p><p>Converting to a number? Easy peasy.</p><pre>console.log(Number(&quot;120&quot;)); // 120<br>console.log(parseInt(&quot;120px&quot;)); // 120 - ignores characters in the end<br>console.log(parseFloat(&quot;3.14someText&quot;)); // 3.14 - as above</pre><p>Converting to a string? I got you!</p><pre>console.log(String(22)) // &quot;22&quot;</pre><p>Would you like to convert it to a boolean? Be my guest!</p><pre>console.log(Boolean(1)); // true<br>console.log(Boolean(0)); // false<br>console.log(Boolean(&quot;Bazinga!&quot;)); // true<br>console.log(Boolean(&quot;&quot;)); // false</pre><p>There&#39;s also this thing called <strong>bang</strong> (!), which is shorthand for converting to a boolean. You can use <strong>double bang</strong> (!!) as well.</p><pre>console.log(!&quot;Bazinga!&quot;); // false - A bang sign<br>console.log(!!&quot;Bazinga!&quot;); // true - Double bang</pre><h3>NaN: The quirkiest of them all</h3><p>So, what happens when JavaScript can&#39;t convert a string to a number? Well, it shows the &quot;I give up&quot; flag. So, NaN stands for &quot;not a number&quot;. The irony? NaN is actually a number type. And here&#39;s a fun fact: NaN == NaN is false, because each NaN is unique.</p><p>Remember the example with parseInt and parseFloat ? I have mentioned that it removes non-numeric characters from the end. What happens when you try to coerce a value that indeed has numbers but starts with a string? It becomes NaN . Let&#39;s go through the examples:</p><pre>console.log(typeof NaN); // &quot;number&quot; (yeah... no comment)<br>console.log(NaN === NaN); // false (they are all snowflakes, unique)<br>console.log(Number(&quot;Bazinga!&quot;)); // NaN<br>console.log(parseFloat(&quot;Bazinga123&quot;)); // NaN<br>console.log(parseInt(&quot;Bazinga123&quot;)); // NaN</pre><h3>Love it or hate it, JavaScript coercion stays</h3><p>Okay, here it is — JavaScript&#39;s type coercion in all its quirky glory. Sure, it can be confusing. Annoying? Of course. Fascinating? Duh.</p><p>Also, let&#39;s not forget about some of the weirdly useful things we get. Who did not create a conditional using if(str.length &gt; 0) ? Exactly…</p><p>So, next time JavaScript surprises you with NaN or anything weird, take a breath. Pour yourself a glass of water, and remember: coercion is not out there to get you. It&#39;s just trying to be its weird self.</p><p>Also, a pro tip: Use === unless you enjoy existential crises.</p><p>Till the next time, thanks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1b2c00c3905" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Project Structure: Approach for Clean, Scalable Code]]></title>
            <link>https://medium.com/@SkorekM/react-project-structure-approach-for-clean-scalable-code-05622d5059ae?source=rss-cc1ca7435010------2</link>
            <guid isPermaLink="false">https://medium.com/p/05622d5059ae</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-applications]]></category>
            <category><![CDATA[folder-structure]]></category>
            <dc:creator><![CDATA[Marcin Skorek]]></dc:creator>
            <pubDate>Sun, 06 Oct 2024 12:44:55 GMT</pubDate>
            <atom:updated>2024-10-06T12:44:55.754Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y53_pZbVFiFrS8GY" /><figcaption>Photo by <a href="https://unsplash.com/@homajob?utm_source=medium&amp;utm_medium=referral">Scott Graham</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>As the project grows, maintaining a clean codebase becomes a challenge. Without the preliminary approach to organizing components, projects can quickly become messy, making them difficult to work with and debug.</p><p>The key to avoiding these pitfalls lies in establishing a clear and consistent structure of the components from the very beginning. This makes projects more manageable to work with and easier to maintain in the long run.</p><p>In this article, I’ll explain approaches to structuring React projects based on their size. It helps to streamline the workflow and maintain projects without the overhead. Dear Reader, consider this article a guide you can follow or adapt to fit your project&#39;s needs. Without further ado, let’s jump right on it.</p><h3>Folder Structure</h3><p>When building a Web application, organizing the project’s folder structure is crucial, although it can sometimes be confusing. Below, I’ll mention two widely used approaches to organizing, which I also use in my projects.</p><h4>Organizing by Feature (Domain-Driven Structure)</h4><p>In this approach, folders are grouped by the particular feature or section of your application. Each folder contains everything related to that feature, meaning components, styles, tests, interfaces, utilities, etc.</p><p>The folder structure might look like this:</p><pre>/src<br>  /features<br>    /auth<br>      /components<br>        /forms<br>          /login<br>            LoginForm.tsx<br>            LoginForm.interface.tsx<br>            LoginForm.helpers.tsx<br>      /hooks<br>        useAuth.ts<br>      /utils<br>        hashPassword.ts</pre><p>The presented structure contains the features folder, and auth inside. Then, we further organize the structure, separating components, hooks, and utilities in the scope of the auth folder.</p><p>This approach, as with everything, has its pros and cons. I’ll list some of both.</p><p><strong>Pros:</strong></p><ul><li>Modularity and Isolation— Each feature is isolated with its components, styles, etc. This makes it easy to work on a specific feature without affecting other parts of the app;</li><li>Scalability — This structure scales very well for large applications. When a new feature appears in the app, you simply add a new folder and put everything there;</li><li>Readability and Ramp-up—This folder structure allows new team members to quickly visualize what to expect on each of the application&#39;s screens. It promotes thinking in terms of features rather than individual components.</li></ul><p><strong>Cons:</strong></p><ul><li>Reusability — While the structure is great for isolation, it gets problematic when different features need to share common components, utilities, etc. In that scenario, you might end up with duplicated code.</li><li>Deep folder nesting—As the feature grows, the folder structure might become deeply nested, making it slightly harder to find specific files.</li></ul><h4>Organizing by Type (Type-Based Structure)</h4><p>Another approach involves organizing folders based on the type of entity, such as components, hooks, etc.</p><p>Here’s an example:</p><pre>/src<br>  /components<br>    /atoms<br>      Button.tsx<br>    /molecules<br>      LabelInput.tsx<br>    /organisms<br>      LoginForm.tsx<br>    /pages<br>      Login.tsx<br>  /hooks<br>    useAuth.ts<br>  /utils<br>    hashPassword.ts</pre><p>This way, components, hooks, and utils are in separate folders. It’s more suitable for smaller applications or ones that share many components across different features. As per the components folder, I would suggest an <a href="https://atomicdesign.bradfrost.com/chapter-2/">Atomic Design Pattern</a>. It’s a methodology for creating design systems with reusable components. It breaks down components into five categories:</p><ul><li><strong>Atoms</strong> — The smallest building blocks, such as a Button or an Input;</li><li><strong>Molecules</strong> — It’s a combination of atoms working together. For instance, it might be a form input with a label;</li><li><strong>Organisms</strong> — Those are more complex sections of the UI, which are made up of molecules. For example, the Login form;</li><li><strong>Templates — </strong>It’s the page-level layout, which contains organisms and components in a consistent format;</li><li><strong>Pages — </strong>It’s the final page that the user interacts with.</li></ul><p>This pattern includes five categories, but you can tailor it to your needs. This approach is indifferent and has pros and cons.</p><h4>Pros</h4><ul><li>Flat folder structure — This approach is straightforward, especially for smaller projects with many shared components. It also results in a flatter folder structure, making it easier to navigate;</li><li>Reusability — When organizing by type, it’s easier to think about reusability. This encourages the creation of shared and generic functions, which, in summary, reduce code duplication;</li><li>Separation of concerns — In this structure, it’s easier to keep files that contain data management logic separate from the presentational layer and business logic. It enforces a clear distinction between different layers of application.</li></ul><h4>Cons</h4><ul><li>Challenging to scale — As the project scales, having all of the files grouped by type can become overwhelming. For instance, having a dozen files in the hooks folder might become hard to navigate, and the folder can become cluttered;</li><li>Context switching — When working on a particular hook or component, it might be harder to immediately understand the context of where and how it’s going to be used;</li><li>Lack of feature isolation — With this approach it’s harder to keep the logic isolated. If a developer needs to work on a particular feature such as auth, they’ll have to browse through multiple folders to find needed files.</li></ul><h3>What’s the Right Approach?</h3><p>Both the <strong>Feature-based</strong> and <strong>Type-based</strong> approaches have their strengths, but each works best in different contexts. Let’s dive deeper into when you should consider using which approach.</p><h4>Organizing by Feature (Domain-Driven Structure)</h4><p>This approach works very well when you’re working on a <strong>large application</strong> where different features work independently. For example, an e-commerce application may have separate areas like auth, products, cart, and orders. Each section would have its own components, utilities, and hooks. Organizing by feature helps to keep everything related to a feature together, which is essential for maintainability and scalability.</p><p><strong>When to use it:</strong></p><ul><li>Large applications with clearly defined features;</li><li>When teams are working on independent parts of the application;</li><li>The application is expected to grow and scale, requiring modularity.</li></ul><h4>Organizing by Type (Type-Based Structure)</h4><p>This structure is better suited for <strong>smaller projects</strong> with many <strong>reusable components</strong>. Instead of grouping files by feature, you organize them by type (e.g. components, hooks, or utilities) regardless of what part of the application they belong to. It works well for applications that rely heavily on shared components.</p><p><strong>Example</strong>:<br>Imagine you’re building a blog platform. Many components, like Button, InputField, or Card, are reused across different screens, such as the post or comment section. A type-based structure makes it easy to find and manage reusable components.</p><p><strong>When to use it</strong>:</p><ul><li>Small to medium-sized applications with lots of shared components;</li><li>Projects where simplicity and ease of navigation are key;</li><li>Early-phase or proof-of-concept projects.</li></ul><h3>Summary</h3><p>Each approach has its pros and cons, and choosing the right one depends on the size of your team and the complexity of your application. For large, scalable projects, organizing by feature is often more effective, while smaller projects usually benefit from organizing by type. Beyond selecting the structure, it’s crucial to involve your team in the decision-making process. Team members may be familiar with different structures, so discussing the benefits and potential drawbacks of each option is essential to ensure alignment and improve collaboration.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=05622d5059ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Guide to Building Accessible Web Applications]]></title>
            <link>https://medium.com/@SkorekM/guide-to-building-accessible-web-applications-35ee5afd313f?source=rss-cc1ca7435010------2</link>
            <guid isPermaLink="false">https://medium.com/p/35ee5afd313f</guid>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[accessibility]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Marcin Skorek]]></dc:creator>
            <pubDate>Fri, 06 Sep 2024 13:17:57 GMT</pubDate>
            <atom:updated>2025-03-24T06:33:26.216Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Two people talking over a cup of coffee" src="https://cdn-images-1.medium.com/max/1024/0*OviXxxEcjO8EPfqC" /><figcaption>Photo by <a href="https://unsplash.com/@curvd?utm_source=medium&amp;utm_medium=referral">CURVD®</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The importance of web accessibility cannot be overstated in the modern digital landscape. Making sure that web applications are accessible to all users, including those with disabilities, is not just a matter of compliance with standards. It also reflects good application design and can help increase lighthouse scores. This article dives into Web Content Accessibility Guidelines (WCAG), building accessible web applications, incorporating accessibility principles, practical tips, and tools for testing and maintaining accessibility standards.</p><h3>Principles and Importance of the Web Accessibility</h3><p>Web accessibility refers to the practice of designing and developing web applications that are usable by people of all abilities and disabilities. To highlight the importance of making web applications accessible, the World Wide Web Consortium (W3C) developed the Web Content Accessibility Guidelines (WCAG), which are structured around four core principles, which can be remembered by the acronym POUR.</p><h4>Core Principles (POUR)</h4><ol><li><strong>Perceivable</strong>: Ensure the content is accessible to all users by providing text alternatives for non-text content, adding captions for the multimedia, and ensuring proper use of color and contrast.</li><li><strong>Operable</strong>: Ensure all functionality is accessible via the keyboard and that users have sufficient time to interact with the content.</li><li><strong>Understandable</strong>: Ensure that content and controls are easy to understand and use.</li><li><strong>Robust</strong>: Ensure the content is compatible with various user agents and assistive technologies.</li></ol><h4>WCAG Versions and Compliance Levels</h4><p>WCAG has evolved over the years to keep pace with the technological advancement. Here’s the breakdown:</p><ul><li><strong>WCAG 2.0</strong>, released in 2008, set the foundation for the web accessibility;</li><li><strong>WCAG 2.1</strong>, released in 2018, was built upon the 2.0 version and incorporates guidelines for mobile accessibility, cognitive disability, and low vision;</li><li><strong>WCAG 2.2</strong>, released on October 2023, builds upon previous versions, enhancing accessibility, for example, for users with cognitive abilities. It also improves the touch-target sizes on mobile devices.</li></ul><p>WCAG is also structured around three levels of compliance—A, AA, and AAA. Each level represents a different degree of accessibility.</p><h4><strong>Level A</strong></h4><p>It’s the most basic level of compliance. Its purpose is to address the most critical barrier that could prevent users with disabilities from accessing the content. At this level, it’s crucial to ensure that web content is technically accessible. Some key features include:</p><ul><li><strong>Text Alternatives — </strong>All non-text content must have a text alternative so that screen readers and other assistive technologies can detect that;</li><li><strong>Keyboard Accessibility — </strong>The website should be navigable using a keyboard;</li><li><strong>Flashing Content — </strong>There is no content that flashes more than three times in any one-second period;</li><li><strong>Labels and Instructions — </strong>Accurate labels and instructions should be provided for user input fields.</li></ul><h4><strong>Level AA</strong></h4><p>This is the most commonly targeted compliance level for organizations as it balances between accessibility and practicality. Its goal is to make content accessible to those with visual, auditory, or cognitive abilities. Some key features include:</p><ul><li><strong>Color Contrast — </strong>Text and images must have a contrast ratio of at least 4.5:1;</li><li><strong>Resizable Text — </strong>Users should be able to resize the text up to 200% without loss of content or functionality;</li><li><strong>Target size — </strong>The size of that target pointer input is at least 24 by 24 pixels (with some exceptions);</li><li><strong>Audio Control — </strong>In case there’s audio that plays automatically for more than 3 seconds, users should be able to pause and control the volume of the audio;</li><li><strong>Consistent Navigation — </strong>If the page has navigation across sub pages, they should appear in a consistent order, helping users predict where to look for the content.</li></ul><h4><strong>Level AAA</strong></h4><p>The last level, as you may expect, is the strictest of them all. It’s also the most comprehensive one. Its aim is to make content accessible to the widest possible audience. Whereas it is noble to aim for this level, it’s very challenging and is often not a legal requirement. The key features of the AAA level are:</p><ul><li><strong>Enhanced Contrast — </strong>Text and images must have a contrast ratio of at least 7:1 against the background (with some exceptions);</li><li><strong>Reading level — </strong>Content that is more complex than a lower secondary education reading level should have a simplified alternative;</li><li><strong>Focus Appearance — </strong>The focus indicator needs to be at least as large as 2 pixels on the thick perimeter of the unfocused component and needs a contrast ratio of at least 3:1 between the same pixels in the focused and unfocused states;</li><li><strong>Contextual Help — </strong>Users interacting with complex or non-standard parts of the website should have contextual help.</li></ul><p>There’s way more. Here’s the official <a href="https://www.w3.org/TR/WCAG22/">website</a> for more reference:</p><h3>Some of the practical tips</h3><p>As we have already seen, compliance levels can be difficult and require a keen eye for details. Here are some practical tips that developers should always have in mind while writing the code:</p><h4>1. Use Semantic HTML</h4><p>Semantic HTML is the foundation of accessible web design. By using the correct HTML elements for their intended purpose (e.g., &lt;header&gt;, &lt;nav&gt;, &lt;article&gt;, &lt;section&gt;), it ensures that assistive technologies like screen readers can accurately interpret and present content to users. This also helps improve the overall structure and readability of the code.</p><h4>2. Provide Text Alternatives</h4><p>All non-text content, such as images, videos, and infographics, should have text alternatives. For images, use the alt attribute to provide descriptive text. For videos, include captions and transcripts. This ensures that users who cannot see or hear the content can still access the information.</p><h4>3. Ensure Keyboard Accessibility</h4><p>A significant amount of users rely on keyboards rather than a mouse to navigate the web. To support these users, make sure that all interactive elements (e.g., links, buttons, form controls) are accessible via the keyboard. This can be tested by navigating through the application using the Tab key and ensuring that all elements are reachable and usable.</p><h4>4. Use ARIA (Accessible Rich Internet Applications) Landmarks and Roles</h4><p>ARIA (Accessible Rich Internet Applications) landmarks and roles can enhance the application&#39;s accessibility by providing additional context to screen readers. Use ARIA roles to define the purpose of UI components (e.g., role=&quot;button&quot; for buttons, role=&quot;navigation&quot; for navigation menus) and landmarks to identify key sections of a page (e.g., role=&quot;main&quot; for the main content area).</p><h4>5. Create Accessible Forms</h4><p>Forms are a critical part of many web applications, and accessibility issues can be particularly challenging for users. Make sure that form fields are properly labeled using the label element, provide instructions and error messages that are easy to understand. Additionally, use fieldsets alongside legends to group related fields.</p><h3>Tools and Techniques for Testing and Maintaining Accessibility</h3><ol><li><strong>axe-core</strong>: This is a great tool for accessibility testing, it’s pretty easy to set up. One way to use it is by integrating it with GitHub Actions, so it automatically checks your pages for accessibility issues. In fact, some other tools, like <strong>Lighthouse, </strong>actually use axe-core behind the scenes. It’s built by Deque, a company that’s well-known for accessibility testing</li><li><strong>Lighthouse: </strong>The first tool that comes to mind when testing various aspects of the web application is the Lighthouse. Even though automatic detection does not guarantee that you will find all of the opportunities to improve the website&#39;s accessibility, it sets a solid foundation.</li><li><a href="https://pa11y.org/"><strong>Pa11y</strong></a>: It’s an open-source accessibility testing tool that can help ensure that the web applications comply with accessibility standards. It offers automated scanning of web pages to detect common accessibility issues, such as missing alt attributes, insufficient color contrast, and improper ARIA roles.</li><li><a href="https://github.com/marketplace/accesslint"><strong>AccessLint</strong></a><strong>: </strong>This tool allows us to find accessibility issues in the Pull Request, which means it’s encoded into the development workflow. It’s super handy, and it runs a growing list of WCAG tests. Unfortunately, only the Hobbist version is free. The standard version costs $49/month.</li><li><a href="https://github.com/jsx-eslint/eslint-plugin-jsx-a11y"><strong>eslint-plugin-jsx-a11y</strong></a><strong>:</strong> It’s a plugin that is easily integrable into the codebase. There are also versions for Vue and many more. It does a static evaluation of the JSX to spot accessibility issues in React apps.</li></ol><h3>Beyond coding</h3><p>It’s important to remember that building accessible web applications is not solely the responsibility of developers. It’s an effort of the whole team. Designers play a foundational role in creating user-friendly interfaces with rules such as Color Contrast in mind. Content creators need to ensure that information is presented in a clear and accessible manner. Also, the QA engineers are crucial in heavy testing for accessibility compliance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35ee5afd313f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why shouldn’t you be scared of code reviews?]]></title>
            <link>https://medium.com/@SkorekM/why-shouldnt-you-be-scared-of-code-reviews-424c4c02536e?source=rss-cc1ca7435010------2</link>
            <guid isPermaLink="false">https://medium.com/p/424c4c02536e</guid>
            <category><![CDATA[code-review]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Marcin Skorek]]></dc:creator>
            <pubDate>Mon, 14 Nov 2022 08:58:38 GMT</pubDate>
            <atom:updated>2022-11-14T08:58:38.261Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y0wNmGp7XXhLq-Ho" /><figcaption>Photo by <a href="https://unsplash.com/@ikukevk?utm_source=medium&amp;utm_medium=referral">Kevin Ku</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>We live in a world where the code is ubiquitous. Any software product consists of code, and often the codebase is massive. Due to that, in most cases, more people are working on it together. This is where code review comes in as a crucial bit. Whereas there are many ways to do a code review, I would like to cover tool-assisted (such as GitHub) in this article, which means that the reviewer is assigned to the pull request created by the colleague.</p><h3>What is a code review?</h3><p>After a developer gets the ticket, regardless of whether that’s a bug or a new feature, some code will be produced. After the work is done, according to the practice, a pull request should be submitted to the upstream. This is when your colleague or someone more “senior” than yourself should check that code and give feedback.</p><h3>What’s the point of the code review?</h3><p>Many people may have in mind something along the lines of, “Hey, but I saw it’s working. Is there a need for someone to check my code?”. Whereas that might be valid in some cases, and we tend to get overprotective of our work, it’s crucial to accept constructive feedback for growth and learning. It might be a bit frustrating at first to get a lot of comments on your work, but with time — you’ll adapt and, most importantly, learn (which is supposed to be our goal!). Also, code review is not only for the developer that submitted the pull request. It’s also for the other team members to see what you have done and get closer to the domain-specific aspect of your work. In short — get up to speed with the code base. It helps them understand what happened and why it happened.</p><h3>Benefits of the code review</h3><h4>Code optimization</h4><p>No matter how senior a developer is, no one can always check for the most optimal solution. It happens mainly due to the monotonous nature of our work. We are not always working on cutting-edge solutions; frequently, we repeat the work we have done in the past. So it’s super easy to overlook a better solution since this “worked in the past.”</p><h4>Finding edge cases</h4><p>Let’s assume you are the one that put together some features, you had your requirements, and you were working on something you did in the past. In those specific moments, it’s easy to forget how people will interact with your work’s fruition. During the code review, someone else usually looks from a bit broader perspective and can easily fit into the user’s shoes and think of some edge cases you haven’t considered (and it’s good!).</p><h4>Learning</h4><p>During the code reviews, you should receive constructive feedback and suggestions on how the solution could have been done differently. It does not mean you have to implement it this way, but it might be something you have yet to think of and want to use in the future. This way, we can learn from each other. Perhaps someone reviewing your code has not seen such a solution either? This can trigger a discussion, which ultimately leads to growth.</p><h4>Keeping others up to date</h4><p>Okay, so I mentioned that code reviews are not only for the creator of the pull request. It’s always a good practice to include other colleagues in the pull request, whether they are new to the project or have been there for some time. It lets people know what you have been working on. Now you might be thinking, “But we have meetings for that, and we see tickets on the board” — that’s right, but there’s more to it. If someone is new or working on another part of the application, it’s good for them to see how your code integrates with everything, what the practices are, etc. Especially new developers that may have used different approaches and techniques. It helps them to get up to speed.</p><h3>Personal perspective</h3><p>Throughout my career, I found that there are some team-specific rules to help the team perform better code reviews. When I am in a position to review roughly 100 files, it becomes very challenging, if possible, to provide accurate and viable feedback. Within the teams I work with, I always try to set a maximum limit on the lines of code to be reviewed. In my case, it’s 200 give or take. This allows me to review the code for the complexity and, most importantly, the domain-specific aspect, which in some cases might be crucial.</p><h3>Summary</h3><p>To conclude everything, don’t be scared of the code review because its purpose is not to undermine your abilities or attack you in any way. Instead, its purpose is to ensure that the code that goes to production is scalable, clean, and optimized. It also enables both sides to learn and stay up to date with whatever is happening in the project! The main takeaway is not to treat this process personally but work as a team to ensure the product’s quality.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=424c4c02536e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>