From b033ce3b8165be9e63740a8e330b1eda6ee81d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=AF=E7=84=B6?= Date: Wed, 19 Jun 2024 15:17:03 +0800 Subject: [PATCH] fix: add warning message for ESLint v9 compatibility with npm --force flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #125 Signed-off-by: 唯然 --- lib/config-generator.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/config-generator.js b/lib/config-generator.js index 2d3d55f5..991e8481 100644 --- a/lib/config-generator.js +++ b/lib/config-generator.js @@ -4,6 +4,7 @@ */ import process from "node:process"; import path from "node:path"; +import fs from "node:fs/promises"; import { spawnSync } from "node:child_process"; import { writeFile } from "node:fs/promises"; import enquirer from "enquirer"; @@ -304,5 +305,17 @@ export default [\n${exportContent}];`; log.info(`Successfully created ${configPath} file.`); log.warn("You will need to install the dependencies yourself."); } + + if (this.result.installFlags.includes("--force")) { + let message = "Note some plugins currently do not support ESLint v9 yet.\nYou may need to use '--force' when installing"; + + if (packageManager === "npm") { + const pkg = JSON.parse(await fs.readFile(this.packageJsonPath, "utf8")); + + message += `, or add the following to your package.json: \n"overrides": { "eslint": "${pkg.devDependencies.eslint}" } `; + } + + log.warn(message); + } } }