Skip to content

Commit 05f561f

Browse files
devversionandrewseguin
authored andcommitted
build: enable buildifier "unsorted-dict-items" and "out-of-order-load" rules (#16857)
Enables the `unsorted-dict-items` rule to enforce that dependencies and more are sorted alphabetically. Additionally enforces that load statements in build files are sorted. Enabling these two rules improves overall health in bazel build files and makes these consistent. (cherry picked from commit aaa656d)
1 parent f76c9af commit 05f561f

File tree

24 files changed

+52
-46
lines changed

24 files changed

+52
-46
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"scripts": {
1616
"postinstall": "ngc -p angular-tsconfig.json",
1717
"build": "gulp build-release-packages",
18-
"bazel:buildifier": "find . -type f \\( -name \"*.bzl\" -or -name WORKSPACE -or -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" | xargs buildifier -v --warnings=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,redefined-variable,repository-name,same-origin-load,string-iteration,unused-variable",
18+
"bazel:buildifier": "find . -type f \\( -name \"*.bzl\" -or -name WORKSPACE -or -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" | xargs buildifier -v --warnings=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,redefined-variable,repository-name,same-origin-load,string-iteration,unused-variable,unsorted-dict-items,out-of-order-load",
1919
"bazel:format-lint": "yarn -s bazel:buildifier --lint=warn --mode=check",
2020
"dev-app": "bazel run //src/dev-app:devserver",
2121
"test": "bazel test //src/... --test_tag_filters=-e2e,-browser:firefox-local --build_tag_filters=-browser:firefox-local --build_tests_only",

packages.bzl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ MATERIAL_SCSS_LIBS = [
8080
for p in MATERIAL_PACKAGES
8181
]
8282

83+
GOOGLE_MAPS_PACKAGES = [
84+
"google-map",
85+
]
86+
87+
GOOGLE_MAPS_TARGETS = ["//src/google-maps"] + ["//src/google-maps/%s" % p for p in GOOGLE_MAPS_PACKAGES]
88+
8389
MATERIAL_EXPERIMENTAL_PACKAGES = [
8490
"mdc-button",
8591
"mdc-card",
@@ -109,18 +115,18 @@ MATERIAL_EXPERIMENTAL_SCSS_LIBS = [
109115
ANGULAR_PACKAGE_VERSION = "^8.0.0 || ^9.0.0-0"
110116
MDC_PACKAGE_VERSION = "^1.1.0"
111117
VERSION_PLACEHOLDER_REPLACEMENTS = {
112-
"0.0.0-NG": ANGULAR_PACKAGE_VERSION,
113118
"0.0.0-MDC": MDC_PACKAGE_VERSION,
119+
"0.0.0-NG": ANGULAR_PACKAGE_VERSION,
114120
}
115121

116122
# Base rollup globals for everything in the repo.
117123
ROLLUP_GLOBALS = {
118-
"tslib": "tslib",
119-
"moment": "moment",
120124
"@angular/cdk": "ng.cdk",
121125
"@angular/cdk-experimental": "ng.cdkExperimental",
122126
"@angular/material": "ng.material",
123127
"@angular/material-experimental": "ng.materialExperimental",
128+
"moment": "moment",
129+
"tslib": "tslib",
124130
}
125131

126132
# Rollup globals for cdk subpackages in the form of, e.g., {"@angular/cdk/table": "ng.cdk.table"}

src/cdk-experimental/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package(default_visibility = ["//visibility:public"])
22

3-
load("//tools:defaults.bzl", "ng_module", "ng_package")
43
load(
54
"//:packages.bzl",
65
"CDK_EXPERIMENTAL_PACKAGES",
76
"CDK_EXPERIMENTAL_TARGETS",
87
"ROLLUP_GLOBALS",
98
)
9+
load("//tools:defaults.bzl", "ng_module", "ng_package")
1010

1111
ng_module(
1212
name = "cdk-experimental",

src/cdk-experimental/scrolling/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package(default_visibility = ["//visibility:public"])
22

3-
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "ng_test_library", "ng_web_test_suite")
43
load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")
4+
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "ng_test_library", "ng_web_test_suite")
55

66
ng_module(
77
name = "scrolling",

src/cdk-experimental/testing/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package(default_visibility = ["//visibility:public"])
22

3-
load("//tools:defaults.bzl", "ng_module", "ng_web_test_suite")
43
load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")
4+
load("//tools:defaults.bzl", "ng_module", "ng_web_test_suite")
55

66
ng_module(
77
name = "testing",

src/e2e-app/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package(default_visibility = ["//visibility:public"])
22

33
load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")
44
load("@npm_bazel_typescript//:defs.bzl", "ts_devserver")
5-
load("//tools:defaults.bzl", "ng_module")
65
load("//:packages.bzl", "ANGULAR_LIBRARY_UMDS")
6+
load("//tools:defaults.bzl", "ng_module")
77

88
exports_files([
99
"protractor.conf.js",

src/material-examples/BUILD.bazel

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,20 @@ package_docs_content(
8282
# in the documentation.
8383
"//guides": "guides",
8484

85-
# For the live-examples in our docs, we want to package the highlighted files
86-
# into the docs content. These will be used to show the source code for examples.
87-
":highlighted-source-files": "examples-highlighted",
88-
89-
# In order to be able to run examples in StackBlitz, we also want to package the
90-
# plain source files into the docs-content.
91-
":example-source-files": "examples-source",
92-
9385
# Package the overviews for "@angular/material" and "@angular/cdk" into the docs content
94-
"//src/material:overviews": "overviews/material",
9586
"//src/cdk:overviews": "overviews/cdk",
87+
"//src/material:overviews": "overviews/material",
9688

9789
# Package the API docs for the Material and CDK package into the docs-content
9890
"//src:api-docs": "api-docs",
91+
92+
# In order to be able to run examples in StackBlitz, we also want to package the
93+
# plain source files into the docs-content.
94+
":example-source-files": "examples-source",
95+
96+
# For the live-examples in our docs, we want to package the highlighted files
97+
# into the docs content. These will be used to show the source code for examples.
98+
":highlighted-source-files": "examples-highlighted",
9999
},
100100
tags = ["docs-package"],
101101
)

src/material-experimental/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package(default_visibility = ["//visibility:public"])
22

3-
load("//tools:defaults.bzl", "ng_module", "ng_package")
43
load("//:packages.bzl", "ROLLUP_GLOBALS")
4+
load("//tools:defaults.bzl", "ng_module", "ng_package")
55

66
exports_files(["mdc_require_config.js"])
77

src/material-experimental/mdc-button/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package(default_visibility = ["//visibility:public"])
22

33
load("@io_bazel_rules_sass//:defs.bzl", "sass_binary", "sass_library")
4-
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "ng_test_library", "ng_web_test_suite", "ts_library")
54
load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")
5+
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "ng_test_library", "ng_web_test_suite", "ts_library")
66

77
ng_module(
88
name = "mdc-button",

src/material-experimental/mdc-card/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package(default_visibility = ["//visibility:public"])
22

33
load("@io_bazel_rules_sass//:defs.bzl", "sass_binary", "sass_library")
4-
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module")
54
load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")
5+
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module")
66

77
ng_module(
88
name = "mdc-card",

0 commit comments

Comments
 (0)