Skip to content

Instantly share code, notes, and snippets.

View phatnguyenuit's full-sized avatar
💪
Working on ReactJS and TypeScript.

Phát Nguyễn (Fast) phatnguyenuit

💪
Working on ReactJS and TypeScript.
View GitHub Profile
@phatnguyenuit
phatnguyenuit / .eslintrc.js
Created May 2, 2022 13:43
How to sort imports like a pro in TypeScript | .eslintrc.js | base ESLint
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
env: {
node: true,
},
plugins: ['@typescript-eslint', 'prettier'],
@phatnguyenuit
phatnguyenuit / how-to-sort-imports-like-a-pro.md
Last active March 11, 2025 07:17
How to sort imports like a pro in TypeScript

How to sort imports like a pro in TypeScript

Crossing reviews becomes a very common activity today in engineering behavior. To help us review changes for pull/merge requests easier, sorting imports can help us a much. The codebase becomes more professional and more consistent, reviewers will be happier, and the review process will be faster, focusing on the implementation changes ONLY.

Have you ever thought about how to sort imports in TypeScript projects automatically?

Let me show you how to archive sorting imports automatically in TypeScript projects with ESLint!

@phatnguyenuit
phatnguyenuit / download_fb_photos.js
Last active June 13, 2022 09:24
Download facebook photos
const fetchedPhotoUrls = [];
function getCurrentPhoto() {
const ele = document.querySelector(
'[data-visualcompletion="media-vc-image"]',
);
return ele.src;
}
@phatnguyenuit
phatnguyenuit / calculator.js
Created March 1, 2022 16:02
Tính Tam Nguyên Cửu Vận dựa vào năm
const THE_1ST_YEAR = 1864;
const CYCLE_YEARS = 180;
const NUM_OF_FATES = 9;
const NUM_OF_YEARS_FOR_FATE = 20;
const ORIGINS = ['Thượng Nguyên', 'Trung Nguyên', 'Hạ Nguyên'];
const NINE_FATES_FACILITIES = [
'Khảm-Thủy',
'Khôn-Thổ',
'Chấn-Mộc',
@phatnguyenuit
phatnguyenuit / styles.module.scss
Created January 29, 2022 08:56
How to build a React library with TypeScript - my-react-package src/global.d.ts
declare module '*.module.css' {
const classes: { readonly [key: string]: string };
export default classes;
}
declare module '*.module.scss' {
const classes: { readonly [key: string]: string };
export default classes;
}
@phatnguyenuit
phatnguyenuit / styles.module.scss
Created January 29, 2022 08:54
How to build a React library with TypeScript - my-react-package hello/styles.module.scss
$with: 600px;
$height: 200px;
.helloScss {
display: flex;
align-items: center;
justify-content: center;
width: $with;
height: $height;
@phatnguyenuit
phatnguyenuit / styles.module.css
Created January 29, 2022 08:53
How to build a React library with TypeScript - my-react-package hello/styles.module.css
.helloCss {
margin: 0;
padding: 0;
color: red;
font-weight: bold;
font-size: 2rem;
}
@phatnguyenuit
phatnguyenuit / native-request.js
Created December 28, 2021 08:59
Native NodeJS request GET with https.get
const https = require('https');
function getJSONRequest(url) {
return new Promise((resolve, reject) => {
https
.get(url, (res) => {
let data = '';
// called when a data chunk is received.
res.on('data', (chunk) => {
@phatnguyenuit
phatnguyenuit / dark-mode.html
Last active December 9, 2021 07:13
Simple dark mode implementation with CSS Variables
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Simple dark mode implementation with CSS Variables</title>
<link rel="stylesheet" type="text/css" href="./theme.css" />
<style>
p {
@phatnguyenuit
phatnguyenuit / script.sh
Created November 26, 2021 12:14
How to enforce TypeScript types in the runtime environment - install ajv scripts