Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cbc755c

Browse files
cyrilletuziclydin
authored andcommittedJun 1, 2020
feat(@schematics/angular): add tslint no-any and typedef rules when in strict mode
1 parent ca42487 commit cbc755c

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed
 

‎packages/schematics/angular/workspace/files/tslint.json.template

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
"instance-method"
4343
]
4444
}
45-
],
45+
],<% if (strict) { %>
46+
"no-any": true,<% } %>
4647
"no-console": [
4748
true,
4849
"debug",
@@ -82,6 +83,7 @@
8283
"named": "never"
8384
}
8485
},
86+
"typedef": [true, "call-signature"],
8587
"typedef-whitespace": {
8688
"options": [
8789
{

‎packages/schematics/angular/workspace/index_spec.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,22 @@ describe('Workspace Schematic', () => {
8181
expect(angularCompilerOptions).toBeUndefined();
8282
});
8383

84-
it('should not add strict compiler options when true', async () => {
84+
it('should add strict compiler options when true', async () => {
8585
const tree = await schematicRunner.runSchematicAsync('workspace', { ...defaultOptions, strict: true }).toPromise();
8686
const { compilerOptions, angularCompilerOptions } = JSON.parse(tree.readContent('/tsconfig.base.json'));
8787
expect(compilerOptions.strict).toBe(true);
8888
expect(angularCompilerOptions.strictTemplates).toBe(true);
8989
});
90+
91+
it('should not add strict lint options when false', async () => {
92+
const tree = await schematicRunner.runSchematicAsync('workspace', { ...defaultOptions, strict: false }).toPromise();
93+
const { rules } = JSON.parse(tree.readContent('/tslint.json'));
94+
expect(rules['no-any']).toBeUndefined();
95+
});
96+
97+
it('should add strict lint options when true', async () => {
98+
const tree = await schematicRunner.runSchematicAsync('workspace', { ...defaultOptions, strict: true }).toPromise();
99+
const { rules } = JSON.parse(tree.readContent('/tslint.json'));
100+
expect(rules['no-any']).toBe(true);
101+
});
90102
});

0 commit comments

Comments
 (0)
Please sign in to comment.