Skip to content

Instantly share code, notes, and snippets.

View azu's full-sized avatar

azu azu

View GitHub Profile
export const requireComment = {
meta: {
type: "suggestion",
docs: {
description: "useEffectにはコメントでの説明が必須です。",
},
schema: [],
messages: {
requireCommentOnUseEffect: `useEffectにはコメントでの説明が必須です。
@azu
azu / pnpm-up.sh
Last active January 5, 2025 13:31
`pnpm --recursive update --interactive --latest` for pnpm catalogs. pnpm + fzf + yq
# Update pnpm catalog with interactive
# pnpm catalog: https://pnpm.io/ja/catalogs
# fzf: https://github.com/junegunn/fzf
# yq: https://github.com/kislyuk/yq
selected_cataglogs=$(pnpm outdated --recursive --json | jq -r 'to_entries[] | .key + ": " + .value.current + " → " + .value.latest' | fzf --multi)
echo $selected_cataglogs | while read line ; do
pkg_name=$(echo "$line" | cut -d: -f1)
pkg_version=$(echo "$line" | cut -d' ' -f4)
echo "Update $pkg_name to $pkg_version"
yq -i ".catalog += {\"$pkg_name\": \"$pkg_version\"}" pnpm-workspace.yaml
@azu
azu / playwright.md
Last active August 16, 2024 09:57
Playwright v1.44.0...v1.46.0
@azu
azu / next-font.md
Created July 29, 2024 15:36
next/fontの実装メモ

next/fontの実装

https://github.com/vercel/next.js/blob/037783445324a85d04675524c941df21b3f4fbb5/packages/font/src/google

  1. next/fontの関数からパラメータを組み立てて https://fonts.googleapis.com/css2?family=xxx に対してリクエスト
  1. ダウンロードしたCSSの src: url(...) を抜き出してwebfontファイルを保存
  1. ダウンロードしたCSSの src: url(...) を保存したファイルパスへ書き換え
@azu
azu / README.md
Last active February 2, 2025 14:23
Node.jsのTypeScriptサポートについて
@azu
azu / createEnv.ts
Last active July 1, 2024 01:20
Type Safe env.ts
export type BaseEnvRecord = Record<
string,
{
value: string | undefined;
required: boolean;
defaultValue?: string;
}
>;
export type ReturnTypeOfCreateEnv<T extends BaseEnvRecord> = {
// If the value is required, it should be a string, otherwise it should be a string or undefined
{
// ベースのtsconfigは決められたカテゴリのみを設定する
// それ以外は、プロジェクトごとに設定する
// https://www.typescriptlang.org/tsconfig/#compilerOptions
"compilerOptions": {
// incrementalビルドは特別にデフォルトで有効にする
"incremental": true,
// # JavaScript Support
"allowJs": false,
// # Type Checking
import React, { useActionState } from "react";
const validate = _ => {};
const isValidationError = _ => {};
const isNetworkError = _ => {};
const DisplayError = ({
error,
}: {
error: ReturnType<typeof usePage>["error"];
}) => {
if(isValidationError(error)) {
const draw = (output) => console.log(output);
const getWeather = async (city) => {
await new Promise((resolve) => setTimeout(resolve, 1000));
return "sunny";
};
const render = async function* ({ city }) {
yield `<Spinner />`;
const weather = await getWeather(city);
return `<Weather info=${weather} />`;
@azu
azu / kagi-to-google.js
Created February 29, 2024 04:10
Surfingkeys shortcut: kagi.com to google
api.mapkey("g", "Kagi to Google", function () {
const isKagi = location.href.startsWith("https://kagi.com/search?");
if (isKagi) {
location.href = `https://www.google.com/search?q=${(new URL(location.href)).searchParams.get("q")}`;
}
});