From 9d5d45e745c3cdaa50d75547fea64d31c36d8aea Mon Sep 17 00:00:00 2001 From: coderiaser Date: Wed, 11 Dec 2024 18:11:40 +0200 Subject: [PATCH] feature: @putout/eslint: change the way of config search --- packages/eslint/lib/eslint.js | 13 ++++++++++++- packages/eslint/lib/eslint.spec.js | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/eslint/lib/eslint.js b/packages/eslint/lib/eslint.js index 2f14c4cca..a1a636212 100644 --- a/packages/eslint/lib/eslint.js +++ b/packages/eslint/lib/eslint.js @@ -1,5 +1,6 @@ 'use strict'; +const {join} = require('node:path'); const process = require('node:process'); const tryToCatch = require('try-to-catch'); @@ -9,9 +10,12 @@ const {isIgnored} = require('./ignore'); const {keys} = Object; const eslintId = ' (eslint)'; -const overrideConfigFile = process.env.ESLINT_CONFIG_FILE; const noESLint = process.env.NO_ESLINT; const noESLintWarnings = process.env.NO_ESLINT_WARNINGS; +const {ESLINT_CONFIG_FILE} = process.env; + +const dir = process.cwd(); +const overrideConfigFile = parseOverride(dir, ESLINT_CONFIG_FILE); const NO_FLAT_CONFIG_FOUND = 'Could not find config file.'; const WARNING = 1; @@ -161,3 +165,10 @@ function parseError(e) { message: `Plugin missing: ${messageData.pluginName}`, }; } + +function parseOverride(dir, configFilePath) { + if (!configFilePath) + return configFilePath; + + return join(dir, configFilePath); +} diff --git a/packages/eslint/lib/eslint.spec.js b/packages/eslint/lib/eslint.spec.js index 8daa37d62..67925d60f 100644 --- a/packages/eslint/lib/eslint.spec.js +++ b/packages/eslint/lib/eslint.spec.js @@ -383,7 +383,7 @@ test('putout: eslint: convertToPlace: control sequences', async (t) => { }); test('putout: eslint: get-eslint: config file', async (t) => { - process.env.ESLINT_CONFIG_FILE = 'hello.js'; + process.env.ESLINT_CONFIG_FILE = 'abcdef.js'; const eslint = reRequire('./eslint.js');