fix(linter): return callback to install deps when running eslint migration to flat config generator (#26323)
<!-- 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` --> ## 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 #
This commit is contained in:
parent
030ede2c95
commit
fbc88f2e6d
@ -1,7 +1,9 @@
|
||||
import {
|
||||
addDependenciesToPackageJson,
|
||||
formatFiles,
|
||||
GeneratorCallback,
|
||||
getProjects,
|
||||
installPackagesTask,
|
||||
NxJsonConfiguration,
|
||||
ProjectConfiguration,
|
||||
readJson,
|
||||
@ -17,10 +19,12 @@ import { eslintrcVersion, eslintVersion } from '../../utils/versions';
|
||||
import { ESLint } from 'eslint';
|
||||
import { convertEslintJsonToFlatConfig } from './converters/json-converter';
|
||||
|
||||
let shouldInstallDeps = false;
|
||||
|
||||
export async function convertToFlatConfigGenerator(
|
||||
tree: Tree,
|
||||
options: ConvertToFlatConfigGeneratorSchema
|
||||
) {
|
||||
): Promise<void | GeneratorCallback> {
|
||||
const eslintFile = findEslintFile(tree);
|
||||
if (!eslintFile) {
|
||||
throw new Error('Could not find root eslint file');
|
||||
@ -60,6 +64,10 @@ export async function convertToFlatConfigGenerator(
|
||||
if (!options.skipFormat) {
|
||||
await formatFiles(tree);
|
||||
}
|
||||
|
||||
if (shouldInstallDeps) {
|
||||
return () => installPackagesTask(tree);
|
||||
}
|
||||
}
|
||||
|
||||
export default convertToFlatConfigGenerator;
|
||||
@ -215,6 +223,7 @@ function processConvertedConfig(
|
||||
|
||||
// add missing packages
|
||||
if (addESLintRC) {
|
||||
shouldInstallDeps = true;
|
||||
addDependenciesToPackageJson(
|
||||
tree,
|
||||
{},
|
||||
@ -224,6 +233,7 @@ function processConvertedConfig(
|
||||
);
|
||||
}
|
||||
if (addESLintJS) {
|
||||
shouldInstallDeps = true;
|
||||
addDependenciesToPackageJson(
|
||||
tree,
|
||||
{},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user