refactor(core): move google3 migration rules into single directory (#30956)

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 #30956
This commit is contained in:
Paul Gschwendtner 2019-06-18 11:28:23 +02:00 committed by Kara Erickson
parent 9f2ae5d6ff
commit f69e4e6f77
18 changed files with 33 additions and 56 deletions

View File

@ -6,6 +6,10 @@ ts_library(
tsconfig = "//packages/core/schematics:tsconfig.json", tsconfig = "//packages/core/schematics:tsconfig.json",
visibility = ["//packages/core/schematics/test:__pkg__"], visibility = ["//packages/core/schematics/test:__pkg__"],
deps = [ deps = [
"//packages/core/schematics/migrations/injectable-pipe",
"//packages/core/schematics/migrations/missing-injectable",
"//packages/core/schematics/migrations/missing-injectable/google3",
"//packages/core/schematics/migrations/static-queries",
"//packages/core/schematics/migrations/template-var-assignment", "//packages/core/schematics/migrations/template-var-assignment",
"//packages/core/schematics/utils", "//packages/core/schematics/utils",
"//packages/core/schematics/utils/tslint", "//packages/core/schematics/utils/tslint",

View File

@ -9,11 +9,11 @@
import {Replacement, RuleFailure, Rules} from 'tslint'; import {Replacement, RuleFailure, Rules} from 'tslint';
import * as ts from 'typescript'; import * as ts from 'typescript';
import {NgComponentTemplateVisitor} from '../../../utils/ng_component_template'; import {NgComponentTemplateVisitor} from '../../utils/ng_component_template';
import {NgQueryResolveVisitor} from '../angular/ng_query_visitor'; import {NgQueryResolveVisitor} from '../static-queries/angular/ng_query_visitor';
import {QueryTiming} from '../angular/query-definition'; import {QueryTiming} from '../static-queries/angular/query-definition';
import {QueryUsageStrategy} from '../strategies/usage_strategy/usage_strategy'; import {QueryUsageStrategy} from '../static-queries/strategies/usage_strategy/usage_strategy';
import {getTransformedQueryCallExpr} from '../transform'; import {getTransformedQueryCallExpr} from '../static-queries/transform';
const FAILURE_MESSAGE = 'Query does not explicitly specify its timing. Read more here: ' + const FAILURE_MESSAGE = 'Query does not explicitly specify its timing. Read more here: ' +
'https://github.com/angular/angular/pull/28810'; 'https://github.com/angular/angular/pull/28810';

View File

@ -9,8 +9,9 @@
import {Replacement, RuleFailure, Rules} from 'tslint'; import {Replacement, RuleFailure, Rules} from 'tslint';
import * as ts from 'typescript'; import * as ts from 'typescript';
import {InjectablePipeVisitor} from '../angular/injectable_pipe_visitor'; import {InjectablePipeVisitor} from '../injectable-pipe/angular/injectable_pipe_visitor';
import {INJECTABLE_DECORATOR_NAME, addImport, getNamedImports} from '../util'; import {INJECTABLE_DECORATOR_NAME, addImport, getNamedImports} from '../injectable-pipe/util';
/** /**
* TSLint rule that flags `@Pipe` classes that haven't been marked as `@Injectable`. * TSLint rule that flags `@Pipe` classes that haven't been marked as `@Injectable`.

View File

@ -8,9 +8,11 @@
import {RuleFailure, Rules} from 'tslint'; import {RuleFailure, Rules} from 'tslint';
import * as ts from 'typescript'; import * as ts from 'typescript';
import {NgModuleCollector} from '../module_collector';
import {MissingInjectableTransform} from '../transform'; import {TslintUpdateRecorder} from '../missing-injectable/google3/tslint_update_recorder';
import {TslintUpdateRecorder} from './tslint_update_recorder'; import {NgModuleCollector} from '../missing-injectable/module_collector';
import {MissingInjectableTransform} from '../missing-injectable/transform';
/** /**
* TSLint rule that flags classes which are declared as providers in NgModules but * TSLint rule that flags classes which are declared as providers in NgModules but

View File

@ -9,9 +9,9 @@
import {RuleFailure, Rules} from 'tslint'; import {RuleFailure, Rules} from 'tslint';
import * as ts from 'typescript'; import * as ts from 'typescript';
import {NgComponentTemplateVisitor} from '../../../utils/ng_component_template'; import {NgComponentTemplateVisitor} from '../../utils/ng_component_template';
import {createHtmlSourceFile} from '../../../utils/tslint/tslint_html_source_file'; import {createHtmlSourceFile} from '../../utils/tslint/tslint_html_source_file';
import {analyzeResolvedTemplate} from '../analyze_template'; import {analyzeResolvedTemplate} from '../template-var-assignment/analyze_template';
const FAILURE_MESSAGE = 'Found assignment to template variable. This does not work with Ivy and ' + const FAILURE_MESSAGE = 'Found assignment to template variable. This does not work with Ivy and ' +
'needs to be updated.'; 'needs to be updated.';

View File

@ -6,7 +6,7 @@ ts_library(
tsconfig = "//packages/core/schematics:tsconfig.json", tsconfig = "//packages/core/schematics:tsconfig.json",
visibility = [ visibility = [
"//packages/core/schematics:__pkg__", "//packages/core/schematics:__pkg__",
"//packages/core/schematics/migrations/injectable-pipe/google3:__pkg__", "//packages/core/schematics/migrations/google3:__pkg__",
"//packages/core/schematics/test:__pkg__", "//packages/core/schematics/test:__pkg__",
], ],
deps = [ deps = [

View File

@ -1,13 +0,0 @@
load("//tools:defaults.bzl", "ts_library")
ts_library(
name = "google3",
srcs = glob(["**/*.ts"]),
tsconfig = "//packages/core/schematics:tsconfig.json",
visibility = ["//packages/core/schematics/test:__pkg__"],
deps = [
"//packages/core/schematics/migrations/injectable-pipe",
"@npm//tslint",
"@npm//typescript",
],
)

View File

@ -6,6 +6,7 @@ ts_library(
tsconfig = "//packages/core/schematics:tsconfig.json", tsconfig = "//packages/core/schematics:tsconfig.json",
visibility = [ visibility = [
"//packages/core/schematics:__pkg__", "//packages/core/schematics:__pkg__",
"//packages/core/schematics/migrations/google3:__pkg__",
"//packages/core/schematics/migrations/missing-injectable/google3:__pkg__", "//packages/core/schematics/migrations/missing-injectable/google3:__pkg__",
"//packages/core/schematics/test:__pkg__", "//packages/core/schematics/test:__pkg__",
], ],

View File

@ -4,7 +4,7 @@ ts_library(
name = "google3", name = "google3",
srcs = glob(["**/*.ts"]), srcs = glob(["**/*.ts"]),
tsconfig = "//packages/core/schematics:tsconfig.json", tsconfig = "//packages/core/schematics:tsconfig.json",
visibility = ["//packages/core/schematics/test:__pkg__"], visibility = ["//packages/core/schematics/migrations/google3:__pkg__"],
deps = [ deps = [
"//packages/core/schematics/migrations/missing-injectable", "//packages/core/schematics/migrations/missing-injectable",
"@npm//tslint", "@npm//tslint",

View File

@ -6,7 +6,7 @@ ts_library(
tsconfig = "//packages/core/schematics:tsconfig.json", tsconfig = "//packages/core/schematics:tsconfig.json",
visibility = [ visibility = [
"//packages/core/schematics:__pkg__", "//packages/core/schematics:__pkg__",
"//packages/core/schematics/migrations/static-queries/google3:__pkg__", "//packages/core/schematics/migrations/google3:__pkg__",
"//packages/core/schematics/test:__pkg__", "//packages/core/schematics/test:__pkg__",
], ],
deps = [ deps = [

View File

@ -1,14 +0,0 @@
load("//tools:defaults.bzl", "ts_library")
ts_library(
name = "google3",
srcs = glob(["**/*.ts"]),
tsconfig = "//packages/core/schematics:tsconfig.json",
visibility = ["//packages/core/schematics/test:__pkg__"],
deps = [
"//packages/core/schematics/migrations/static-queries",
"//packages/core/schematics/utils",
"@npm//tslint",
"@npm//typescript",
],
)

View File

@ -6,7 +6,7 @@ ts_library(
tsconfig = "//packages/core/schematics:tsconfig.json", tsconfig = "//packages/core/schematics:tsconfig.json",
visibility = [ visibility = [
"//packages/core/schematics:__pkg__", "//packages/core/schematics:__pkg__",
"//packages/core/schematics/migrations/template-var-assignment/google3:__pkg__", "//packages/core/schematics/migrations/google3:__pkg__",
"//packages/core/schematics/test:__pkg__", "//packages/core/schematics/test:__pkg__",
], ],
deps = [ deps = [

View File

@ -9,17 +9,14 @@ ts_library(
"//packages/core/schematics:migrations.json", "//packages/core/schematics:migrations.json",
], ],
deps = [ deps = [
"//packages/core/schematics/migrations/google3",
"//packages/core/schematics/migrations/injectable-pipe", "//packages/core/schematics/migrations/injectable-pipe",
"//packages/core/schematics/migrations/injectable-pipe/google3",
"//packages/core/schematics/migrations/missing-injectable", "//packages/core/schematics/migrations/missing-injectable",
"//packages/core/schematics/migrations/missing-injectable/google3",
"//packages/core/schematics/migrations/move-document", "//packages/core/schematics/migrations/move-document",
"//packages/core/schematics/migrations/renderer-to-renderer2", "//packages/core/schematics/migrations/renderer-to-renderer2",
"//packages/core/schematics/migrations/renderer-to-renderer2/google3", "//packages/core/schematics/migrations/renderer-to-renderer2/google3",
"//packages/core/schematics/migrations/static-queries", "//packages/core/schematics/migrations/static-queries",
"//packages/core/schematics/migrations/static-queries/google3",
"//packages/core/schematics/migrations/template-var-assignment", "//packages/core/schematics/migrations/template-var-assignment",
"//packages/core/schematics/migrations/template-var-assignment/google3",
"//packages/core/schematics/utils", "//packages/core/schematics/utils",
"@npm//@angular-devkit/core", "@npm//@angular-devkit/core",
"@npm//@angular-devkit/schematics", "@npm//@angular-devkit/schematics",

View File

@ -18,7 +18,7 @@ describe('Google3 explicitQueryTiming TSLint rule', () => {
* the Bazel runfiles, because on Windows runfiles are not symlinked into the working directory. * the Bazel runfiles, because on Windows runfiles are not symlinked into the working directory.
*/ */
const rulesDirectory = const rulesDirectory =
dirname(require.resolve('../../migrations/static-queries/google3/explicitQueryTimingRule')); dirname(require.resolve('../../migrations/google3/explicitQueryTimingRule'));
let tmpDir: string; let tmpDir: string;

View File

@ -12,8 +12,7 @@ import * as shx from 'shelljs';
import {Configuration, Linter} from 'tslint'; import {Configuration, Linter} from 'tslint';
describe('Google3 injectable pipe TSLint rule', () => { describe('Google3 injectable pipe TSLint rule', () => {
const rulesDirectory = const rulesDirectory = dirname(require.resolve('../../migrations/google3/injectablePipeRule'));
dirname(require.resolve('../../migrations/injectable-pipe/google3/injectablePipeRule'));
let tmpDir: string; let tmpDir: string;

View File

@ -12,8 +12,8 @@ import * as shx from 'shelljs';
import {Configuration, Linter} from 'tslint'; import {Configuration, Linter} from 'tslint';
describe('Google3 missing injectable tslint rule', () => { describe('Google3 missing injectable tslint rule', () => {
const rulesDirectory = dirname( const rulesDirectory =
require.resolve('../../migrations/missing-injectable/google3/noMissingInjectableRule')); dirname(require.resolve('../../migrations/google3/noMissingInjectableRule'));
let tmpDir: string; let tmpDir: string;

View File

@ -12,8 +12,8 @@ import * as shx from 'shelljs';
import {Configuration, Linter} from 'tslint'; import {Configuration, Linter} from 'tslint';
describe('Google3 noTemplateVariableAssignment TSLint rule', () => { describe('Google3 noTemplateVariableAssignment TSLint rule', () => {
const rulesDirectory = dirname(require.resolve( const rulesDirectory =
'../../migrations/template-var-assignment/google3/noTemplateVariableAssignmentRule')); dirname(require.resolve('../../migrations/google3/noTemplateVariableAssignmentRule'));
let tmpDir: string; let tmpDir: string;

View File

@ -5,7 +5,7 @@ ts_library(
srcs = glob(["**/*.ts"]), srcs = glob(["**/*.ts"]),
tsconfig = "//packages/core/schematics:tsconfig.json", tsconfig = "//packages/core/schematics:tsconfig.json",
visibility = [ visibility = [
"//packages/core/schematics/migrations/template-var-assignment/google3:__pkg__", "//packages/core/schematics/migrations/google3:__pkg__",
], ],
deps = ["@npm//typescript"], deps = ["@npm//typescript"],
) )