Skip to content

Commit

Permalink
feat(@schematics/angular): don't generate special package.json and …
Browse files Browse the repository at this point in the history
…`no-any` when using `--strict`

Following feedback from the community, which showed a high number of users found it hard to work with the `no-any` lint rule and also the `sideEffects` package.json file. With DevRel we decided to remove both features when generating a strict workspace and/or application.
  • Loading branch information
alan-agius4 committed Sep 30, 2020
1 parent 4e80c00 commit ae73e44
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 42 deletions.
17 changes: 0 additions & 17 deletions packages/schematics/angular/application/index_spec.ts
Expand Up @@ -289,23 +289,6 @@ describe('Application Schematic', () => {
});
});

it('sideEffects property should be true when strict mode', async () => {
const options = { ...defaultOptions, projectRoot: '', strict: true };

const tree = await schematicRunner.runSchematicAsync('application', options, workspaceTree)
.toPromise();
const content = JSON.parse(tree.readContent('/src/app/package.json'));
expect(content.sideEffects).toBe(false);
});

it('sideEffects package.json should not exist when not in strict mode', async () => {
const options = { ...defaultOptions, projectRoot: '', strict: false };

const tree = await schematicRunner.runSchematicAsync('application', options, workspaceTree)
.toPromise();
expect(tree.exists('/src/app/package.json')).toBeFalse();
});

describe('custom projectRoot', () => {
it('should put app files in the right spot', async () => {
const options = { ...defaultOptions, projectRoot: '' };
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion packages/schematics/angular/application/schema.json
Expand Up @@ -107,7 +107,7 @@
"x-user-analytics": 15
},
"strict": {
"description": "Creates an application with stricter build optimization options.",
"description": "Creates an application with stricter bundle budgets settings.",
"type": "boolean",
"default": false
},
Expand Down
2 changes: 1 addition & 1 deletion packages/schematics/angular/ng-new/schema.json
Expand Up @@ -129,7 +129,7 @@
"x-user-analytics": 14
},
"strict": {
"description": "Creates a workspace with stricter type checking and build optimization options.",
"description": "Creates a workspace with stricter type checking and stricter bundle budgets settings.",
"type": "boolean",
"default": false
},
Expand Down
Expand Up @@ -42,8 +42,7 @@
"instance-method"
]
}
],<% if (strict) { %>
"no-any": true,<% } %>
],
"no-console": [
true,
"debug",
Expand Down
12 changes: 0 additions & 12 deletions packages/schematics/angular/workspace/index_spec.ts
Expand Up @@ -90,16 +90,4 @@ describe('Workspace Schematic', () => {
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 ae73e44

Please sign in to comment.