Skip Navigation
InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)PH
philnash @programming.dev
Posts 21
Comments 7
www.sonarsource.com __dirname is back in Node.js with ES modules

Node.js is reducing friction when using ES modules by making it easier to get the current module directory name

__dirname is back in Node.js with ES modules

cross-posted from: https://programming.dev/post/11927506

> Many times when I’ve tried to write some code in Node.js using ES modules I’ve found myself reaching for __dirname and then looking up how to replace it. Now Node.js, Deno and Bun support import.meta.dirname. Check out the article for more detail.

0
www.sonarsource.com __dirname is back in Node.js with ES modules

Node.js is reducing friction when using ES modules by making it easier to get the current module directory name

__dirname is back in Node.js with ES modules

Many times when I’ve tried to write some code in Node.js using ES modules I’ve found myself reaching for __dirname and then looking up how to replace it. Now Node.js, Deno and Bun support import.meta.dirname. Check out the article for more detail.

0
dkundel.com Creating your own image generation model using JavaScript

Learn how you can create a custom text-to-image generation model using JavaScript, SDXL and Replicate without needing a machine learning background or needing specialized hardware.

Creating your own image generation model using JavaScript
0
www.sonarsource.com Union, intersection, difference, and more are coming to JavaScript Sets

The JavaScript Set was introduced to the language in the ES2015 spec, but it has always seemed incomplete. That's about to change with the addition of functions like intersection, union and difference.

Union, intersection, difference, and more are coming to JavaScript Sets
0
www.sonarsource.com Lessons learned upgrading to React 18 in SonarQube

We share the biggest three issues we faced and the lessons we learned as we upgraded SonarQube to React 18.

Lessons learned upgrading to React 18 in SonarQube
0
www.sonarsource.com Stop nesting ternaries in JavaScript

Nesting ternary operators makes code more complex and less clear. Let's investigate other ways to write conditional expressions.

Stop nesting ternaries in JavaScript
32
A comprehensive guide to the dangers of Regular Expressions in JavaScript
  • JavaScript's regex engine isn't the only one to have these problems. There certainly are other implementations, like Re2 and Rust's implementation, that don't have this issue. But they also lack some of the features of the JS implementation too.

  • www.sonarsource.com A comprehensive guide to the dangers of Regular Expressions in JavaScript

    A deep investigation into regular expression denial of service (ReDoS) vulnerabilities in JavaScript

    A comprehensive guide to the dangers of Regular Expressions in JavaScript
    0
    www.sonarsource.com A comprehensive guide to the dangers of Regular Expressions in JavaScript

    A deep investigation into regular expression denial of service (ReDoS) vulnerabilities in JavaScript

    A comprehensive guide to the dangers of Regular Expressions in JavaScript
    15
    A comprehensive guide to the dangers of Regular Expressions in JavaScript
  • The only real way to validate an email address is send it an email and see if it arrives! I'm sure many of us have fallen to the urge to validate an email with a regex though, and yes, it's just too dangerous! I definitely like the simplicity of checking for an @.

    I think regular expressions are actually very tempting to use because they seem hard. I feel like I go through this XKCD comic every time the opportunity to use a regex comes up. But string functions often have the answer. I hope, if this article achieves anything, it just stops people using regex to trim whitespace!

  • www.sonarsource.com A comprehensive guide to the dangers of Regular Expressions in JavaScript

    A deep investigation into regular expression denial of service (ReDoS) vulnerabilities in JavaScript

    A comprehensive guide to the dangers of Regular Expressions in JavaScript
    4
    marvinh.dev Speeding up the JavaScript ecosystem - Polyfills gone rogue

    Many popular npm packages depend on 6-8x more packages than they need to. Most of these are unnecessary polyfills and it's one of the key reasons node_modules folders are so large. The eslint ecosystem seems to be most affected by this.

    Speeding up the JavaScript ecosystem - Polyfills gone rogue
    1
    redd.one One Thing Nobody Explained To You About TypeScript

    One of the most common mistakes in configuring TypeScript.

    One Thing Nobody Explained To You About TypeScript

    Click bait title, but this post goes into depth about using tsconfig.json correctly and across different layers of your project.

    1
    cjihrig.com NODE_ENV Considered Harmful

    At some point in the distant past, certain Node.js projects adopted the convention of using the NODE_ENV environment variable to denote how the project was being run. For example:

    0
    www.sonarsource.com Typing your JavaScript without writing TypeScript

    TypeScript already understands JavaScript, but you can get more out of it when you add types to your JavaScript with JSDoc or TypeScript declaration files

    Typing your JavaScript without writing TypeScript

    This is a follow up to my previous article on how to get more TypeScript benefits in your JavaScript. This goes into how to add types using JSDoc or TypeScript declaration files.

    0
    philna.sh JavaScript is getting array grouping methods

    Grouping items in an array is one of those things you've probably done a load of times. Each time you would have written a grouping function by hand or...

    JavaScript is getting array grouping methods
    0
    www.sonarsource.com Get the benefits of TypeScript in your JavaScript

    Let's dive into what you can do to get more and more of TypeScript's benefits in your JavaScript projects.

    Get the benefits of TypeScript in your JavaScript
    0

    Node.js 20.6.0 includes built-in support for .env files

    philna.sh Node.js includes built-in support for .env files

    With the recent release of version 20.6.0, Node.js now has built-in support for .env files. You can now load environment variables from a .env file into...

    Node.js includes built-in support for .env files
    2
    www.sonarsource.com What is deeper SAST in JavaScript?

    What is SAST, what does deeper SAST mean, and how does this apply to your JavaScript and TypeScript applications?

    What is deeper SAST in JavaScript?
    0
    oida.dev 5 Inconvenient Truths about TypeScript

    I’m writing books about TypeScript and I do workshops and trainings online and in-house. Every time I meet a new group of developers there are some TypeScript facts that they need to be confronted with:

    5 Inconvenient Truths about TypeScript
    4
    philna.sh Easy and accessible pagination links for your Astro collections

    Generating pagination links is not as straightforward as it may seem. So, while rebuilding my own site with Astro, I released a <Pagination /> component on...

    Easy and accessible pagination links for your Astro collections
    0
    Hands on with the Node.js test runner
  • I think you're absolutely right about the difficulty for developers inadvertently getting the legacy assert behaviour. Though I hope if they do that, they at least recognise that they can use the strict methods.

    The early module had both non-strict and strict methods, even from that early time, so the original author recognised the need for using ===, but I guess wanted to be flexible and allow for == usage too. Perhaps this was a bad decision, but it was made in version 0.1.21, so I would guess there was a lot of fast work going on with Node at the time and maybe not everything was thought through in as much depth as it could be. It's possible that one day the strict module may take over the place of the existing assert module, but that would be quite the breaking change!

  • www.sonarsource.com Hands on with the Node.js test runner

    Node.js released a new test runner in version 20. Let's dive in to how to write tests for JavaScript applications with the test runner.

    Hands on with the Node.js test runner

    Node.js version 20 comes with a new, built-in, stable test runner. This post takes a look into what you can do with it, with a small example test project.

    3