Skip to content

Commit

Permalink
fix(core): update move generator to move multiple projects in eslint …
Browse files Browse the repository at this point in the history
…parserOptions override (#10775)

move generator now copies over all projects in the parserOptions of the .eslintrc.json rather than
just overriding with the base tsconfigs

ISSUES CLOSED: #10774
  • Loading branch information
jackmorrison12 committed Jun 16, 2022
1 parent 8cae2c9 commit a0f5b7c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,48 @@ describe('updateEslint', () => {
})
);
});

it('should update multiple .eslintrc.json overrides parser project when project is moved', async () => {
await libraryGenerator(tree, {
name: 'my-lib',
linter: Linter.EsLint,
setParserOptionsProject: true,
standaloneConfig: false,
});

// Add another parser project to eslint.json
const storybookProject = '.storybook/tsconfig.json';
updateJson(tree, '/libs/my-lib/.eslintrc.json', (eslintRcJson) => {
eslintRcJson.overrides[0].parserOptions.project.push(
`libs/my-lib/${storybookProject}`
);
return eslintRcJson;
});

// This step is usually handled elsewhere
tree.rename(
'libs/my-lib/.eslintrc.json',
'libs/shared/my-destination/.eslintrc.json'
);
const projectConfig = readProjectConfiguration(tree, 'my-lib');

updateEslintrcJson(tree, schema, projectConfig);

expect(
readJson(tree, '/libs/shared/my-destination/.eslintrc.json')
).toEqual(
expect.objectContaining({
overrides: expect.arrayContaining([
expect.objectContaining({
parserOptions: expect.objectContaining({
project: [
'libs/shared/my-destination/tsconfig.*?.json',
`libs/shared/my-destination/${storybookProject}`,
],
}),
}),
]),
})
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { NormalizedSchema } from '../schema';

interface PartialEsLintrcOverride {
parserOptions?: {
project?: [string];
project?: string[];
};
}

Expand Down Expand Up @@ -65,9 +65,9 @@ export function updateEslintrcJson(

eslintRcJson.overrides?.forEach((o) => {
if (o.parserOptions?.project) {
o.parserOptions.project = [
`${schema.relativeToRootDestination}/tsconfig.*?.json`,
];
o.parserOptions.project = o.parserOptions.project.map((p) =>
p.replace(project.root, schema.relativeToRootDestination)
);
}
});

Expand Down

1 comment on commit a0f5b7c

@vercel
Copy link

@vercel vercel bot commented on a0f5b7c Jun 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx.dev
nx-dev-nrwl.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app

Please sign in to comment.