Skip to content

Commit 5986bef

Browse files
alan-agius4filipesilva
authored andcommitted
feat(@schematics/angular): remove deprecated options
With this change we removed several deprecated `@schematics/angular` deprecated options. BREAKING CHANGE: We removed several deprecated `@schematics/angular` deprecated options. - `lintFix` have been removed from all schematics. `ng lint --fix` should be used instead. - `legacyBrowsers` have been removed from the `application` schematics since IE 11 is no longer supported. - `configuration` has been removed from the `web-worker` as it was unused. - `target` has been removed from the `service-worker` as it was unused.
1 parent ac3fc27 commit 5986bef

35 files changed

+141
-236
lines changed

docs/design/analytics.md

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ Note: There's a limit of 20 custom dimensions.
5858
| 12 | `Flag: --skip-tests` | `boolean` |
5959
| 13 | `Flag: --aot` | `boolean` |
6060
| 14 | `Flag: --minimal` | `boolean` |
61-
| 15 | `Flag: --lint-fix` | `boolean` |
6261
| 16 | `Flag: --optimization` | `boolean` |
6362
| 17 | `Flag: --routing` | `boolean` |
6463
| 18 | `Flag: --skip-import` | `boolean` |

packages/angular/pwa/pwa/index_spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ describe('PWA Schematic', () => {
1818
const defaultOptions: PwaOptions = {
1919
project: 'bar',
2020
target: 'build',
21-
configuration: 'production',
2221
title: 'Fake Title',
2322
};
2423

packages/angular/pwa/pwa/schema.json

-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
"description": "The target to apply service worker to.",
1717
"default": "build"
1818
},
19-
"configuration": {
20-
"type": "string",
21-
"description": "The configuration to apply service worker to.",
22-
"default": "production"
23-
},
2419
"title": {
2520
"type": "string",
2621
"description": "The title of the application."

packages/schematics/angular/application/files/.browserslistrc.template

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,4 @@ last 1 Firefox version
1313
last 2 Edge major versions
1414
last 2 Safari major versions
1515
last 2 iOS major versions
16-
Firefox ESR<% if (legacyBrowsers) { %>
17-
IE 11<% } else { %>
18-
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.<% } %>
16+
Firefox ESR

packages/schematics/angular/application/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
2727
import { Schema as ComponentOptions } from '../component/schema';
2828
import { NodeDependencyType, addPackageJsonDependency } from '../utility/dependencies';
2929
import { latestVersions } from '../utility/latest-versions';
30-
import { applyLintFix } from '../utility/lint-fix';
3130
import { relativePathToWorkspaceRoot } from '../utility/paths';
3231
import { validateProjectName } from '../utility/validation';
3332
import { getWorkspace, updateWorkspace } from '../utility/workspace';
@@ -324,7 +323,6 @@ export default function (options: ApplicationOptions): Rule {
324323
MergeStrategy.Overwrite,
325324
),
326325
options.skipPackageJson ? noop() : addDependenciesToPackageJson(options),
327-
options.lintFix ? applyLintFix(appDir) : noop(),
328326
]);
329327
};
330328
}

packages/schematics/angular/application/index_spec.ts

-19
Original file line numberDiff line numberDiff line change
@@ -525,25 +525,6 @@ describe('Application Schematic', () => {
525525
});
526526
});
527527

528-
it(`should add support for IE 11 in '.browserslistrc' when 'legacyBrowsers' is true`, async () => {
529-
const options: ApplicationOptions = { ...defaultOptions, legacyBrowsers: true };
530-
const tree = await schematicRunner
531-
.runSchematicAsync('application', options, workspaceTree)
532-
.toPromise();
533-
const content = tree.readContent('/projects/foo/.browserslistrc');
534-
expect(content).not.toContain('not IE 11');
535-
expect(content).toContain('IE 11');
536-
});
537-
538-
it(`should not add support for IE 11 in '.browserslistrc' when 'legacyBrowsers' is false`, async () => {
539-
const options: ApplicationOptions = { ...defaultOptions, legacyBrowsers: false };
540-
const tree = await schematicRunner
541-
.runSchematicAsync('application', options, workspaceTree)
542-
.toPromise();
543-
const content = tree.readContent('/projects/foo/.browserslistrc');
544-
expect(content).toContain('not IE 11');
545-
});
546-
547528
it(`should create kebab-case project folder names with camelCase project name`, async () => {
548529
const options: ApplicationOptions = { ...defaultOptions, name: 'myCool' };
549530
const tree = await schematicRunner

packages/schematics/angular/application/schema.json

-12
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,11 @@
101101
"type": "boolean",
102102
"default": false
103103
},
104-
"lintFix": {
105-
"type": "boolean",
106-
"description": "Apply lint fixes after generating the application.",
107-
"x-user-analytics": 15,
108-
"x-deprecated": "Use \"ng lint --fix\" directly instead."
109-
},
110104
"strict": {
111105
"description": "Creates an application with stricter bundle budgets settings.",
112106
"type": "boolean",
113107
"default": true,
114108
"x-user-analytics": 7
115-
},
116-
"legacyBrowsers": {
117-
"type": "boolean",
118-
"description": "Add support for legacy browsers like Internet Explorer using differential loading.",
119-
"default": false,
120-
"x-deprecated": "Legacy browsers support is deprecated since version 12. For more information, see https://angular.io/guide/browser-support"
121109
}
122110
},
123111
"required": ["name"]

packages/schematics/angular/class/schema.json

-7
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@
3838
"type": "string",
3939
"description": "Adds a developer-defined type to the filename, in the format \"name.type.ts\".",
4040
"default": ""
41-
},
42-
"lintFix": {
43-
"type": "boolean",
44-
"default": false,
45-
"description": "Apply lint fixes after generating the class.",
46-
"x-user-analytics": 15,
47-
"x-deprecated": "Use \"ng lint --fix\" directly instead."
4841
}
4942
},
5043
"required": ["name"]

packages/schematics/angular/component/index.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import * as ts from '../third_party/github.com/Microsoft/TypeScript/lib/typescri
2626
import { addDeclarationToModule, addExportToModule } from '../utility/ast-utils';
2727
import { InsertChange } from '../utility/change';
2828
import { buildRelativePath, findModuleFromOptions } from '../utility/find-module';
29-
import { applyLintFix } from '../utility/lint-fix';
3029
import { parseName } from '../utility/parse-name';
3130
import { validateHtmlSelector, validateName } from '../utility/validation';
3231
import { buildDefaultPath, getWorkspace } from '../utility/workspace';
@@ -158,10 +157,6 @@ export default function (options: ComponentOptions): Rule {
158157
move(parsedPath.path),
159158
]);
160159

161-
return chain([
162-
addDeclarationToNgModule(options),
163-
mergeWith(templateSource),
164-
options.lintFix ? applyLintFix(options.path) : noop(),
165-
]);
160+
return chain([addDeclarationToNgModule(options), mergeWith(templateSource)]);
166161
};
167162
}

packages/schematics/angular/component/schema.json

-6
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,6 @@
125125
"default": false,
126126
"description": "The declaring NgModule exports this component.",
127127
"x-user-analytics": 19
128-
},
129-
"lintFix": {
130-
"type": "boolean",
131-
"description": "Apply lint fixes after generating the component.",
132-
"x-user-analytics": 15,
133-
"x-deprecated": "Use \"ng lint --fix\" directly instead."
134128
}
135129
},
136130
"required": ["name"]

packages/schematics/angular/directive/index.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import * as ts from '../third_party/github.com/Microsoft/TypeScript/lib/typescri
2424
import { addDeclarationToModule, addExportToModule } from '../utility/ast-utils';
2525
import { InsertChange } from '../utility/change';
2626
import { buildRelativePath, findModuleFromOptions } from '../utility/find-module';
27-
import { applyLintFix } from '../utility/lint-fix';
2827
import { parseName } from '../utility/parse-name';
2928
import { validateHtmlSelector } from '../utility/validation';
3029
import { buildDefaultPath, getWorkspace } from '../utility/workspace';
@@ -136,10 +135,6 @@ export default function (options: DirectiveOptions): Rule {
136135
move(parsedPath.path),
137136
]);
138137

139-
return chain([
140-
addDeclarationToNgModule(options),
141-
mergeWith(templateSource),
142-
options.lintFix ? applyLintFix(options.path) : noop(),
143-
]);
138+
return chain([addDeclarationToNgModule(options), mergeWith(templateSource)]);
144139
};
145140
}

packages/schematics/angular/directive/schema.json

-6
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,6 @@
7474
"default": false,
7575
"description": "The declaring NgModule exports this directive.",
7676
"x-user-analytics": 19
77-
},
78-
"lintFix": {
79-
"type": "boolean",
80-
"description": "Apply lint fixes after generating the directive.",
81-
"x-user-analytics": 15,
82-
"x-deprecated": "Use \"ng lint --fix\" directly instead."
8377
}
8478
},
8579
"required": ["name"]

packages/schematics/angular/enum/schema.json

-6
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@
3131
"type": {
3232
"type": "string",
3333
"description": "Adds a developer-defined type to the filename, in the format \"name.type.ts\"."
34-
},
35-
"lintFix": {
36-
"type": "boolean",
37-
"description": "Apply lint fixes after generating the enum.",
38-
"x-user-analytics": 15,
39-
"x-deprecated": "Use \"ng lint --fix\" directly instead."
4034
}
4135
},
4236
"required": ["name"]

packages/schematics/angular/guard/schema.json

-6
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@
3939
"$source": "projectName"
4040
}
4141
},
42-
"lintFix": {
43-
"type": "boolean",
44-
"description": "Apply lint fixes after generating the guard.",
45-
"x-user-analytics": 15,
46-
"x-deprecated": "Use \"ng lint --fix\" directly instead."
47-
},
4842
"implements": {
4943
"type": "array",
5044
"description": "Specifies which interfaces to implement.",

packages/schematics/angular/interceptor/schema.json

-6
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@
3838
"description": "Do not create \"spec.ts\" test files for the new interceptor.",
3939
"default": false,
4040
"x-user-analytics": 12
41-
},
42-
"lintFix": {
43-
"type": "boolean",
44-
"description": "Apply lint fixes after generating the interceptor.",
45-
"x-user-analytics": 15,
46-
"x-deprecated": "Use \"ng lint --fix\" directly instead."
4741
}
4842
},
4943
"required": ["name"]

packages/schematics/angular/interface/schema.json

-6
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@
4040
"$source": "argv",
4141
"index": 1
4242
}
43-
},
44-
"lintFix": {
45-
"type": "boolean",
46-
"description": "Apply lint fixes after generating the interface.",
47-
"x-user-analytics": 15,
48-
"x-deprecated": "Use \"ng lint --fix\" directly instead."
4943
}
5044
},
5145
"required": ["name"]

packages/schematics/angular/library/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
2525
import { NodeDependencyType, addPackageJsonDependency } from '../utility/dependencies';
2626
import { JSONFile } from '../utility/json-file';
2727
import { latestVersions } from '../utility/latest-versions';
28-
import { applyLintFix } from '../utility/lint-fix';
2928
import { relativePathToWorkspaceRoot } from '../utility/paths';
3029
import { validateProjectName } from '../utility/validation';
3130
import { getWorkspace, updateWorkspace } from '../utility/workspace';
@@ -197,7 +196,6 @@ export default function (options: LibraryOptions): Rule {
197196
path: sourceDir,
198197
project: projectName,
199198
}),
200-
options.lintFix ? applyLintFix(sourceDir) : noop(),
201199
(_tree: Tree, context: SchematicContext) => {
202200
if (!options.skipPackageJson && !options.skipInstall) {
203201
context.addTask(new NodePackageInstallTask());

packages/schematics/angular/library/schema.json

-6
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@
4343
"type": "boolean",
4444
"default": false,
4545
"description": "Do not update \"tsconfig.json\" to add a path mapping for the new library. The path mapping is needed to use the library in an app, but can be disabled here to simplify development."
46-
},
47-
"lintFix": {
48-
"type": "boolean",
49-
"description": "Apply lint fixes after generating the library.",
50-
"x-user-analytics": 15,
51-
"x-deprecated": "Use \"ng lint --fix\" directly instead."
5246
}
5347
},
5448
"required": []

packages/schematics/angular/migrations/migration-collection.json

+5
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@
129129
"version": "9999.0.0",
130130
"factory": "./update-12/production-default-config",
131131
"description": "Optional migration to update Angular CLI workspace configurations to 'production' mode by default."
132+
},
133+
"schematic-options-13": {
134+
"version": "13.0.0",
135+
"factory": "./update-13/schematic-options",
136+
"description": "Remove no longer valid Angular schematic options from `angular.json`."
132137
}
133138
}
134139
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import { json } from '@angular-devkit/core';
10+
import { Rule } from '@angular-devkit/schematics';
11+
import { updateWorkspace } from '../../utility/workspace';
12+
13+
export default function (): Rule {
14+
return updateWorkspace((workspace) => {
15+
// Update root level schematics options if present
16+
const rootSchematics = workspace.extensions.schematics;
17+
if (rootSchematics && json.isJsonObject(rootSchematics)) {
18+
updateSchematicsField(rootSchematics);
19+
}
20+
21+
// Update project level schematics options if present
22+
for (const [, project] of workspace.projects) {
23+
const projectSchematics = project.extensions.schematics;
24+
if (projectSchematics && json.isJsonObject(projectSchematics)) {
25+
updateSchematicsField(projectSchematics);
26+
}
27+
}
28+
});
29+
}
30+
31+
function updateSchematicsField(schematics: json.JsonObject): void {
32+
for (const [schematicName, schematicOptions] of Object.entries(schematics)) {
33+
if (!json.isJsonObject(schematicOptions)) {
34+
continue;
35+
}
36+
37+
if (schematicName.startsWith('@schematics/angular')) {
38+
delete schematicOptions.lintFix;
39+
}
40+
41+
switch (schematicName) {
42+
case '@schematics/angular:service-worker':
43+
delete schematicOptions.configuration;
44+
break;
45+
case '@schematics/angular:web-worker':
46+
delete schematicOptions.target;
47+
break;
48+
case '@schematics/angular:application':
49+
delete schematicOptions.legacyBrowsers;
50+
break;
51+
default:
52+
break;
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)