eslint-plugin-function-rule 0.2.0 → 0.2.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/dist/index.d.ts +16 -8
- package/dist/index.js +13 -9
- package/package.json +1 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
|
-
import { Plugin } from "@eslint/core";
|
|
2
1
|
import { Rule } from "eslint";
|
|
3
2
|
|
|
4
3
|
//#region src/index.d.ts
|
|
5
|
-
|
|
6
4
|
/**
|
|
7
5
|
* Wraps an ESLint rule's create function as an ESLint Plugin with a single rule named "function-rule".
|
|
8
6
|
* The rule is fixable and supports suggestions.
|
|
9
7
|
* @param create The rule's listener create function.
|
|
10
8
|
* @returns ESLint Plugin object with "function-rule".
|
|
11
9
|
*/
|
|
12
|
-
declare function functionRule(create: Rule.RuleModule["create"]):
|
|
10
|
+
declare function functionRule(create: Rule.RuleModule["create"]): {
|
|
11
|
+
readonly rules: {
|
|
12
|
+
readonly "function-rule": {
|
|
13
|
+
readonly meta: {
|
|
14
|
+
readonly fixable: "code";
|
|
15
|
+
readonly hasSuggestions: true;
|
|
16
|
+
};
|
|
17
|
+
readonly create: (context: Rule.RuleContext) => Rule.RuleListener;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
13
21
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* @param
|
|
17
|
-
* @returns
|
|
22
|
+
* Defines a RuleListener by merging multiple visitor objects
|
|
23
|
+
* @param visitor The base visitor object
|
|
24
|
+
* @param visitors Additional visitor objects to merge
|
|
25
|
+
* @returns
|
|
18
26
|
*/
|
|
19
|
-
declare function defineRuleListener(
|
|
27
|
+
declare function defineRuleListener(visitor: Rule.RuleListener, ...visitors: Rule.RuleListener[]): Rule.RuleListener;
|
|
20
28
|
//#endregion
|
|
21
29
|
export { defineRuleListener, functionRule };
|
package/dist/index.js
CHANGED
|
@@ -14,17 +14,21 @@ function functionRule(create) {
|
|
|
14
14
|
create
|
|
15
15
|
} } };
|
|
16
16
|
}
|
|
17
|
-
let id = 1;
|
|
18
17
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @param
|
|
22
|
-
* @returns
|
|
18
|
+
* Defines a RuleListener by merging multiple visitor objects
|
|
19
|
+
* @param visitor The base visitor object
|
|
20
|
+
* @param visitors Additional visitor objects to merge
|
|
21
|
+
* @returns
|
|
23
22
|
*/
|
|
24
|
-
function defineRuleListener(
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
function defineRuleListener(visitor, ...visitors) {
|
|
24
|
+
for (const v of visitors) for (const key in v) if (visitor[key] != null) {
|
|
25
|
+
const o = visitor[key];
|
|
26
|
+
visitor[key] = (...args) => {
|
|
27
|
+
o(...args);
|
|
28
|
+
v[key]?.(...args);
|
|
29
|
+
};
|
|
30
|
+
} else visitor[key] = v[key];
|
|
31
|
+
return visitor;
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-function-rule",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "An ESLint plugin to write custom rules with JavaScript functions.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/dx",
|
|
6
6
|
"bugs": {
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"@local/configs": "0.0.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@eslint/core": "^1.0.0",
|
|
37
36
|
"eslint": "^9.39.2"
|
|
38
37
|
},
|
|
39
38
|
"engines": {
|