Skip to content

Commit

Permalink
chore(deps): update rules_lint
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle committed Aug 14, 2024
1 parent c06bb78 commit 67c4b97
Show file tree
Hide file tree
Showing 14 changed files with 413 additions and 449 deletions.
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ buildifier(

alias(
name = "format",
actual = "//tools:format",
actual = "//tools/format",
)

bzl_library(
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 0 additions & 8 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
50 changes: 25 additions & 25 deletions e2e/test/3p_deps.bats
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
load "common.bats"

setup() {
cd $BATS_FILE_TMPDIR
cd $BATS_FILE_TMPDIR
}

teardown() {
bazel shutdown
rm -rf $BATS_FILE_TMPDIR/*
bazel shutdown
rm -rf $BATS_FILE_TMPDIR/*
}

@test 'should handle 3p dependency upgrade and downgrade gracefully' {
run pnpm add @nestjs/[email protected] @nestjs/[email protected] [email protected] @types/[email protected] --lockfile-only
run pnpm add @nestjs/[email protected] @nestjs/[email protected] [email protected] @types/[email protected] --lockfile-only

workspace --npm-translate-lock
tsconfig
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"
run bazel build :foo
assert_success
refute_output -p "error" "@nestjs/core" "@types/node"
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
refute_output -p "error" "@nestjs/core" "@types/node"

# 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/[email protected] @types/[email protected] --lockfile-only
# 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/[email protected] @types/[email protected] --lockfile-only

run bazel build :foo
assert_failure
assert_output -p "error TS2403: Subsequent variable declarations must have the same type. Variable 'AbortSignal' must be of type"
run bazel build :foo
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
run pnpm add @nestjs/[email protected] @types/[email protected] --lockfile-only
# 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/[email protected] @types/[email protected] --lockfile-only

run bazel build :foo
assert_success
refute_output -p "error" "@nestjs/core" "@types/node"
}
run bazel build :foo
assert_success
refute_output -p "error" "@nestjs/core" "@types/node"
}
97 changes: 48 additions & 49 deletions e2e/test/diagnostics.bats
Original file line number Diff line number Diff line change
@@ -1,70 +1,69 @@
load "common.bats"

setup() {
cd $BATS_FILE_TMPDIR
cd $BATS_FILE_TMPDIR
}

teardown() {
bazel shutdown
rm -rf $BATS_FILE_TMPDIR/*
bazel shutdown
rm -rf $BATS_FILE_TMPDIR/*
}

@test 'build a target that will never succeed' {
workspace
ts_project --src "source.ts"
tsconfig
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"
workspace
ts_project --src "source.ts"
tsconfig
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
run bazel build :foo
assert_failure
assert_output -p "source.ts(1,7): error TS1155: 'const' declarations must be initialized."
workspace
ts_project --src "source.ts"
tsconfig
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
run bazel build :foo
assert_success
refute_output -p "error"
echo 'const t: string = "";' >source.ts
run bazel build :foo
assert_success
refute_output -p "error"
}

@test 'should stop reporting diagnostics for removed srcs' {
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
run bazel build :foo
assert_failure
assert_output -p "to_be_removed.ts(1,7): error TS1155: 'const' declarations must be initialized."
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

run bazel build :foo
assert_failure
assert_output -p "to_be_removed.ts(1,7): error TS1155: 'const' declarations must be initialized."

rm to_be_removed.ts
ts_project --src "source.ts"
run bazel build :foo
assert_success
refute_output -p "error"
rm to_be_removed.ts
ts_project --src "source.ts"
run bazel build :foo
assert_success
refute_output -p "error"
}

@test 'tsconfig changes should emit new errors' {
workspace
ts_project --src "source.ts"
tsconfig
echo 'export function t(a) { return typeof a != "string" }' > source.ts

run bazel build :foo
assert_success
refute_output -p "error"
workspace
ts_project --src "source.ts"
tsconfig
echo 'export function t(a) { return typeof a != "string" }' >source.ts

tsconfig --no-implicit-any
run bazel build :foo
assert_failure
assert_output -p "source.ts(1,19): error TS7006: Parameter 'a' implicitly has an 'any' type."
}
run bazel build :foo
assert_success
refute_output -p "error"

tsconfig --no-implicit-any
run bazel build :foo
assert_failure
assert_output -p "source.ts(1,19): error TS7006: Parameter 'a' implicitly has an 'any' type."
}
35 changes: 17 additions & 18 deletions e2e/test/emit_cache.bats
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
load "common.bats"

setup() {
cd $BATS_FILE_TMPDIR
cd $BATS_FILE_TMPDIR
}

teardown() {
bazel shutdown
rm -rf $BATS_FILE_TMPDIR/*
bazel shutdown
rm -rf $BATS_FILE_TMPDIR/*
}


@test 'should emit .tsbuildinfo' {
workspace
mkdir ./a ./b
workspace
mkdir ./a ./b

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 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
tsconfig --path ./b --declaration --composite
ts_project --path ./b --name b --src "index.ts" --declaration --composite
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
tsconfig --declaration --composite
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
}
ts_project --src "index.ts" --dep "//a" --dep "//b" --declaration --composite
run bazel build :foo
assert_success
}
Loading

0 comments on commit 67c4b97

Please sign in to comment.