Skip to content

Commit

Permalink
add eslint; split building and linting in makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
reinhrst committed Dec 10, 2023
1 parent 7b60f82 commit e4334b9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
19 changes: 19 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": { "project": "./tsconfig.json" },
"plugins": ["@typescript-eslint"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"rules": {
"@typescript-eslint/no-floating-promises": ["error"],
"no-constant-condition": ["error", { "checkLoops": false }],
"@typescript-eslint/no-unused-vars": [
"warn", // or "error"
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}
]
}
}
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
# is unchanged.
run: make -t public/app/bundled/libavjs/version.txt || true
- name: Build
run: DOCKER="docker buildx" DOCKER_TMPDIR=/tmp make all
run: DOCKER="docker buildx" DOCKER_TMPDIR=/tmp make lint all
- name: Set AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand Down
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ LIBAVJS_MAKE_FILES := $(addprefix dist/libav-$(LIBAVJS_VERSION)-, $(LIBAVJS_BASE
LIBAVJS_TARGET_FILES := $(addprefix public/app/bundled/libavjs-$(LIBAVJS_COMMIT)/, $(LIBAVJS_MAKE_FILES))
HTML_FILES := $(wildcard *.html)
HTML_TARGET_FILES := $(addprefix public/, $(HTML_FILES))
ENTRYPOINTS := $(shell node -p "require('./tsconfig.json').include.filter(x => !x.endsWith('.d.ts')).join(' ')")
ENTRYPOINTS := \
./src/convert/App.tsx \
./src/infer/App.tsx \
./src/debug/App.tsx \
./src/viewer/index.tsx
OUTFILESBASE := $(basename $(ENTRYPOINTS:./src/%=app/%))

.PHONY=all public/app/bundled/libavjs
.PHONY=all public/app/bundled/libavjs lint

all: public/app/tsc public/app/bundled/libavjs-$(LIBAVJS_COMMIT)/version.txt $(HTML_TARGET_FILES) public/app/bundled/tfjs-wasm

Expand Down Expand Up @@ -43,8 +47,11 @@ node_modules/tag: package.json
@cd node_modules/libavjs-webcodecs-bridge && make all
@touch $@

public/app/tsc: tsconfig.json $(shell find src) public/app/bundled/libavjs-$(LIBAVJS_COMMIT)/version.txt node_modules/tag
lint: tsconfig.json $(shell find src) public/app/bundled/libavjs-$(LIBAVJS_COMMIT)/version.txt node_modules/tag
@tsc --noEmit
@./node_modules/eslint/bin/eslint.js src

public/app/tsc: tsconfig.json $(shell find src) public/app/bundled/libavjs-$(LIBAVJS_COMMIT)/version.txt node_modules/tag
@./node_modules/esbuild/bin/esbuild $(ENTRYPOINTS) --sourcemap --bundle --format=esm --outbase=src --outdir=public/app/
@(cd public $(foreach ext,js css,$(foreach outfilebase,$(OUTFILESBASE),&& MD5=$$(md5sum "$(outfilebase).$(ext)" | cut -c-10) && mv "$(outfilebase).$(ext)" "$(outfilebase).$${MD5}.$(ext)" && echo "s|$(outfilebase).$(ext)|$(outfilebase).$${MD5}.$(ext)|g"))) > $@.part
@echo "s|app/bundled/libavjs/|app/bundled/libavjs-$(LIBAVJS_COMMIT)/|g" >> $@.part
Expand Down
5 changes: 1 addition & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
}
},
"include": [
"./src/Globals.d.ts",
"./src/convert/App.tsx",
"./src/infer/App.tsx",
"./src/viewer/index.tsx"
"./src"
]
}

0 comments on commit e4334b9

Please sign in to comment.