Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2023-01-19 - deno で stylelint を走らせる #206

Closed
kachick opened this issue Jan 27, 2023 · 1 comment
Closed

2023-01-19 - deno で stylelint を走らせる #206

kachick opened this issue Jan 27, 2023 · 1 comment

Comments

@kachick
Copy link
Owner

kachick commented Jan 27, 2023

#194 みたいな事をかいてはいたけれど、なんかどうも bun で stylelint 叩くときに node にもパスが通ってないと動かない感があった。
Nix に切り替えるときにちょっと触っていくと、nodejs の無い環境では次のようなエラーが出る

> bun run stylelint **/*.css

error: Cannot find package "vm" from "/home/kachick/repos/kachick.github.io/node_modules/v8-compile-cache/v8-compile-cache.js"
error: "stylelint" exited with code 1 (SIGHUP)
error: script "lint" exited with code 1 (SIGHUP)

この v8-compile-cache という名前が bun で出てくるというのが如何にも怪しい。
どうやら stylelint/stylelint#4272 で速度向上を狙って eslint の PR eslint/eslint#11921 を真似して突っ込んだということなんだけど、 eslint 側でも引っかかるようなら流石にもっと話題になってるやろと思ったら eslint/eslint#16235 の中でなんか他の作業と混ぜつつ捨てられてた。
ほーん・・・これは外からなんか出来るんかなー

当時より deno の npm 対応が進んだということで、最終的に deno にしてしまった。速度面でのメリットは享受できなくなった気がするけど、ツールセット面での悩みが減るのはやはり嬉しい

kachick/kachick.github.io#61

> deno cache --node-modules-dir npm:stylelint npm:stylelint-config-standard npm:stylelint-config-prettier

# stdbuf does not correctly handle the original color... :<
# unbuffer does not end in GitHub Actions... :<
# So add `unbuffer ` prefix into deno when I want local developping
> stylelintoutput="$(mktemp)" && \
  deno run --node-modules-dir --allow-env --allow-read npm:stylelint/stylelint '**/*.css' | tee "$stylelintoutput" && \
  ! [ -s "$stylelintoutput" ]

コマンドラインの組み立て方がピンと来ず四苦八苦したけれど、先に cache してやれば良さそう。
しかし、これだと stylelint でエラー扱いになっても、 deno としてはコマンドを正常に完了できたからなのか exit 0 になるというよくわからないことに・・・
渋々色を残しつつ tee を挟んだけれど、シンプルとは・・・?みたいな気持ちにちょっとなってきたのでどっかでまだなんか触って見るかも

refs

@kachick
Copy link
Owner Author

kachick commented Feb 13, 2023

stylelint 15 から prettier plugin が deprecated になったらしい prettier/stylelint-config-prettier#140
ので、バージョン固定とかと併せるとこんな感じ

deno cache --node-modules-dir npm:stylelint@15.1.0 npm:stylelint-config-standard@30.0.1 --reload

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant