fix(linter): handle eslint flat config path correctly in lint executor (#26687)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #26424
Fixes #26586 
Fixes #26532
This commit is contained in:
Leosvel Pérez Espinosa 2024-06-26 16:19:35 +02:00 committed by GitHub
parent 6528da3bd8
commit 7ba49ffc41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,7 +2,7 @@ import { joinPathFragments, type ExecutorContext } from '@nx/devkit';
import type { ESLint } from 'eslint'; import type { ESLint } from 'eslint';
import { mkdirSync, writeFileSync } from 'fs'; import { mkdirSync, writeFileSync } from 'fs';
import { interpolate } from 'nx/src/tasks-runner/utils'; import { interpolate } from 'nx/src/tasks-runner/utils';
import { dirname, posix, resolve } from 'path'; import { dirname, posix, relative, resolve } from 'path';
import { findFlatConfigFile, findOldConfigFile } from '../../utils/config-file'; import { findFlatConfigFile, findOldConfigFile } from '../../utils/config-file';
import type { Schema } from './schema'; import type { Schema } from './schema';
import { resolveAndInstantiateESLint } from './utility/eslint-utils'; import { resolveAndInstantiateESLint } from './utility/eslint-utils';
@ -45,10 +45,7 @@ export default async function run(
// the flat config would be resolved starting from the cwd, which we changed to the workspace root // the flat config would be resolved starting from the cwd, which we changed to the workspace root
// so we explicitly set the config path to the flat config file path we previously found // so we explicitly set the config path to the flat config file path we previously found
if (hasFlatConfig && !normalizedOptions.eslintConfig) { if (hasFlatConfig && !normalizedOptions.eslintConfig) {
normalizedOptions.eslintConfig = posix.relative( normalizedOptions.eslintConfig = relative(systemRoot, flatConfigFilePath);
systemRoot,
flatConfigFilePath
);
} }
/** /**