Skip to content

Commit

Permalink
feature: @putout/eslint: change the way of config search
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Dec 11, 2024
1 parent 948f1a2 commit 9d5d45e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion packages/eslint/lib/eslint.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const {join} = require('node:path');
const process = require('node:process');
const tryToCatch = require('try-to-catch');

Expand All @@ -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;
Expand Down Expand Up @@ -161,3 +165,10 @@ function parseError(e) {
message: `Plugin missing: ${messageData.pluginName}`,
};
}

function parseOverride(dir, configFilePath) {
if (!configFilePath)
return configFilePath;

return join(dir, configFilePath);
}
2 changes: 1 addition & 1 deletion packages/eslint/lib/eslint.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down

0 comments on commit 9d5d45e

Please sign in to comment.