Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eslint-plugin): improve install flow #3447

Merged
merged 1 commit into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/eslint-plugin/schematics/ng-add/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"all-requiring-type-checking"
],
"x-prompt": {
"message": "Which config would you like to use?",
"message": "Which ESLint configuration would you like to use?",
"type": "list",
"items": [
{
Expand Down
2 changes: 2 additions & 0 deletions modules/store/schematics/ng-add/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ describe('Store ng-add Schematic', () => {
it('adds the @ngrx/eslint-plugin schematic', async () => {
const options = { ...defaultOptions, skipESLintPlugin: false };

appTree.create('.eslintrc.json', '{}');

await schematicRunner
.runSchematicAsync('ng-add', options, appTree)
.toPromise();
Expand Down
27 changes: 15 additions & 12 deletions modules/store/schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,21 @@ function addNgRxStoreToPackageJson() {

function addNgRxESLintPlugin() {
return (host: Tree, context: SchematicContext) => {
addPackageToPackageJson(
host,
'devDependencies',
'@ngrx/eslint-plugin',
platformVersion
);

const installTaskId = context.addTask(new NodePackageInstallTask());
context.addTask(new RunSchematicTask('@ngrx/eslint-plugin', 'ng-add', {}), [
installTaskId,
]);

const eslint = host.read('.eslintrc.json')?.toString('utf-8');
if (eslint) {
addPackageToPackageJson(
host,
'devDependencies',
'@ngrx/eslint-plugin',
platformVersion
);

const installTaskId = context.addTask(new NodePackageInstallTask());
context.addTask(
new RunSchematicTask('@ngrx/eslint-plugin', 'ng-add', {}),
[installTaskId]
);
}
return host;
};
}
Expand Down