@bemoje/eslint 2.1.0 → 2.1.1

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 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)
package/lib/index.cjs CHANGED
@@ -68,6 +68,9 @@ var noBlankLineBetweenCommentAndDeclaration = createRule({
68
68
  };
69
69
  }
70
70
  });
71
+
72
+ // src/lib/forEslint.ts
73
+ var ruleForEslint = /* @__PURE__ */ __name((rule) => rule, "ruleForEslint");
71
74
  var splitImports = createRule({
72
75
  name: "split-imports",
73
76
  meta: {
@@ -117,12 +120,20 @@ var splitImports = createRule({
117
120
  }
118
121
  });
119
122
 
123
+ // src/lib/bemojePlugin.ts
124
+ var bemojePlugin = {
125
+ meta: {
126
+ name: "@bemoje/eslint"
127
+ },
128
+ rules: {
129
+ "no-blank-line-between-comment-and-declaration": ruleForEslint(noBlankLineBetweenCommentAndDeclaration),
130
+ "split-imports": ruleForEslint(splitImports)
131
+ }
132
+ };
133
+
120
134
  // src/lib/eslintPluginBemoje.ts
121
135
  function eslintPluginBemoje() {
122
- const rules = {
123
- "no-blank-line-between-comment-and-declaration": noBlankLineBetweenCommentAndDeclaration,
124
- "split-imports": splitImports
125
- };
136
+ const rules = bemojePlugin.rules;
126
137
  const plugins = {
127
138
  get "eslint-plugin-bemoje"() {
128
139
  return eslintPluginBemoje();
@@ -133,30 +144,22 @@ function eslintPluginBemoje() {
133
144
  get recommended() {
134
145
  return {
135
146
  plugins,
136
- rules
147
+ rules: Object.fromEntries(Object.keys(rules).map((name) => [
148
+ `eslint-plugin-bemoje/${name}`,
149
+ "error"
150
+ ]))
137
151
  };
138
152
  }
139
153
  },
140
154
  meta: {
141
155
  name: "eslint-plugin-bemoje",
142
- version: "2.1.0"
156
+ version: "2.1.1"
143
157
  },
144
158
  rules
145
159
  };
146
160
  }
147
161
  __name(eslintPluginBemoje, "eslintPluginBemoje");
148
162
 
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
163
  // src/configs/enforceNoBlankLineBetweenCommentAndDeclaration.ts
161
164
  var enforceNoBlankLineBetweenCommentAndDeclaration = {
162
165
  name: "@bemoje/eslint/no-blank-line-between-comment-and-declaration",
package/lib/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { ESLintUtils, TSESLint } from '@typescript-eslint/utils';
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,77 +17,47 @@ declare const createRule: <Options extends readonly unknown[], MessageIds extend
17
17
  };
18
18
 
19
19
  /**
20
- * ESLint plugin for Bemoje projects.
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
- declare function eslintPluginBemoje(): {
23
- configs: {
24
- readonly recommended: {
25
- plugins: {
26
- readonly 'eslint-plugin-bemoje': {
27
- configs: {
28
- readonly recommended: /*elided*/ any;
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: string;
35
+ version?: string;
73
36
  };
74
- rules: {
75
- 'no-blank-line-between-comment-and-declaration': _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
76
- description: string;
77
- recommended?: boolean;
78
- requiresTypeChecking?: boolean;
79
- }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
80
- name: string;
81
- };
82
- 'split-imports': _typescript_eslint_utils_ts_eslint.RuleModule<"split-import", readonly unknown[], {
83
- description: string;
84
- recommended?: boolean;
85
- requiresTypeChecking?: boolean;
86
- }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
87
- name: string;
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
63
  * Enforce no blank lines between block comments and the next declaration.
@@ -116,39 +86,19 @@ declare const splitImports: _typescript_eslint_utils_ts_eslint.RuleModule<"split
116
86
  * ESLint accepts the same plugin name in several config entries only when it is the same object each time, so the
117
87
  * entries share this one. A rule's full name is `bemoje/<rule>`, for an `eslint-disable` comment.
118
88
  */
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
- };
89
+ declare const bemojePlugin: PluginForEslint;
140
90
 
141
91
  /**
142
92
  * A ready-made ESLint flat config entry that turns the rule `no-blank-line-between-comment-and-declaration` on as an
143
93
  * error: a block comment over several lines has no blank line between it and the code right after it. Put it in the
144
94
  * list a config file exports, with no plugin to register and no rule name to type.
145
95
  */
146
- declare const enforceNoBlankLineBetweenCommentAndDeclaration: TSESLint.FlatConfig.Config;
96
+ declare const enforceNoBlankLineBetweenCommentAndDeclaration: ConfigForEslint;
147
97
 
148
98
  /**
149
99
  * A ready-made ESLint flat config entry that turns the rule `split-imports` on as an error: one import declaration
150
100
  * per imported name. Put it in the list a config file exports, with no plugin to register and no rule name to type.
151
101
  */
152
- declare const enforceSplitImports: TSESLint.FlatConfig.Config;
102
+ declare const enforceSplitImports: ConfigForEslint;
153
103
 
154
104
  export { bemojePlugin, createRule, enforceNoBlankLineBetweenCommentAndDeclaration, enforceSplitImports, eslintPluginBemoje, noBlankLineBetweenCommentAndDeclaration, splitImports };
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ESLintUtils, TSESLint } from '@typescript-eslint/utils';
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,77 +17,47 @@ declare const createRule: <Options extends readonly unknown[], MessageIds extend
17
17
  };
18
18
 
19
19
  /**
20
- * ESLint plugin for Bemoje projects.
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
- declare function eslintPluginBemoje(): {
23
- configs: {
24
- readonly recommended: {
25
- plugins: {
26
- readonly 'eslint-plugin-bemoje': {
27
- configs: {
28
- readonly recommended: /*elided*/ any;
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: string;
35
+ version?: string;
73
36
  };
74
- rules: {
75
- 'no-blank-line-between-comment-and-declaration': _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
76
- description: string;
77
- recommended?: boolean;
78
- requiresTypeChecking?: boolean;
79
- }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
80
- name: string;
81
- };
82
- 'split-imports': _typescript_eslint_utils_ts_eslint.RuleModule<"split-import", readonly unknown[], {
83
- description: string;
84
- recommended?: boolean;
85
- requiresTypeChecking?: boolean;
86
- }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
87
- name: string;
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
63
  * Enforce no blank lines between block comments and the next declaration.
@@ -116,39 +86,19 @@ declare const splitImports: _typescript_eslint_utils_ts_eslint.RuleModule<"split
116
86
  * ESLint accepts the same plugin name in several config entries only when it is the same object each time, so the
117
87
  * entries share this one. A rule's full name is `bemoje/<rule>`, for an `eslint-disable` comment.
118
88
  */
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
- };
89
+ declare const bemojePlugin: PluginForEslint;
140
90
 
141
91
  /**
142
92
  * A ready-made ESLint flat config entry that turns the rule `no-blank-line-between-comment-and-declaration` on as an
143
93
  * error: a block comment over several lines has no blank line between it and the code right after it. Put it in the
144
94
  * list a config file exports, with no plugin to register and no rule name to type.
145
95
  */
146
- declare const enforceNoBlankLineBetweenCommentAndDeclaration: TSESLint.FlatConfig.Config;
96
+ declare const enforceNoBlankLineBetweenCommentAndDeclaration: ConfigForEslint;
147
97
 
148
98
  /**
149
99
  * A ready-made ESLint flat config entry that turns the rule `split-imports` on as an error: one import declaration
150
100
  * per imported name. Put it in the list a config file exports, with no plugin to register and no rule name to type.
151
101
  */
152
- declare const enforceSplitImports: TSESLint.FlatConfig.Config;
102
+ declare const enforceSplitImports: ConfigForEslint;
153
103
 
154
104
  export { bemojePlugin, createRule, enforceNoBlankLineBetweenCommentAndDeclaration, enforceSplitImports, eslintPluginBemoje, noBlankLineBetweenCommentAndDeclaration, splitImports };
package/lib/index.js CHANGED
@@ -66,6 +66,9 @@ var noBlankLineBetweenCommentAndDeclaration = createRule({
66
66
  };
67
67
  }
68
68
  });
69
+
70
+ // src/lib/forEslint.ts
71
+ var ruleForEslint = /* @__PURE__ */ __name((rule) => rule, "ruleForEslint");
69
72
  var splitImports = createRule({
70
73
  name: "split-imports",
71
74
  meta: {
@@ -115,12 +118,20 @@ var splitImports = createRule({
115
118
  }
116
119
  });
117
120
 
121
+ // src/lib/bemojePlugin.ts
122
+ var bemojePlugin = {
123
+ meta: {
124
+ name: "@bemoje/eslint"
125
+ },
126
+ rules: {
127
+ "no-blank-line-between-comment-and-declaration": ruleForEslint(noBlankLineBetweenCommentAndDeclaration),
128
+ "split-imports": ruleForEslint(splitImports)
129
+ }
130
+ };
131
+
118
132
  // src/lib/eslintPluginBemoje.ts
119
133
  function eslintPluginBemoje() {
120
- const rules = {
121
- "no-blank-line-between-comment-and-declaration": noBlankLineBetweenCommentAndDeclaration,
122
- "split-imports": splitImports
123
- };
134
+ const rules = bemojePlugin.rules;
124
135
  const plugins = {
125
136
  get "eslint-plugin-bemoje"() {
126
137
  return eslintPluginBemoje();
@@ -131,30 +142,22 @@ function eslintPluginBemoje() {
131
142
  get recommended() {
132
143
  return {
133
144
  plugins,
134
- rules
145
+ rules: Object.fromEntries(Object.keys(rules).map((name) => [
146
+ `eslint-plugin-bemoje/${name}`,
147
+ "error"
148
+ ]))
135
149
  };
136
150
  }
137
151
  },
138
152
  meta: {
139
153
  name: "eslint-plugin-bemoje",
140
- version: "2.1.0"
154
+ version: "2.1.1"
141
155
  },
142
156
  rules
143
157
  };
144
158
  }
145
159
  __name(eslintPluginBemoje, "eslintPluginBemoje");
146
160
 
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
161
  // src/configs/enforceNoBlankLineBetweenCommentAndDeclaration.ts
159
162
  var enforceNoBlankLineBetweenCommentAndDeclaration = {
160
163
  name: "@bemoje/eslint/no-blank-line-between-comment-and-declaration",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemoje/eslint",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Custom ESLint plugin and rule utilities for consistent code style in TypeScript projects.",
5
5
  "type": "module",
6
6
  "sideEffects": false,