created: 2024-11-23T08:51:15.837Z
nodejs の zx スクリプトだけ eslint の globals を追加する
zx スクリプトファイルは、ファイル名の拡張子を *.zx.mjs
にリネームして、以下の設定を追加する。
$ GIT_PAGER=cat git diff
diff --git a/eslint.config.mjs b/eslint.config.mjs
index 796bb38..6a64f2a 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -2,11 +2,33 @@ import pluginJs from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";
+const zx = {
+ files: ["**/*.zx.mjs"],
+ languageOptions: {
+ globals: {
+ $: "readonly",
+ cd: "readonly",
+ chalk: "readonly",
+ fs: "readonly",
+ glob: "readonly",
+ os: "readonly",
+ path: "readonly",
+ question: "readonly",
+ sleep: "readonly",
+ which: "readonly",
+ __dirname: "readonly",
+ __filename: "readonly",
+ },
+ },
+};
+
export default [
{ files: ["**/*.{js,mjs,cjs,ts}"] },
{ languageOptions: { globals: globals.browser } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
+ zx,
{
rules: {