Install ESLint and create configuration
()
| 145 | |
| 146 | |
| 147 | def setup_eslint(): |
| 148 | """Install ESLint and create configuration""" |
| 149 | print("Installing ESLint...") |
| 150 | |
| 151 | # Create package.json with TypeScript ESLint support |
| 152 | package_json = { |
| 153 | "name": "fastled-js-linting", |
| 154 | "version": "1.0.0", |
| 155 | "private": True, |
| 156 | "dependencies": { |
| 157 | "eslint": "^8.56.0", |
| 158 | "@typescript-eslint/parser": "^6.19.0", |
| 159 | "@typescript-eslint/eslint-plugin": "^6.19.0", |
| 160 | "typescript": "^5.3.3", |
| 161 | }, |
| 162 | } |
| 163 | |
| 164 | with open(TOOLS_DIR / "package.json", "w") as f: |
| 165 | json.dump(package_json, f, indent=2) |
| 166 | |
| 167 | # Install ESLint |
| 168 | try: |
| 169 | # Get absolute paths for node and npm |
| 170 | _node_exe_abs = ( |
| 171 | (TOOLS_DIR / "node" / "node.exe").resolve() |
| 172 | if platform.system() == "Windows" |
| 173 | else (TOOLS_DIR / "node" / "bin" / "node").resolve() |
| 174 | ) |
| 175 | npm_exe_abs = ( |
| 176 | (TOOLS_DIR / "node" / "npm.cmd").resolve() |
| 177 | if platform.system() == "Windows" |
| 178 | else (TOOLS_DIR / "node" / "bin" / "npm").resolve() |
| 179 | ) |
| 180 | |
| 181 | # Add node directory to PATH for npm to find node executable |
| 182 | env = os.environ.copy() |
| 183 | node_bin_dir = ( |
| 184 | str((TOOLS_DIR / "node").resolve()) |
| 185 | if platform.system() == "Windows" |
| 186 | else str((TOOLS_DIR / "node" / "bin").resolve()) |
| 187 | ) |
| 188 | env["PATH"] = f"{node_bin_dir}{os.pathsep}{env.get('PATH', '')}" |
| 189 | |
| 190 | # On Windows, use shell=True to properly execute .cmd files |
| 191 | if platform.system() == "Windows": |
| 192 | subprocess.run( |
| 193 | [str(npm_exe_abs), "install"], |
| 194 | cwd=TOOLS_DIR, |
| 195 | check=True, |
| 196 | capture_output=True, |
| 197 | text=True, |
| 198 | shell=True, |
| 199 | env=env, |
| 200 | ) |
| 201 | else: |
| 202 | subprocess.run( |
| 203 | [str(npm_exe_abs), "install"], |
| 204 | cwd=TOOLS_DIR, |