Skip to content

Commit

Permalink
feat(@schematics/angular): add tslint no-any and typedef rules when i…
Browse files Browse the repository at this point in the history
…n strict mode
  • Loading branch information
cyrilletuzi authored and clydin committed Jun 1, 2020
1 parent ca42487 commit cbc755c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"instance-method"
]
}
],
],<% if (strict) { %>
"no-any": true,<% } %>
"no-console": [
true,
"debug",
Expand Down Expand Up @@ -82,6 +83,7 @@
"named": "never"
}
},
"typedef": [true, "call-signature"],
"typedef-whitespace": {
"options": [
{
Expand Down
14 changes: 13 additions & 1 deletion packages/schematics/angular/workspace/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,22 @@ describe('Workspace Schematic', () => {
expect(angularCompilerOptions).toBeUndefined();
});

it('should not add strict compiler options when true', async () => {
it('should add strict compiler options when true', async () => {
const tree = await schematicRunner.runSchematicAsync('workspace', { ...defaultOptions, strict: true }).toPromise();
const { compilerOptions, angularCompilerOptions } = JSON.parse(tree.readContent('/tsconfig.base.json'));
expect(compilerOptions.strict).toBe(true);
expect(angularCompilerOptions.strictTemplates).toBe(true);
});

it('should not add strict lint options when false', async () => {
const tree = await schematicRunner.runSchematicAsync('workspace', { ...defaultOptions, strict: false }).toPromise();
const { rules } = JSON.parse(tree.readContent('/tslint.json'));
expect(rules['no-any']).toBeUndefined();
});

it('should add strict lint options when true', async () => {
const tree = await schematicRunner.runSchematicAsync('workspace', { ...defaultOptions, strict: true }).toPromise();
const { rules } = JSON.parse(tree.readContent('/tslint.json'));
expect(rules['no-any']).toBe(true);
});
});

0 comments on commit cbc755c

Please sign in to comment.