From c0bee7cb86a3bc2d3a4a2f405031ccb39ef807ac Mon Sep 17 00:00:00 2001 From: Samson <16504129+sagudev@users.noreply.github.com> Date: Thu, 17 Aug 2023 17:07:43 +0200 Subject: [PATCH] Format toml files (#30112) * Add taplo fmt config for toml fmt * fmt toml files * Add even-better-toml to extensions recommendations --- .vscode/extensions.json | 7 +- Cargo.toml | 2 +- components/constellation/Cargo.toml | 2 +- components/layout/Cargo.toml | 1 - components/net/Cargo.toml | 6 +- components/script_plugins/Cargo.toml | 2 +- components/selectors/Cargo.toml | 2 +- components/style/Cargo.toml | 22 ++- components/webrender_surfman/Cargo.toml | 1 - components/webrender_traits/Cargo.toml | 1 - ports/gstplugin/Cargo.toml | 1 - ports/libsimpleservo/api/Cargo.toml | 4 +- ports/libsimpleservo/capi/cbindgen.toml | 1 - ports/winit/Cargo.toml | 2 +- python/tidy/tests/Cargo.toml | 2 +- python/tidy/tests/servo-tidy.toml | 4 +- rustfmt.toml | 2 +- servo-tidy.toml | 192 ++++++++++++------------ taplo.toml | 9 ++ 19 files changed, 139 insertions(+), 124 deletions(-) create mode 100644 taplo.toml diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 4fcf0446d25..d776261927d 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,7 +1,6 @@ { // See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp - // List of extensions which should be recommended for users of this workspace. "recommendations": [ // Trim only touched lines. @@ -15,6 +14,8 @@ // CSS support for HTML documents. "ecmel.vscode-html-css", // IDL language support - "mythmon.idl" + "mythmon.idl", + // TOML files + "tamasfe.even-better-toml" ] -} +} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 45a472b3cc1..c29f205cb8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ byteorder = "1.0" encoding_rs = "0.8" euclid = "0.22" cookie = "0.12" -content-security-policy = { version = "0.5", features = ["serde"]} +content-security-policy = { version = "0.5", features = ["serde"] } crossbeam-channel = "0.5" cssparser = "0.29" darling = { version = "0.13", default-features = false } diff --git a/components/constellation/Cargo.toml b/components/constellation/Cargo.toml index 3704d404b62..fa260f102ad 100644 --- a/components/constellation/Cargo.toml +++ b/components/constellation/Cargo.toml @@ -37,7 +37,7 @@ profile_traits = { path = "../profile_traits" } script_traits = { path = "../script_traits" } serde = { workspace = true } servo_config = { path = "../config" } -servo_rand = {path = "../rand" } +servo_rand = { path = "../rand" } servo_remutex = { path = "../remutex" } servo_url = { path = "../url" } style_traits = { path = "../style_traits" } diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml index fe501517c6e..6065abdf95e 100644 --- a/components/layout/Cargo.toml +++ b/components/layout/Cargo.toml @@ -52,4 +52,3 @@ unicode-bidi = { workspace = true, features = ["with_serde"] } unicode-script = { workspace = true } webrender_api = { workspace = true } xi-unicode = { workspace = true } - diff --git a/components/net/Cargo.toml b/components/net/Cargo.toml index 929000b9c94..70010a6412b 100644 --- a/components/net/Cargo.toml +++ b/components/net/Cargo.toml @@ -5,7 +5,7 @@ authors = ["The Servo Project Developers"] license = "MPL-2.0" edition = "2018" publish = false -autotests = false # Inhibit lookup for tests/*.rs without [[test]] sections +autotests = false # Inhibit lookup for tests/*.rs without [[test]] sections [lib] name = "net" @@ -27,7 +27,7 @@ devtools_traits = { path = "../devtools_traits" } embedder_traits = { path = "../embedder_traits" } flate2 = "1" futures = { version = "0.3", package = "futures" } -futures-util = { version = "0.3" } +futures-util = { version = "0.3" } generic-array = "0.14" headers = { workspace = true } http = { workspace = true } @@ -69,7 +69,7 @@ webrender_api = { workspace = true } webpki-roots = { workspace = true } [dev-dependencies] -futures = {version = "0.3", features = ["compat"]} +futures = { version = "0.3", features = ["compat"] } std_test_override = { path = "../std_test_override" } tokio-test = "0.4" tokio-stream = { version = "0.1", features = ["net"] } diff --git a/components/script_plugins/Cargo.toml b/components/script_plugins/Cargo.toml index 505317eb900..b5a4d6f43f1 100644 --- a/components/script_plugins/Cargo.toml +++ b/components/script_plugins/Cargo.toml @@ -15,4 +15,4 @@ unrooted_must_root_lint = [] trace_in_no_trace_lint = [] [package.metadata.rust-analyzer] -rustc_private=true +rustc_private = true diff --git a/components/selectors/Cargo.toml b/components/selectors/Cargo.toml index 880c4db0c61..bb9efec3a05 100644 --- a/components/selectors/Cargo.toml +++ b/components/selectors/Cargo.toml @@ -17,7 +17,7 @@ path = "lib.rs" [features] bench = [] -shmem = [ "dep:to_shmem", "dep:to_shmem_derive" ] +shmem = ["dep:to_shmem", "dep:to_shmem_derive"] [dependencies] bitflags = "1.0" diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index 44ac2998e83..483027736ef 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -18,10 +18,20 @@ doctest = false [features] gecko = ["style_traits/gecko", "bindgen", "regex", "toml", "num_cpus", "mozbuild"] -servo = ["serde", "style_traits/servo", "servo_atoms", "servo_config", "html5ever", - "cssparser/serde", "encoding_rs", "malloc_size_of/servo", "servo_url", - "string_cache", "to_shmem/servo", - "servo_arc/servo"] +servo = [ + "serde", + "style_traits/servo", + "servo_atoms", + "servo_config", + "html5ever", + "cssparser/serde", + "encoding_rs", + "malloc_size_of/servo", + "servo_url", + "string_cache", + "to_shmem/servo", + "servo_arc/servo", +] gecko_debug = [] gecko_refcount_logging = [] @@ -54,7 +64,7 @@ owning_ref = "0.4" parking_lot = "0.11" precomputed-hash = "0.1.1" rayon = "1" -selectors = { path = "../selectors", features = ["shmem"] } +selectors = { path = "../selectors", features = ["shmem"] } serde = { version = "1.0", optional = true, features = ["derive"] } servo_arc = { path = "../servo_arc" } servo_atoms = { path = "../atoms", optional = true } @@ -78,7 +88,7 @@ void = "1.0.2" bindgen = { version = "0.62", optional = true, default-features = false } lazy_static = "1" log = "0.4" -mozbuild = {version = "0.1", optional = true} +mozbuild = { version = "0.1", optional = true } regex = { version = "1.1", optional = true } toml = { version = "0.5", optional = true, default-features = false } walkdir = "2.1.4" diff --git a/components/webrender_surfman/Cargo.toml b/components/webrender_surfman/Cargo.toml index 13469c9d40d..b84cf344220 100644 --- a/components/webrender_surfman/Cargo.toml +++ b/components/webrender_surfman/Cargo.toml @@ -13,4 +13,3 @@ path = "lib.rs" [dependencies] euclid = { workspace = true } surfman = { workspace = true } - diff --git a/components/webrender_traits/Cargo.toml b/components/webrender_traits/Cargo.toml index 98dd3c4e5e4..f078b96101d 100644 --- a/components/webrender_traits/Cargo.toml +++ b/components/webrender_traits/Cargo.toml @@ -13,4 +13,3 @@ path = "lib.rs" [dependencies] euclid = { workspace = true } webrender_api = { workspace = true } - diff --git a/ports/gstplugin/Cargo.toml b/ports/gstplugin/Cargo.toml index a8db373fa1b..739610d4959 100644 --- a/ports/gstplugin/Cargo.toml +++ b/ports/gstplugin/Cargo.toml @@ -34,4 +34,3 @@ webxr = { git = "https://github.com/servo/webxr", features = ["glwindow"] } [build-dependencies] gst-plugin-version-helper = "0.2" - diff --git a/ports/libsimpleservo/api/Cargo.toml b/ports/libsimpleservo/api/Cargo.toml index 39e62004e32..17ce97834fe 100644 --- a/ports/libsimpleservo/api/Cargo.toml +++ b/ports/libsimpleservo/api/Cargo.toml @@ -13,7 +13,7 @@ libservo = { path = "../../../components/servo" } log = { workspace = true } servo-media = { git = "https://github.com/servo/media" } surfman = { workspace = true, features = ["sm-angle-default"] } -webxr = { git = "https://github.com/servo/webxr"} +webxr = { git = "https://github.com/servo/webxr" } webxr-api = { git = "https://github.com/servo/webxr", features = ["ipc"] } [target.'cfg(not(target_os = "macos"))'.dependencies] @@ -31,7 +31,7 @@ libloading = "0.5" [build-dependencies] gl_generator = "0.14" serde_json = { workspace = true } -vergen = { version = "8.0.0", features = [ "git", "gitcl" ]} +vergen = { version = "8.0.0", features = ["git", "gitcl"] } [features] debugmozjs = ["libservo/debugmozjs"] diff --git a/ports/libsimpleservo/capi/cbindgen.toml b/ports/libsimpleservo/capi/cbindgen.toml index 2d6ddc3e531..e2b1dc8acd9 100644 --- a/ports/libsimpleservo/capi/cbindgen.toml +++ b/ports/libsimpleservo/capi/cbindgen.toml @@ -6,4 +6,3 @@ documentation_style = "c99" [export] exclude = ["OutputDebugStringA"] - diff --git a/ports/winit/Cargo.toml b/ports/winit/Cargo.toml index 06978d3ae69..f70305d63b8 100644 --- a/ports/winit/Cargo.toml +++ b/ports/winit/Cargo.toml @@ -14,7 +14,7 @@ path = "main.rs" bench = false [build-dependencies] -vergen = { version = "8.0.0", features = [ "git", "gitcl" ]} +vergen = { version = "8.0.0", features = ["git", "gitcl"] } [target.'cfg(windows)'.build-dependencies] winres = "0.1" diff --git a/python/tidy/tests/Cargo.toml b/python/tidy/tests/Cargo.toml index c664352e45f..37a8a5cabe1 100644 --- a/python/tidy/tests/Cargo.toml +++ b/python/tidy/tests/Cargo.toml @@ -8,4 +8,4 @@ publish = false test-package = { version = "*" } [lib] -path = "lib.rs" \ No newline at end of file +path = "lib.rs" diff --git a/python/tidy/tests/servo-tidy.toml b/python/tidy/tests/servo-tidy.toml index 690098b0e44..3e6117e2c80 100644 --- a/python/tidy/tests/servo-tidy.toml +++ b/python/tidy/tests/servo-tidy.toml @@ -12,8 +12,8 @@ wrong-key = true [ignore] files = [ - "./fake/file.html", + "./fake/file.html", ] directories = [ - "./fake/dir", + "./fake/dir", ] diff --git a/rustfmt.toml b/rustfmt.toml index 90fcdc76cd8..8968311a3f5 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,4 +1,4 @@ match_block_trailing_comma = true binop_separator = "Back" reorder_imports = true -ignore = [ "third_party" ] +ignore = ["third_party"] diff --git a/servo-tidy.toml b/servo-tidy.toml index 0560ae5afd8..14f4a16b862 100644 --- a/servo-tidy.toml +++ b/servo-tidy.toml @@ -10,123 +10,123 @@ check-ordered-json-keys = ["./resources/prefs.json"] [blocked-packages] num = [] rand = [ - "ipc-channel", - "phf_generator", - "quickcheck", # Only used in tests - "servo_rand", - "tungstenite", - "ws", + "ipc-channel", + "phf_generator", + "quickcheck", # Only used in tests + "servo_rand", + "tungstenite", + "ws", ] [ignore] # Ignored packages with duplicated versions packages = [ - "arrayvec", - "base64", - "cfg-if", - "cookie", - "fixedbitset", - "getrandom", - "image", - "itoa", - "libloading", - "metal", - "miniz_oxide", - "num-rational", - "parking_lot", - "parking_lot_core", - "petgraph", - "png", - "rand", - "rand_chacha", - "rand_core", - "redox_syscall", - "ron", - "time", - "wasi", - "wayland-sys", - "bitflags", + "arrayvec", + "base64", + "cfg-if", + "cookie", + "fixedbitset", + "getrandom", + "image", + "itoa", + "libloading", + "metal", + "miniz_oxide", + "num-rational", + "parking_lot", + "parking_lot_core", + "petgraph", + "png", + "rand", + "rand_chacha", + "rand_core", + "redox_syscall", + "ron", + "time", + "wasi", + "wayland-sys", + "bitflags", - # Duplicated by rustls and image. - "spin", + # Duplicated by rustls and image. + "spin", - # Duplicated by rustls and the version of webpki-roots required by async_tungstenite. - "rustls-webpki", + # Duplicated by rustls and the version of webpki-roots required by async_tungstenite. + "rustls-webpki", - # https://github.com/servo/servo/issues/26933 - "bytes", - "futures", - "mio", + # https://github.com/servo/servo/issues/26933 + "bytes", + "futures", + "mio", - # https://github.com/servo/servo/pull/23288#issuecomment-494687746 - "gl_generator", + # https://github.com/servo/servo/pull/23288#issuecomment-494687746 + "gl_generator", - # https://github.com/servo/servo/pull/25518 - "core-foundation", - "core-foundation-sys", - "lyon_geom", + # https://github.com/servo/servo/pull/25518 + "core-foundation", + "core-foundation-sys", + "lyon_geom", - # https://github.com/servo/servo/pull/28236 - "nix", + # https://github.com/servo/servo/pull/28236 + "nix", - # Duplicated by webrender debugger via ws - "block-buffer", - "digest", - "generic-array", + # Duplicated by webrender debugger via ws + "block-buffer", + "digest", + "generic-array", - # Duplicated by winit/surfman update. - "raw-window-handle", + # Duplicated by winit/surfman update. + "raw-window-handle", - # Temporarily duplicated until gleam can be upgrded. - "uuid", + # Temporarily duplicated until gleam can be upgrded. + "uuid", - # winit port minibrowser (servo/servo#30049) - "clipboard-win", + # winit port minibrowser (servo/servo#30049) + "clipboard-win", ] # Files that are ignored for all tidy and lint checks. files = [ - "./components/net/tests/parsable_mime/text", - # Ignore style files to avoid diverging too much from upstream Gecko - "./components/style/", - "./components/style_derive/parse.rs", - "./resources/hsts_preload.json", - "./tests/wpt/meta/MANIFEST.json", - "./tests/wpt/meta-legacy-layout/MANIFEST.json", - "./tests/wpt/mozilla/meta/MANIFEST.json", - "./tests/wpt/mozilla/meta-legacy-layout/MANIFEST.json", - # Long encoded string - "./tests/wpt/mozilla/tests/mozilla/resources/brotli.py", - "./tests/wpt/webgl/meta/MANIFEST.json", - # Upstream code from Khronos/WebGL uses tabs for indentation - "./tests/wpt/webgl/tests", - # Vendored from upstream - "./tests/wpt/webgpu/tests", - # Our import script is not currently respecting the lint. - "./tests/wpt/webgl/tools/import-conformance-tests.py", - # Ignore those files since the issues reported are on purpose - "./tests/html/bad-line-ends.html", - "./tests/wpt/mozilla/tests/css/fonts", - "./tests/wpt/mozilla/tests/css/pre_with_tab.html", - "./tests/wpt/mozilla/tests/mozilla/textarea_placeholder.html", - # Python 3 syntax causes "E901 SyntaxError" when flake8 runs in Python 2 - "./components/style/properties/build.py", - # The tidy tests currently don't pass tidy. - "./python/tidy/test.py", + "./components/net/tests/parsable_mime/text", + # Ignore style files to avoid diverging too much from upstream Gecko + "./components/style/", + "./components/style_derive/parse.rs", + "./resources/hsts_preload.json", + "./tests/wpt/meta/MANIFEST.json", + "./tests/wpt/meta-legacy-layout/MANIFEST.json", + "./tests/wpt/mozilla/meta/MANIFEST.json", + "./tests/wpt/mozilla/meta-legacy-layout/MANIFEST.json", + # Long encoded string + "./tests/wpt/mozilla/tests/mozilla/resources/brotli.py", + "./tests/wpt/webgl/meta/MANIFEST.json", + # Upstream code from Khronos/WebGL uses tabs for indentation + "./tests/wpt/webgl/tests", + # Vendored from upstream + "./tests/wpt/webgpu/tests", + # Our import script is not currently respecting the lint. + "./tests/wpt/webgl/tools/import-conformance-tests.py", + # Ignore those files since the issues reported are on purpose + "./tests/html/bad-line-ends.html", + "./tests/wpt/mozilla/tests/css/fonts", + "./tests/wpt/mozilla/tests/css/pre_with_tab.html", + "./tests/wpt/mozilla/tests/mozilla/textarea_placeholder.html", + # Python 3 syntax causes "E901 SyntaxError" when flake8 runs in Python 2 + "./components/style/properties/build.py", + # The tidy tests currently don't pass tidy. + "./python/tidy/test.py", ] # Directories that are ignored for the non-WPT tidy check. directories = [ - # Upstream - "./support/android/apk", - "./tests/wpt/harness", - "./tests/wpt/tests", - "./tests/wpt/mozilla/tests/mozilla/referrer-policy", - "./tests/wpt/mozilla/tests/webgl", - "./python/tidy/tests", - "./python/_virtualenv*", - "./python/mach", - # Generated and upstream code combined with our own. Could use cleanup - "./target", - "./third_party", + # Upstream + "./support/android/apk", + "./tests/wpt/harness", + "./tests/wpt/tests", + "./tests/wpt/mozilla/tests/mozilla/referrer-policy", + "./tests/wpt/mozilla/tests/webgl", + "./python/tidy/tests", + "./python/_virtualenv*", + "./python/mach", + # Generated and upstream code combined with our own. Could use cleanup + "./target", + "./third_party", ] # Directories that are checked for correct file extension diff --git a/taplo.toml b/taplo.toml new file mode 100644 index 00000000000..a629f939b96 --- /dev/null +++ b/taplo.toml @@ -0,0 +1,9 @@ +# upstream files we should not format +exclude = ["third_party/**", "tests/**"] + +[formatting] +array_auto_collapse = false +array_auto_expand = false +align_comments = false +column_width = 120 +indent_string = " "