From ae4abad2f1a7322077dd4be01a7848b927cd2bff Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Tue, 13 Aug 2024 19:34:42 -0700 Subject: [PATCH] chore(deps): update rules_lint --- .editorconfig | 3 + BUILD.bazel | 2 +- MODULE.bazel | 2 +- WORKSPACE.bzlmod | 8 - e2e/test/3p_deps.bats | 18 +- e2e/test/common.bats | 476 +++++++++++++------------- e2e/test/diagnostics.bats | 19 +- e2e/test/emit_cache.bats | 9 +- e2e/test/invalidation.bats | 43 ++- e2e/test/isolated_modules.bats | 17 +- e2e/test/source_maps.bats | 12 +- e2e/test/strategy.bats | 5 +- e2e/test/third_party_deps.bats | 32 +- e2e/test/tracing_and_performance.bats | 5 +- tools/BUILD.bazel | 30 -- tools/format/BUILD.bazel | 14 + 16 files changed, 331 insertions(+), 364 deletions(-) create mode 100644 .editorconfig delete mode 100644 tools/BUILD.bazel create mode 100644 tools/format/BUILD.bazel diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..4fea659f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,3 @@ +[[shell]] +indent_style = space +indent_size = 4 diff --git a/BUILD.bazel b/BUILD.bazel index e58dffbe..740ab566 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -30,7 +30,7 @@ buildifier( alias( name = "format", - actual = "//tools:format", + actual = "//tools/format", ) bzl_library( diff --git a/MODULE.bazel b/MODULE.bazel index f442b77b..9d123b75 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -21,7 +21,7 @@ bazel_dep(name = "rules_proto", version = "6.0.0") ####### Dev dependencies ######## -bazel_dep(name = "aspect_rules_lint", version = "0.9.1", dev_dependency = True) +bazel_dep(name = "aspect_rules_lint", version = "1.0.0-rc8", dev_dependency = True) bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.5.0", dev_dependency = True) bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True) bazel_dep(name = "gazelle", version = "0.36.0", dev_dependency = True, repo_name = "bazel_gazelle") diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod index 14dafc13..cd7b79ce 100644 --- a/WORKSPACE.bzlmod +++ b/WORKSPACE.bzlmod @@ -3,14 +3,6 @@ load("//.github/workflows:deps.bzl", "aspect_workflows_github_actions_deps") aspect_workflows_github_actions_deps() -# TODO: rules_lint doesn't have a way to bring deps in under bzlmod -load( - "@aspect_rules_lint//format:repositories.bzl", - "fetch_shfmt", -) - -fetch_shfmt() - # Needed for stardoc to compile from Java sources http_jar( name = "protobuf-java", diff --git a/e2e/test/3p_deps.bats b/e2e/test/3p_deps.bats index fbb32680..fdfb67bd 100644 --- a/e2e/test/3p_deps.bats +++ b/e2e/test/3p_deps.bats @@ -15,15 +15,15 @@ teardown() { workspace --npm-translate-lock tsconfig - echo 'export * as core from "@nestjs/core"' > source.ts - echo 'console.log("test")' >> source.ts + echo 'export * as core from "@nestjs/core"' >source.ts + echo 'console.log("test")' >>source.ts - ts_project -l -s "source.ts" -d ":node_modules/@types/node" -d ":node_modules/@nestjs/core" -d ":node_modules/@nestjs/common" + ts_project -l -s "source.ts" -d ":node_modules/@types/node" -d ":node_modules/@nestjs/core" -d ":node_modules/@nestjs/common" run bazel build :foo - assert_success + assert_success refute_output -p "error" "@nestjs/core" "@types/node" - # upgrade: @nestjs/core from 9.2.0 to 9.2.1 + # upgrade: @nestjs/core from 9.2.0 to 9.2.1 # dowgrade: @types/node from 18.11.9 to 18.6.1 run pnpm add @nestjs/core@9.2.1 @types/node@18.6.1 --lockfile-only @@ -31,11 +31,11 @@ teardown() { assert_failure assert_output -p "error TS2403: Subsequent variable declarations must have the same type. Variable 'AbortSignal' must be of type" - # dowgrade: @nestjs/core from 9.2.1 to 9.2.0 - # upgrade: @types/node from 18.6.1 to 18.11.9 + # dowgrade: @nestjs/core from 9.2.1 to 9.2.0 + # upgrade: @types/node from 18.6.1 to 18.11.9 run pnpm add @nestjs/core@9.2.0 @types/node@18.11.9 --lockfile-only run bazel build :foo - assert_success + assert_success refute_output -p "error" "@nestjs/core" "@types/node" -} \ No newline at end of file +} diff --git a/e2e/test/common.bats b/e2e/test/common.bats index dc17f085..014c3669 100644 --- a/e2e/test/common.bats +++ b/e2e/test/common.bats @@ -2,24 +2,24 @@ bats_load_library "bats-support" bats_load_library "bats-assert" function workspace() { - local rules_ts_path="$(realpath $BATS_TEST_DIRNAME/../../)" - local -i is_npm_translate_lock=0 - local -i no_convenience_symlinks=0 - while (($# > 0)); do - case "$1" in - -t | --npm-translate-lock) - is_npm_translate_lock=1 - shift - ;; - -t | --noconvenience-symlinks) - no_convenience_symlinks=1 - shift - ;; - *) break ;; - esac - done + local rules_ts_path="$(realpath $BATS_TEST_DIRNAME/../../)" + local -i is_npm_translate_lock=0 + local -i no_convenience_symlinks=0 + while (($# > 0)); do + case "$1" in + -t | --npm-translate-lock) + is_npm_translate_lock=1 + shift + ;; + -t | --noconvenience-symlinks) + no_convenience_symlinks=1 + shift + ;; + *) break ;; + esac + done - cat >WORKSPACE <WORKSPACE <.bazelrc <.bazelrc <>.bazelrc - fi + if ((no_convenience_symlinks)); then + echo "build --noexperimental_convenience_symlinks" >>.bazelrc + fi - if ((is_npm_translate_lock)); then - cat >>WORKSPACE <>WORKSPACE < 0)); do - case "$1" in - --path) - shift - path="$1" - shift - ;; - --no-implicit-any) - no_implicit_any="true" - shift - ;; - --isolated-modules) - isolated_modules="true" - shift - ;; - --source-map) - source_map="true" - shift - ;; - --declaration) - declaration="true" - shift - ;; - --composite) - composite="true" - shift - ;; - --target) - shift - target="$1" - shift - ;; - --module-resolution) - shift - module_resolution="$1" - shift - ;; - --trace-resolution) - trace_resolution="true" - shift - ;; - --extended-diagnostics) - extended_diagnostics="true" - shift - ;; - *) break ;; - esac - done - cat >"$path/tsconfig.json" < 0)); do + case "$1" in + --path) + shift + path="$1" + shift + ;; + --no-implicit-any) + no_implicit_any="true" + shift + ;; + --isolated-modules) + isolated_modules="true" + shift + ;; + --source-map) + source_map="true" + shift + ;; + --declaration) + declaration="true" + shift + ;; + --composite) + composite="true" + shift + ;; + --target) + shift + target="$1" + shift + ;; + --module-resolution) + shift + module_resolution="$1" + shift + ;; + --trace-resolution) + trace_resolution="true" + shift + ;; + --extended-diagnostics) + extended_diagnostics="true" + shift + ;; + *) break ;; + esac + done + cat >"$path/tsconfig.json" < 0)); do - case "$1" in - --path) - shift - path="$1" - shift - ;; - --out_dir) - shift - out_dir="$1" - shift - ;; - --tsconfig) - shift - tsconfig="$1" - shift - ;; - -n | --name) - shift - name="$1" - shift - ;; - -l | --npm-link-all-packages) - npm_link_all_packages="" - shift - ;; - -d | --dep) - shift - deps+=("\"$1"\") - shift - ;; - -s | --src) - shift - srcs+=("\"$1\"") - shift - ;; - --arg) - shift - args+=("\"$1\"" "\"$2\"") - shift - shift - ;; - --source-map) - shift - source_map="source_map = True," - ;; - --declaration) - shift - declaration="declaration = True," - ;; - --composite) - shift - composite="composite = True," - ;; - --) - shift - break - ;; - *) break ;; - esac - done - local deps_joined=$( - IFS=, - echo "${deps[*]}" - ) - local srcs_joined=$( - IFS=, - echo "${srcs[*]}" - ) - local args_joined=$( - IFS=, - echo "${args[*]}" - ) - cat >"$path/BUILD.bazel" < 0)); do + case "$1" in + --path) + shift + path="$1" + shift + ;; + --out_dir) + shift + out_dir="$1" + shift + ;; + --tsconfig) + shift + tsconfig="$1" + shift + ;; + -n | --name) + shift + name="$1" + shift + ;; + -l | --npm-link-all-packages) + npm_link_all_packages="" + shift + ;; + -d | --dep) + shift + deps+=("\"$1"\") + shift + ;; + -s | --src) + shift + srcs+=("\"$1\"") + shift + ;; + --arg) + shift + args+=("\"$1\"" "\"$2\"") + shift + shift + ;; + --source-map) + shift + source_map="source_map = True," + ;; + --declaration) + shift + declaration="declaration = True," + ;; + --composite) + shift + composite="composite = True," + ;; + --) + shift + break + ;; + *) break ;; + esac + done + local deps_joined=$( + IFS=, + echo "${deps[*]}" + ) + local srcs_joined=$( + IFS=, + echo "${srcs[*]}" + ) + local args_joined=$( + IFS=, + echo "${args[*]}" + ) + cat >"$path/BUILD.bazel" < 0)); do - case "$1" in - --path) - shift - path="$1" - shift - ;; - -n | --name) - shift - name="$1" - shift - ;; - -s | --src) - shift - srcs+=("\"$1\"") - shift - ;; - -l | --npm-link-all-packages) - npm_link_all_packages="" - shift - ;; - --) - shift - break - ;; - *) break ;; - esac - done - local -a srcs_joined=$( - IFS=, - echo "${srcs[*]}" - ) - cat >"$path/BUILD.bazel" < 0)); do + case "$1" in + --path) + shift + path="$1" + shift + ;; + -n | --name) + shift + name="$1" + shift + ;; + -s | --src) + shift + srcs+=("\"$1\"") + shift + ;; + -l | --npm-link-all-packages) + npm_link_all_packages="" + shift + ;; + --) + shift + break + ;; + *) break ;; + esac + done + local -a srcs_joined=$( + IFS=, + echo "${srcs[*]}" + ) + cat >"$path/BUILD.bazel" < 0)); do - case "$1" in - --path) - shift - path="$1" - shift - ;; - -n | --name) - shift - name="$1" - shift - ;; - -s | --src) - shift - srcs+=("\"$1\"") - shift - ;; - --) - shift - break - ;; - *) break ;; - esac - done - local -a srcs_joined=$( - IFS=, - echo "${srcs[*]}" - ) - cat >>"$path/BUILD.bazel" < 0)); do + case "$1" in + --path) + shift + path="$1" + shift + ;; + -n | --name) + shift + name="$1" + shift + ;; + -s | --src) + shift + srcs+=("\"$1\"") + shift + ;; + --) + shift + break + ;; + *) break ;; + esac + done + local -a srcs_joined=$( + IFS=, + echo "${srcs[*]}" + ) + cat >>"$path/BUILD.bazel" < source.ts + echo 'const t: string = 1' >source.ts run bazel build :foo assert_failure assert_output -p "source.ts(1,7): error TS2322: Type 'number' is not assignable to type 'string'" "FAILED: Build did NOT complete successfully" } - @test 'should stop reporting diagnostics' { workspace ts_project --src "source.ts" tsconfig - echo 'const t: string;' > source.ts + echo 'const t: string;' >source.ts run bazel build :foo assert_failure assert_output -p "source.ts(1,7): error TS1155: 'const' declarations must be initialized." - echo 'const t: string = "";' > source.ts + echo 'const t: string = "";' >source.ts run bazel build :foo assert_success refute_output -p "error" @@ -39,9 +38,9 @@ teardown() { workspace ts_project --src "source.ts" --src "to_be_removed.ts" tsconfig - echo 'let t: string;' > source.ts - echo 'const t2: string;' > to_be_removed.ts - + echo 'let t: string;' >source.ts + echo 'const t2: string;' >to_be_removed.ts + run bazel build :foo assert_failure assert_output -p "to_be_removed.ts(1,7): error TS1155: 'const' declarations must be initialized." @@ -57,8 +56,8 @@ teardown() { workspace ts_project --src "source.ts" tsconfig - echo 'export function t(a) { return typeof a != "string" }' > source.ts - + echo 'export function t(a) { return typeof a != "string" }' >source.ts + run bazel build :foo assert_success refute_output -p "error" @@ -67,4 +66,4 @@ teardown() { run bazel build :foo assert_failure assert_output -p "source.ts(1,19): error TS7006: Parameter 'a' implicitly has an 'any' type." -} \ No newline at end of file +} diff --git a/e2e/test/emit_cache.bats b/e2e/test/emit_cache.bats index 4876534d..4c0504b1 100644 --- a/e2e/test/emit_cache.bats +++ b/e2e/test/emit_cache.bats @@ -9,23 +9,22 @@ teardown() { rm -rf $BATS_FILE_TMPDIR/* } - @test 'should emit .tsbuildinfo' { workspace mkdir ./a ./b - echo "export function a(): string { return 'a'; }" > ./a/index.ts + echo "export function a(): string { return 'a'; }" >./a/index.ts tsconfig --path ./a --declaration --composite ts_project --path ./a --name a --src "index.ts" --declaration --composite - echo "export function b(): string { return 'b'; }" > ./b/index.ts + echo "export function b(): string { return 'b'; }" >./b/index.ts tsconfig --path ./b --declaration --composite ts_project --path ./b --name b --src "index.ts" --declaration --composite - echo "export * from './a'; export * from './b'" > index.ts + echo "export * from './a'; export * from './b'" >index.ts tsconfig --declaration --composite ts_project --src "index.ts" --dep "//a" --dep "//b" --declaration --composite run bazel build :foo assert_success -} \ No newline at end of file +} diff --git a/e2e/test/invalidation.bats b/e2e/test/invalidation.bats index c66678d6..1f6a77a2 100644 --- a/e2e/test/invalidation.bats +++ b/e2e/test/invalidation.bats @@ -1,7 +1,5 @@ load "common.bats" - - setup() { cd $BATS_FILE_TMPDIR } @@ -18,17 +16,17 @@ teardown() { workspace # js_library pivot - echo "export declare function name(): string;" > ./apps/triad/pivot/index.d.ts - echo "module.exports = { name: function () { return 'pivot'; } };" > ./apps/triad/pivot/index.js + echo "export declare function name(): string;" >./apps/triad/pivot/index.d.ts + echo "module.exports = { name: function () { return 'pivot'; } };" >./apps/triad/pivot/index.js js_library --path ./apps/triad/pivot --name pivot --src "index.d.ts" --src "index.js" # ts_project vibe - echo "export function name(): string { return 'vibe'; }" > ./apps/triad/vibe/index.ts + echo "export function name(): string { return 'vibe'; }" >./apps/triad/vibe/index.ts tsconfig --path ./apps/triad/vibe --declaration ts_project --path ./apps/triad/vibe --name vibe --declaration --src "index.ts" - + # ts_project triad - cat > ./apps/triad/main.ts <./apps/triad/main.ts < ./feature1/index.ts + echo "export function name1(): string { return 'feature1'; }" >./feature1/index.ts tsconfig --path ./feature1 --declaration ts_project --path ./feature1 --name feature1 --declaration --src "index.ts" - echo "export function name2(): string { return 'feature2'; }" > ./feature2/index.ts + echo "export function name2(): string { return 'feature2'; }" >./feature2/index.ts tsconfig --path ./feature2 --declaration ts_project --path ./feature2 --name feature2 --declaration --src "index.ts" - echo "export * from './feature1'; export * from './feature2'" > index.ts + echo "export * from './feature1'; export * from './feature2'" >index.ts tsconfig - + ts_project --src "index.ts" run bazel build :foo assert_failure assert_output -p "index.ts(1,15): error TS2307: Cannot find module './feature1' or its corresponding type declarations." - assert_output -p "index.ts(1,43): error TS2307: Cannot find module './feature2' or its corresponding type declarations." + assert_output -p "index.ts(1,43): error TS2307: Cannot find module './feature2' or its corresponding type declarations." ts_project --src "index.ts" --dep "//feature1" run bazel build :foo assert_failure refute_output -p "index.ts(1,15): error TS2307: Cannot find module './feature1' or its corresponding type declarations." - assert_output -p "index.ts(1,43): error TS2307: Cannot find module './feature2' or its corresponding type declarations." + assert_output -p "index.ts(1,43): error TS2307: Cannot find module './feature2' or its corresponding type declarations." ts_project --src "index.ts" --dep "//feature2" run bazel build :foo assert_failure assert_output -p "index.ts(1,15): error TS2307: Cannot find module './feature1' or its corresponding type declarations." - refute_output -p "index.ts(1,43): error TS2307: Cannot find module './feature2' or its corresponding type declarations." + refute_output -p "index.ts(1,43): error TS2307: Cannot find module './feature2' or its corresponding type declarations." ts_project --src "index.ts" --dep "//feature1" --dep "//feature2" @@ -104,18 +102,17 @@ EOF @test 'should not read a file thats been removed from srcs' { workspace tsconfig - echo "const t = true;" > default.ts + echo "const t = true;" >default.ts - for i in $(seq 0 10) - do - echo "const a = $i" > "source_$i.ts" + for i in $(seq 0 10); do + echo "const a = $i" >"source_$i.ts" ts_project --src default.ts --src "source_$i.ts" run bazel build :foo assert_success rm "source_$i.ts" ts_project --src default.ts - run bazel build :foo + run bazel build :foo assert_success done } @@ -123,21 +120,21 @@ EOF @test 'should handle tsconfig change, file addition and removal in one batch' { workspace tsconfig - echo "export class T{ get t(){ return 'test' } }" > default.ts + echo "export class T{ get t(){ return 'test' } }" >default.ts ts_project --src default.ts - run bazel build :foo + run bazel build :foo assert_success run cat bazel-bin/default.js assert_output -p "get t() { return 'test'; }" tsconfig --target ES5 rm default.ts - echo "export class T{ get t(){ return 'test' } }" > new.ts + echo "export class T{ get t(){ return 'test' } }" >new.ts ts_project --src new.ts run bazel build :foo assert_success run cat bazel-bin/new.js refute_output -p "get t() { return 'test'; }" 'var T = /** @class */ (function () {" "Object.defineProperty(T.prototype, "t", {' -} \ No newline at end of file +} diff --git a/e2e/test/isolated_modules.bats b/e2e/test/isolated_modules.bats index ab10bed6..e38ee8ca 100644 --- a/e2e/test/isolated_modules.bats +++ b/e2e/test/isolated_modules.bats @@ -13,9 +13,9 @@ teardown() { workspace tsconfig - echo 'function fn() {}' > nonmodule.ts - echo 'export type test = string' > lib.ts - echo 'import {test} from "./lib"; export {test}' > source.ts + echo 'function fn() {}' >nonmodule.ts + echo 'export type test = string' >lib.ts + echo 'import {test} from "./lib"; export {test}' >source.ts ts_project -s "source.ts" -s "lib.ts" -s "nonmodule.ts" run bazel build :foo @@ -28,14 +28,13 @@ teardown() { assert_output -p "nonmodule.ts(1,1): error TS1208: 'nonmodule.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module." } - @test 'should report errors for 3p deps' { run pnpm add @types/node@18.11.9 --lockfile-only workspace --npm-translate-lock tsconfig --extended-diagnostics - echo 'import {BigIntStats} from "node:fs"; export {BigIntStats}' > source.ts + echo 'import {BigIntStats} from "node:fs"; export {BigIntStats}' >source.ts ts_project -l -s "source.ts" -d ":node_modules/@types/node" run bazel build :foo @@ -43,10 +42,10 @@ teardown() { refute_output -p "error" tsconfig --isolated-modules --extended-diagnostics - echo " " >> source.ts # TODO: figure out why the case above works but not this one. + echo " " >>source.ts # TODO: figure out why the case above works but not this one. run bazel build :foo - + assert_failure assert_output -p "source.ts(1,46): error TS1205: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'." - -} \ No newline at end of file + +} diff --git a/e2e/test/source_maps.bats b/e2e/test/source_maps.bats index c0df6e31..d8fd97d1 100644 --- a/e2e/test/source_maps.bats +++ b/e2e/test/source_maps.bats @@ -13,7 +13,7 @@ teardown() { workspace tsconfig --source-map ts_project --src "source.ts" --source-map - echo 'const t: string = "sourcemaps";' > source.ts + echo 'const t: string = "sourcemaps";' >source.ts run bazel build :foo assert_success run cat bazel-bin/source.js.map @@ -26,7 +26,7 @@ teardown() { mkdir subpkg tsconfig --path "./subpkg" --source-map ts_project --path "./subpkg" --src "source.ts" --source-map - echo 'const t: string = "sourcemaps";' > ./subpkg/source.ts + echo 'const t: string = "sourcemaps";' >./subpkg/source.ts run bazel build //subpkg:foo assert_success run cat bazel-bin/subpkg/source.js.map @@ -38,7 +38,7 @@ teardown() { workspace tsconfig --source-map ts_project --src "source.ts" --source-map --out_dir "outdir" - echo 'const t: string = "sourcemaps";' > source.ts + echo 'const t: string = "sourcemaps";' >source.ts run bazel build :foo assert_success run cat bazel-bin/outdir/source.js.map @@ -51,7 +51,7 @@ teardown() { tsconfig ts_project --src "sourcemap.ts" - echo 'const t: string = "sourcemaps";' > sourcemap.ts + echo 'const t: string = "sourcemaps";' >sourcemap.ts run bazel build :foo assert_success @@ -59,13 +59,11 @@ teardown() { assert_failure assert_output -p "No such file or directory" - tsconfig --source-map ts_project --src "sourcemap.ts" --source-map - echo 'const t: string = "sourcemaps";' > sourcemap.ts + echo 'const t: string = "sourcemaps";' >sourcemap.ts run bazel build :foo assert_success run cat bazel-bin/sourcemap.js.map assert_output -p '{"version":3,"file":"sourcemap.js","sourceRoot":"","sources":["sourcemap.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,GAAW,YAAY,CAAC"}' } - diff --git a/e2e/test/strategy.bats b/e2e/test/strategy.bats index 04ff285b..e5aa944a 100644 --- a/e2e/test/strategy.bats +++ b/e2e/test/strategy.bats @@ -14,19 +14,18 @@ teardown() { tsconfig ts_project --src "source.ts" - echo 'const t: string = "sandboxed";' > source.ts + echo 'const t: string = "sandboxed";' >source.ts run bazel build :foo --strategy=TsProject=sandboxed assert_success refute_output -p "WARNING: Running" "TsProject" "as a standalone process" "From Compiling TypeScript project" } - @test 'should build successfully and print the error message with --strategy=local' { workspace tsconfig ts_project --src "source.ts" - echo 'const t: string = "local";' > source.ts + echo 'const t: string = "local";' >source.ts run bazel build :foo --strategy=TsProject=local --@aspect_rules_ts//ts:supports_workers assert_success assert_output -p "WARNING: Running" "TsProject" "as a standalone process" "From Compiling TypeScript project" diff --git a/e2e/test/third_party_deps.bats b/e2e/test/third_party_deps.bats index 12468372..6c304174 100644 --- a/e2e/test/third_party_deps.bats +++ b/e2e/test/third_party_deps.bats @@ -15,7 +15,7 @@ teardown() { workspace --npm-translate-lock tsconfig - echo 'export * as core from "@nestjs/core"' > source.ts + echo 'export * as core from "@nestjs/core"' >source.ts ts_project -l -s "source.ts" -d ":node_modules/@types/node" run bazel build :foo @@ -28,7 +28,7 @@ teardown() { ts_project -l -s "source.ts" -d ":node_modules/@nestjs/core" run bazel build :foo - assert_failure + assert_failure assert_output -p "error TS2688: Cannot find type definition file for 'node'." "error TS2503: Cannot find namespace 'NodeJS'." ts_project -l -s "source.ts" -d ":node_modules/@nestjs/core" -d ":node_modules/@types/node" @@ -42,8 +42,8 @@ teardown() { workspace --npm-translate-lock tsconfig --extended-diagnostics --trace-resolution - echo 'import * as debug from "debug";' > source.ts - echo 'debug.log("test");' >> source.ts + echo 'import * as debug from "debug";' >source.ts + echo 'debug.log("test");' >>source.ts ts_project -l -s "source.ts" -d ":node_modules/@types/debug" run bazel build :foo @@ -54,48 +54,46 @@ teardown() { run bazel build :foo assert_success refute_output -p "Cannot find module 'debug' or its corresponding type declarations." - + # TODO: !!!!A TYPESCRIPT BUG!!!. we correctly report changes for modules but tsc doesn't calculate diagnostics for sources eventhough modules don't exist anymore. # think this as if you'd have to do cmd+s to make tsc --watch to reconsider the decision. - echo " " >> source.ts + echo " " >>source.ts ts_project -l -s "source.ts" run bazel build :foo assert_failure assert_output -p "source.ts(1,24): error TS2307: Cannot find module 'debug' or its corresponding type declarations." } - @test 'should report new transitive deps correctly and tsc should not ignore it' { workspace --npm-translate-lock --noconvenience-symlinks # bazel- symlinks makes pnpm hang tsconfig --extended-diagnostics --trace-resolution mkdir -p ./features/cool ./features/notcool - echo "export declare function cool(): import('@feature/notcool').not" > ./features/cool/index.d.ts + echo "export declare function cool(): import('@feature/notcool').not" >./features/cool/index.d.ts js_library -l --path ./features/cool --name cool_lib --src "index.d.ts" npm_package --path ./features/cool --name cool --src ":cool_lib" - echo '{"name": "@feature/cool"}' > ./features/cool/package.json + echo '{"name": "@feature/cool"}' >./features/cool/package.json - echo "export declare type not = string" > ./features/notcool/index.d.ts + echo "export declare type not = string" >./features/notcool/index.d.ts js_library -l --path ./features/notcool --name notcool_lib --src "index.d.ts" npm_package --path ./features/notcool --name notcool --src ":notcool_lib" - echo '{"name": "@feature/notcool"}' > ./features/notcool/package.json + echo '{"name": "@feature/notcool"}' >./features/notcool/package.json - echo '-packages: ["features/cool", "features/notcool"]' > pnpm-workspace.yaml - echo '{"dependencies":{"@feature/cool": "workspace:*", "@types/node": "*"}}' > package.json + echo '-packages: ["features/cool", "features/notcool"]' >pnpm-workspace.yaml + echo '{"dependencies":{"@feature/cool": "workspace:*", "@types/node": "*"}}' >package.json run pnpm install --lockfile-only assert_success - echo "import {cool} from '@feature/cool'; export const t: number = cool()" > source.ts + echo "import {cool} from '@feature/cool'; export const t: number = cool()" >source.ts ts_project -l -s "source.ts" -d ":node_modules/@feature/cool" run bazel build :foo --@aspect_rules_ts//ts:supports_workers assert_failure assert_output -p "node_modules/.aspect_rules_js/@feature+cool@0.0.0/node_modules/@feature/cool/index.d.ts(1,40): error TS2307: Cannot find module '@feature/notcool' or its corresponding type declarations." - - echo '{"dependencies":{"@feature/cool": "workspace:*", "@types/node": "*"}, "pnpm": {"packageExtensions": {"@feature/cool": {"dependencies": {"@feature/notcool": "workspace:*"}}}}}' > package.json + echo '{"dependencies":{"@feature/cool": "workspace:*", "@types/node": "*"}, "pnpm": {"packageExtensions": {"@feature/cool": {"dependencies": {"@feature/notcool": "workspace:*"}}}}}' >package.json run pnpm install --lockfile-only assert_success run bazel build :foo --@aspect_rules_ts//ts:supports_workers assert_success -} \ No newline at end of file +} diff --git a/e2e/test/tracing_and_performance.bats b/e2e/test/tracing_and_performance.bats index 6bc19175..efbb5fdc 100644 --- a/e2e/test/tracing_and_performance.bats +++ b/e2e/test/tracing_and_performance.bats @@ -9,14 +9,13 @@ teardown() { rm -rf $BATS_FILE_TMPDIR/* } - @test 'should print diagnostics with --worker_verbose flag' { workspace tsconfig ts_project --src "source.ts" - echo "export const f = 1;" > source.ts + echo "export const f = 1;" >source.ts run bazel build :foo --@aspect_rules_ts//ts:supports_workers assert_success run cat $(bazel info output_base)/bazel-workers/worker-1-TsProject.log - assert_output -p "# Beginning new work" "# Finished the work" "creating a new worker with the key" + assert_output -p "# Beginning new work" "# Finished the work" "creating a new worker with the key" } diff --git a/tools/BUILD.bazel b/tools/BUILD.bazel deleted file mode 100644 index 91369d89..00000000 --- a/tools/BUILD.bazel +++ /dev/null @@ -1,30 +0,0 @@ -"""BUILD definition for the formatter binary -This is in its own package because it has so many loading-time symbols, -we don't want to trigger eager fetches of these for builds that don't want to run format. -""" - -load("@aspect_rules_lint//format:defs.bzl", "multi_formatter_binary") - -package(default_visibility = ["//:__subpackages__"]) - -sh_binary( - name = "noop", - srcs = ["noop.sh"], -) - -alias( - name = "shfmt", - actual = select({ - "@bazel_tools//src/conditions:darwin_arm64": "@shfmt_darwin_aarch64//file:shfmt", - "@bazel_tools//src/conditions:darwin_x86_64": "@shfmt_darwin_x86_64//file:shfmt", - "@bazel_tools//src/conditions:linux_aarch64": "@shfmt_linux_aarch64//file:shfmt", - "@bazel_tools//src/conditions:linux_x86_64": "@shfmt_linux_x86_64//file:shfmt", - "//conditions:default": ":noop", - }), -) - -multi_formatter_binary( - name = "format", - sh = ":shfmt", - starlark = "@buildifier_prebuilt//:buildifier", -) diff --git a/tools/format/BUILD.bazel b/tools/format/BUILD.bazel new file mode 100644 index 00000000..ebcc4957 --- /dev/null +++ b/tools/format/BUILD.bazel @@ -0,0 +1,14 @@ +"""BUILD definition for the formatter binary +This is in its own package because it has so many loading-time symbols, +we don't want to trigger eager fetches of these for builds that don't want to run format. +""" + +load("@aspect_rules_lint//format:defs.bzl", "format_multirun") + +package(default_visibility = ["//:__subpackages__"]) + +format_multirun( + name = "format", + shell = "@aspect_rules_lint//format:shfmt", + starlark = "@buildifier_prebuilt//:buildifier", +)