Skip to content

Commit

Permalink
ci: lint deno.json (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
uki00a authored Jul 15, 2024
1 parent 495ff80 commit 5160c2b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ jobs:
deno task make_mod
git diff --exit-code
deno check mod.ts
- name: Run lint
- name: Run linters
run: |
deno fmt --check
deno lint
deno task check:deno-json
- name: Set up Redis ${{ matrix.redis }}
uses: shogo82148/actions-setup-redis@v1
with:
Expand Down
1 change: 1 addition & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"exclude": ["benchmark/", "tmp/", "vendor/"]
},
"tasks": {
"check:deno-json": "deno run --allow-read=deno.json tools/check_deno_json.js",
"test": "DENO_FUTURE=1 deno test --allow-net --allow-read=tests --allow-write=tests/tmp --allow-run=redis-server,redis-cli --coverage=coverage --trace-leaks",
"test:doc": "deno test --doc --no-run --import-map=import_map.test.json",
"coverage": "deno coverage ./coverage --lcov --output=coverage/lcov.info",
Expand Down
22 changes: 22 additions & 0 deletions tools/check_deno_json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { dirname, join } from "node:path";

const pathToDenoJSON = join(dirname(import.meta.dirname), "deno.json");
const denoJSON = JSON.parse(await Deno.readTextFile(pathToDenoJSON));
if (denoJSON.imports) {
// deno-lint-ignore no-console
console.error(
"`imports` should not be defined in `deno.json`. Use `import_map.test.json` instead.",
);
Deno.exit(1);
}

if (denoJSON.importMap) {
// deno-lint-ignore no-console
console.error(
"`importMap` should not be defined in `deno.json`. Use `import_map.test.json` instead.",
);
Deno.exit(1);
}

// deno-lint-ignore no-console
console.info("✅ OK");

0 comments on commit 5160c2b

Please sign in to comment.