diary

I like Hatena Star with a text selection.

2020-08-13

scrapbox.io

久しぶりに漫画scrapboxを更新した。めっちゃ溜まってた…。


typescript-eslint に ts-expect-errorを禁止するルールがあるのだけど、ts-expect-errorは使いたいのでこれを無効化した。 無効化した時のパッチとコメントは以下。

diff --git a/.eslintrc.js b/.eslintrc.js
index bcf12cc34..b67b68102 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -102,6 +102,12 @@ module.exports = {
     "@typescript-eslint/no-var-requires": "off",
     "@typescript-eslint/no-empty-function": "off",
     "@typescript-eslint/explicit-module-boundary-types": "off",
+    "@typescript-eslint/ban-ts-comment": [
+      "warn",
+      {
+        "ts-expect-error": false,
+      },
+    ],
 
     // prettier is "error" by default but it's too strict
     "prettier/prettier": "warn",

ESLintで ts-expect-error を弾くルールがあるのですが、これを無効化しています。 https://github.com/typescript-eslint/typescript-eslint/blob/v3.9.0/packages/eslint-plugin/docs/rules/ban-ts-comment.md

ts-expect-error を使うと、型エラーが出てしまうようなコードを一時的に無視できます。また、その名の通り、型エラーが出なくなった場合はこのコメントがエラーとなります。 そのため、これはライブラリが出す型が合わないけど、将来的には修正したいという意図がある場合に便利です。

このコメントは普通に便利だと思うので、使えるようにしておきたいです。 なお、ESLintのこのルールにはallow-with-descriptionという「説明を書けばok」というオプションもあります。 ですが、ts-expect-errorの場合には「無効化している型エラー」以上のことを説明に書くのは難しいし、型エラーが出なくなったら気がつけるので、説明が必要なケースはないかなと思っています。


Androidのlocaleをスペイン語にしたら、PCのChromeロケールまでスペイン語になったぽくてびっくりした。


Twitterのトレンドを見たくないという話をしていたら、locationを変えると良いと教えてもらった。

twitter.com

twitter.com

トレンドが完全に理解不能になって便利。

twitter.com

教えてくださった皆様ありがとうございます。