@mocoto/mahoraga 0.14.6 → 0.14.8
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/README.md +165 -511
- package/dist/analysts/css/analysts/analyst-css.js +10 -1
- package/dist/analysts/detectors/detector-bugs-ml.js +81 -19
- package/dist/analysts/js-ts/registrar.js +1 -1
- package/dist/analysts/react/analysts/analyst-react-hooks.js +109 -90
- package/dist/analysts/react/detectors/detector-react-best-practices.js +100 -6
- package/dist/cli/commands/command-perf.js +1 -1
- package/dist/cli/commands/command-update.js +3 -2
- package/dist/core/config/auto/auto-fix-config.js +9 -4
- package/dist/core/config/config.js +1 -1
- package/dist/core/messages/en/core/formatters-messages.js +1 -0
- package/dist/core/messages/ja/core/formatters-messages.js +1 -0
- package/dist/core/messages/pt/core/formatters-messages.js +1 -0
- package/dist/core/messages/shared/icons.js +3 -3
- package/dist/core/messages/zh/core/formatters-messages.js +1 -0
- package/dist/core/parsing/langs/json.js +2 -2
- package/dist/core/parsing/langs/typescript.js +33 -7
- package/dist/core/schema/version.js +1 -1
- package/dist/core/utils/exec-safe.js +47 -25
- package/dist/lib/api.js +14 -0
- package/dist/shared/data-processing/occurrences.js +3 -0
- package/dist/shared/formatters/code-min-formatter.js +1 -1
- package/dist/shared/formatters/formatters/commons.js +19 -5
- package/dist/shared/formatters/formatters/shell.js +128 -9
- package/dist/shared/helpers/ast-visitor-utils.js +3 -0
- package/dist/shared/helpers/imports.js +1 -1
- package/dist/shared/helpers/reader-report.js +13 -0
- package/dist/shared/helpers/structure.js +2 -2
- package/dist/types/guardian/result.js +38 -0
- package/dist/types/reports/processing.js +12 -0
- package/dist/types/shared/validation.js +111 -0
- package/dist/vulnerabilities/scanner.js +7 -2
- package/package.json +11 -18
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
import { SharedCommonMensagens } from '../../core/messages/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Extrai mensagem de erro de qualquer valor de forma segura.
|
|
5
|
+
*/
|
|
6
|
+
export function extrairMensagemErro(err) {
|
|
7
|
+
if (err === null || err === undefined) {
|
|
8
|
+
return SharedCommonMensagens?.erroDesconhecido ?? 'Erro desconhecido';
|
|
9
|
+
}
|
|
10
|
+
if (err instanceof Error) {
|
|
11
|
+
return err.message;
|
|
12
|
+
}
|
|
13
|
+
if (typeof err === 'string') {
|
|
14
|
+
return err;
|
|
15
|
+
}
|
|
16
|
+
if (typeof err === 'object') {
|
|
17
|
+
const obj = err;
|
|
18
|
+
if (typeof obj.message === 'string') {
|
|
19
|
+
return obj.message;
|
|
20
|
+
}
|
|
21
|
+
if (obj.message instanceof Error) {
|
|
22
|
+
return obj.message.message;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return SharedCommonMensagens?.erroDesconhecido ?? 'Erro desconhecido';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Valida um valor com type guard e retorna fallback se falhar.
|
|
29
|
+
*/
|
|
30
|
+
export function validarSeguro(validador, valor, fallback) {
|
|
31
|
+
if (validador(valor)) {
|
|
32
|
+
return valor;
|
|
33
|
+
}
|
|
34
|
+
console.warn('validação falhou, usando fallback', valor);
|
|
35
|
+
return fallback;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Converte um valor com type guard e retorna fallback se falhar.
|
|
39
|
+
*/
|
|
40
|
+
export function converterSeguro(valor, validador, fallback) {
|
|
41
|
+
if (validador(valor)) {
|
|
42
|
+
return valor;
|
|
43
|
+
}
|
|
44
|
+
return fallback;
|
|
45
|
+
}
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
export function isErroComMensagem(value) {
|
|
48
|
+
if (value === null || value === undefined) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
if (typeof value !== 'object') {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
return typeof value.message === 'string';
|
|
55
|
+
}
|
|
56
|
+
export function isGlobalComVitest(value) {
|
|
57
|
+
if (value === null || value === undefined || typeof value !== 'object') {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
return 'vi' in value;
|
|
61
|
+
}
|
|
62
|
+
export function isIntlComDisplayNames(value) {
|
|
63
|
+
if (value === null || value === undefined || typeof value !== 'object') {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
// Aceita tanto se tiver DisplayNames quanto qualquer objeto (fallback)
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
export function isGlobalComImport(value) {
|
|
70
|
+
if (value === null || value === undefined || typeof value !== 'object') {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
// Aceita tanto se tiver import quanto qualquer objeto (fallback)
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
export function isConfigPlugin(value) {
|
|
77
|
+
return value !== null && value !== undefined && typeof value === 'object';
|
|
78
|
+
}
|
|
79
|
+
export function isPlanoSugestaoEstrutura(value) {
|
|
80
|
+
if (value === null || value === undefined || typeof value !== 'object') {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
const obj = value;
|
|
84
|
+
return Array.isArray(obj.mover);
|
|
85
|
+
}
|
|
86
|
+
export function isSnapshotAnalise(value) {
|
|
87
|
+
if (value === null || value === undefined || typeof value !== 'object') {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
const obj = value;
|
|
91
|
+
return typeof obj.timestamp === 'string' && Array.isArray(obj.arquivos);
|
|
92
|
+
}
|
|
93
|
+
export function isEntradaMapaReversao(value) {
|
|
94
|
+
if (value === null || value === undefined || typeof value !== 'object') {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
const obj = value;
|
|
98
|
+
if (typeof obj.arquivo !== 'string') {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
return ['adicionar', 'remover', 'modificar'].includes(obj.operacao);
|
|
102
|
+
}
|
|
103
|
+
export function isStringNaoVazia(value) {
|
|
104
|
+
return typeof value === 'string' && value.trim().length > 0;
|
|
105
|
+
}
|
|
106
|
+
export function isNumeroValido(value) {
|
|
107
|
+
return typeof value === 'number' && Number.isFinite(value);
|
|
108
|
+
}
|
|
109
|
+
export function isArrayNaoVazio(value) {
|
|
110
|
+
return Array.isArray(value) && value.length > 0;
|
|
111
|
+
}
|
|
@@ -31,8 +31,13 @@ export async function scanVulnerabilities(opts = {}) {
|
|
|
31
31
|
}
|
|
32
32
|
catch (err) {
|
|
33
33
|
if (isNpmAuditError(err)) {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
try {
|
|
35
|
+
const parsed = JSON.parse(err.stdout);
|
|
36
|
+
return normalizeAuditResult(parsed);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return emptyResult();
|
|
40
|
+
}
|
|
36
41
|
}
|
|
37
42
|
return emptyResult();
|
|
38
43
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mocoto/mahoraga",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "C.L.I modular para análise, diagnóstico e manutenção de projetos JavaScript/TypeScript e multi-stack leve",
|
|
6
6
|
"author": "rei macaco",
|
|
@@ -116,46 +116,39 @@
|
|
|
116
116
|
"THIRD-PARTY-NOTICES.txt"
|
|
117
117
|
],
|
|
118
118
|
"dependencies": {
|
|
119
|
-
"@babel/parser": "^8.0.
|
|
120
|
-
"@babel/traverse": "^8.0.
|
|
121
|
-
"@babel/types": "^8.0.
|
|
119
|
+
"@babel/parser": "^8.0.4",
|
|
120
|
+
"@babel/traverse": "^8.0.4",
|
|
121
|
+
"@babel/types": "^8.0.4",
|
|
122
122
|
"chalk": "^5.6.2",
|
|
123
123
|
"commander": "^15.0.0",
|
|
124
124
|
"dotenv": "^17.4.2",
|
|
125
|
-
"fast-xml-parser": "^5.
|
|
125
|
+
"fast-xml-parser": "^5.10.0",
|
|
126
126
|
"htmlparser2": "^12.0.0",
|
|
127
|
-
"marked": "^18.0.
|
|
127
|
+
"marked": "^18.0.6",
|
|
128
128
|
"micromatch": "^4.0.8",
|
|
129
129
|
"minimatch": "^10.2.5",
|
|
130
130
|
"openpgp": "^6.3.1",
|
|
131
131
|
"ora": "^9.4.1",
|
|
132
132
|
"p-limit": "^7.3.0",
|
|
133
|
+
"postcss": "^8.5.17",
|
|
133
134
|
"postcss-sass": "^0.5.0",
|
|
134
135
|
"postcss-scss": "^4.0.9",
|
|
135
136
|
"xxhashjs": "^0.2.2",
|
|
136
|
-
"yaml": "^2.9.0"
|
|
137
|
-
"postcss": "^8.5.16"
|
|
137
|
+
"yaml": "^2.9.0"
|
|
138
138
|
},
|
|
139
139
|
"devDependencies": {
|
|
140
140
|
"@types/micromatch": "^4.0.10",
|
|
141
|
-
"@types/node": "^26.1.
|
|
142
|
-
"@typescript-eslint/eslint-plugin": "^8.62.1",
|
|
143
|
-
"@typescript-eslint/parser": "^8.62.1",
|
|
141
|
+
"@types/node": "^26.1.1",
|
|
144
142
|
"@vitest/coverage-istanbul": "^4.1.8",
|
|
145
143
|
"@vitest/coverage-v8": "^4.1.8",
|
|
146
144
|
"autoprefixer": "^10.5.2",
|
|
147
|
-
"eslint": "^10.6.0",
|
|
148
|
-
"eslint-import-resolver-typescript": "^4.4.5",
|
|
149
|
-
"eslint-plugin-import-x": "^4.17.1",
|
|
150
|
-
"eslint-plugin-simple-import-sort": "^13.0.0",
|
|
151
|
-
"eslint-plugin-unused-imports": "^4.4.1",
|
|
152
145
|
"husky": "^9.1.7",
|
|
153
146
|
"license-checker-rseidelsohn": "^5.0.1",
|
|
154
147
|
"lint-staged": "^17.0.8",
|
|
155
148
|
"rimraf": "^6.1.3",
|
|
156
|
-
"tsc-alias": "^1.
|
|
149
|
+
"tsc-alias": "^1.9.0",
|
|
157
150
|
"tsx": "^4.23.0",
|
|
158
|
-
"typescript": "^
|
|
151
|
+
"typescript": "^7.0.2",
|
|
159
152
|
"vitest": "^4.1.8"
|
|
160
153
|
},
|
|
161
154
|
"lint-staged": {
|