Skip to content

Commit

Permalink
remove the redundant skipRuntimeCheck flag
Browse files Browse the repository at this point in the history
  • Loading branch information
itayod committed Jul 1, 2019
1 parent 58f4fd3 commit 0f384b0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 34 deletions.
13 changes: 0 additions & 13 deletions modules/schematics/src/store/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ describe('Store Schematic', () => {
module: undefined,
flat: false,
root: true,
skipRuntimeCheck: false,
};

const projectPath = getTestProjectPath();
Expand Down Expand Up @@ -249,16 +248,4 @@ describe('Store Schematic', () => {
expect(content).toMatch(/strictStateImmutability: true,/);
expect(content).toMatch(/strictActionImmutability: true/);
});

it('should not add store runtime checks', () => {
const options = {
...defaultOptions,
module: 'app.module.ts',
skipRuntimeCheck: true,
};

const tree = schematicRunner.runSchematic('store', options, appTree);
const content = tree.readContent(`${projectPath}/src/app/app.module.ts`);
expect(content).not.toMatch(/, runtimeChecks: {/);
});
});
18 changes: 6 additions & 12 deletions modules/schematics/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ import {
} from '@ngrx/schematics/schematics-core';
import { Schema as StoreOptions } from './schema';

function addRuntimeChecks(skipRuntimeChecks?: boolean) {
return skipRuntimeChecks
? ''
: `, runtimeChecks: {
strictStateImmutability: true,
strictActionImmutability: true
}`;
}

function addImportToNgModule(options: StoreOptions): Rule {
return (host: Tree) => {
const modulePath = options.module;
Expand Down Expand Up @@ -70,13 +61,16 @@ function addImportToNgModule(options: StoreOptions): Rule {
`${options.path}/environments/environment`
);

const runtimeChecks = `runtimeChecks: {
strictStateImmutability: true,
strictActionImmutability: true,
}`;

const storeNgModuleImport = addImportToModule(
source,
modulePath,
options.root
? `StoreModule.forRoot(reducers, { metaReducers${addRuntimeChecks(
options.skipRuntimeCheck
)} })`
? `StoreModule.forRoot(reducers, { metaReducers, ${runtimeChecks} })`
: `StoreModule.forFeature('${stringUtils.camelize(
options.name
)}', from${stringUtils.classify(
Expand Down
5 changes: 0 additions & 5 deletions modules/schematics/src/store/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@
"default": "State",
"description": "Specifies the interface for the state.",
"alias": "si"
},
"skipRuntimeCheck": {
"type": "boolean",
"default": false,
"description": "Flag to skip the store runtime checks"
}
},
"required": []
Expand Down
4 changes: 0 additions & 4 deletions modules/schematics/src/store/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,4 @@ export interface Schema {
* Specifies the interface for the state
*/
stateInterface?: string;
/**
* Flag to skip the store runtime checks
*/
skipRuntimeCheck?: boolean;
}

0 comments on commit 0f384b0

Please sign in to comment.