fix(ngrx): fix lint issues in schematic templates

The ngrx schematic templates have some minor lint errors that manfiest in new ngrx generated code.

*  In the ngrx e2e tests, add check for tsLint errors in the generated code
*  Fix lint issues for the upgrade-module and associated tests.
This commit is contained in:
Thomas Burleson 2018-07-27 10:59:05 -05:00 committed by Victor Savkin
parent 829fb32614
commit aa1b7766c5
7 changed files with 19 additions and 10 deletions

View File

@ -18,6 +18,8 @@ describe('ngrx', () => {
'generate ngrx flights --module=libs/feature-flights/src/lib/feature-flights.module.ts --collection=@nrwl/schematics'
);
expect(runCLI('lint', { silenceError: true })).not.toContain('ERROR');
expect(runCLI('build')).toContain('chunk {main} main.js,');
expect(runCLI('test myapp --no-watch')).toContain(
'Executed 10 of 10 SUCCESS'

View File

@ -11,7 +11,7 @@ describe('Upgrade', () => {
'apps/myapp/src/legacy.js',
`
const angular = window.angular.module('legacy', []);
angular.component('rootLegacyCmp', {
angular.component('proj-root-legacy', {
template: 'Expected Value'
});
`
@ -20,7 +20,7 @@ describe('Upgrade', () => {
updateFile(
'apps/myapp/src/app/app.component.html',
`
EXPECTED [<rootLegacyCmp></rootLegacyCmp>]
EXPECTED [<proj-root-legacy></proj-root-legacy>]
`
);
@ -28,9 +28,11 @@ describe('Upgrade', () => {
runCLI(
'generate upgrade-module legacy --angularJsImport=./legacy ' +
'--angularJsCmpSelector=rootLegacyCmp --project=myapp'
'--angularJsCmpSelector=proj-root-legacy --project=myapp'
);
expect(runCLI('lint', { silenceError: true })).not.toContain('ERROR');
runCLI('build');
runCLI('test --single-run');
},

View File

@ -26,4 +26,4 @@ export const from<%= className %>Actions = {
Load<%= className %>,
<%= className %>Loaded,
<%= className %>LoadError
}
};

View File

@ -7,8 +7,10 @@ import { <%= className %>Action, <%= className %>ActionTypes } from './<%= fileN
*
* Note: remove if already defined in another module
*/
/* tslint:disable:no-empty-interface */
export interface <%= className %> {
}
};
export interface <%= className %>State {
list : <%= className %>[]; // analogous to a sql normalized table

View File

@ -12,7 +12,7 @@ const getAll<%= className %> = createSelector( get<%= className %>State, getLoad
});
const getSelectedId = createSelector( get<%= className %>State, (state:<%= className %>State) => state.selectedId );
const getSelected<%= className %> = createSelector( getAll<%= className %>, getSelectedId, (<%= propertyName %>, id) => {
let result = <%= propertyName %>.find(<%= propertyName %> => <%= propertyName %>['id'] == id);
const result = <%= propertyName %>.find(it => it['id'] === id);
return result ? Object.assign({}, result) : undefined;
});

View File

@ -1,4 +1,4 @@
import {Directive, ElementRef, Injector} from '@angular/core';
import {Component, ElementRef, Injector} from '@angular/core';
import {setAngularJSGlobal, UpgradeComponent, downgradeComponent, UpgradeModule} from '@angular/upgrade/static';
<% if (router) { %>
import {Router} from '@angular/router';
@ -20,7 +20,10 @@ angular.module('downgraded', []).
<% if (angularJsCmpSelector) { %>
// all components upgraded from AngularJS to Angular go here
@Directive({selector: '<%= angularJsCmpSelector %>'})
@Component({
selector: '<%= angularJsCmpSelector %>',
template: '',
})
export class <%= className %>Component extends UpgradeComponent {
constructor(ref: ElementRef, inj: Injector) {
super('<%= angularJsCmpSelector %>', ref, inj);

View File

@ -7326,7 +7326,7 @@ run-queue@^1.0.0, run-queue@^1.0.3:
dependencies:
aproba "^1.1.1"
rxjs-compat@^6.0.0:
rxjs-compat@^6.1.0:
version "6.2.2"
resolved "https://registry.yarnpkg.com/rxjs-compat/-/rxjs-compat-6.2.2.tgz#3c0fcdb46130cc70aa55412c2b1147905ab4680a"
@ -9095,6 +9095,6 @@ yeast@0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419"
zone.js@^0.8.19:
zone.js@^0.8.26:
version "0.8.26"
resolved "https://registry.yarnpkg.com/zone.js/-/zone.js-0.8.26.tgz#7bdd72f7668c5a7ad6b118148b4ea39c59d08d2d"