fix(core): remove .eslintrc double extends update on move (#6765)

* fix(core): remove eslintrc double extends update on move

* fix(core): move eslintrc move logic back to eslint update
This commit is contained in:
Miroslav Jonaš 2021-08-20 08:56:56 +02:00 committed by GitHub
parent 81d36ee737
commit 3b2f0b64ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

@ -65,6 +65,35 @@ describe('updateEslint', () => {
);
});
it('should update .eslintrc.json extends path when project is moved from subdirectory', async () => {
await libraryGenerator(tree, {
name: 'test',
directory: 'api',
linter: Linter.EsLint,
standaloneConfig: false,
});
// This step is usually handled elsewhere
tree.rename('libs/api/test/.eslintrc.json', 'libs/test/.eslintrc.json');
const projectConfig = readProjectConfiguration(tree, 'api-test');
const newSchema = {
projectName: 'api-test',
destination: 'test',
importPath: '@proj/test',
updateImportPath: true,
newProjectName: 'test',
relativeToRootDestination: 'libs/test',
};
updateEslintrcJson(tree, newSchema, projectConfig);
expect(readJson(tree, '/libs/test/.eslintrc.json')).toEqual(
expect.objectContaining({
extends: ['../../.eslintrc.json'],
})
);
});
it('should preserve .eslintrc.json non-relative extends when project is moved to subdirectory', async () => {
await libraryGenerator(tree, {
name: 'my-lib',

View File

@ -40,6 +40,9 @@ export function updateProjectRootFiles(
if (!extname(file).startsWith('.js')) {
continue;
}
if (file === '.eslintrc.json') {
continue;
}
const oldContent = tree.read(
join(schema.relativeToRootDestination, file),