fix(storybook): fix .eslintrc.json being undefined when adding storybook to project (#3851)
This commit is contained in:
parent
ad56f5785a
commit
6fb780e474
@ -1,7 +1,11 @@
|
|||||||
import { Tree } from '@angular-devkit/schematics';
|
import { Tree } from '@angular-devkit/schematics';
|
||||||
import { readJsonInTree, getProjectConfig } from '@nrwl/workspace';
|
import {
|
||||||
|
readJsonInTree,
|
||||||
|
getProjectConfig,
|
||||||
|
updateJsonInTree,
|
||||||
|
} from '@nrwl/workspace';
|
||||||
|
|
||||||
import { createTestUILib, runSchematic } from '../../utils/testing';
|
import { callRule, createTestUILib, runSchematic } from '../../utils/testing';
|
||||||
import { getTsConfigContent, TsConfig } from '../../utils/utils';
|
import { getTsConfigContent, TsConfig } from '../../utils/utils';
|
||||||
import * as fileUtils from '@nrwl/workspace/src/core/file-utils';
|
import * as fileUtils from '@nrwl/workspace/src/core/file-utils';
|
||||||
|
|
||||||
@ -143,4 +147,36 @@ describe('schematic:configuration', () => {
|
|||||||
]
|
]
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should update the project's .eslintrc.json if config exists", async () => {
|
||||||
|
appTree = await createTestUILib('test-ui-lib2', '@nrwl/angular', {
|
||||||
|
linter: 'eslint',
|
||||||
|
});
|
||||||
|
|
||||||
|
appTree = await callRule(
|
||||||
|
updateJsonInTree('libs/test-ui-lib2/.eslintrc.json', (json) => {
|
||||||
|
json.parserOptions = {
|
||||||
|
project: [],
|
||||||
|
};
|
||||||
|
return json;
|
||||||
|
}),
|
||||||
|
appTree
|
||||||
|
);
|
||||||
|
|
||||||
|
const tree = await runSchematic(
|
||||||
|
'configuration',
|
||||||
|
{ name: 'test-ui-lib2' },
|
||||||
|
appTree
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
readJsonInTree(tree, 'libs/test-ui-lib2/.eslintrc.json').parserOptions
|
||||||
|
).toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"project": Array [
|
||||||
|
"libs/test-ui-lib2/.storybook/tsconfig.json",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -241,6 +241,7 @@ function updateLintConfig(schema: StorybookConfigureSchema): Rule {
|
|||||||
`${projectConfig.root}/.storybook/tsconfig.json`
|
`${projectConfig.root}/.storybook/tsconfig.json`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
return json;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -63,13 +63,15 @@ export function runMigration(migrationName: string, options: any, tree: Tree) {
|
|||||||
|
|
||||||
export async function createTestUILib(
|
export async function createTestUILib(
|
||||||
libName: string,
|
libName: string,
|
||||||
collectionName: '@nrwl/angular' | '@nrwl/react'
|
collectionName: '@nrwl/angular' | '@nrwl/react',
|
||||||
|
options: any = {}
|
||||||
): Promise<Tree> {
|
): Promise<Tree> {
|
||||||
let appTree = Tree.empty();
|
let appTree = Tree.empty();
|
||||||
appTree = createEmptyWorkspace(appTree);
|
appTree = createEmptyWorkspace(appTree);
|
||||||
appTree = await callRule(
|
appTree = await callRule(
|
||||||
externalSchematic(collectionName, 'library', {
|
externalSchematic(collectionName, 'library', {
|
||||||
name: libName,
|
name: libName,
|
||||||
|
...options,
|
||||||
}),
|
}),
|
||||||
appTree
|
appTree
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user