@bhsd/common 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +16 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +23 -0
- package/eslintrc.browser.cjs +15 -4
- package/eslintrc.cjs +15 -25
- package/eslintrc.dist.cjs +26 -0
- package/package.json +3 -5
package/.eslintrc.cjs
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,11 @@ export declare const CDN = "https://testingcf.jsdelivr.net";
|
|
|
2
2
|
declare global {
|
|
3
3
|
const define: unknown;
|
|
4
4
|
}
|
|
5
|
+
/**
|
|
6
|
+
* 包含颜色时断开字符串
|
|
7
|
+
* @param str 字符串
|
|
8
|
+
*/
|
|
9
|
+
export declare const splitColors: (str: string) => [string, number, number, boolean][];
|
|
5
10
|
/**
|
|
6
11
|
* 使用传统方法加载脚本
|
|
7
12
|
* @param src 脚本地址
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
export const CDN = 'https://testingcf.jsdelivr.net';
|
|
2
|
+
const hexColor = String.raw `#(?:[\da-f]{3,4}|(?:[\da-f]{2}){3,4})(?![\p{L}\d_])`, rgbColor = String.raw `rgba?\(\s*(?:${String.raw `[\d.]+\s+[\d.]+\s+[\d.]+(?:\s*\/\s*[\d.]+%?)?`}|${String.raw `[\d.]+\s*,\s*[\d.]+\s*,\s*[\d.]+(?:\s*,\s*[\d.]+%?)?`})\s*\)`, re = new RegExp(String.raw `(^|[^\p{L}\d_])(${hexColor}|${rgbColor})`, 'giu');
|
|
3
|
+
/**
|
|
4
|
+
* 包含颜色时断开字符串
|
|
5
|
+
* @param str 字符串
|
|
6
|
+
*/
|
|
7
|
+
export const splitColors = (str) => {
|
|
8
|
+
re.lastIndex = 0;
|
|
9
|
+
const pieces = [];
|
|
10
|
+
let mt = re.exec(str), lastIndex = 0;
|
|
11
|
+
while (mt) {
|
|
12
|
+
const index = mt.index + mt[1].length;
|
|
13
|
+
if (index > lastIndex) {
|
|
14
|
+
pieces.push([str.slice(lastIndex, index), lastIndex, index, false]);
|
|
15
|
+
}
|
|
16
|
+
({ lastIndex } = re);
|
|
17
|
+
pieces.push([mt[2], index, lastIndex, true]);
|
|
18
|
+
mt = re.exec(str);
|
|
19
|
+
}
|
|
20
|
+
if (str.length > lastIndex) {
|
|
21
|
+
pieces.push([str.slice(lastIndex), lastIndex, str.length, false]);
|
|
22
|
+
}
|
|
23
|
+
return pieces;
|
|
24
|
+
};
|
|
2
25
|
/**
|
|
3
26
|
* 使用传统方法加载脚本
|
|
4
27
|
* @param src 脚本地址
|
package/eslintrc.browser.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const config = require('
|
|
3
|
+
const config = require('./eslintrc.cjs');
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
6
|
...config,
|
|
@@ -16,13 +16,24 @@ module.exports = {
|
|
|
16
16
|
...config.rules,
|
|
17
17
|
'prefer-object-has-own': 0,
|
|
18
18
|
'es-x/no-array-prototype-at': 2,
|
|
19
|
-
'es-x/no-
|
|
20
|
-
'es-x/no-
|
|
19
|
+
'es-x/no-array-prototype-findlast-findlastindex': 2,
|
|
20
|
+
'es-x/no-array-prototype-toreversed': 2,
|
|
21
|
+
'es-x/no-array-prototype-tosorted': 2,
|
|
22
|
+
'es-x/no-array-prototype-tospliced': 2,
|
|
23
|
+
'es-x/no-array-prototype-with': 2,
|
|
24
|
+
'es-x/no-error-cause': 2,
|
|
25
|
+
'es-x/no-map-groupby': 2,
|
|
26
|
+
'es-x/no-object-groupby': 2,
|
|
21
27
|
'es-x/no-object-hasown': 2,
|
|
28
|
+
'es-x/no-promise-any': 2,
|
|
29
|
+
'es-x/no-promise-withresolvers': 2,
|
|
30
|
+
'es-x/no-regexp-d-flag': 2,
|
|
22
31
|
'es-x/no-regexp-lookbehind-assertions': 2,
|
|
32
|
+
'es-x/no-regexp-v-flag': 2,
|
|
23
33
|
'es-x/no-string-prototype-at': 2,
|
|
24
|
-
'es-x/no-string-prototype-
|
|
34
|
+
'es-x/no-string-prototype-iswellformed': 2,
|
|
25
35
|
'es-x/no-string-prototype-replaceall': 2,
|
|
36
|
+
'es-x/no-string-prototype-towellformed': 2,
|
|
26
37
|
},
|
|
27
38
|
settings: {
|
|
28
39
|
...config.settings,
|
package/eslintrc.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module.exports = {
|
|
4
4
|
root: true,
|
|
5
5
|
env: {
|
|
6
|
-
|
|
6
|
+
es2024: true,
|
|
7
7
|
},
|
|
8
8
|
plugins: [
|
|
9
9
|
'@stylistic',
|
|
@@ -19,11 +19,9 @@ module.exports = {
|
|
|
19
19
|
'plugin:eslint-comments/recommended',
|
|
20
20
|
],
|
|
21
21
|
parserOptions: {
|
|
22
|
-
ecmaVersion:
|
|
22
|
+
ecmaVersion: 'latest',
|
|
23
23
|
},
|
|
24
|
-
ignorePatterns: [
|
|
25
|
-
'dist/',
|
|
26
|
-
],
|
|
24
|
+
ignorePatterns: ['dist/'],
|
|
27
25
|
rules: {
|
|
28
26
|
'array-callback-return': 2,
|
|
29
27
|
'no-cond-assign': [
|
|
@@ -151,9 +149,7 @@ module.exports = {
|
|
|
151
149
|
'no-empty-function': [
|
|
152
150
|
2,
|
|
153
151
|
{
|
|
154
|
-
allow: [
|
|
155
|
-
'arrowFunctions',
|
|
156
|
-
],
|
|
152
|
+
allow: ['arrowFunctions'],
|
|
157
153
|
},
|
|
158
154
|
],
|
|
159
155
|
'no-empty-static-block': 2,
|
|
@@ -345,7 +341,7 @@ module.exports = {
|
|
|
345
341
|
2,
|
|
346
342
|
{
|
|
347
343
|
allowBlockStart: true,
|
|
348
|
-
ignorePattern:
|
|
344
|
+
ignorePattern: String.raw`^\* @`,
|
|
349
345
|
},
|
|
350
346
|
],
|
|
351
347
|
'@stylistic/lines-between-class-members': [
|
|
@@ -612,9 +608,7 @@ module.exports = {
|
|
|
612
608
|
'jsdoc/check-indentation': [
|
|
613
609
|
1,
|
|
614
610
|
{
|
|
615
|
-
excludeTags: [
|
|
616
|
-
'description',
|
|
617
|
-
],
|
|
611
|
+
excludeTags: ['description'],
|
|
618
612
|
},
|
|
619
613
|
],
|
|
620
614
|
'jsdoc/check-tag-names': 1,
|
|
@@ -649,7 +643,11 @@ module.exports = {
|
|
|
649
643
|
contexts: [
|
|
650
644
|
'FunctionDeclaration:not(TSDeclareFunction + FunctionDeclaration)',
|
|
651
645
|
'TSDeclareFunction:not(TSDeclareFunction + TSDeclareFunction)',
|
|
652
|
-
|
|
646
|
+
'MethodDefinition:not('
|
|
647
|
+
+ 'MethodDefinition:has(TSEmptyBodyFunctionExpression) + MethodDefinition,'
|
|
648
|
+
+ "[kind='get'] + [kind='set'],"
|
|
649
|
+
+ '[override=true]'
|
|
650
|
+
+ ')',
|
|
653
651
|
],
|
|
654
652
|
exemptEmptyConstructors: true,
|
|
655
653
|
checkGetters: true,
|
|
@@ -676,9 +674,7 @@ module.exports = {
|
|
|
676
674
|
{
|
|
677
675
|
files: '**/*.json',
|
|
678
676
|
parser: 'eslint-plugin-json-es',
|
|
679
|
-
extends: [
|
|
680
|
-
'plugin:eslint-plugin-json-es/recommended',
|
|
681
|
-
],
|
|
677
|
+
extends: ['plugin:eslint-plugin-json-es/recommended'],
|
|
682
678
|
rules: {
|
|
683
679
|
'@stylistic/array-bracket-newline': [
|
|
684
680
|
2,
|
|
@@ -723,9 +719,7 @@ module.exports = {
|
|
|
723
719
|
ecmaVersion: 'latest',
|
|
724
720
|
project: './tsconfig.json',
|
|
725
721
|
},
|
|
726
|
-
plugins: [
|
|
727
|
-
'@typescript-eslint',
|
|
728
|
-
],
|
|
722
|
+
plugins: ['@typescript-eslint'],
|
|
729
723
|
extends: [
|
|
730
724
|
'plugin:@typescript-eslint/recommended',
|
|
731
725
|
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
|
@@ -753,9 +747,7 @@ module.exports = {
|
|
|
753
747
|
'@typescript-eslint/no-empty-function': [
|
|
754
748
|
2,
|
|
755
749
|
{
|
|
756
|
-
allow: [
|
|
757
|
-
'arrowFunctions',
|
|
758
|
-
],
|
|
750
|
+
allow: ['arrowFunctions'],
|
|
759
751
|
},
|
|
760
752
|
],
|
|
761
753
|
'no-invalid-this': 0,
|
|
@@ -887,9 +879,7 @@ module.exports = {
|
|
|
887
879
|
'@typescript-eslint/no-this-alias': [
|
|
888
880
|
2,
|
|
889
881
|
{
|
|
890
|
-
allowedNames: [
|
|
891
|
-
'self',
|
|
892
|
-
],
|
|
882
|
+
allowedNames: ['self'],
|
|
893
883
|
},
|
|
894
884
|
],
|
|
895
885
|
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 2,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
root: true,
|
|
5
|
+
env: {
|
|
6
|
+
browser: true,
|
|
7
|
+
es2024: true,
|
|
8
|
+
},
|
|
9
|
+
plugins: ['es-x'],
|
|
10
|
+
extends: ['plugin:es-x/restrict-to-es2019'],
|
|
11
|
+
parserOptions: {
|
|
12
|
+
ecmaVersion: 'latest',
|
|
13
|
+
},
|
|
14
|
+
rules: {
|
|
15
|
+
'es-x/no-global-this': 0,
|
|
16
|
+
'es-x/no-import-meta': 0,
|
|
17
|
+
'es-x/no-promise-all-settled': 0,
|
|
18
|
+
'es-x/no-regexp-lookbehind-assertions': 2,
|
|
19
|
+
'es-x/no-string-prototype-matchall': 0,
|
|
20
|
+
},
|
|
21
|
+
settings: {
|
|
22
|
+
'es-x': {
|
|
23
|
+
aggressive: true,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bhsd/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "GPL-2.0",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"files": [
|
|
6
7
|
"/dist/",
|
|
7
8
|
"*.cjs"
|
|
@@ -10,10 +11,7 @@
|
|
|
10
11
|
"types": "./dist/index.d.ts",
|
|
11
12
|
"scripts": {
|
|
12
13
|
"build": "tsc",
|
|
13
|
-
"lint": "tsc --noEmit && eslint
|
|
14
|
-
},
|
|
15
|
-
"engines": {
|
|
16
|
-
"node": "^20.9.0"
|
|
14
|
+
"lint": "tsc --noEmit && eslint --cache ."
|
|
17
15
|
},
|
|
18
16
|
"devDependencies": {
|
|
19
17
|
"@stylistic/eslint-plugin": "^2.3.0",
|