forked from MrXujiang/xijs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add eslint specification and pre-commit check (MrXujiang#34)
* chore: add eslint specification and pre-commit check * chore: update .commitlintrc
- Loading branch information
Showing
48 changed files
with
445 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
extends: "@commitlint/config-conventional" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es2021": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:prettier/recommended" | ||
], | ||
"overrides": [], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
"plugins": ["@typescript-eslint", "prettier"], | ||
"rules": { | ||
"semi": "off", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"no-console": "error", | ||
"@typescript-eslint/no-this-alias": "off" | ||
}, | ||
"ignorePatterns": ["**/*.test.js"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx --no-install commitlint -e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,47 @@ | ||
import isArray from '../isArray'; | ||
import isArray from '../isArray'; | ||
/** | ||
* 对象数组、普通数组冒泡排序 | ||
* @param obj | ||
* @param arrKey | ||
* @param obj | ||
* @param arrKey | ||
* @param orderby | ||
* @returns | ||
* @returns | ||
* 对象数组使用 bubbleSort(arr,key,orderby) | ||
* 普通数组使用 bubbleSort(arr) bubbleSort(arr,'',orderby) | ||
*/ | ||
function bubbleSort(obj: (object | string | number) [], arrKey: string, orderby: 'asc' | 'desc' = 'asc') { | ||
let result : any[] = obj; | ||
let temp = null; | ||
if (isArray(obj)) { | ||
if (obj.length > 1) { | ||
for (let i = 0; i < result.length; i++) { | ||
for (let j = 0; j < i; j++) { | ||
let resultfiled_i = result[i][arrKey] | ||
? result[i][arrKey] | ||
: result[i], | ||
resultfiled_j = result[j][arrKey] | ||
? result[j][arrKey] | ||
: result[j]; | ||
// 降序 | ||
if (orderby === 'desc') { | ||
if (parseInt(resultfiled_i) > parseInt(resultfiled_j)) { | ||
temp = result[j]; | ||
result[j] = result[i]; | ||
result[i] = temp; | ||
} | ||
// 升序 | ||
} else { | ||
if (parseInt(resultfiled_i) < parseInt(resultfiled_j)) { | ||
temp = result[j]; | ||
result[j] = result[i]; | ||
result[i] = temp; | ||
} | ||
} | ||
} | ||
function bubbleSort( | ||
obj: (object | string | number)[], | ||
arrKey: string, | ||
orderby: 'asc' | 'desc' = 'asc', | ||
) { | ||
const result: any[] = obj; | ||
let temp = null; | ||
if (isArray(obj)) { | ||
if (obj.length > 1) { | ||
for (let i = 0; i < result.length; i++) { | ||
for (let j = 0; j < i; j++) { | ||
const resultfiled_i = result[i][arrKey] | ||
? result[i][arrKey] | ||
: result[i], | ||
resultfiled_j = result[j][arrKey] ? result[j][arrKey] : result[j]; | ||
// 降序 | ||
if (orderby === 'desc') { | ||
if (parseInt(resultfiled_i) > parseInt(resultfiled_j)) { | ||
temp = result[j]; | ||
result[j] = result[i]; | ||
result[i] = temp; | ||
} | ||
// 升序 | ||
} else { | ||
if (parseInt(resultfiled_i) < parseInt(resultfiled_j)) { | ||
temp = result[j]; | ||
result[j] = result[i]; | ||
result[i] = temp; | ||
} | ||
} | ||
} | ||
return result; | ||
}else throw Error('数据格式错误'); | ||
} | ||
} | ||
return result; | ||
} else throw Error('数据格式错误'); | ||
} | ||
export default bubbleSort; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.