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:
parent
829fb32614
commit
aa1b7766c5
@ -18,6 +18,8 @@ describe('ngrx', () => {
|
|||||||
'generate ngrx flights --module=libs/feature-flights/src/lib/feature-flights.module.ts --collection=@nrwl/schematics'
|
'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('build')).toContain('chunk {main} main.js,');
|
||||||
expect(runCLI('test myapp --no-watch')).toContain(
|
expect(runCLI('test myapp --no-watch')).toContain(
|
||||||
'Executed 10 of 10 SUCCESS'
|
'Executed 10 of 10 SUCCESS'
|
||||||
|
|||||||
@ -11,7 +11,7 @@ describe('Upgrade', () => {
|
|||||||
'apps/myapp/src/legacy.js',
|
'apps/myapp/src/legacy.js',
|
||||||
`
|
`
|
||||||
const angular = window.angular.module('legacy', []);
|
const angular = window.angular.module('legacy', []);
|
||||||
angular.component('rootLegacyCmp', {
|
angular.component('proj-root-legacy', {
|
||||||
template: 'Expected Value'
|
template: 'Expected Value'
|
||||||
});
|
});
|
||||||
`
|
`
|
||||||
@ -20,7 +20,7 @@ describe('Upgrade', () => {
|
|||||||
updateFile(
|
updateFile(
|
||||||
'apps/myapp/src/app/app.component.html',
|
'apps/myapp/src/app/app.component.html',
|
||||||
`
|
`
|
||||||
EXPECTED [<rootLegacyCmp></rootLegacyCmp>]
|
EXPECTED [<proj-root-legacy></proj-root-legacy>]
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -28,9 +28,11 @@ describe('Upgrade', () => {
|
|||||||
|
|
||||||
runCLI(
|
runCLI(
|
||||||
'generate upgrade-module legacy --angularJsImport=./legacy ' +
|
'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('build');
|
||||||
runCLI('test --single-run');
|
runCLI('test --single-run');
|
||||||
},
|
},
|
||||||
|
|||||||
@ -26,4 +26,4 @@ export const from<%= className %>Actions = {
|
|||||||
Load<%= className %>,
|
Load<%= className %>,
|
||||||
<%= className %>Loaded,
|
<%= className %>Loaded,
|
||||||
<%= className %>LoadError
|
<%= className %>LoadError
|
||||||
}
|
};
|
||||||
|
|||||||
@ -7,8 +7,10 @@ import { <%= className %>Action, <%= className %>ActionTypes } from './<%= fileN
|
|||||||
*
|
*
|
||||||
* Note: remove if already defined in another module
|
* Note: remove if already defined in another module
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* tslint:disable:no-empty-interface */
|
||||||
export interface <%= className %> {
|
export interface <%= className %> {
|
||||||
}
|
};
|
||||||
|
|
||||||
export interface <%= className %>State {
|
export interface <%= className %>State {
|
||||||
list : <%= className %>[]; // analogous to a sql normalized table
|
list : <%= className %>[]; // analogous to a sql normalized table
|
||||||
|
|||||||
@ -12,7 +12,7 @@ const getAll<%= className %> = createSelector( get<%= className %>State, getLoad
|
|||||||
});
|
});
|
||||||
const getSelectedId = createSelector( get<%= className %>State, (state:<%= className %>State) => state.selectedId );
|
const getSelectedId = createSelector( get<%= className %>State, (state:<%= className %>State) => state.selectedId );
|
||||||
const getSelected<%= className %> = createSelector( getAll<%= className %>, getSelectedId, (<%= propertyName %>, id) => {
|
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;
|
return result ? Object.assign({}, result) : undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -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';
|
import {setAngularJSGlobal, UpgradeComponent, downgradeComponent, UpgradeModule} from '@angular/upgrade/static';
|
||||||
<% if (router) { %>
|
<% if (router) { %>
|
||||||
import {Router} from '@angular/router';
|
import {Router} from '@angular/router';
|
||||||
@ -20,7 +20,10 @@ angular.module('downgraded', []).
|
|||||||
|
|
||||||
<% if (angularJsCmpSelector) { %>
|
<% if (angularJsCmpSelector) { %>
|
||||||
// all components upgraded from AngularJS to Angular go here
|
// all components upgraded from AngularJS to Angular go here
|
||||||
@Directive({selector: '<%= angularJsCmpSelector %>'})
|
@Component({
|
||||||
|
selector: '<%= angularJsCmpSelector %>',
|
||||||
|
template: '',
|
||||||
|
})
|
||||||
export class <%= className %>Component extends UpgradeComponent {
|
export class <%= className %>Component extends UpgradeComponent {
|
||||||
constructor(ref: ElementRef, inj: Injector) {
|
constructor(ref: ElementRef, inj: Injector) {
|
||||||
super('<%= angularJsCmpSelector %>', ref, inj);
|
super('<%= angularJsCmpSelector %>', ref, inj);
|
||||||
|
|||||||
@ -7326,7 +7326,7 @@ run-queue@^1.0.0, run-queue@^1.0.3:
|
|||||||
dependencies:
|
dependencies:
|
||||||
aproba "^1.1.1"
|
aproba "^1.1.1"
|
||||||
|
|
||||||
rxjs-compat@^6.0.0:
|
rxjs-compat@^6.1.0:
|
||||||
version "6.2.2"
|
version "6.2.2"
|
||||||
resolved "https://registry.yarnpkg.com/rxjs-compat/-/rxjs-compat-6.2.2.tgz#3c0fcdb46130cc70aa55412c2b1147905ab4680a"
|
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"
|
version "0.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419"
|
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"
|
version "0.8.26"
|
||||||
resolved "https://registry.yarnpkg.com/zone.js/-/zone.js-0.8.26.tgz#7bdd72f7668c5a7ad6b118148b4ea39c59d08d2d"
|
resolved "https://registry.yarnpkg.com/zone.js/-/zone.js-0.8.26.tgz#7bdd72f7668c5a7ad6b118148b4ea39c59d08d2d"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user