Paul Gschwendtner 04642e7985 feat(dev-infra): add lint rule to enforce no-implicit-override abstract members (#42512)
TypeScript introduced a new flag called `noImplicitOverride` as part
of TypeScript v4.3. This flag introduces a new keyword called `override`
that can be applied to members which override declarations from a base
class. This helps with code health as TS will report an error if e.g.
the base class changes the method name but the override would still
have the old method name. Similarly, if the base class removes the method
completely, TS would complain that the memeber with `override` no longer
overrides any method.

A similar concept applies to abstract methods, with the exception that
TypeScript's builtin `noImplicitOverride` option does not flag members
which are implemented as part of an abstract class. We want to enforce
this as a best-practice in the repository as adding `override` to such
implemented members will cause TS to complain if an abstract member is
removed, but still implemented by derived classes.

More details: https://github.com/microsoft/TypeScript/issues/44457.

PR Close #42512
2021-07-12 13:11:16 -07:00

116 lines
3.8 KiB
Python

# BEGIN-INTERNAL
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
load("//dev-infra:defaults.bzl", "ng_dev_rolled_up_generated_file", "ts_library")
# END-INTERNAL
exports_files(["tsconfig.json"])
# BEGIN-INTERNAL
ts_library(
name = "cli",
srcs = [
"cli.ts",
],
deps = [
"//dev-infra/caretaker",
"//dev-infra/commit-message",
"//dev-infra/format",
"//dev-infra/misc",
"//dev-infra/ngbot",
"//dev-infra/pr",
"//dev-infra/pullapprove",
"//dev-infra/release",
"//dev-infra/ts-circular-dependencies",
"//dev-infra/utils",
"@npm//@types/node",
"@npm//@types/yargs",
"@npm//yargs",
],
)
genrule(
name = "package-json",
srcs = [
"tmpl-package.json",
"//:package.json",
],
outs = ["package.json"],
cmd = """
$(execpath //tools:inline-package-json-deps) $(execpath tmpl-package.json) \
$(execpath //:package.json) $@
""",
tools = ["//tools:inline-package-json-deps"],
)
pkg_npm(
name = "npm_package",
srcs = [
# Main bazel entry-point for the shared `dev-infra` package.
"index.bzl",
"BUILD.bazel",
# Some tools within `dev-infra` which are shipped as Bazel rules might
# rely on a tsconfig file. We bring the config into the NPM package.
"tsconfig.json",
"//dev-infra/bazel:files",
"//dev-infra/benchmark:files",
],
substitutions = {
# angular/angular should not consume it's own packages, so we use
# substitutions to replace these in the published version of dev-infra.
"//dev-infra/": "@npm//@angular/dev-infra-private/",
"//dev-infra:": "@npm//@angular/dev-infra-private:",
# Substitutions needed for `//dev-infra/benchmark`:
"//packages/benchpress": "@npm//@angular/benchpress",
"//packages/bazel": "@npm//@angular/bazel",
"//packages/zone.js/bundles:zone.umd.js": "@npm//zone.js",
"//packages/core": "@npm//@angular/core",
"//packages/platform-browser": "@npm//@angular/platform-browser",
# This substitution is particularly verbose because we need to make sure
# that only things available via Angular Bazel are imported from
# tools/defaults.bzl.
"load\\(\"//tools:defaults.bzl\", \"ng_module\"\\)": "load(\"@npm//@angular/bazel:index.bzl\", \"ng_module\")",
},
visibility = ["//visibility:public"],
deps = [
":cli",
":package-json",
"//dev-infra/benchmark/driver-utilities",
"//dev-infra/commit-message",
"//dev-infra/ts-circular-dependencies",
"//dev-infra/tslint-rules",
],
)
# Because the angular/angular repository relies on the local repository for running ng-dev commands,
# the rollup generated javascript files are committed into the repository to be used as node
# scripts. To ensure they stay up to date, they are created using a generated file test.
#
# Currently there are two generated files which are needed
# ng-dev.js - The main script representing ng-dev
# build-worker.js - The worker script for the `ng-dev release build` command, allowing it to run
# in a forked process.
ng_dev_rolled_up_generated_file(
name = "ng-dev",
entry_point = ":cli.ts",
rollup_args = [
"--plugin",
"rollup-plugin-hashbang",
],
deps = [
":cli",
# TODO(josephperrott): Determine if this plugin is the best method for ensuring the hashbang
# in both local and published use case.
"@npm//rollup-plugin-hashbang",
],
)
ng_dev_rolled_up_generated_file(
name = "build-worker",
entry_point = "//dev-infra/release/build:build-worker.ts",
deps = [
"//dev-infra/release/build",
],
)
# END-INTERNAL