Skip to content

Commit

Permalink
fix(linter): handle eslint flat config path correctly in lint executor (
Browse files Browse the repository at this point in the history
#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

(cherry picked from commit 7ba49ff)
  • Loading branch information
leosvelperez authored and FrozenPandaz committed Jun 26, 2024
1 parent 5818942 commit 3abd352
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/eslint/src/executors/lint/lint.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { joinPathFragments, type ExecutorContext } from '@nx/devkit';
import type { ESLint } from 'eslint';
import { mkdirSync, writeFileSync } from 'fs';
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 type { Schema } from './schema';
import { resolveAndInstantiateESLint } from './utility/eslint-utils';
Expand Down Expand Up @@ -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
// so we explicitly set the config path to the flat config file path we previously found
if (hasFlatConfig && !normalizedOptions.eslintConfig) {
normalizedOptions.eslintConfig = posix.relative(
systemRoot,
flatConfigFilePath
);
normalizedOptions.eslintConfig = relative(systemRoot, flatConfigFilePath);
}

/**
Expand Down

0 comments on commit 3abd352

Please sign in to comment.