17 Commits

Author SHA1 Message Date
Kristiyan Kostadinov
190fa07b9a feat(router): add migration for ActivatedRouteSnapshot.fragment ()
Adds a migration that casts the value of `ActivatedRouteSnapshot.fragment` to be non-nullable.

Also moves some code from the `AbstractControl.parent` migration so that it can be reused.

Relates to .

PR Close 
2021-03-23 11:18:00 -07:00
Andrew Scott
805b4f936b feat(core): Add schematic to fix invalid Route configs ()
`Route` configs with `redirectTo` as well as `canActivate` are not valid
because the `canActivate` guards will never execute. Redirects are
applied before activation. There is no error currently for these
configs, but another commit will change this so that an error does
appear in dev mode. This migration fixes the configs by removing the
`canActivate` property.

PR Close 
2021-01-05 10:09:28 -08:00
Kristiyan Kostadinov
1a26f6da6e fix(core): migration error if program contains files outside of the project ()
Currently all of our migrations are set up to find the tsconfig paths within a project,
create a `Program` out of each and migrate the files inside of the `Program`. The
problem is that the `Program` can include files outside of the project and the CLI
APIs that we use to interact with the file system assume that all files are within
the project.

These changes consolidate the logic, that determines whether a file can be migrated,
in a single place and add an extra check to exclude files outside of the root.

Fixes .

PR Close 
2020-11-20 12:51:19 -08:00
Adam Plumer
0ec7043490 feat(core): add initialNavigation schematic ()
Add a schematic to update users to the new v11 `initialNavigation`
options for `RouterModule`. This replaces the deprecated/removed
`true`, `false`, `legacy_disabled`, and `legacy_enabled` options
with the newer `enabledBlocking` and `enabledNonBlocking` options.

PR Close 
2020-10-14 12:01:07 -07:00
Kristiyan Kostadinov
5ce71e0fbc feat(core): add automated migration to replace async with waitForAsync ()
Adds a migration that finds all imports and calls to the deprecated `async` function from
`@angular/core/testing` and replaces them with `waitForAsync`.

These changes also move a bit of code out of the `Renderer2` migration so that it can be reused.

PR Close 
2020-10-13 09:55:34 -07:00
Andrew Scott
15ea811f05 feat(router): Add relativeLinkResolution migration to update default value ()
The default value for `relativeLinkResolution` is changing from 'legacy' to 'corrected'.
This migration updates `RouterModule` configurations that use the default value to
now specifically use 'legacy' to prevent breakages when updating.

PR Close 
2020-09-23 15:45:37 -04:00
Kristiyan Kostadinov
7849fdde09 feat(router): add migration to update calls to navigateByUrl and createUrlTree with invalid parameters ()
In  the signatures of `navigateByUrl` and `createUrlTree` were updated to exclude unsupported
properties from their `extras` parameter. This migration looks for the relevant method calls that
pass in an `extras` parameter and drops the unsupported properties.

**Before:**
```
this._router.navigateByUrl('/', {skipLocationChange: false, fragment: 'foo'});
```

**After:**
```
this._router.navigateByUrl('/', {
  /* Removed unsupported properties by Angular migration: fragment. */
  skipLocationChange: false
});
```

These changes also move the method call detection logic out of the `Renderer2` migration and into
a common place so that it can be reused in other migrations.

PR Close 
2020-09-16 15:16:18 -07:00
Joey Perrott
d1ea1f4c7f build: update license headers to reference Google LLC ()
Update the license headers throughout the repository to reference Google LLC
rather than Google Inc, for the required license headers.

PR Close 
2020-05-26 14:26:58 -04:00
Joey Perrott
698b0288be build: reformat repo to new clang@1.4.0 ()
PR Close 
2020-04-14 12:08:36 -07:00
Paul Gschwendtner
32eafef6a7 fix(core): undecorated-classes-with-decorated-fields migration does not decorate derived classes ()
The `undecorated-classes-with-decorated-fields` migration has been
introduced with 904a2018e0d3394ad91ffb6472f8271af7845295, but misses
logic for decorating derived classes of undecorated classes which use
Angular features. Example scenario:

```ts
export abstract class MyBaseClass {
  @Input() someInput = true;
}

export abstract class BaseClassTwo extends MyBaseClass {}

@Component(...)
export class MyButton extends BaseClassTwo {}
```

Both abstract classes would need to be migrated. Previously, the migration
only added `@Directive()` to `MyBaseClass`, but with this change, it
also decorates `BaseClassTwo`.

This is necessary because the Angular Compiler requires `BaseClassTwo` to
have a directive definition when it flattens the directive metadata for
`MyButton` in order to perform type checking. Technically, not decorating
`BaseClassTwo` does not break at runtime.

We basically want to enforce consistent use of `@Directive` to simplify the
mental model. [See the migration guide](https://angular.io/guide/migration-undecorated-classes#migrating-classes-that-use-field-decorators).

Fixes .

PR Close 
2020-04-02 10:51:48 -07:00
Paul Gschwendtner
5557dec120 refactor(core): missing-injectable migration should respect providers of directives and components ()
Currenly the `missing-injectable` migration only migrates providers referenced from
`@NgModule` definitions. The schematic currently does not cover the migration for
providers referenced in `@Directive` or `@Component` definitions.

We need to handle the following keys for directives/components:

- `@Directive` -> `providers`
- `@Component` -> `providers` and `viewProviders`.

This commit ensures that the migration handles providers for these
definitions.

PR Close 
2019-10-14 20:24:01 +00:00
crisbeto
f5982fd746 feat(core): add dynamic queries schematic ()
Adds a schematic that will remove the explicit `static: false` flag from dynamic queries. E.g.

```ts
import { Directive, ViewChild, ContentChild, ElementRef } from '@angular/core';

@Directive()
export class MyDirective {
  @ViewChild('child', { static: false }) child: any;
  @ViewChild('secondChild', { read: ElementRef, static: false }) secondChild: ElementRef;
  @ContentChild('thirdChild', { static: false }) thirdChild: any;
}
```

```ts
import { Directive, ViewChild, ContentChild, ElementRef } from '@angular/core';

@Directive()
export class MyDirective {
  @ViewChild('child') child: any;
  @ViewChild('secondChild', { read: ElementRef }) secondChild: ElementRef;
  @ContentChild('thirdChild') thirdChild: any;
}
```

PR Close 
2019-09-11 19:14:03 -04:00
Kristiyan Kostadinov
904a2018e0 feat(core): add undecorated classes with decorated fields schematic ()
Adds a schematic that adds a `Directive` decorator to undecorated classes that have fields that use Angular decorators.

PR Close 
2019-08-22 10:05:38 -07:00
Paul Gschwendtner
639b732024 refactor(core): remove disabled injectable-pipe migration ()
Initially the plan was to have a migration that adds `@Injectable()` to
all pipes in a CLI project so that the pipes can be injected in Ivy
similarly to how it worked in view engine.

Due to the planned refactorings which ensure that `@Directive`, `@Component`
and `@Pipe` also have a factory definition, this migration is no longer
needed for Ivy. Additionally since it is already disabled (due to
572b54967c969c88c61970650fb857afc1d74f8a) and we have a more generic
migration (known as `missing-injectable)` that could do the same as
`injectable-pipe`, we remove the migration from the code-base.

PR Close 
2019-08-19 15:44:02 -07:00
Paul Gschwendtner
9896d438c0 refactor(core): move renderer2 migration lint rule into google3 folder ()
Moves the `renderer_to_renderer2` migration google3 tslint rule
into the new `google3` directory. This is done for consistency
as we recently moved all google3 migration rules into a new
`google3` folder (see: f69e4e6f770907f6811de88e52692df1a3d2f43e).

PR Close 
2019-08-09 10:46:45 -07:00
Paul Gschwendtner
684579b338 build: create google3 migration tests bazel target ()
Creates a separate bazel target for the google3 migration
tests. The benefit is that it's faster to run tests for
public migrations in development. Google3 lint rules are
usually another story/implementation and the tests are quite
slow due to how TSLint applies replacements.

Additionally if something changes in the google3 tslint rules,
the tests which aren't affected re-run unnecessarily.

PR Close 
2019-08-09 10:46:45 -07:00
Paul Gschwendtner
f69e4e6f77 refactor(core): move google3 migration rules into single directory ()
Moves all google3 migration tslint rules into a single directory.
This makes it easier to wire up multiple migration rules in
google3 without having to update the rule directories each time
a new migration is available.

PR Close 
2019-07-23 15:52:40 -07:00