eslint-plugin-function-rule 0.5.3 → 0.6.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/dist/index.d.ts +18 -9
- package/dist/index.js +26 -17
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { Rule } from "eslint";
|
|
|
2
2
|
|
|
3
3
|
//#region src/index.d.ts
|
|
4
4
|
/**
|
|
5
|
-
* Wraps an ESLint rule's create function as an ESLint Plugin with a single rule named "function-rule"
|
|
6
|
-
* The rule is fixable and supports suggestions
|
|
7
|
-
* @param create The rule's listener create function
|
|
8
|
-
* @returns ESLint Plugin object with "function-rule"
|
|
5
|
+
* Wraps an ESLint rule's create function as an ESLint Plugin with a single rule named "function-rule"
|
|
6
|
+
* The rule is fixable and supports suggestions
|
|
7
|
+
* @param create The rule's listener create function
|
|
8
|
+
* @returns ESLint Plugin object with "function-rule"
|
|
9
9
|
*/
|
|
10
10
|
declare function functionRule(create: Rule.RuleModule["create"]): {
|
|
11
11
|
readonly rules: {
|
|
@@ -19,11 +19,20 @@ declare function functionRule(create: Rule.RuleModule["create"]): {
|
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
|
-
* Defines a
|
|
23
|
-
*
|
|
24
|
-
* @param
|
|
25
|
-
* @
|
|
22
|
+
* Defines a rule listener by merging multiple visitor objects
|
|
23
|
+
*
|
|
24
|
+
* @param base Base visitor object (target of merge)
|
|
25
|
+
* @param rest Additional visitor objects to merge (one or more)
|
|
26
|
+
* @returns Merged RuleListener object
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const listener1 = { Identifier: () => console.log(1) };
|
|
31
|
+
* const listener2 = { Identifier: () => console.log(2) };
|
|
32
|
+
* const merged = defineRuleListener(listener1, listener2);
|
|
33
|
+
* // When encountering Identifier nodes, outputs 1 then 2
|
|
34
|
+
* ```
|
|
26
35
|
*/
|
|
27
|
-
declare function defineRuleListener(
|
|
36
|
+
declare function defineRuleListener(base: Rule.RuleListener, ...rest: Rule.RuleListener[]): Rule.RuleListener;
|
|
28
37
|
//#endregion
|
|
29
38
|
export { defineRuleListener, functionRule };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
//#region src/index.ts
|
|
2
2
|
/**
|
|
3
|
-
* Wraps an ESLint rule's create function as an ESLint Plugin with a single rule named "function-rule"
|
|
4
|
-
* The rule is fixable and supports suggestions
|
|
5
|
-
* @param create The rule's listener create function
|
|
6
|
-
* @returns ESLint Plugin object with "function-rule"
|
|
3
|
+
* Wraps an ESLint rule's create function as an ESLint Plugin with a single rule named "function-rule"
|
|
4
|
+
* The rule is fixable and supports suggestions
|
|
5
|
+
* @param create The rule's listener create function
|
|
6
|
+
* @returns ESLint Plugin object with "function-rule"
|
|
7
7
|
*/
|
|
8
8
|
function functionRule(create) {
|
|
9
9
|
return { rules: { "function-rule": {
|
|
@@ -15,20 +15,29 @@ function functionRule(create) {
|
|
|
15
15
|
} } };
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Defines a
|
|
19
|
-
*
|
|
20
|
-
* @param
|
|
21
|
-
* @
|
|
18
|
+
* Defines a rule listener by merging multiple visitor objects
|
|
19
|
+
*
|
|
20
|
+
* @param base Base visitor object (target of merge)
|
|
21
|
+
* @param rest Additional visitor objects to merge (one or more)
|
|
22
|
+
* @returns Merged RuleListener object
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const listener1 = { Identifier: () => console.log(1) };
|
|
27
|
+
* const listener2 = { Identifier: () => console.log(2) };
|
|
28
|
+
* const merged = defineRuleListener(listener1, listener2);
|
|
29
|
+
* // When encountering Identifier nodes, outputs 1 then 2
|
|
30
|
+
* ```
|
|
22
31
|
*/
|
|
23
|
-
function defineRuleListener(
|
|
24
|
-
for (const
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
return
|
|
32
|
+
function defineRuleListener(base, ...rest) {
|
|
33
|
+
for (const r of rest) for (const key in r) {
|
|
34
|
+
const existing = base[key];
|
|
35
|
+
base[key] = existing != null ? (...args) => {
|
|
36
|
+
existing(...args);
|
|
37
|
+
r[key]?.(...args);
|
|
38
|
+
} : r[key];
|
|
39
|
+
}
|
|
40
|
+
return base;
|
|
32
41
|
}
|
|
33
42
|
|
|
34
43
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-function-rule",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
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,7 @@
|
|
|
33
33
|
"@local/configs": "0.0.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"eslint": "^
|
|
36
|
+
"eslint": "^10.0.0"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=20.0.0"
|