Skip to content

Commit

Permalink
Correctly configure linting tool for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
widoz committed Apr 23, 2024
1 parent 37f94ed commit 9b32855
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 32 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/js-qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ jobs:
- name: Install
run: yarn install

- name: Linting JavaScript
- name: Lint Source Code
run: yarn lint

- name: Testing JavaScript
- name: Lint Tests
run: yarn lint:test

- name: Execute Tests
run: yarn test
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"jest.jestCommandLine": "yarn jest",
"jest.rootPath": "src",
"favorites.resources": []
"favorites.resources": [],
"typescript.tsdk": "node_modules/typescript/lib"
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
"scripts": {
"build": "tsc --outDir build && ncc build -o dist ./index.ts",
"prettify": "prettier --write src/**/*.ts index.ts",
"lint": "eslint . --ext .ts",
"prepare": "husky"
"lint": "eslint ./src --ext .ts",
"lint:test": "eslint --config ./tests/.eslintrc.js ./tests --ext .ts",
"prepare": "husky",
"test": "jest --config ./tests/jest.config.ts",
"qa": "yarn lint && yarn lint:test && yarn test"
}
}
9 changes: 9 additions & 0 deletions tests/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const path = require('path');

module.exports = {
extends: path.resolve(__dirname, '../.eslintrc.json'),
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: __dirname,
},
};
6 changes: 3 additions & 3 deletions jest.config.ts → tests/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ module.exports = {
preset: 'ts-jest',
moduleDirectories: ['node_modules'],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
'^@model/(.*)$': '<rootDir>/src/model/$1',
'^@/(.*)$': '<rootDir>/../src/$1',
'^@model/(.*)$': '<rootDir>/../src/model/$1',
},
setupFilesAfterEnv: ['<rootDir>/tests/setup-tests.ts'],
setupFilesAfterEnv: ['<rootDir>/setup-tests.ts'],
maxWorkers: 8,
};
14 changes: 14 additions & 0 deletions tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": "./",
"typeRoots": ["../node_modules/@types"],
"paths": {
"@/*": ["../src/*"],
"@model/*": ["../src/model/*"]
},
"rootDir": "./"
},
"include": ["../src/**/*.ts", "./unit/**/*.ts", "jest.config.ts", "setup-tests.ts"],
"exclude": ["../node_modules"]
}
31 changes: 7 additions & 24 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,15 @@
"baseUrl": "./",
"module": "nodeNext",
"moduleResolution": "NodeNext",
"typeRoots": [
"./node_modules/@types"
],
"typeRoots": ["./node_modules/@types"],
"paths": {
"@/*": [
"./src/*"
],
"@model/*": [
"./src/model/*"
],
"*": [
"node_modules/*",
"types/*"
]
"@/*": ["./src/*"],
"@model/*": ["./src/model/*"],
"*": ["node_modules/*", "types/*"]
},
"rootDir": "./"
},
"files": [
"./index.ts"
],
"include": [
"./src/**/*.ts",
"./tests/**/*.ts",
"jest.config.ts"
],
"exclude": [
"node_modules"
]
"files": ["./index.ts"],
"include": ["./src/**/*.ts"],
"exclude": ["node_modules", "tests"]
}

0 comments on commit 9b32855

Please sign in to comment.