eslint-plugin-function-rule 0.0.13 → 0.0.14
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 +16 -32
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -24,34 +24,18 @@ npm install --save-dev eslint-plugin-function-rule
|
|
|
24
24
|
```js
|
|
25
25
|
// eslint.config.ts
|
|
26
26
|
|
|
27
|
-
import eslintJs from "@eslint/js";
|
|
28
27
|
import type { Rule } from "eslint";
|
|
29
|
-
import { defineRule } from "eslint-plugin-function-rule";
|
|
30
28
|
import { defineConfig } from "eslint/config";
|
|
31
|
-
import
|
|
29
|
+
import { functionRule } from "eslint-plugin-function-rule";
|
|
32
30
|
|
|
33
31
|
export default defineConfig(
|
|
34
|
-
{
|
|
35
|
-
files: ["**/*.ts", "**/*.tsx"],
|
|
36
|
-
extends: [
|
|
37
|
-
eslintJs.configs.recommended,
|
|
38
|
-
tseslint.configs.recommended,
|
|
39
|
-
],
|
|
40
|
-
languageOptions: {
|
|
41
|
-
parser: tseslint.parser,
|
|
42
|
-
parserOptions: {
|
|
43
|
-
projectService: true,
|
|
44
|
-
tsconfigRootDir: import.meta.dirname,
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
32
|
{
|
|
49
33
|
files: ["**/*.ts"],
|
|
50
34
|
rules: {
|
|
51
35
|
"function-rule/function-rule": "error",
|
|
52
36
|
},
|
|
53
37
|
plugins: {
|
|
54
|
-
"function-rule":
|
|
38
|
+
"function-rule": functionRule((context) => {
|
|
55
39
|
return {
|
|
56
40
|
DebuggerStatement(node) {
|
|
57
41
|
context.report({
|
|
@@ -63,7 +47,7 @@ export default defineConfig(
|
|
|
63
47
|
},
|
|
64
48
|
});
|
|
65
49
|
},
|
|
66
|
-
}
|
|
50
|
+
};
|
|
67
51
|
}),
|
|
68
52
|
},
|
|
69
53
|
},
|
|
@@ -76,14 +60,14 @@ export default defineConfig(
|
|
|
76
60
|
// noDebugger.ts
|
|
77
61
|
|
|
78
62
|
import type { Rule } from "eslint";
|
|
79
|
-
import {
|
|
63
|
+
import { functionRuleListener } from "eslint-plugin-function-rule";
|
|
80
64
|
|
|
81
65
|
// Define and document function rule options
|
|
82
66
|
export interface noDebuggerOptions {}
|
|
83
67
|
|
|
84
68
|
// Define and document function rule
|
|
85
69
|
export function noDebugger(options?: noDebuggerOptions) {
|
|
86
|
-
return (context: Rule.RuleContext) =>
|
|
70
|
+
return (context: Rule.RuleContext): Rule.RuleListener => ({
|
|
87
71
|
DebuggerStatement(node) {
|
|
88
72
|
context.report({
|
|
89
73
|
node,
|
|
@@ -101,19 +85,18 @@ export function noDebugger(options?: noDebuggerOptions) {
|
|
|
101
85
|
```js
|
|
102
86
|
// eslint.config.ts
|
|
103
87
|
|
|
104
|
-
|
|
105
|
-
import {
|
|
88
|
+
import { functionRule } from "eslint-plugin-function-rule";
|
|
89
|
+
import { defineConfig } from "eslint/config";
|
|
106
90
|
import { noDebugger } from "./noDebugger.ts";
|
|
107
91
|
|
|
108
92
|
export default defineConfig(
|
|
109
|
-
// ...
|
|
110
93
|
{
|
|
111
94
|
files: ["**/*.ts"],
|
|
112
95
|
rules: {
|
|
113
96
|
"function-rule/function-rule": "error",
|
|
114
97
|
},
|
|
115
98
|
plugins: {
|
|
116
|
-
"function-rule":
|
|
99
|
+
"function-rule": functionRule(noDebugger({/* pass rule options */})),
|
|
117
100
|
},
|
|
118
101
|
},
|
|
119
102
|
);
|
|
@@ -124,11 +107,10 @@ export default defineConfig(
|
|
|
124
107
|
```js
|
|
125
108
|
// eslint.config.ts
|
|
126
109
|
|
|
127
|
-
|
|
128
|
-
import {
|
|
110
|
+
import { functionRule } from "eslint-plugin-function-rule";
|
|
111
|
+
import { defineConfig } from "eslint/config";
|
|
129
112
|
|
|
130
113
|
export default defineConfig(
|
|
131
|
-
// ...
|
|
132
114
|
{
|
|
133
115
|
files: ["**/*.ts"],
|
|
134
116
|
rules: {
|
|
@@ -136,11 +118,11 @@ export default defineConfig(
|
|
|
136
118
|
"custom-2/function-rule": 2,
|
|
137
119
|
},
|
|
138
120
|
plugins: {
|
|
139
|
-
"custom-1":
|
|
140
|
-
return {
|
|
121
|
+
"custom-1": functionRule((context) => {
|
|
122
|
+
return {/* your won rule logic */};
|
|
141
123
|
}),
|
|
142
|
-
"custom-2":
|
|
143
|
-
return {
|
|
124
|
+
"custom-2": functionRule((context) => {
|
|
125
|
+
return {/* your won rule logic */};
|
|
144
126
|
}),
|
|
145
127
|
},
|
|
146
128
|
},
|
|
@@ -150,3 +132,5 @@ export default defineConfig(
|
|
|
150
132
|
## License
|
|
151
133
|
|
|
152
134
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
135
|
+
|
|
136
|
+
This project is and will continue to maintain that 90% of the code is written by humans.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Rule } from "eslint";
|
|
2
2
|
|
|
3
3
|
//#region index.d.ts
|
|
4
|
-
declare function
|
|
4
|
+
declare function functionRule(create: Rule.RuleModule["create"]): {
|
|
5
5
|
readonly rules: {
|
|
6
6
|
readonly "function-rule": {
|
|
7
7
|
readonly meta: {
|
|
@@ -14,4 +14,4 @@ declare function defineRule(create: Rule.RuleModule["create"]): {
|
|
|
14
14
|
};
|
|
15
15
|
declare function defineRuleListener(ruleListener: Rule.RuleListener): Rule.RuleListener;
|
|
16
16
|
//#endregion
|
|
17
|
-
export {
|
|
17
|
+
export { defineRuleListener, functionRule };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region index.ts
|
|
2
|
-
function
|
|
2
|
+
function functionRule(create) {
|
|
3
3
|
return { rules: { "function-rule": {
|
|
4
4
|
meta: {
|
|
5
5
|
fixable: "code",
|
|
@@ -16,4 +16,4 @@ function defineRuleListener(ruleListener) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
//#endregion
|
|
19
|
-
export {
|
|
19
|
+
export { defineRuleListener, functionRule };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-function-rule",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"@eslint/core": "^0.17.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
+
"dprint": "^0.50.2",
|
|
21
22
|
"tsdown": "^0.16.1"
|
|
22
23
|
},
|
|
23
24
|
"peerDependencies": {
|
|
@@ -25,6 +26,8 @@
|
|
|
25
26
|
"typescript": "^5"
|
|
26
27
|
},
|
|
27
28
|
"scripts": {
|
|
28
|
-
"build": "tsdown"
|
|
29
|
+
"build": "tsdown",
|
|
30
|
+
"format:check": "dprint check",
|
|
31
|
+
"format:write": "dprint fmt"
|
|
29
32
|
}
|
|
30
33
|
}
|