eslint-plugin-function 0.2.8 → 0.3.1
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/dist/index.js +11 -9
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
|
9
9
|
|
|
10
10
|
//#region package.json
|
|
11
11
|
var name = "eslint-plugin-function";
|
|
12
|
-
var version = "0.
|
|
12
|
+
var version = "0.3.0";
|
|
13
13
|
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/utils/create-rule.ts
|
|
@@ -77,17 +77,17 @@ function getTypeVariants(types) {
|
|
|
77
77
|
} else if (booleans.length === 2) variants.add("boolean");
|
|
78
78
|
const strings = types.filter(isStringType);
|
|
79
79
|
if (strings.length > 0) {
|
|
80
|
-
const evaluated = match(strings).when((types
|
|
80
|
+
const evaluated = match(strings).when((types) => types.every(isTruthyStringType), () => "truthy string").when((types) => types.every(isFalsyStringType), () => "falsy string").otherwise(() => "string");
|
|
81
81
|
variants.add(evaluated);
|
|
82
82
|
}
|
|
83
83
|
const bigints = types.filter(isBigIntType);
|
|
84
84
|
if (bigints.length > 0) {
|
|
85
|
-
const evaluated = match(bigints).when((types
|
|
85
|
+
const evaluated = match(bigints).when((types) => types.every(isTruthyBigIntType), () => "truthy bigint").when((types) => types.every(isFalsyBigIntType), () => "falsy bigint").otherwise(() => "bigint");
|
|
86
86
|
variants.add(evaluated);
|
|
87
87
|
}
|
|
88
88
|
const numbers = types.filter(isNumberType);
|
|
89
89
|
if (numbers.length > 0) {
|
|
90
|
-
const evaluated = match(numbers).when((types
|
|
90
|
+
const evaluated = match(numbers).when((types) => types.every(isTruthyNumberType), () => "truthy number").when((types) => types.every(isFalsyNumberType), () => "falsy number").otherwise(() => "number");
|
|
91
91
|
variants.add(evaluated);
|
|
92
92
|
}
|
|
93
93
|
if (types.some(isEnumType)) variants.add("enum");
|
|
@@ -142,7 +142,7 @@ function create$1(context) {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
//#endregion
|
|
145
|
-
//#region
|
|
145
|
+
//#region ../../.pkgs/eff/dist/index.js
|
|
146
146
|
/**
|
|
147
147
|
* Creates a function that can be used in a data-last (aka `pipe`able) or
|
|
148
148
|
* data-first style.
|
|
@@ -208,9 +208,10 @@ function create$1(context) {
|
|
|
208
208
|
* @param arity - The arity of the uncurried function or a predicate that determines if the function is being used in a data-first or data-last style.
|
|
209
209
|
* @param body - The function to be curried.
|
|
210
210
|
* @since 1.0.0
|
|
211
|
-
*/
|
|
211
|
+
*/
|
|
212
|
+
const dual = function(arity, body) {
|
|
212
213
|
if (typeof arity === "function") return function() {
|
|
213
|
-
return arity(arguments) ? body.apply(this, arguments) : (self) => body(self, ...arguments);
|
|
214
|
+
return arity(arguments) ? body.apply(this, arguments) : ((self) => body(self, ...arguments));
|
|
214
215
|
};
|
|
215
216
|
switch (arity) {
|
|
216
217
|
case 0:
|
|
@@ -252,7 +253,8 @@ function create$1(context) {
|
|
|
252
253
|
* ```
|
|
253
254
|
*
|
|
254
255
|
* @since 1.0.0
|
|
255
|
-
*/
|
|
256
|
+
*/
|
|
257
|
+
const compose = dual(2, (ab, bc) => (a) => bc(ab(a)));
|
|
256
258
|
|
|
257
259
|
//#endregion
|
|
258
260
|
//#region src/rules/function-return-boolean.ts
|
|
@@ -291,7 +293,7 @@ function create(context, [opts]) {
|
|
|
291
293
|
const services = ESLintUtils.getParserServices(context, false);
|
|
292
294
|
const pattern = toRegExp(opts?.pattern ?? defaultPattern);
|
|
293
295
|
const functionEntries = [];
|
|
294
|
-
function handleReturnExpression(context
|
|
296
|
+
function handleReturnExpression(context, returnExpression, onViolation) {
|
|
295
297
|
if (returnExpression == null) {
|
|
296
298
|
onViolation(returnExpression, { variants: "nullish" });
|
|
297
299
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-function",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "(WIP) An ESLint plugin for function-related rules.",
|
|
6
6
|
"homepage": "https://github.com/Rel1cx/dx",
|
|
@@ -27,24 +27,24 @@
|
|
|
27
27
|
"package.json"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@eslint-react/ast": "^2.7.
|
|
31
|
-
"@eslint-react/shared": "^2.7.
|
|
32
|
-
"@typescript-eslint/scope-manager": "^8.
|
|
33
|
-
"@typescript-eslint/type-utils": "^8.
|
|
34
|
-
"@typescript-eslint/types": "^8.
|
|
35
|
-
"@typescript-eslint/utils": "^8.
|
|
30
|
+
"@eslint-react/ast": "^2.7.4",
|
|
31
|
+
"@eslint-react/shared": "^2.7.4",
|
|
32
|
+
"@typescript-eslint/scope-manager": "^8.54.0",
|
|
33
|
+
"@typescript-eslint/type-utils": "^8.54.0",
|
|
34
|
+
"@typescript-eslint/types": "^8.54.0",
|
|
35
|
+
"@typescript-eslint/utils": "^8.54.0",
|
|
36
36
|
"string-ts": "^2.3.1",
|
|
37
37
|
"ts-api-utils": "^2.4.0",
|
|
38
38
|
"ts-pattern": "^5.9.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@typescript-eslint/rule-tester": "^8.53.0",
|
|
41
|
+
"@types/node": "^25.0.10",
|
|
42
|
+
"@typescript-eslint/rule-tester": "^8.54.0",
|
|
44
43
|
"dedent": "^1.7.1",
|
|
45
44
|
"eslint": "^9.39.2",
|
|
46
|
-
"tsdown": "^0.20.
|
|
47
|
-
"tsl": "^1.0.28"
|
|
45
|
+
"tsdown": "^0.20.1",
|
|
46
|
+
"tsl": "^1.0.28",
|
|
47
|
+
"@local/eff": "0.2.9"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"eslint": "^9.39.2",
|