From c1223e37d35472f1d32b9f52ea5b0cd2765e3f21 Mon Sep 17 00:00:00 2001 From: Matthew Struble Date: Wed, 10 Mar 2021 19:17:49 -0800 Subject: [PATCH] chore: more setup with linter/jest and ts --- .eslintrc | 5 +++-- .gitlab-ci.yml | 3 ++- package.json | 4 +++- src/index.test.ts | 2 +- tsconfig.build.json | 5 +++++ tsconfig.json | 5 +++-- yarn.lock | 9 ++++++++- 7 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 tsconfig.build.json diff --git a/.eslintrc b/.eslintrc index a2747ff..fa5f823 100644 --- a/.eslintrc +++ b/.eslintrc @@ -8,7 +8,7 @@ "project": "tsconfig.json", "sourceType": "module" }, - "plugins": ["@typescript-eslint", "import"], + "plugins": ["@typescript-eslint", "import", "jest"], "extends": [ "eslint:recommended", "plugin:@typescript-eslint/recommended", @@ -40,7 +40,8 @@ "files": ["**/*.test.ts"], "env": { "jest/globals": true - } + }, + "extends": ["plugin:jest/recommended", "plugin:jest/style"] } ] } diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fc4518b..2e93cac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,6 +4,7 @@ before_script: cache: key: "$CI_COMMIT_REF_SLUG" paths: + - "tsconfig.build.tsbuildinfo" - "node_modules/" .base: @@ -15,13 +16,13 @@ build: extends: .base stage: build script: - - "yarn run eslint ./src" - "yarn build" test: extends: .base stage: test script: + - "yarn lint" - "yarn test" # TODO automatically create tags from builds on master diff --git a/package.json b/package.json index 144769e..3a36ac2 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "license": "MIT", "type": "module", "scripts": { - "build": "tsc", + "lint": "eslint ./src", + "build": "tsc --build tsconfig.build.json", "test": "jest" }, "jest": { @@ -20,6 +21,7 @@ "@typescript-eslint/parser": "^4.17.0", "eslint": "^7.21.0", "eslint-plugin-import": "^2.22.1", + "eslint-plugin-jest": "^24.2.1", "jest": "^26.6.3", "ts-jest": "^26.5.3", "typescript": "^4.2.3" diff --git a/src/index.test.ts b/src/index.test.ts index 65ab722..377366f 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -1,3 +1,3 @@ -describe.only("todo", () => { +describe("todo", () => { test.todo("hello world!"); }); diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000..678d21d --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,5 @@ +{ + "extends": "./tsconfig.json", + "include": ["src/**/*.ts"], + "exclude": ["**/*.test.ts"] +} diff --git a/tsconfig.json b/tsconfig.json index 172d596..46e8e4d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,9 +13,10 @@ "declaration": true, "strict": true, - "esModuleInterop": true + "esModuleInterop": true, + "incremental": true }, "include": ["src/**/*.ts"], - "exclude": ["node_modules/", "**/*.test.ts"] + "exclude": ["node_modules/"] } diff --git a/yarn.lock b/yarn.lock index aa44607..a777413 100644 --- a/yarn.lock +++ b/yarn.lock @@ -666,7 +666,7 @@ semver "^7.3.2" tsutils "^3.17.1" -"@typescript-eslint/experimental-utils@4.17.0": +"@typescript-eslint/experimental-utils@4.17.0", "@typescript-eslint/experimental-utils@^4.0.1": version "4.17.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.17.0.tgz#762c44aaa1a6a3c05b6d63a8648fb89b89f84c80" integrity sha512-ZR2NIUbnIBj+LGqCFGQ9yk2EBQrpVVFOh9/Kd0Lm6gLpSAcCuLLe5lUCibKGCqyH9HPwYC0GIJce2O1i8VYmWA== @@ -1562,6 +1562,13 @@ eslint-plugin-import@^2.22.1: resolve "^1.17.0" tsconfig-paths "^3.9.0" +eslint-plugin-jest@^24.2.1: + version "24.2.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-24.2.1.tgz#7e84f16a3ca6589b86be9732a93d71367a4ed627" + integrity sha512-s24ve8WUu3DLVidvlSzaqlOpTZre9lTkZTAO+a7X0WMtj8HraWTiTEkW3pbDT1xVxqEHMWSv+Kx7MyqR50nhBw== + dependencies: + "@typescript-eslint/experimental-utils" "^4.0.1" + eslint-scope@^5.0.0, eslint-scope@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"