@skapxd/eslint-opinionated 0.2.0 → 0.4.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/README.md +46 -24
- package/dist/astro/index.js +2 -2
- package/dist/astro/index.js.map +1 -1
- package/dist/astro/index.mjs +2 -2
- package/dist/{chunk-4LJJTF3P.mjs → chunk-3XDQN6ZH.mjs} +2 -2
- package/dist/{chunk-DYCSUKTL.mjs → chunk-NYLQRBBK.mjs} +9 -8
- package/dist/chunk-NYLQRBBK.mjs.map +1 -0
- package/dist/{chunk-UI2RB5G6.mjs → chunk-OQLKVDGZ.mjs} +3 -3
- package/dist/{chunk-UI2RB5G6.mjs.map → chunk-OQLKVDGZ.mjs.map} +1 -1
- package/dist/{chunk-RP7BOODV.mjs → chunk-OYVXAPDZ.mjs} +19 -10
- package/dist/chunk-OYVXAPDZ.mjs.map +1 -0
- package/dist/index.js +28 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/dist/next/index.js +3 -3
- package/dist/next/index.js.map +1 -1
- package/dist/next/index.mjs +2 -2
- package/dist/shared/index.d.mts +1 -1
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.js +26 -16
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +2 -2
- package/package.json +1 -1
- package/dist/chunk-DYCSUKTL.mjs.map +0 -1
- package/dist/chunk-RP7BOODV.mjs.map +0 -1
- /package/dist/{chunk-4LJJTF3P.mjs.map → chunk-3XDQN6ZH.mjs.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -38,8 +38,8 @@ module.exports = __toCommonJS(index_exports);
|
|
|
38
38
|
|
|
39
39
|
// src/shared/configs/base-rules.ts
|
|
40
40
|
var baseRules = {
|
|
41
|
-
"skapxd/no-ad-hoc-ok-result": "
|
|
42
|
-
"skapxd/no-deep-relative-imports": "
|
|
41
|
+
"skapxd/no-ad-hoc-ok-result": "error",
|
|
42
|
+
"skapxd/no-deep-relative-imports": "error",
|
|
43
43
|
"skapxd/no-promise-chain": "error",
|
|
44
44
|
"skapxd/no-try-catch": "error",
|
|
45
45
|
"skapxd/one-root-function-per-file": "error",
|
|
@@ -100,15 +100,16 @@ function createSharedConfigs(pluginReference) {
|
|
|
100
100
|
plugins: { skapxd: pluginReference },
|
|
101
101
|
rules: {
|
|
102
102
|
...baseRules,
|
|
103
|
-
// En el front no se obliga a retornar Result, pero
|
|
104
|
-
//
|
|
105
|
-
//
|
|
106
|
-
|
|
103
|
+
// En el front no se obliga a retornar Result, pero todo await debe
|
|
104
|
+
// resolver en uno: o la función llamada ya retorna Promise<Result>
|
|
105
|
+
// (camino preferido: errores modelados en el dominio) o se envuelve
|
|
106
|
+
// en trySafe en el sitio.
|
|
107
|
+
"skapxd/await-requires-result": "error",
|
|
107
108
|
"skapxd/jsx-return-name-pascal-case": "error",
|
|
108
109
|
"skapxd/no-functions-inside-components": "error",
|
|
109
110
|
"skapxd/no-jsx-ternary-null": "error",
|
|
110
111
|
"skapxd/max-hook-size": [
|
|
111
|
-
"
|
|
112
|
+
"error",
|
|
112
113
|
{
|
|
113
114
|
maxLines: 120,
|
|
114
115
|
maxUseState: 1
|
|
@@ -212,7 +213,7 @@ function createNextConfigs(pluginReference) {
|
|
|
212
213
|
"skapxd/no-functions-inside-components": "error",
|
|
213
214
|
"skapxd/no-jsx-ternary-null": "error",
|
|
214
215
|
"skapxd/max-hook-size": [
|
|
215
|
-
"
|
|
216
|
+
"error",
|
|
216
217
|
{
|
|
217
218
|
maxLines: 120,
|
|
218
219
|
maxUseState: 1
|
|
@@ -1032,8 +1033,8 @@ var noAdHocOkResult = {
|
|
|
1032
1033
|
}
|
|
1033
1034
|
};
|
|
1034
1035
|
|
|
1035
|
-
// src/utils/get-await-requires-
|
|
1036
|
-
function
|
|
1036
|
+
// src/utils/get-await-requires-result-options.ts
|
|
1037
|
+
function getAwaitRequiresResultOptions(options = {}) {
|
|
1037
1038
|
return {
|
|
1038
1039
|
allowFilePatterns: options.allowFilePatterns ?? [],
|
|
1039
1040
|
trySafeCallNames: options.trySafeCallNames ?? ["trySafe"]
|
|
@@ -1120,15 +1121,15 @@ function isTrySafeCall(node, trySafeCallNames) {
|
|
|
1120
1121
|
return node?.type === "CallExpression" && isCalleeNamed(node.callee, trySafeCallNames);
|
|
1121
1122
|
}
|
|
1122
1123
|
|
|
1123
|
-
// src/rules/await-requires-
|
|
1124
|
-
var
|
|
1124
|
+
// src/rules/await-requires-result.ts
|
|
1125
|
+
var awaitRequiresResult = {
|
|
1125
1126
|
meta: {
|
|
1126
1127
|
type: "problem",
|
|
1127
1128
|
docs: {
|
|
1128
|
-
description: "Exige que
|
|
1129
|
+
description: "Exige que todo await resuelva en un Result: una funcion que retorne Promise<Result<...>> o trySafe en el sitio."
|
|
1129
1130
|
},
|
|
1130
1131
|
messages: {
|
|
1131
|
-
|
|
1132
|
+
awaitWithoutResult: "El await dentro de `{{name}}` no resuelve en un Result. Mejor opcion: extrae la operacion a una funcion que retorne Promise<Result<...>> y modela ahi los errores de dominio (el trySafe vive dentro de esa funcion). Alternativa: envuelvela aqui mismo: `{{suggestion}}`."
|
|
1132
1133
|
},
|
|
1133
1134
|
schema: [
|
|
1134
1135
|
{
|
|
@@ -1148,7 +1149,7 @@ var awaitRequiresTrySafe = {
|
|
|
1148
1149
|
]
|
|
1149
1150
|
},
|
|
1150
1151
|
create(context) {
|
|
1151
|
-
const options =
|
|
1152
|
+
const options = getAwaitRequiresResultOptions(context.options[0]);
|
|
1152
1153
|
const filename = context.filename ?? context.getFilename();
|
|
1153
1154
|
const sourceCode = context.sourceCode ?? context.getSourceCode();
|
|
1154
1155
|
const typeContext = getTypeContext(context);
|
|
@@ -1183,7 +1184,7 @@ var awaitRequiresTrySafe = {
|
|
|
1183
1184
|
name: getAwaitScopeName(node),
|
|
1184
1185
|
suggestion: getTrySafeAwaitSuggestion(node.argument, sourceCode)
|
|
1185
1186
|
},
|
|
1186
|
-
messageId: "
|
|
1187
|
+
messageId: "awaitWithoutResult",
|
|
1187
1188
|
node
|
|
1188
1189
|
});
|
|
1189
1190
|
}
|
|
@@ -1758,7 +1759,16 @@ var rules = {
|
|
|
1758
1759
|
"jsx-return-name-pascal-case": jsxReturnNamePascalCase,
|
|
1759
1760
|
"async-functions-return-result": asyncFunctionsReturnResult,
|
|
1760
1761
|
"no-ad-hoc-ok-result": noAdHocOkResult,
|
|
1761
|
-
"await-requires-
|
|
1762
|
+
"await-requires-result": awaitRequiresResult,
|
|
1763
|
+
// Alias deprecado del nombre anterior; se elimina en una versión futura.
|
|
1764
|
+
"await-requires-try-safe": {
|
|
1765
|
+
...awaitRequiresResult,
|
|
1766
|
+
meta: {
|
|
1767
|
+
...awaitRequiresResult.meta,
|
|
1768
|
+
deprecated: true,
|
|
1769
|
+
replacedBy: ["skapxd/await-requires-result"]
|
|
1770
|
+
}
|
|
1771
|
+
},
|
|
1762
1772
|
"result-error-requires-cause": resultErrorRequiresCause,
|
|
1763
1773
|
"max-hook-size": maxHookSize,
|
|
1764
1774
|
"no-deep-relative-imports": noDeepRelativeImports,
|
|
@@ -1777,7 +1787,7 @@ var plugin = {
|
|
|
1777
1787
|
configs: {},
|
|
1778
1788
|
meta: {
|
|
1779
1789
|
name: "@skapxd/eslint-opinionated",
|
|
1780
|
-
version: "0.
|
|
1790
|
+
version: "0.4.0"
|
|
1781
1791
|
},
|
|
1782
1792
|
rules
|
|
1783
1793
|
};
|