Monthly News March 2022

News

Alert: peacenotwar module sabotages npm developers in the node-ipc package to protest the invasion of Ukraine

Tools

Shader Park: Create Interactive 2D and 3D Shaders with JavaScript
Shader Park is a library that simplifies creating procedural graphics using javascript. With just a few lines of code, create shaders which are: Animated, Interactive and 2D or 3D.
It allows folks who aren't necessarily familiar with writing shaders to create amazing interactive 3D graphics, skipping all the difficult boilerplate and math.
It has a lot of fun examples to explore. These examples is using WebGL, I suggest using a platform that supports a modern browser to open it, safari or any ios browser may not support.

React Flow: A highly customizable React component for building node-based editors and interactive diagrams

MDX: Markdown for the component era
Use JSX in Markdown Documents

Releases

Prettier 2.6 Released
Prettier is one of the most popular code formatting tools. It just released version 2.6. In this version, Single attribute per line caught my eye. This is an option to print only one attribute per line in Vue SFC templates, HTML, and JSX.Β This used to piss me off so much. I would have to run prettier first, then run eslint with that rule enabled. Now I can finally get prettier to do most of the work.

Articles

Delightful React File/Directory Structure

Tao of Node - Design, Architecture & Best Practices
Author list his own rules and principles including Structure & Coding Practices, Tooling, Testing and Performance for building Node applications.
The Structure opinion is very interesting. Most of MVC structure by technical responsibilities, the author think that a better way to structure a node application is in modules representing a part of the domain.
He also advises you not to shoehorn everything into one utility folder but create separate files and group the business logic in them.

// πŸ‘Ž Don't structure by technical responsibilities
β”œβ”€β”€ src
| β”œβ”€β”€ controllers
| | β”œβ”€β”€ user.js
| | β”œβ”€β”€ catalog.js
| | β”œβ”€β”€ order.js
| β”œβ”€β”€ models
| | β”œβ”€β”€ user.js
| | β”œβ”€β”€ product.js
| | β”œβ”€β”€ order.js
| β”œβ”€β”€ utils
| | β”œβ”€β”€ order.js
| | β”œβ”€β”€ calculate-shipping.js
| | β”œβ”€β”€ watchlist-query.js
| | β”œβ”€β”€ products-query.js
| | β”œβ”€β”€ capitalize.js
| | β”œβ”€β”€ validate-update-request.js
| β”œβ”€β”€ tests
| | β”œβ”€β”€ user.test.js
| | β”œβ”€β”€ product.test.js

// πŸ‘ Structure by domain modules
β”œβ”€β”€ src
| β”œβ”€β”€ user
| | β”œβ”€β”€ user-handlers.js
| | β”œβ”€β”€ user-service.js
| | β”œβ”€β”€ user-queries.js
| | β”œβ”€β”€ user-handlers.test.js
| | β”œβ”€β”€ index.js
| | β”œβ”€β”€ validation
| | | β”œβ”€β”€ validate-update-request.js
| β”œβ”€β”€ order
| | β”œβ”€β”€ order-handlers.js
| | β”œβ”€β”€ order-service.js
| | β”œβ”€β”€ order-queries.js
| | β”œβ”€β”€ order-handlers.test.js
| | β”œβ”€β”€ calculate-shipping.js
| | β”œβ”€β”€ calculate-shipping.test.js
| | β”œβ”€β”€ index.js
| β”œβ”€β”€ catalog
| | β”œβ”€β”€ catalog-handlers.js
| | β”œβ”€β”€ product-queries.js
| | β”œβ”€β”€ catalog-handlers.test.js
| | β”œβ”€β”€ index.js
| | β”œβ”€β”€ queries
| | | β”œβ”€β”€ products-query.js
| | | β”œβ”€β”€ watchlist-query.js
| β”œβ”€β”€ utils
| | β”œβ”€β”€ capitalize.js

Handmade

Building Table Sorting and Pagination in JavaScript

Implementing JavaScript Delay for Cookie Consent Banner

How To Create and Validate a React Form With Hooks

Writing a React Table of Contents Component