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 {
|
import {
|
||||||
addDependenciesToPackageJson,
|
addDependenciesToPackageJson,
|
||||||
formatFiles,
|
formatFiles,
|
||||||
|
GeneratorCallback,
|
||||||
getProjects,
|
getProjects,
|
||||||
|
installPackagesTask,
|
||||||
NxJsonConfiguration,
|
NxJsonConfiguration,
|
||||||
ProjectConfiguration,
|
ProjectConfiguration,
|
||||||
readJson,
|
readJson,
|
||||||
@ -17,10 +19,12 @@ import { eslintrcVersion, eslintVersion } from '../../utils/versions';
|
|||||||
import { ESLint } from 'eslint';
|
import { ESLint } from 'eslint';
|
||||||
import { convertEslintJsonToFlatConfig } from './converters/json-converter';
|
import { convertEslintJsonToFlatConfig } from './converters/json-converter';
|
||||||
|
|
||||||
|
let shouldInstallDeps = false;
|
||||||
|
|
||||||
export async function convertToFlatConfigGenerator(
|
export async function convertToFlatConfigGenerator(
|
||||||
tree: Tree,
|
tree: Tree,
|
||||||
options: ConvertToFlatConfigGeneratorSchema
|
options: ConvertToFlatConfigGeneratorSchema
|
||||||
) {
|
): Promise<void | GeneratorCallback> {
|
||||||
const eslintFile = findEslintFile(tree);
|
const eslintFile = findEslintFile(tree);
|
||||||
if (!eslintFile) {
|
if (!eslintFile) {
|
||||||
throw new Error('Could not find root eslint file');
|
throw new Error('Could not find root eslint file');
|
||||||
@ -60,6 +64,10 @@ export async function convertToFlatConfigGenerator(
|
|||||||
if (!options.skipFormat) {
|
if (!options.skipFormat) {
|
||||||
await formatFiles(tree);
|
await formatFiles(tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shouldInstallDeps) {
|
||||||
|
return () => installPackagesTask(tree);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default convertToFlatConfigGenerator;
|
export default convertToFlatConfigGenerator;
|
||||||
@ -215,6 +223,7 @@ function processConvertedConfig(
|
|||||||
|
|
||||||
// add missing packages
|
// add missing packages
|
||||||
if (addESLintRC) {
|
if (addESLintRC) {
|
||||||
|
shouldInstallDeps = true;
|
||||||
addDependenciesToPackageJson(
|
addDependenciesToPackageJson(
|
||||||
tree,
|
tree,
|
||||||
{},
|
{},
|
||||||
@ -224,6 +233,7 @@ function processConvertedConfig(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (addESLintJS) {
|
if (addESLintJS) {
|
||||||
|
shouldInstallDeps = true;
|
||||||
addDependenciesToPackageJson(
|
addDependenciesToPackageJson(
|
||||||
tree,
|
tree,
|
||||||
{},
|
{},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user