eslint-plugin-function-rule 0.0.11 → 0.0.13
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 +22 -16
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
# eslint-plugin-function-rule
|
|
2
|
-
|
|
3
1
|
ESLint plugin to write custom rules with JavaScript functions.
|
|
4
2
|
|
|
5
3
|
> [!WARNING]
|
|
6
4
|
> This package is a work in progress and is not yet ready for production use.
|
|
7
5
|
|
|
6
|
+
## Index
|
|
7
|
+
|
|
8
|
+
- [Index](#index)
|
|
9
|
+
- [Installation](#installation)
|
|
10
|
+
- [Write function rules inline](#write-function-rules-inline)
|
|
11
|
+
- [Or import function rules from modules](#or-import-function-rules-from-modules)
|
|
12
|
+
- [Define multiple function rules with custom prefix](#define-multiple-function-rules-with-custom-prefix)
|
|
13
|
+
- [License](#license)
|
|
14
|
+
|
|
8
15
|
## Installation
|
|
9
16
|
|
|
10
17
|
```sh
|
|
@@ -12,9 +19,7 @@ ESLint plugin to write custom rules with JavaScript functions.
|
|
|
12
19
|
npm install --save-dev eslint-plugin-function-rule
|
|
13
20
|
```
|
|
14
21
|
|
|
15
|
-
##
|
|
16
|
-
|
|
17
|
-
### Write function rules inline
|
|
22
|
+
## Write function rules inline
|
|
18
23
|
|
|
19
24
|
```js
|
|
20
25
|
// eslint.config.ts
|
|
@@ -65,7 +70,7 @@ export default defineConfig(
|
|
|
65
70
|
);
|
|
66
71
|
```
|
|
67
72
|
|
|
68
|
-
|
|
73
|
+
## Or import function rules from modules
|
|
69
74
|
|
|
70
75
|
```js
|
|
71
76
|
// noDebugger.ts
|
|
@@ -93,8 +98,6 @@ export function noDebugger(options?: noDebuggerOptions) {
|
|
|
93
98
|
}
|
|
94
99
|
```
|
|
95
100
|
|
|
96
|
-
### Define function rule with default prefix
|
|
97
|
-
|
|
98
101
|
```js
|
|
99
102
|
// eslint.config.ts
|
|
100
103
|
|
|
@@ -116,31 +119,34 @@ export default defineConfig(
|
|
|
116
119
|
);
|
|
117
120
|
```
|
|
118
121
|
|
|
119
|
-
|
|
122
|
+
## Define multiple function rules with custom prefix
|
|
120
123
|
|
|
121
124
|
```js
|
|
122
125
|
// eslint.config.ts
|
|
123
126
|
|
|
124
127
|
// ...
|
|
125
128
|
import { defineRule } from "eslint-plugin-function-rule";
|
|
126
|
-
import { noDebugger } from "./noDebugger.ts";
|
|
127
129
|
|
|
128
130
|
export default defineConfig(
|
|
129
131
|
// ...
|
|
130
132
|
{
|
|
131
133
|
files: ["**/*.ts"],
|
|
132
134
|
rules: {
|
|
133
|
-
"
|
|
134
|
-
|
|
135
|
-
"custom/function-rule": "error",
|
|
135
|
+
"custom-1/function-rule": 1,
|
|
136
|
+
"custom-2/function-rule": 2,
|
|
136
137
|
},
|
|
137
138
|
plugins: {
|
|
138
|
-
"
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
"custom-1": defineRule((context) => {
|
|
140
|
+
return { /* your won rule logic */ }
|
|
141
|
+
}),
|
|
142
|
+
"custom-2": defineRule((context) => {
|
|
141
143
|
return { /* your won rule logic */ }
|
|
142
144
|
}),
|
|
143
145
|
},
|
|
144
146
|
},
|
|
145
147
|
);
|
|
146
148
|
```
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
package/dist/index.js
CHANGED
|
@@ -8,10 +8,10 @@ function defineRule(create) {
|
|
|
8
8
|
create
|
|
9
9
|
} } };
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
let id = 1;
|
|
12
12
|
function defineRuleListener(ruleListener) {
|
|
13
13
|
const listener = {};
|
|
14
|
-
for (const key of Object.keys(ruleListener)) listener[
|
|
14
|
+
for (const key of Object.keys(ruleListener)) listener[" ".repeat(id++) + key] = ruleListener[key];
|
|
15
15
|
return listener;
|
|
16
16
|
}
|
|
17
17
|
|