Skip to content

Commit 2ab6621

Browse files
authored
Merge pull request #28 from sinoui/jest-setup-files
Jest setup files
2 parents ccdef2d + 2a26f97 commit 2ab6621

File tree

13 files changed

+128
-10
lines changed

13 files changed

+128
-10
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# 变更说明
22

3+
## v0.5.2 - 2019.11.1
4+
5+
- fix(ts-lib-scripts): 修复 lint-staged 配置错误
6+
- fix(eslint-config-ts-lib): 修复单元测试代码提示 `import/no-extraneous-dependencies` 错误
7+
- fix(ts-lib-tools): 修复无法添加 Jest 初始化配置文件的缺陷 ( #24 )
8+
39
## v0.5.1 - 2019.11.1
410

511
- fix(ts-lib-tools): 修复非 monorepo 模式下,单元测试会阻止打包命令执行的错误 ( #23 )

examples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
}
4141
},
4242
"lint-staged": {
43-
"*.{js,jsx,ts,tsx}": [
43+
"src/**/*.{js,jsx,ts,tsx}": [
4444
"eslint --fix",
4545
"git add"
4646
]

packages/eslint-config-ts-lib/index.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,18 @@ const eslintConfig = {
5454
'react-hooks/exhaustive-deps': 'warn',
5555
'import/no-extraneous-dependencies': [
5656
'error',
57-
{ devDependencies: ['**/*.{spec,test}.{ts,tsx,js,jsx}'] },
57+
{
58+
devDependencies: [
59+
'**/*.test.ts',
60+
'**/*.test.tsx',
61+
'**/*.spec.ts',
62+
'**/*.spec.tsx',
63+
'**/*.test.js',
64+
'**/*.test.jsx',
65+
'**/*.spec.js',
66+
'**/*.spec.jsx',
67+
],
68+
},
5869
],
5970
'@typescript-eslint/explicit-function-return-type': 0,
6071
'import/named': 0,
@@ -101,8 +112,8 @@ const eslintConfig = {
101112
],
102113
'no-console': ['warn', { allow: ['warn', 'error'] }],
103114
// 关闭标准的缩进和typescript缩进规则,启用prettier的缩进规则
104-
"indent": "off",
105-
"@typescript-eslint/indent": "off"
115+
indent: 'off',
116+
'@typescript-eslint/indent': 'off',
106117
},
107118

108119
overrides: [
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2019 sinoui
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
'Software'), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# eslint-config-ts-lib
2+
3+
[ts-lib-scripts](https://github.com/sinoui/ts-lib-scripts) 创建的 ts 库项目使用的 ESLint 配置
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
if (typeof window !== 'undefined') {
2+
window.requestAnimationFrame = (callback) => {
3+
return setTimeout(callback, 16);
4+
};
5+
window.cancelAnimationFrame = (rafId) => {
6+
clearTimeout(rafId);
7+
};
8+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "ts-lib-jsdom-polyfill",
3+
"description": "ts库的 jsdom polyfill",
4+
"version": "0.5.1",
5+
"main": "index.js",
6+
"license": "MIT",
7+
"homepage": "https://github.com/sinoui/ts-lib-scripts",
8+
"bugs": {
9+
"url": "https://github.com/sinoui/ts-lib-scripts/issues"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/sinoui/ts-lib-scripts.git"
14+
},
15+
"files": [
16+
"index.js"
17+
],
18+
"peerDependencies": {
19+
"@typescript-eslint/eslint-plugin": "2.x",
20+
"@typescript-eslint/parser": "2.x",
21+
"eslint": "6.x",
22+
"eslint-config-airbnb": "18.x",
23+
"eslint-config-prettier": "6.x",
24+
"eslint-import-resolver-typescript": "1.x",
25+
"eslint-plugin-import": "2.x",
26+
"eslint-plugin-jsx-a11y": "6.x",
27+
"eslint-plugin-prettier": "3.x",
28+
"eslint-plugin-react": "7.x",
29+
"eslint-plugin-react-hooks": "1.x",
30+
"eslint-plugin-standard": "4.x"
31+
},
32+
"gitHead": "a0ec9d27b2f24cb228993286530f89957d055b9b"
33+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"include": ["."],
4+
"compilerOptions": {
5+
"allowJs": true,
6+
"noEmit": true
7+
}
8+
}

packages/ts-lib-scripts/assets/react-template/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
}
3636
},
3737
"lint-staged": {
38-
"src/*.{ts,tsx}": [
38+
"src/**/*.{ts,tsx}": [
3939
"cross-env CI=true ts-lib-tools test",
4040
"eslint --fix --color",
4141
"git add"

packages/ts-lib-scripts/assets/template/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
}
3636
},
3737
"lint-staged": {
38-
"src/*.{ts,tsx}": [
38+
"src/**/*.{ts,tsx}": [
3939
"cross-env CI=true ts-lib-tools test",
4040
"eslint --fix --color",
4141
"git add"

0 commit comments

Comments
 (0)