fix(nextjs): update migration to handle projects without eslintrc (#20932)
This commit is contained in:
parent
cbb26cb368
commit
d1a2d455a0
@ -1,8 +1,7 @@
|
|||||||
import { Tree, addProjectConfiguration, writeJson } from '@nx/devkit';
|
import { addProjectConfiguration, readJson, Tree, writeJson } from '@nx/devkit';
|
||||||
import { createTreeWithEmptyWorkspace } from 'nx/src/devkit-testing-exports';
|
import { createTreeWithEmptyWorkspace } from 'nx/src/devkit-testing-exports';
|
||||||
|
|
||||||
import update from './remove-eslint-rules-patch';
|
import update from './remove-eslint-rules-patch';
|
||||||
import { readJson } from '@nx/devkit';
|
|
||||||
|
|
||||||
describe('update-nx-next-dependency', () => {
|
describe('update-nx-next-dependency', () => {
|
||||||
let tree: Tree;
|
let tree: Tree;
|
||||||
@ -11,6 +10,16 @@ describe('update-nx-next-dependency', () => {
|
|||||||
tree = createTreeWithEmptyWorkspace();
|
tree = createTreeWithEmptyWorkspace();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle projects without eslintrc file', async () => {
|
||||||
|
tree.write('.eslintrc.json', '{}');
|
||||||
|
|
||||||
|
addProjectConfiguration(tree, 'my-pkg', {
|
||||||
|
root: 'packages/my-pkg',
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(update(tree)).resolves.not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
it('should remove @next/next/no-html-link-for-pages in json configs', async () => {
|
it('should remove @next/next/no-html-link-for-pages in json configs', async () => {
|
||||||
tree.write('.eslintrc.json', '{}');
|
tree.write('.eslintrc.json', '{}');
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,13 @@
|
|||||||
import { Tree, formatFiles, getProjects } from '@nx/devkit';
|
import { formatFiles, getProjects, Tree } from '@nx/devkit';
|
||||||
import { updateOverrideInLintConfig } from '@nx/eslint/src/generators/utils/eslint-file';
|
import {
|
||||||
|
isEslintConfigSupported,
|
||||||
|
updateOverrideInLintConfig,
|
||||||
|
} from '@nx/eslint/src/generators/utils/eslint-file';
|
||||||
|
|
||||||
export default async function update(tree: Tree) {
|
export default async function update(tree: Tree) {
|
||||||
const projects = getProjects(tree);
|
const projects = getProjects(tree);
|
||||||
projects.forEach((project) => {
|
projects.forEach((project) => {
|
||||||
|
if (!isEslintConfigSupported(tree, project.root)) return;
|
||||||
updateOverrideInLintConfig(
|
updateOverrideInLintConfig(
|
||||||
tree,
|
tree,
|
||||||
project.root,
|
project.root,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user