Skip to content

Commit dad5a25

Browse files
manekinekkobenlesh
authored andcommitted
style: enforce buildifier lint on CI (angular#28186)
PR Close angular#28186
1 parent ce68b4d commit dad5a25

File tree

33 files changed

+62
-113
lines changed

33 files changed

+62
-113
lines changed

BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
22

33
package(default_visibility = ["//visibility:public"])
44

5-
load("@build_bazel_rules_nodejs//:defs.bzl", "node_modules_filegroup")
65
load("//tools:defaults.bzl", "karma_web_test")
76

87
exports_files([

WORKSPACE

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_reposi
3535
# Bazel version must be at least v0.21.0 because:
3636
# - 0.21.0 Using --incompatible_strict_action_env flag fixes cache when running `yarn bazel`
3737
# (see https://github.com/angular/angular/issues/27514#issuecomment-451438271)
38-
check_bazel_version("0.21.0", """
38+
check_bazel_version(
39+
message = """
3940
You no longer need to install Bazel on your machine.
4041
Angular has a dependency on the @bazel/bazel package which supplies it.
4142
Try running `yarn bazel` instead.

integration/bazel/WORKSPACE

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ load("@build_bazel_rules_nodejs//:defs.bzl", "check_bazel_version", "node_reposi
2323
# Bazel version must be at least v0.21.0 because:
2424
# - 0.21.0 Using --incompatible_strict_action_env flag fixes cache when running `yarn bazel`
2525
# (see https://github.com/angular/angular/issues/27514#issuecomment-451438271)
26-
check_bazel_version("0.21.0", """
26+
check_bazel_version(
27+
message = """
2728
You no longer need to install Bazel on your machine.
2829
Angular has a dependency on the @bazel/bazel package which supplies it.
2930
Try running `yarn bazel` instead.
3031
(If you did run that, check that you've got a fresh `yarn install`)
3132
32-
""")
33+
""",
34+
minimum_bazel_version = "0.21.0",
35+
)
3336

3437
# Setup the Node.js toolchain
3538
node_repositories(

integration/bazel/src/BUILD.bazel

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package(default_visibility = ["//visibility:public"])
22

33
load("@npm_angular_bazel//:index.bzl", "ng_module")
4-
load("@build_bazel_rules_nodejs//:defs.bzl", "http_server", "nodejs_binary", "rollup_bundle")
4+
load("@build_bazel_rules_nodejs//:defs.bzl", "http_server", "rollup_bundle")
55
load("@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", "web_package")
66
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
77

8-
package(default_visibility = ["//visibility:public"])
9-
108
# Allow targets under sub-packages to reference the tsconfig.json file
119
exports_files(["tsconfig.json"])
1210

integration/bazel/src/hello-world/BUILD.bazel

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ load("@npm_bazel_typescript//:defs.bzl", "ts_library")
55
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_binary")
66
load("@npm_angular_bazel//:index.bzl", "ng_module", "ng_package")
77

8-
package(default_visibility = ["//visibility:public"])
9-
108
sass_binary(
119
name = "hello-world-styles",
1210
src = "hello-world.component.scss",

modules/benchmarks/src/largetable/iv/BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
load("//tools:defaults.bzl", "ts_library")
21
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
32
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")
43

modules/benchmarks/src/largetable/render3/BUILD.bazel

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle")
44
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
55
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")
66

7-
package(default_visibility = ["//visibility:public"])
8-
97
ng_module(
108
name = "largetable_lib",
119
srcs = glob(["**/*.ts"]),

modules/benchmarks/src/tree/render3/BUILD.bazel

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle")
44
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
55
load("//modules/benchmarks:benchmark_test.bzl", "benchmark_test")
66

7-
package(default_visibility = ["//visibility:public"])
8-
97
ng_module(
108
name = "tree_lib",
119
srcs = glob(["**/*.ts"]),

modules/playground/src/zippy_component/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package(default_visibility = ["//modules/playground:__subpackages__"])
66
ng_module(
77
name = "zippy_component",
88
srcs = glob(["**/*.ts"]),
9-
assets = glob(["app/zippy.html"]),
9+
assets = ["app/zippy.html"],
1010
tsconfig = "//modules/playground:tsconfig-build.json",
1111
# TODO: FW-1004 Type checking is currently not complete.
1212
type_check = False,

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"url": "https://github.com/angular/angular.git"
1717
},
1818
"scripts": {
19-
"bazel:format": "find . -type f \\( -name \"*.bzl\" -or -name WORKSPACE -or -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" | xargs buildifier -v --warnings=args-order,attr-cfg,attr-license,attr-non-empty,attr-output-default,attr-single-file,constant-glob,ctx-args,depset-iteration,depset-union,dict-concatenation,duplicated-name,filetype,git-repository,http-archive,integer-division,load,load-on-top,native-build,native-package,out-of-order-load,output-group,package-name,package-on-top,positional-args,redefined-variable,repository-name,same-origin-load,string-iteration,unsorted-dict-items,unused-variable",
19+
"bazel:format": "find . -type f \\( -name \"*.bzl\" -or -name WORKSPACE -or -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" | xargs buildifier -v --warnings=args-order,attr-cfg,attr-license,attr-non-empty,attr-output-default,attr-single-file,constant-glob,ctx-args,depset-iteration,depset-union,dict-concatenation,duplicated-name,filetype,git-repository,http-archive,integer-division,load,load-on-top,native-build,native-package,output-group,package-name,package-on-top,positional-args,redefined-variable,repository-name,same-origin-load,string-iteration,unused-variable",
2020
"bazel:lint": "yarn bazel:format --lint=warn",
2121
"bazel:lint-fix": "yarn bazel:format --lint=fix",
2222
"preinstall": "node tools/yarn/check-yarn.js",

packages/BUILD.bazel

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
load("//tools:defaults.bzl", "ts_library")
2-
31
package(default_visibility = ["//visibility:public"])
42

53
exports_files([

packages/bazel/src/BUILD.bazel

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ filegroup(
88
# For generating skydoc
99
exports_files(glob(["*.bzl"]))
1010

11+
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
12+
1113
nodejs_binary(
1214
name = "rollup_with_build_optimizer",
1315
data = [

packages/bazel/src/esm5.bzl

-5
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,6 @@ esm5_outputs_aspect = aspect(
170170
executable = True,
171171
cfg = "host",
172172
),
173-
"_tsc_wrapped": attr.label(
174-
default = Label("@build_bazel_rules_typescript//:@bazel/typescript/tsc_wrapped"),
175-
executable = True,
176-
cfg = "host",
177-
),
178173
},
179174
)
180175

packages/bazel/src/ng_module.bzl

+19-30
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,6 @@ def _expected_outs(ctx):
244244
# TODO(alxhub): i18n is only produced by the legacy compiler currently. This should be re-enabled
245245
# when ngtsc can extract messages
246246
if is_legacy_ngc:
247-
# TODO(manekinekko): due to bazelbuild/bazel#4858 we cannot fix the call to ctx.new_file(genfiles_dir)
248-
# so the rule is turned off for now.
249247
i18n_messages_files = [ctx.new_file(ctx.genfiles_dir, ctx.label.name + "_ngc_messages.xmb")]
250248
else:
251249
i18n_messages_files = []
@@ -270,9 +268,9 @@ def _ngc_tsconfig(ctx, files, srcs, **kwargs):
270268
expected_outs = outs.closure_js
271269

272270
angular_compiler_options = {
273-
"allowEmptyCodegenFiles": True,
274-
"enableIvy": _enable_ivy_value(ctx),
275271
"enableResourceInlining": ctx.attr.inline_resources,
272+
"generateCodeForLibraries": False,
273+
"allowEmptyCodegenFiles": True,
276274
# Summaries are only enabled if Angular outputs are to be produced.
277275
"enableSummariesForJit": is_legacy_ngc,
278276
"enableIvy": _enable_ivy_value(ctx),
@@ -539,8 +537,8 @@ def ng_module_impl(ctx, ts_compile_actions):
539537

540538
if is_legacy_ngc:
541539
providers["angular"] = {
542-
"metadata": outs.metadata,
543540
"summaries": outs.summaries,
541+
"metadata": outs.metadata,
544542
}
545543
providers["ngc_messages"] = outs.i18n_messages
546544

@@ -570,6 +568,13 @@ local_deps_aspects = [collect_node_modules_aspect, _collect_summaries_aspect]
570568

571569
NG_MODULE_ATTRIBUTES = {
572570
"srcs": attr.label_list(allow_files = [".ts"]),
571+
572+
# Note: DEPS_ASPECTS is already a list, we add the cast to workaround
573+
# https://github.com/bazelbuild/skydoc/issues/21
574+
"deps": attr.label_list(
575+
doc = "Targets that are imported by this target",
576+
aspects = local_deps_aspects,
577+
),
573578
"assets": attr.label_list(
574579
doc = ".html and .css files needed by the Angular compiler",
575580
allow_files = [
@@ -578,6 +583,14 @@ NG_MODULE_ATTRIBUTES = {
578583
".html",
579584
],
580585
),
586+
"factories": attr.label_list(
587+
allow_files = [".ts", ".html"],
588+
mandatory = False,
589+
),
590+
"filter_summaries": attr.bool(default = False),
591+
"type_check": attr.bool(default = True),
592+
"inline_resources": attr.bool(default = True),
593+
"no_i18n": attr.bool(default = False),
581594
"compiler": attr.label(
582595
doc = """Sets a different ngc compiler binary to use for this library.
583596
@@ -592,40 +605,16 @@ NG_MODULE_ATTRIBUTES = {
592605
executable = True,
593606
cfg = "host",
594607
),
595-
"factories": attr.label_list(
596-
allow_files = [".ts", ".html"],
597-
mandatory = False,
598-
),
599-
"filter_summaries": attr.bool(default = False),
600-
"inline_resources": attr.bool(default = True),
601608
"ng_xi18n": attr.label(
602609
default = Label(DEFAULT_NG_XI18N),
603610
executable = True,
604611
cfg = "host",
605612
),
606-
"no_i18n": attr.bool(default = False),
607-
"type_check": attr.bool(default = True),
608-
609-
# Note: DEPS_ASPECTS is already a list, we add the cast to workaround
610-
# https://github.com/bazelbuild/skydoc/issues/21
611-
"deps": attr.label_list(
612-
doc = "Targets that are imported by this target",
613-
aspects = local_deps_aspects,
614-
),
615613
"_supports_workers": attr.bool(default = True),
616614
}
617615

618616
NG_MODULE_RULE_ATTRS = dict(dict(COMMON_ATTRIBUTES, **NG_MODULE_ATTRIBUTES), **{
619-
"entry_point": attr.string(),
620-
621-
# Default is %{name}_public_index
622-
# The suffix points to the generated "bundle index" files that users import from
623-
# The default is intended to avoid collisions with the users input files.
624-
# Later packaging rules will point to these generated files as the entry point
625-
# into the package.
626-
# See the flatModuleOutFile documentation in
627-
# https://github.com/angular/angular/blob/master/packages/compiler-cli/src/transformers/api.ts
628-
"flat_module_out_file": attr.string(),
617+
"tsconfig": attr.label(allow_single_file = True),
629618
"node_modules": attr.label(
630619
doc = """The npm packages which should be available during the compile.
631620

packages/bazel/src/ng_package/BUILD.bazel

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package(default_visibility = ["//visibility:public"])
2+
13
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
24

35
# BEGIN-DEV-ONLY

packages/bazel/src/ng_package/ng_package.bzl

+3-13
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ specification of this format at https://goo.gl/jB3GVv
1616
load("@build_bazel_rules_nodejs//internal/common:collect_es6_sources.bzl", "collect_es6_sources")
1717
load("@build_bazel_rules_nodejs//internal/common:node_module_info.bzl", "NodeModuleInfo")
1818
load("@build_bazel_rules_nodejs//internal/common:sources_aspect.bzl", "sources_aspect")
19-
load(
20-
"@build_bazel_rules_nodejs//:internal/npm_package/npm_package.bzl",
21-
"NPM_PACKAGE_ATTRS",
22-
"NPM_PACKAGE_OUTPUTS",
23-
"create_package",
24-
)
2519
load(
2620
"@build_bazel_rules_nodejs//:internal/rollup/rollup_bundle.bzl",
2721
"ROLLUP_ATTRS",
@@ -38,7 +32,6 @@ load(
3832
load("//packages/bazel/src:external.bzl", "FLAT_DTS_FILE_SUFFIX")
3933
load("//packages/bazel/src:esm5.bzl", "esm5_outputs_aspect", "esm5_root_dir", "flatten_esm5")
4034
load("//packages/bazel/src/ng_package:collect-type-definitions.bzl", "collect_type_definitions")
41-
load("//packages/bazel/src:esm5.bzl", "esm5_outputs_aspect", "esm5_root_dir", "flatten_esm5")
4235

4336
_DEFAULT_NG_PACKAGER = "@npm//@angular/bazel/bin:packager"
4437

@@ -343,8 +336,8 @@ def _ng_package_impl(ctx):
343336
packager_inputs.extend([m.metadata_file])
344337
metadata_arg[m.module_name] = {
345338
"index": m.typings_file.path.replace(".d.ts", ".js"),
346-
"metadata": m.metadata_file.path,
347339
"typings": m.typings_file.path,
340+
"metadata": m.metadata_file.path,
348341
}
349342
packager_args.add(str(metadata_arg))
350343

@@ -408,6 +401,7 @@ DEPS_ASPECTS = [esm5_outputs_aspect, sources_aspect]
408401

409402
NG_PACKAGE_ATTRS = dict(NPM_PACKAGE_ATTRS, **dict(ROLLUP_ATTRS, **{
410403
"srcs": attr.label_list(allow_files = True),
404+
"deps": attr.label_list(aspects = DEPS_ASPECTS),
411405
"data": attr.label_list(
412406
doc = "Additional, non-Angular files to be added to the package, e.g. global CSS assets.",
413407
allow_files = True,
@@ -418,15 +412,11 @@ NG_PACKAGE_ATTRS = dict(NPM_PACKAGE_ATTRS, **dict(ROLLUP_ATTRS, **{
418412
"entry_point_name": attr.string(
419413
doc = "Name to use when generating bundle files for the primary entry-point.",
420414
),
421-
"globals": attr.string_dict(default = {}),
422-
"include_devmode_srcs": attr.bool(default = False),
423415
"ng_packager": attr.label(
424416
default = Label(_DEFAULT_NG_PACKAGER),
425417
executable = True,
426418
cfg = "host",
427419
),
428-
"readme_md": attr.label(allow_single_file = [".md"]),
429-
"deps": attr.label_list(aspects = DEPS_ASPECTS),
430420
"_rollup": attr.label(
431421
default = Label("@build_bazel_rules_nodejs//internal/rollup"),
432422
executable = True,
@@ -489,8 +479,8 @@ def ng_package_outputs(name, entry_point, entry_point_name):
489479

490480
basename = primary_entry_point_name(name, entry_point, entry_point_name)
491481
outputs = {
492-
"fesm2015": "fesm2015/%s.js" % basename,
493482
"fesm5": "fesm5/%s.js" % basename,
483+
"fesm2015": "fesm2015/%s.js" % basename,
494484
"umd": "%s.umd.js" % basename,
495485
"umd_min": "%s.umd.min.js" % basename,
496486
}

packages/bazel/src/protractor/utils/BUILD.bazel

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package(default_visibility = ["//visibility:public"])
22

33
load("@npm_bazel_typescript//:defs.bzl", "ts_library")
44

5-
package(default_visibility = ["//visibility:public"])
6-
75
ts_library(
86
name = "utils",
97
srcs = ["index.ts"],

packages/compiler-cli/BUILD.bazel

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package(default_visibility = ["//visibility:public"])
33
load("//tools:defaults.bzl", "npm_package", "ts_library")
44
load("@npm_bazel_typescript//:defs.bzl", "ts_config")
55

6-
package(default_visibility = ["//visibility:public"])
7-
86
ts_config(
97
name = "tsconfig",
108
src = "tsconfig-build.json",

packages/compiler-cli/src/ngtsc/cycles/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ load("//tools:defaults.bzl", "ts_library")
44

55
ts_library(
66
name = "cycles",
7-
srcs = glob([
8-
"index.ts",
7+
srcs = ["index.ts"] + glob([
98
"src/**/*.ts",
109
]),
1110
module_name = "@angular/compiler-cli/src/ngtsc/cycles",

packages/compiler-cli/src/ngtsc/path/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ load("//tools:defaults.bzl", "ts_library")
44

55
ts_library(
66
name = "path",
7-
srcs = glob([
8-
"index.ts",
7+
srcs = ["index.ts"] + glob([
98
"src/*.ts",
109
]),
1110
deps = [

packages/compiler-cli/src/ngtsc/routing/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ load("//tools:defaults.bzl", "ts_library")
44

55
ts_library(
66
name = "routing",
7-
srcs = glob([
8-
"index.ts",
7+
srcs = ["index.ts"] + glob([
98
"src/**/*.ts",
109
]),
1110
module_name = "@angular/compiler-cli/src/ngtsc/routing",

packages/compiler-cli/src/ngtsc/scope/BUILD.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ load("//tools:defaults.bzl", "ts_library")
44

55
ts_library(
66
name = "scope",
7-
srcs = glob([
8-
"index.ts",
7+
srcs = ["index.ts"] + glob([
98
"src/**/*.ts",
109
]),
1110
deps = [

packages/compiler-cli/test/ngtsc/fake_core/BUILD.bazel

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
load("//tools:defaults.bzl", "ng_package", "ts_library")
2-
31
package(default_visibility = ["//visibility:public"])
42

3+
load("//tools:defaults.bzl", "ng_package", "ts_library")
4+
55
ts_library(
66
name = "fake_core",
77
srcs = [

packages/core/test/bundling/animation_world/BUILD.bazel

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package(default_visibility = ["//visibility:public"])
22

3-
load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ng_rollup_bundle", "ts_library")
3+
load("//tools:defaults.bzl", "ng_module", "ng_rollup_bundle")
44
load("@build_bazel_rules_nodejs//:defs.bzl", "http_server")
55

6-
package(default_visibility = ["//visibility:public"])
7-
86
ng_module(
97
name = "animation_world",
108
srcs = ["index.ts"],

packages/core/test/bundling/hello_world/BUILD.bazel

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ load("//tools:defaults.bzl", "jasmine_node_test", "ng_module", "ng_rollup_bundle
44
load("//tools/symbol-extractor:index.bzl", "js_expected_symbol_test")
55
load("@build_bazel_rules_nodejs//:defs.bzl", "http_server")
66

7-
package(default_visibility = ["//visibility:public"])
8-
97
ng_module(
108
name = "hello_world",
119
srcs = ["index.ts"],

0 commit comments

Comments
 (0)