Skip to content

Commit 9b32855

Browse files
committed
Correctly configure linting tool for testing
1 parent 37f94ed commit 9b32855

File tree

7 files changed

+45
-32
lines changed

7 files changed

+45
-32
lines changed

.github/workflows/js-qa.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ jobs:
2828
- name: Install
2929
run: yarn install
3030

31-
- name: Linting JavaScript
31+
- name: Lint Source Code
3232
run: yarn lint
3333

34-
- name: Testing JavaScript
34+
- name: Lint Tests
35+
run: yarn lint:test
36+
37+
- name: Execute Tests
3538
run: yarn test

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"jest.jestCommandLine": "yarn jest",
33
"jest.rootPath": "src",
4-
"favorites.resources": []
4+
"favorites.resources": [],
5+
"typescript.tsdk": "node_modules/typescript/lib"
56
}

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
"scripts": {
2828
"build": "tsc --outDir build && ncc build -o dist ./index.ts",
2929
"prettify": "prettier --write src/**/*.ts index.ts",
30-
"lint": "eslint . --ext .ts",
31-
"prepare": "husky"
30+
"lint": "eslint ./src --ext .ts",
31+
"lint:test": "eslint --config ./tests/.eslintrc.js ./tests --ext .ts",
32+
"prepare": "husky",
33+
"test": "jest --config ./tests/jest.config.ts",
34+
"qa": "yarn lint && yarn lint:test && yarn test"
3235
}
3336
}

tests/.eslintrc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
extends: path.resolve(__dirname, '../.eslintrc.json'),
5+
parserOptions: {
6+
project: './tsconfig.json',
7+
tsconfigRootDir: __dirname,
8+
},
9+
};

jest.config.ts renamed to tests/jest.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ module.exports = {
44
preset: 'ts-jest',
55
moduleDirectories: ['node_modules'],
66
moduleNameMapper: {
7-
'^@/(.*)$': '<rootDir>/src/$1',
8-
'^@model/(.*)$': '<rootDir>/src/model/$1',
7+
'^@/(.*)$': '<rootDir>/../src/$1',
8+
'^@model/(.*)$': '<rootDir>/../src/model/$1',
99
},
10-
setupFilesAfterEnv: ['<rootDir>/tests/setup-tests.ts'],
10+
setupFilesAfterEnv: ['<rootDir>/setup-tests.ts'],
1111
maxWorkers: 8,
1212
};

tests/tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"baseUrl": "./",
5+
"typeRoots": ["../node_modules/@types"],
6+
"paths": {
7+
"@/*": ["../src/*"],
8+
"@model/*": ["../src/model/*"]
9+
},
10+
"rootDir": "./"
11+
},
12+
"include": ["../src/**/*.ts", "./unit/**/*.ts", "jest.config.ts", "setup-tests.ts"],
13+
"exclude": ["../node_modules"]
14+
}

tsconfig.json

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,15 @@
2424
"baseUrl": "./",
2525
"module": "nodeNext",
2626
"moduleResolution": "NodeNext",
27-
"typeRoots": [
28-
"./node_modules/@types"
29-
],
27+
"typeRoots": ["./node_modules/@types"],
3028
"paths": {
31-
"@/*": [
32-
"./src/*"
33-
],
34-
"@model/*": [
35-
"./src/model/*"
36-
],
37-
"*": [
38-
"node_modules/*",
39-
"types/*"
40-
]
29+
"@/*": ["./src/*"],
30+
"@model/*": ["./src/model/*"],
31+
"*": ["node_modules/*", "types/*"]
4132
},
4233
"rootDir": "./"
4334
},
44-
"files": [
45-
"./index.ts"
46-
],
47-
"include": [
48-
"./src/**/*.ts",
49-
"./tests/**/*.ts",
50-
"jest.config.ts"
51-
],
52-
"exclude": [
53-
"node_modules"
54-
]
35+
"files": ["./index.ts"],
36+
"include": ["./src/**/*.ts"],
37+
"exclude": ["node_modules", "tests"]
5538
}

0 commit comments

Comments
 (0)