Skip to content

Commit

Permalink
fix(nextjs): update migration to handle projects without eslintrc (#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo committed Dec 27, 2023
1 parent 0f04558 commit 9cc72df
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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 update from './remove-eslint-rules-patch';
import { readJson } from '@nx/devkit';

describe('update-nx-next-dependency', () => {
let tree: Tree;
Expand All @@ -11,6 +10,16 @@ describe('update-nx-next-dependency', () => {
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 () => {
tree.write('.eslintrc.json', '{}');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { Tree, formatFiles, getProjects } from '@nx/devkit';
import { updateOverrideInLintConfig } from '@nx/eslint/src/generators/utils/eslint-file';
import { formatFiles, getProjects, Tree } from '@nx/devkit';
import {
isEslintConfigSupported,
updateOverrideInLintConfig,
} from '@nx/eslint/src/generators/utils/eslint-file';

export default async function update(tree: Tree) {
const projects = getProjects(tree);
projects.forEach((project) => {
if (!isEslintConfigSupported(tree, project.root)) return;
updateOverrideInLintConfig(
tree,
project.root,
Expand Down

0 comments on commit 9cc72df

Please sign in to comment.