@bemoje/eslint 2.1.0 → 2.1.2
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 +4 -0
- package/lib/index.cjs +26 -17
- package/lib/index.d.cts +41 -90
- package/lib/index.d.ts +41 -90
- package/lib/index.js +26 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,6 +42,8 @@ import { enforceSplitImports } from '@bemoje/eslint'
|
|
|
42
42
|
export default [enforceSplitImports, enforceNoBlankLineBetweenCommentAndDeclaration]
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
+
The entries fit ESLint's own config type, so a typed `eslint.config.ts` (`const config: Linter.Config[] = [...]`) takes them with no cast.
|
|
46
|
+
|
|
45
47
|
A rule's full name, for an `eslint-disable` comment, is `bemoje/<rule>`: `bemoje/split-imports`, `bemoje/no-blank-line-between-comment-and-declaration`.
|
|
46
48
|
|
|
47
49
|
### Plugin Setup (Flat Config)
|
|
@@ -99,3 +101,5 @@ export function add(a: number, b: number) {
|
|
|
99
101
|
```
|
|
100
102
|
|
|
101
103
|
Single-line block comments and line comments between the block comment and the declaration are ignored.
|
|
104
|
+
|
|
105
|
+
A file's header is left alone: the block comment that nothing comes before (a shebang line aside) is about the file, so it keeps the blank line after it.
|
package/lib/index.cjs
CHANGED
|
@@ -32,6 +32,12 @@ var noBlankLineBetweenCommentAndDeclaration = createRule({
|
|
|
32
32
|
if (Math.abs(comment.loc.start.line - comment.loc.end.line) < 2) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
+
const before = context.sourceCode.getTokenBefore(comment, {
|
|
36
|
+
includeComments: true
|
|
37
|
+
});
|
|
38
|
+
if (!before || before.type === "Shebang") {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
35
41
|
const nextToken = context.sourceCode.getTokenAfter(comment, {
|
|
36
42
|
includeComments: true
|
|
37
43
|
});
|
|
@@ -68,6 +74,9 @@ var noBlankLineBetweenCommentAndDeclaration = createRule({
|
|
|
68
74
|
};
|
|
69
75
|
}
|
|
70
76
|
});
|
|
77
|
+
|
|
78
|
+
// src/lib/forEslint.ts
|
|
79
|
+
var ruleForEslint = /* @__PURE__ */ __name((rule) => rule, "ruleForEslint");
|
|
71
80
|
var splitImports = createRule({
|
|
72
81
|
name: "split-imports",
|
|
73
82
|
meta: {
|
|
@@ -117,12 +126,20 @@ var splitImports = createRule({
|
|
|
117
126
|
}
|
|
118
127
|
});
|
|
119
128
|
|
|
129
|
+
// src/lib/bemojePlugin.ts
|
|
130
|
+
var bemojePlugin = {
|
|
131
|
+
meta: {
|
|
132
|
+
name: "@bemoje/eslint"
|
|
133
|
+
},
|
|
134
|
+
rules: {
|
|
135
|
+
"no-blank-line-between-comment-and-declaration": ruleForEslint(noBlankLineBetweenCommentAndDeclaration),
|
|
136
|
+
"split-imports": ruleForEslint(splitImports)
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
120
140
|
// src/lib/eslintPluginBemoje.ts
|
|
121
141
|
function eslintPluginBemoje() {
|
|
122
|
-
const rules =
|
|
123
|
-
"no-blank-line-between-comment-and-declaration": noBlankLineBetweenCommentAndDeclaration,
|
|
124
|
-
"split-imports": splitImports
|
|
125
|
-
};
|
|
142
|
+
const rules = bemojePlugin.rules;
|
|
126
143
|
const plugins = {
|
|
127
144
|
get "eslint-plugin-bemoje"() {
|
|
128
145
|
return eslintPluginBemoje();
|
|
@@ -133,30 +150,22 @@ function eslintPluginBemoje() {
|
|
|
133
150
|
get recommended() {
|
|
134
151
|
return {
|
|
135
152
|
plugins,
|
|
136
|
-
rules
|
|
153
|
+
rules: Object.fromEntries(Object.keys(rules).map((name) => [
|
|
154
|
+
`eslint-plugin-bemoje/${name}`,
|
|
155
|
+
"error"
|
|
156
|
+
]))
|
|
137
157
|
};
|
|
138
158
|
}
|
|
139
159
|
},
|
|
140
160
|
meta: {
|
|
141
161
|
name: "eslint-plugin-bemoje",
|
|
142
|
-
version: "2.1.
|
|
162
|
+
version: "2.1.2"
|
|
143
163
|
},
|
|
144
164
|
rules
|
|
145
165
|
};
|
|
146
166
|
}
|
|
147
167
|
__name(eslintPluginBemoje, "eslintPluginBemoje");
|
|
148
168
|
|
|
149
|
-
// src/lib/bemojePlugin.ts
|
|
150
|
-
var bemojePlugin = {
|
|
151
|
-
meta: {
|
|
152
|
-
name: "@bemoje/eslint"
|
|
153
|
-
},
|
|
154
|
-
rules: {
|
|
155
|
-
"no-blank-line-between-comment-and-declaration": noBlankLineBetweenCommentAndDeclaration,
|
|
156
|
-
"split-imports": splitImports
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
|
|
160
169
|
// src/configs/enforceNoBlankLineBetweenCommentAndDeclaration.ts
|
|
161
170
|
var enforceNoBlankLineBetweenCommentAndDeclaration = {
|
|
162
171
|
name: "@bemoje/eslint/no-blank-line-between-comment-and-declaration",
|
package/lib/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ESLintUtils
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
2
|
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -17,80 +17,51 @@ declare const createRule: <Options extends readonly unknown[], MessageIds extend
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* The types this package's plugin and config entries are offered under. They say what ESLint's own config type
|
|
21
|
+
* (`Linter.Config`) asks for and nothing more, so an entry goes into a typed config with no cast. A rule keeps its
|
|
22
|
+
* full typescript-eslint type where it is declared: that type does not fit ESLint's, which is why presets written
|
|
23
|
+
* with typescript-eslint usually need `as Linter.Config[]` where they are used. ESLint itself is not imported here,
|
|
24
|
+
* so the package does not depend on a version of it.
|
|
21
25
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
meta: {
|
|
31
|
-
name: string;
|
|
32
|
-
version: string;
|
|
33
|
-
};
|
|
34
|
-
rules: {
|
|
35
|
-
'no-blank-line-between-comment-and-declaration': _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
|
|
36
|
-
description: string;
|
|
37
|
-
recommended?: boolean;
|
|
38
|
-
requiresTypeChecking?: boolean;
|
|
39
|
-
}, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
40
|
-
name: string;
|
|
41
|
-
};
|
|
42
|
-
'split-imports': _typescript_eslint_utils_ts_eslint.RuleModule<"split-import", readonly unknown[], {
|
|
43
|
-
description: string;
|
|
44
|
-
recommended?: boolean;
|
|
45
|
-
requiresTypeChecking?: boolean;
|
|
46
|
-
}, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
47
|
-
name: string;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
rules: {
|
|
53
|
-
'no-blank-line-between-comment-and-declaration': _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
|
|
54
|
-
description: string;
|
|
55
|
-
recommended?: boolean;
|
|
56
|
-
requiresTypeChecking?: boolean;
|
|
57
|
-
}, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
58
|
-
name: string;
|
|
59
|
-
};
|
|
60
|
-
'split-imports': _typescript_eslint_utils_ts_eslint.RuleModule<"split-import", readonly unknown[], {
|
|
61
|
-
description: string;
|
|
62
|
-
recommended?: boolean;
|
|
63
|
-
requiresTypeChecking?: boolean;
|
|
64
|
-
}, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
65
|
-
name: string;
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
};
|
|
26
|
+
/** A rule as ESLint's config type asks for it: what `create` is given, and what its listeners take, is ESLint's own. */
|
|
27
|
+
interface RuleForEslint {
|
|
28
|
+
meta?: object;
|
|
29
|
+
create: (context: never) => Record<string, ((...args: any[]) => void) | undefined>;
|
|
30
|
+
}
|
|
31
|
+
/** A plugin as ESLint's config type asks for it. */
|
|
32
|
+
interface PluginForEslint {
|
|
70
33
|
meta: {
|
|
71
34
|
name: string;
|
|
72
|
-
version
|
|
35
|
+
version?: string;
|
|
73
36
|
};
|
|
74
|
-
rules:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
37
|
+
rules: Record<string, RuleForEslint>;
|
|
38
|
+
}
|
|
39
|
+
/** One entry of a flat config that registers a plugin and turns rules of it on. */
|
|
40
|
+
interface ConfigForEslint {
|
|
41
|
+
name?: string;
|
|
42
|
+
plugins: Record<string, PluginForEslint>;
|
|
43
|
+
rules: Record<string, 'error'>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** What `eslintPluginBemoje()` returns: the plugin, and a config that registers it and turns every rule on. */
|
|
47
|
+
interface EslintPluginBemoje extends PluginForEslint {
|
|
48
|
+
configs: {
|
|
49
|
+
recommended: {
|
|
50
|
+
plugins: {
|
|
51
|
+
'eslint-plugin-bemoje': EslintPluginBemoje;
|
|
52
|
+
};
|
|
53
|
+
rules: Record<string, 'error'>;
|
|
88
54
|
};
|
|
89
55
|
};
|
|
90
|
-
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* ESLint plugin for Bemoje projects.
|
|
59
|
+
*/
|
|
60
|
+
declare function eslintPluginBemoje(): EslintPluginBemoje;
|
|
91
61
|
|
|
92
62
|
/**
|
|
93
|
-
* Enforce no blank lines between block comments and the next declaration.
|
|
63
|
+
* Enforce no blank lines between block comments and the next declaration. A file's header, the comment that nothing
|
|
64
|
+
* comes before, is left alone.
|
|
94
65
|
*/
|
|
95
66
|
declare const noBlankLineBetweenCommentAndDeclaration: _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
|
|
96
67
|
description: string;
|
|
@@ -116,39 +87,19 @@ declare const splitImports: _typescript_eslint_utils_ts_eslint.RuleModule<"split
|
|
|
116
87
|
* ESLint accepts the same plugin name in several config entries only when it is the same object each time, so the
|
|
117
88
|
* entries share this one. A rule's full name is `bemoje/<rule>`, for an `eslint-disable` comment.
|
|
118
89
|
*/
|
|
119
|
-
declare const bemojePlugin:
|
|
120
|
-
meta: {
|
|
121
|
-
name: string;
|
|
122
|
-
};
|
|
123
|
-
rules: {
|
|
124
|
-
'no-blank-line-between-comment-and-declaration': TSESLint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
|
|
125
|
-
description: string;
|
|
126
|
-
recommended?: boolean;
|
|
127
|
-
requiresTypeChecking?: boolean;
|
|
128
|
-
}, TSESLint.RuleListener> & {
|
|
129
|
-
name: string;
|
|
130
|
-
};
|
|
131
|
-
'split-imports': TSESLint.RuleModule<"split-import", readonly unknown[], {
|
|
132
|
-
description: string;
|
|
133
|
-
recommended?: boolean;
|
|
134
|
-
requiresTypeChecking?: boolean;
|
|
135
|
-
}, TSESLint.RuleListener> & {
|
|
136
|
-
name: string;
|
|
137
|
-
};
|
|
138
|
-
};
|
|
139
|
-
};
|
|
90
|
+
declare const bemojePlugin: PluginForEslint;
|
|
140
91
|
|
|
141
92
|
/**
|
|
142
93
|
* A ready-made ESLint flat config entry that turns the rule `no-blank-line-between-comment-and-declaration` on as an
|
|
143
94
|
* error: a block comment over several lines has no blank line between it and the code right after it. Put it in the
|
|
144
95
|
* list a config file exports, with no plugin to register and no rule name to type.
|
|
145
96
|
*/
|
|
146
|
-
declare const enforceNoBlankLineBetweenCommentAndDeclaration:
|
|
97
|
+
declare const enforceNoBlankLineBetweenCommentAndDeclaration: ConfigForEslint;
|
|
147
98
|
|
|
148
99
|
/**
|
|
149
100
|
* A ready-made ESLint flat config entry that turns the rule `split-imports` on as an error: one import declaration
|
|
150
101
|
* per imported name. Put it in the list a config file exports, with no plugin to register and no rule name to type.
|
|
151
102
|
*/
|
|
152
|
-
declare const enforceSplitImports:
|
|
103
|
+
declare const enforceSplitImports: ConfigForEslint;
|
|
153
104
|
|
|
154
105
|
export { bemojePlugin, createRule, enforceNoBlankLineBetweenCommentAndDeclaration, enforceSplitImports, eslintPluginBemoje, noBlankLineBetweenCommentAndDeclaration, splitImports };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ESLintUtils
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
2
|
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -17,80 +17,51 @@ declare const createRule: <Options extends readonly unknown[], MessageIds extend
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* The types this package's plugin and config entries are offered under. They say what ESLint's own config type
|
|
21
|
+
* (`Linter.Config`) asks for and nothing more, so an entry goes into a typed config with no cast. A rule keeps its
|
|
22
|
+
* full typescript-eslint type where it is declared: that type does not fit ESLint's, which is why presets written
|
|
23
|
+
* with typescript-eslint usually need `as Linter.Config[]` where they are used. ESLint itself is not imported here,
|
|
24
|
+
* so the package does not depend on a version of it.
|
|
21
25
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
meta: {
|
|
31
|
-
name: string;
|
|
32
|
-
version: string;
|
|
33
|
-
};
|
|
34
|
-
rules: {
|
|
35
|
-
'no-blank-line-between-comment-and-declaration': _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
|
|
36
|
-
description: string;
|
|
37
|
-
recommended?: boolean;
|
|
38
|
-
requiresTypeChecking?: boolean;
|
|
39
|
-
}, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
40
|
-
name: string;
|
|
41
|
-
};
|
|
42
|
-
'split-imports': _typescript_eslint_utils_ts_eslint.RuleModule<"split-import", readonly unknown[], {
|
|
43
|
-
description: string;
|
|
44
|
-
recommended?: boolean;
|
|
45
|
-
requiresTypeChecking?: boolean;
|
|
46
|
-
}, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
47
|
-
name: string;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
rules: {
|
|
53
|
-
'no-blank-line-between-comment-and-declaration': _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
|
|
54
|
-
description: string;
|
|
55
|
-
recommended?: boolean;
|
|
56
|
-
requiresTypeChecking?: boolean;
|
|
57
|
-
}, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
58
|
-
name: string;
|
|
59
|
-
};
|
|
60
|
-
'split-imports': _typescript_eslint_utils_ts_eslint.RuleModule<"split-import", readonly unknown[], {
|
|
61
|
-
description: string;
|
|
62
|
-
recommended?: boolean;
|
|
63
|
-
requiresTypeChecking?: boolean;
|
|
64
|
-
}, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
65
|
-
name: string;
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
};
|
|
26
|
+
/** A rule as ESLint's config type asks for it: what `create` is given, and what its listeners take, is ESLint's own. */
|
|
27
|
+
interface RuleForEslint {
|
|
28
|
+
meta?: object;
|
|
29
|
+
create: (context: never) => Record<string, ((...args: any[]) => void) | undefined>;
|
|
30
|
+
}
|
|
31
|
+
/** A plugin as ESLint's config type asks for it. */
|
|
32
|
+
interface PluginForEslint {
|
|
70
33
|
meta: {
|
|
71
34
|
name: string;
|
|
72
|
-
version
|
|
35
|
+
version?: string;
|
|
73
36
|
};
|
|
74
|
-
rules:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
37
|
+
rules: Record<string, RuleForEslint>;
|
|
38
|
+
}
|
|
39
|
+
/** One entry of a flat config that registers a plugin and turns rules of it on. */
|
|
40
|
+
interface ConfigForEslint {
|
|
41
|
+
name?: string;
|
|
42
|
+
plugins: Record<string, PluginForEslint>;
|
|
43
|
+
rules: Record<string, 'error'>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** What `eslintPluginBemoje()` returns: the plugin, and a config that registers it and turns every rule on. */
|
|
47
|
+
interface EslintPluginBemoje extends PluginForEslint {
|
|
48
|
+
configs: {
|
|
49
|
+
recommended: {
|
|
50
|
+
plugins: {
|
|
51
|
+
'eslint-plugin-bemoje': EslintPluginBemoje;
|
|
52
|
+
};
|
|
53
|
+
rules: Record<string, 'error'>;
|
|
88
54
|
};
|
|
89
55
|
};
|
|
90
|
-
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* ESLint plugin for Bemoje projects.
|
|
59
|
+
*/
|
|
60
|
+
declare function eslintPluginBemoje(): EslintPluginBemoje;
|
|
91
61
|
|
|
92
62
|
/**
|
|
93
|
-
* Enforce no blank lines between block comments and the next declaration.
|
|
63
|
+
* Enforce no blank lines between block comments and the next declaration. A file's header, the comment that nothing
|
|
64
|
+
* comes before, is left alone.
|
|
94
65
|
*/
|
|
95
66
|
declare const noBlankLineBetweenCommentAndDeclaration: _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
|
|
96
67
|
description: string;
|
|
@@ -116,39 +87,19 @@ declare const splitImports: _typescript_eslint_utils_ts_eslint.RuleModule<"split
|
|
|
116
87
|
* ESLint accepts the same plugin name in several config entries only when it is the same object each time, so the
|
|
117
88
|
* entries share this one. A rule's full name is `bemoje/<rule>`, for an `eslint-disable` comment.
|
|
118
89
|
*/
|
|
119
|
-
declare const bemojePlugin:
|
|
120
|
-
meta: {
|
|
121
|
-
name: string;
|
|
122
|
-
};
|
|
123
|
-
rules: {
|
|
124
|
-
'no-blank-line-between-comment-and-declaration': TSESLint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
|
|
125
|
-
description: string;
|
|
126
|
-
recommended?: boolean;
|
|
127
|
-
requiresTypeChecking?: boolean;
|
|
128
|
-
}, TSESLint.RuleListener> & {
|
|
129
|
-
name: string;
|
|
130
|
-
};
|
|
131
|
-
'split-imports': TSESLint.RuleModule<"split-import", readonly unknown[], {
|
|
132
|
-
description: string;
|
|
133
|
-
recommended?: boolean;
|
|
134
|
-
requiresTypeChecking?: boolean;
|
|
135
|
-
}, TSESLint.RuleListener> & {
|
|
136
|
-
name: string;
|
|
137
|
-
};
|
|
138
|
-
};
|
|
139
|
-
};
|
|
90
|
+
declare const bemojePlugin: PluginForEslint;
|
|
140
91
|
|
|
141
92
|
/**
|
|
142
93
|
* A ready-made ESLint flat config entry that turns the rule `no-blank-line-between-comment-and-declaration` on as an
|
|
143
94
|
* error: a block comment over several lines has no blank line between it and the code right after it. Put it in the
|
|
144
95
|
* list a config file exports, with no plugin to register and no rule name to type.
|
|
145
96
|
*/
|
|
146
|
-
declare const enforceNoBlankLineBetweenCommentAndDeclaration:
|
|
97
|
+
declare const enforceNoBlankLineBetweenCommentAndDeclaration: ConfigForEslint;
|
|
147
98
|
|
|
148
99
|
/**
|
|
149
100
|
* A ready-made ESLint flat config entry that turns the rule `split-imports` on as an error: one import declaration
|
|
150
101
|
* per imported name. Put it in the list a config file exports, with no plugin to register and no rule name to type.
|
|
151
102
|
*/
|
|
152
|
-
declare const enforceSplitImports:
|
|
103
|
+
declare const enforceSplitImports: ConfigForEslint;
|
|
153
104
|
|
|
154
105
|
export { bemojePlugin, createRule, enforceNoBlankLineBetweenCommentAndDeclaration, enforceSplitImports, eslintPluginBemoje, noBlankLineBetweenCommentAndDeclaration, splitImports };
|
package/lib/index.js
CHANGED
|
@@ -30,6 +30,12 @@ var noBlankLineBetweenCommentAndDeclaration = createRule({
|
|
|
30
30
|
if (Math.abs(comment.loc.start.line - comment.loc.end.line) < 2) {
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
+
const before = context.sourceCode.getTokenBefore(comment, {
|
|
34
|
+
includeComments: true
|
|
35
|
+
});
|
|
36
|
+
if (!before || before.type === "Shebang") {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
33
39
|
const nextToken = context.sourceCode.getTokenAfter(comment, {
|
|
34
40
|
includeComments: true
|
|
35
41
|
});
|
|
@@ -66,6 +72,9 @@ var noBlankLineBetweenCommentAndDeclaration = createRule({
|
|
|
66
72
|
};
|
|
67
73
|
}
|
|
68
74
|
});
|
|
75
|
+
|
|
76
|
+
// src/lib/forEslint.ts
|
|
77
|
+
var ruleForEslint = /* @__PURE__ */ __name((rule) => rule, "ruleForEslint");
|
|
69
78
|
var splitImports = createRule({
|
|
70
79
|
name: "split-imports",
|
|
71
80
|
meta: {
|
|
@@ -115,12 +124,20 @@ var splitImports = createRule({
|
|
|
115
124
|
}
|
|
116
125
|
});
|
|
117
126
|
|
|
127
|
+
// src/lib/bemojePlugin.ts
|
|
128
|
+
var bemojePlugin = {
|
|
129
|
+
meta: {
|
|
130
|
+
name: "@bemoje/eslint"
|
|
131
|
+
},
|
|
132
|
+
rules: {
|
|
133
|
+
"no-blank-line-between-comment-and-declaration": ruleForEslint(noBlankLineBetweenCommentAndDeclaration),
|
|
134
|
+
"split-imports": ruleForEslint(splitImports)
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
118
138
|
// src/lib/eslintPluginBemoje.ts
|
|
119
139
|
function eslintPluginBemoje() {
|
|
120
|
-
const rules =
|
|
121
|
-
"no-blank-line-between-comment-and-declaration": noBlankLineBetweenCommentAndDeclaration,
|
|
122
|
-
"split-imports": splitImports
|
|
123
|
-
};
|
|
140
|
+
const rules = bemojePlugin.rules;
|
|
124
141
|
const plugins = {
|
|
125
142
|
get "eslint-plugin-bemoje"() {
|
|
126
143
|
return eslintPluginBemoje();
|
|
@@ -131,30 +148,22 @@ function eslintPluginBemoje() {
|
|
|
131
148
|
get recommended() {
|
|
132
149
|
return {
|
|
133
150
|
plugins,
|
|
134
|
-
rules
|
|
151
|
+
rules: Object.fromEntries(Object.keys(rules).map((name) => [
|
|
152
|
+
`eslint-plugin-bemoje/${name}`,
|
|
153
|
+
"error"
|
|
154
|
+
]))
|
|
135
155
|
};
|
|
136
156
|
}
|
|
137
157
|
},
|
|
138
158
|
meta: {
|
|
139
159
|
name: "eslint-plugin-bemoje",
|
|
140
|
-
version: "2.1.
|
|
160
|
+
version: "2.1.2"
|
|
141
161
|
},
|
|
142
162
|
rules
|
|
143
163
|
};
|
|
144
164
|
}
|
|
145
165
|
__name(eslintPluginBemoje, "eslintPluginBemoje");
|
|
146
166
|
|
|
147
|
-
// src/lib/bemojePlugin.ts
|
|
148
|
-
var bemojePlugin = {
|
|
149
|
-
meta: {
|
|
150
|
-
name: "@bemoje/eslint"
|
|
151
|
-
},
|
|
152
|
-
rules: {
|
|
153
|
-
"no-blank-line-between-comment-and-declaration": noBlankLineBetweenCommentAndDeclaration,
|
|
154
|
-
"split-imports": splitImports
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
|
|
158
167
|
// src/configs/enforceNoBlankLineBetweenCommentAndDeclaration.ts
|
|
159
168
|
var enforceNoBlankLineBetweenCommentAndDeclaration = {
|
|
160
169
|
name: "@bemoje/eslint/no-blank-line-between-comment-and-declaration",
|