@sfirew/minecraft-motd-parser 1.1.4 → 1.1.5
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/CHANGELOG.md +278 -0
- package/README.md +125 -221
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/coverage-summary.json +13 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +131 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +131 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +632 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/eslint.config.mjs +82 -0
- package/jest.config.ts +32 -0
- package/package.json +17 -10
- package/types/index.d.ts +1 -1
- package/types/utils.d.ts +17 -10
- package/.eslintrc.ts +0 -23
- package/jest.config.js +0 -5
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
import tseslint from "typescript-eslint";
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
// Ignore patterns
|
|
7
|
+
{
|
|
8
|
+
ignores: ["dist/**", "node_modules/**", "*.min.js", "build/**"],
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
// Base JavaScript configuration
|
|
12
|
+
{
|
|
13
|
+
files: ["**/*.{js,mjs,cjs}"],
|
|
14
|
+
...js.configs.recommended,
|
|
15
|
+
languageOptions: {
|
|
16
|
+
ecmaVersion: "latest",
|
|
17
|
+
sourceType: "module",
|
|
18
|
+
globals: {
|
|
19
|
+
...globals.browser,
|
|
20
|
+
...globals.node,
|
|
21
|
+
...globals.es2021,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
// TypeScript configuration - use the recommended config directly
|
|
27
|
+
...tseslint.configs.recommended.map(config => ({
|
|
28
|
+
...config,
|
|
29
|
+
files: ["**/*.{ts,mts,cts}"],
|
|
30
|
+
languageOptions: {
|
|
31
|
+
...config.languageOptions,
|
|
32
|
+
ecmaVersion: "latest",
|
|
33
|
+
sourceType: "module",
|
|
34
|
+
globals: {
|
|
35
|
+
...globals.browser,
|
|
36
|
+
...globals.node,
|
|
37
|
+
...globals.es2021,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
})),
|
|
41
|
+
|
|
42
|
+
// Custom rules and relaxed settings
|
|
43
|
+
{
|
|
44
|
+
files: ["**/*.{js,mjs,cjs,ts,mts,cts}"],
|
|
45
|
+
rules: {
|
|
46
|
+
quotes: [
|
|
47
|
+
"error",
|
|
48
|
+
"double",
|
|
49
|
+
{ avoidEscape: true },
|
|
50
|
+
],
|
|
51
|
+
// Relax some strict rules for better development experience
|
|
52
|
+
"no-useless-escape": "warn",
|
|
53
|
+
|
|
54
|
+
// Keep these as errors for important issues
|
|
55
|
+
"no-redeclare": "error",
|
|
56
|
+
"no-undef": "error",
|
|
57
|
+
"no-constant-binary-expression": "error",
|
|
58
|
+
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
// TypeScript specific rules
|
|
63
|
+
{
|
|
64
|
+
files: ["**/*.{ts,mts,cts}"],
|
|
65
|
+
rules: {
|
|
66
|
+
"@typescript-eslint/no-explicit-any": "warn", // Change to warning instead of error
|
|
67
|
+
"@typescript-eslint/no-unused-vars": "warn",
|
|
68
|
+
"@typescript-eslint/no-require-imports": "warn",
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
// Test files - even more relaxed rules
|
|
73
|
+
{
|
|
74
|
+
files: ["test/**/*.{ts,js}", "**/*.test.{ts,js}", "**/*.spec.{ts,js}"],
|
|
75
|
+
rules: {
|
|
76
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
77
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
78
|
+
"@typescript-eslint/no-require-imports": "off",
|
|
79
|
+
"no-useless-escape": "off",
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
];
|
package/jest.config.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
2
|
+
export default {
|
|
3
|
+
preset: "ts-jest",
|
|
4
|
+
testEnvironment: "node",
|
|
5
|
+
collectCoverage: true,
|
|
6
|
+
collectCoverageFrom: [
|
|
7
|
+
"src/**/*.{ts,tsx}",
|
|
8
|
+
"!src/**/*.d.ts",
|
|
9
|
+
"!src/test.ts", // 排除自測試文件
|
|
10
|
+
],
|
|
11
|
+
coverageDirectory: "coverage",
|
|
12
|
+
coverageReporters: [
|
|
13
|
+
"text",
|
|
14
|
+
"lcov",
|
|
15
|
+
"html",
|
|
16
|
+
"json-summary"
|
|
17
|
+
],
|
|
18
|
+
coverageThreshold: {
|
|
19
|
+
global: {
|
|
20
|
+
branches: 80,
|
|
21
|
+
functions: 85,
|
|
22
|
+
lines: 85,
|
|
23
|
+
statements: 85
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
testMatch: [
|
|
27
|
+
"**/test/**/*.test.ts"
|
|
28
|
+
],
|
|
29
|
+
// 效能測試配置
|
|
30
|
+
testTimeout: 30000, // 30 秒超時
|
|
31
|
+
maxWorkers: "50%", // 使用 50% 的 CPU 核心
|
|
32
|
+
};
|
package/package.json
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sfirew/minecraft-motd-parser",
|
|
3
3
|
"description": "Minecraft Server MOTD Parser, can convert to html, json, text.",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.5",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "types/index.d.ts",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "jest",
|
|
11
|
+
"test:coverage": "jest --coverage",
|
|
12
|
+
"test:watch": "jest --watch",
|
|
13
|
+
"test:performance": "jest --testNamePattern=\"Performance test|Stress test\"",
|
|
14
|
+
"test:security": "jest --testNamePattern=\"Security Tests\"",
|
|
15
|
+
"test:all": "jest --coverage --verbose",
|
|
11
16
|
"test-self": "ts-node ./src/test.ts",
|
|
12
17
|
"build": "yarn build:dist && yarn build:declarations",
|
|
13
18
|
"build:dist": "tsup --format cjs,esm",
|
|
14
19
|
"build:declarations": "tsc --emitDeclarationOnly --declaration --outDir types",
|
|
15
|
-
"
|
|
20
|
+
"lint": "eslint \"**/*.ts\""
|
|
16
21
|
},
|
|
17
22
|
"tsup": {
|
|
18
23
|
"entry": [
|
|
@@ -24,17 +29,19 @@
|
|
|
24
29
|
"minify": true
|
|
25
30
|
},
|
|
26
31
|
"devDependencies": {
|
|
32
|
+
"@eslint/js": "^9.28.0",
|
|
27
33
|
"@jest/globals": "^29.7.0",
|
|
28
|
-
"@types/node": "^20.
|
|
29
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
30
|
-
"@typescript-eslint/parser": "^5.
|
|
31
|
-
"eslint": "^8.
|
|
34
|
+
"@types/node": "^20.17.57",
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
36
|
+
"@typescript-eslint/parser": "^5.62.0",
|
|
37
|
+
"eslint": "^8.57.1",
|
|
38
|
+
"globals": "^16.2.0",
|
|
32
39
|
"jest": "^29.7.0",
|
|
33
|
-
"
|
|
34
|
-
"ts-jest": "^29.2.2",
|
|
40
|
+
"ts-jest": "^29.3.4",
|
|
35
41
|
"ts-node": "^10.9.2",
|
|
36
|
-
"tsup": "^8.
|
|
37
|
-
"typescript": "^5.
|
|
42
|
+
"tsup": "^8.5.0",
|
|
43
|
+
"typescript": "^5.8.3",
|
|
44
|
+
"typescript-eslint": "^8.33.0"
|
|
38
45
|
},
|
|
39
46
|
"repository": "https://github.com/SnowFireWolf/minecraft-motd-parser.git",
|
|
40
47
|
"author": "SnowFireWolf",
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { htmlStringFormatting, cleanCodes, cleanHtmlTags } from "./utils";
|
|
2
2
|
import { JSONToHTML, JSONToCleanedText, textToHTML, textToJSON, JSONRender, autoToHTML, autoCleanToText } from "./parser";
|
|
3
|
-
export * from
|
|
3
|
+
export * from "./utils";
|
|
4
4
|
export * from "./parser";
|
|
5
5
|
declare const motdParser: {
|
|
6
6
|
textToHTML: typeof textToHTML;
|
package/types/utils.d.ts
CHANGED
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
import { motdJsonType } from "./types";
|
|
2
|
-
export declare function isMotdJSONType(object: object): object is motdJsonType;
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
5
|
-
|
|
3
|
+
* Base color code regex
|
|
4
|
+
*/
|
|
5
|
+
export declare const baseColorCodeRegex: RegExp;
|
|
6
|
+
export declare function isMotdJSONType(object: unknown): object is motdJsonType;
|
|
7
|
+
/**
|
|
8
|
+
* Replace all HTML special characters with HTML entities
|
|
9
|
+
* Prevents HTML injection by safely encoding special characters
|
|
6
10
|
*/
|
|
7
11
|
export declare function htmlStringFormatting(text: string): string;
|
|
8
12
|
/**
|
|
9
|
-
*
|
|
13
|
+
* Clean HTML tags safely
|
|
14
|
+
*
|
|
15
|
+
* Safely removes HTML tags and prevents HTML injection vulnerabilities.
|
|
10
16
|
*
|
|
11
|
-
* @param text
|
|
12
|
-
* example
|
|
17
|
+
* @param text - Input text that may contain HTML tags
|
|
18
|
+
* @example `<span>hello world</span>` → `hello world`
|
|
13
19
|
*
|
|
14
|
-
*
|
|
20
|
+
* @returns Clean text without HTML tags
|
|
15
21
|
*/
|
|
16
22
|
export declare function cleanHtmlTags(text: string): string;
|
|
17
23
|
/**
|
|
18
|
-
*
|
|
24
|
+
* Clean MOTD color codes
|
|
19
25
|
*
|
|
20
|
-
* Clean all codes from
|
|
26
|
+
* Clean all formatting codes from MOTD source string.
|
|
21
27
|
*
|
|
22
|
-
* @param {string} text -
|
|
28
|
+
* @param {string} text - MOTD string with § formatting codes to be removed
|
|
29
|
+
* @returns {string} Text without MOTD formatting codes
|
|
23
30
|
*/
|
|
24
31
|
export declare function cleanCodes(text: string): string;
|
package/.eslintrc.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
"env": {
|
|
3
|
-
"browser": true,
|
|
4
|
-
"es2021": true,
|
|
5
|
-
"node": true
|
|
6
|
-
},
|
|
7
|
-
"extends": [
|
|
8
|
-
"eslint:recommended",
|
|
9
|
-
"plugin:@typescript-eslint/recommended"
|
|
10
|
-
],
|
|
11
|
-
"overrides": [
|
|
12
|
-
],
|
|
13
|
-
"parser": "@typescript-eslint/parser",
|
|
14
|
-
"parserOptions": {
|
|
15
|
-
"ecmaVersion": "latest",
|
|
16
|
-
"sourceType": "module"
|
|
17
|
-
},
|
|
18
|
-
"plugins": [
|
|
19
|
-
"@typescript-eslint"
|
|
20
|
-
],
|
|
21
|
-
"rules": {
|
|
22
|
-
}
|
|
23
|
-
}
|