Skip to content

Commit 8ddaf60

Browse files
feat(eslint-plugin): improve install flow (#3447)
1 parent d443f50 commit 8ddaf60

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

modules/eslint-plugin/schematics/ng-add/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"all-requiring-type-checking"
2525
],
2626
"x-prompt": {
27-
"message": "Which config would you like to use?",
27+
"message": "Which ESLint configuration would you like to use?",
2828
"type": "list",
2929
"items": [
3030
{

modules/store/schematics/ng-add/index.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ describe('Store ng-add Schematic', () => {
151151
it('adds the @ngrx/eslint-plugin schematic', async () => {
152152
const options = { ...defaultOptions, skipESLintPlugin: false };
153153

154+
appTree.create('.eslintrc.json', '{}');
155+
154156
await schematicRunner
155157
.runSchematicAsync('ng-add', options, appTree)
156158
.toPromise();

modules/store/schematics/ng-add/index.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,21 @@ function addNgRxStoreToPackageJson() {
120120

121121
function addNgRxESLintPlugin() {
122122
return (host: Tree, context: SchematicContext) => {
123-
addPackageToPackageJson(
124-
host,
125-
'devDependencies',
126-
'@ngrx/eslint-plugin',
127-
platformVersion
128-
);
129-
130-
const installTaskId = context.addTask(new NodePackageInstallTask());
131-
context.addTask(new RunSchematicTask('@ngrx/eslint-plugin', 'ng-add', {}), [
132-
installTaskId,
133-
]);
134-
123+
const eslint = host.read('.eslintrc.json')?.toString('utf-8');
124+
if (eslint) {
125+
addPackageToPackageJson(
126+
host,
127+
'devDependencies',
128+
'@ngrx/eslint-plugin',
129+
platformVersion
130+
);
131+
132+
const installTaskId = context.addTask(new NodePackageInstallTask());
133+
context.addTask(
134+
new RunSchematicTask('@ngrx/eslint-plugin', 'ng-add', {}),
135+
[installTaskId]
136+
);
137+
}
135138
return host;
136139
};
137140
}

0 commit comments

Comments
 (0)