@bemoje/eslint 1.1.4 → 1.2.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/README.md CHANGED
@@ -2,8 +2,17 @@
2
2
 
3
3
  Custom ESLint plugin and rule utilities for consistent code style in TypeScript projects.
4
4
 
5
- [![TypeScript](https://img.shields.io/badge/TypeScript-5-blue)](https://www.typescriptlang.org/)
6
- [![Module](https://img.shields.io/badge/Module-ESM-yellow)](https://nodejs.org/api/esm.html)
5
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5-blue)](https://www.typescriptlang.org/) [![Module](https://img.shields.io/badge/Module-ESM-yellow)](https://nodejs.org/api/esm.html)
6
+
7
+ ## Exports
8
+
9
+ <!-- EXPORTS_START -->
10
+
11
+ - **createRule**: Helper to create an ESLint rule with a consistent format.
12
+ - **eslintPluginBemoje**: ESLint plugin for Bemoje projects.
13
+ - **noBlankLineBetweenCommentAndDeclaration**: Enforce no blank lines between block comments and the next declaration.
14
+
15
+ <!-- EXPORTS_END -->
7
16
 
8
17
  ## Installation
9
18
 
@@ -49,8 +58,7 @@ export default [{ plugins, rules }]
49
58
 
50
59
  ### no-blank-line-between-comment-and-declaration
51
60
 
52
- Enforces that there are no blank lines between a block comment (JSDoc or multi-line) and the declaration it
53
- documents. Auto-fixable.
61
+ Enforces that there are no blank lines between a block comment (JSDoc or multi-line) and the declaration it documents. Auto-fixable.
54
62
 
55
63
  **Incorrect:**
56
64
 
@@ -76,11 +84,3 @@ export function add(a: number, b: number) {
76
84
  ```
77
85
 
78
86
  Single-line block comments and line comments between the block comment and the declaration are ignored.
79
-
80
- ## API Reference
81
-
82
- | Export | Description |
83
- | ----------------------------------------- | ------------------------------------------------------------ |
84
- | `eslintPluginBemoje` | Returns the ESLint plugin object with rules and configs |
85
- | `createRule` | Helper for creating ESLint rules with consistent metadata |
86
- | `noBlankLineBetweenCommentAndDeclaration` | Rule: no blank lines between block comments and declarations |
package/lib/index.cjs CHANGED
@@ -68,10 +68,65 @@ var noBlankLineBetweenCommentAndDeclaration = createRule({
68
68
  }
69
69
  });
70
70
 
71
+ // src/rules/splitImports.ts
72
+ var splitImports = createRule({
73
+ name: "split-imports",
74
+ meta: {
75
+ docs: {
76
+ description: "Require one line per import, disallow multiple imports"
77
+ },
78
+ fixable: "code",
79
+ messages: {
80
+ "split-import": "Split multi-import into seperate import declarations."
81
+ },
82
+ type: "suggestion",
83
+ schema: []
84
+ },
85
+ create(context) {
86
+ return {
87
+ ImportDeclaration(node) {
88
+ if (node.specifiers.length > 1) {
89
+ const sourceCode = context.sourceCode;
90
+ const insideBraces = sourceCode.getText(node).match(/{([^{}]+)}/)?.[1]?.split(",").map((s) => {
91
+ return s.trim();
92
+ }).filter((s) => {
93
+ return !!s;
94
+ }) ?? [];
95
+ const maybeWrapInBraces = /* @__PURE__ */ __name((code) => {
96
+ return insideBraces.includes(code) ? `{ ${code} }` : code;
97
+ }, "maybeWrapInBraces");
98
+ const isType = /* @__PURE__ */ __name((code) => {
99
+ return node.importKind === "type" || code.startsWith("type ");
100
+ }, "isType");
101
+ const stripTypeKeyword = /* @__PURE__ */ __name((code) => {
102
+ return code.replace(/\btype\s+\b/, "").trim();
103
+ }, "stripTypeKeyword");
104
+ const importStrings = node.specifiers.map((specifier) => {
105
+ const code = sourceCode.getText(specifier).trim();
106
+ return [
107
+ isType(code) ? "import type" : "import",
108
+ maybeWrapInBraces(stripTypeKeyword(code)),
109
+ `from "${node.source.value}";`
110
+ ].join(" ");
111
+ });
112
+ context.report({
113
+ fix: /* @__PURE__ */ __name((fixer) => {
114
+ return fixer.replaceText(node, importStrings.join("\n"));
115
+ }, "fix"),
116
+ messageId: "split-import",
117
+ node
118
+ });
119
+ }
120
+ }
121
+ };
122
+ }
123
+ });
124
+
71
125
  // src/lib/eslintPluginBemoje.ts
72
126
  function eslintPluginBemoje() {
73
127
  const rules = {
74
- "no-blank-line-between-comment-and-declaration": noBlankLineBetweenCommentAndDeclaration
128
+ "no-blank-line-between-comment-and-declaration": noBlankLineBetweenCommentAndDeclaration,
129
+ "split-imports": splitImports
75
130
  };
76
131
  const plugins = {
77
132
  get "eslint-plugin-bemoje"() {
@@ -89,7 +144,7 @@ function eslintPluginBemoje() {
89
144
  },
90
145
  meta: {
91
146
  name: "eslint-plugin-bemoje",
92
- version: "1.0.1"
147
+ version: "1.2.0"
93
148
  },
94
149
  rules
95
150
  };
@@ -99,3 +154,4 @@ __name(eslintPluginBemoje, "eslintPluginBemoje");
99
154
  exports.createRule = createRule;
100
155
  exports.eslintPluginBemoje = eslintPluginBemoje;
101
156
  exports.noBlankLineBetweenCommentAndDeclaration = noBlankLineBetweenCommentAndDeclaration;
157
+ exports.splitImports = splitImports;
package/lib/index.d.cts CHANGED
@@ -1,5 +1,90 @@
1
- export { createRule } from './lib/createRule.cjs';
2
- export { eslintPluginBemoje } from './lib/eslintPluginBemoje.cjs';
3
- export { noBlankLineBetweenCommentAndDeclaration } from './rules/noBlankLineBetweenCommentAndDeclaration.cjs';
4
- import '@typescript-eslint/utils';
5
- import '@typescript-eslint/utils/ts-eslint';
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
3
+
4
+ /**
5
+ * Helper to create an ESLint rule with a consistent format.
6
+ */
7
+ declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, {
8
+ description: string;
9
+ recommended?: boolean;
10
+ requiresTypeChecking?: boolean;
11
+ }>>) => ESLintUtils.RuleModule<MessageIds, Options, {
12
+ description: string;
13
+ recommended?: boolean;
14
+ requiresTypeChecking?: boolean;
15
+ }, ESLintUtils.RuleListener> & {
16
+ name: string;
17
+ };
18
+
19
+ /**
20
+ * ESLint plugin for Bemoje projects.
21
+ */
22
+ declare function eslintPluginBemoje(): {
23
+ configs: {
24
+ readonly recommended: {
25
+ plugins: {
26
+ readonly 'eslint-plugin-bemoje': any;
27
+ };
28
+ rules: {
29
+ 'no-blank-line-between-comment-and-declaration': _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
30
+ description: string;
31
+ recommended?: boolean;
32
+ requiresTypeChecking?: boolean;
33
+ }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
34
+ name: string;
35
+ };
36
+ 'split-imports': _typescript_eslint_utils_ts_eslint.RuleModule<"split-import", readonly unknown[], {
37
+ description: string;
38
+ recommended?: boolean;
39
+ requiresTypeChecking?: boolean;
40
+ }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
41
+ name: string;
42
+ };
43
+ };
44
+ };
45
+ };
46
+ meta: {
47
+ name: string;
48
+ version: string;
49
+ };
50
+ rules: {
51
+ 'no-blank-line-between-comment-and-declaration': _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
52
+ description: string;
53
+ recommended?: boolean;
54
+ requiresTypeChecking?: boolean;
55
+ }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
56
+ name: string;
57
+ };
58
+ 'split-imports': _typescript_eslint_utils_ts_eslint.RuleModule<"split-import", readonly unknown[], {
59
+ description: string;
60
+ recommended?: boolean;
61
+ requiresTypeChecking?: boolean;
62
+ }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
63
+ name: string;
64
+ };
65
+ };
66
+ };
67
+
68
+ /**
69
+ * Enforce no blank lines between block comments and the next declaration.
70
+ */
71
+ declare const noBlankLineBetweenCommentAndDeclaration: _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
72
+ description: string;
73
+ recommended?: boolean;
74
+ requiresTypeChecking?: boolean;
75
+ }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
76
+ name: string;
77
+ };
78
+
79
+ /**
80
+ * Enforce no blank lines between block comments and the next declaration.
81
+ */
82
+ declare const splitImports: _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;
88
+ };
89
+
90
+ export { createRule, eslintPluginBemoje, noBlankLineBetweenCommentAndDeclaration, splitImports };
package/lib/index.d.ts CHANGED
@@ -1,5 +1,90 @@
1
- export { createRule } from './lib/createRule.js';
2
- export { eslintPluginBemoje } from './lib/eslintPluginBemoje.js';
3
- export { noBlankLineBetweenCommentAndDeclaration } from './rules/noBlankLineBetweenCommentAndDeclaration.js';
4
- import '@typescript-eslint/utils';
5
- import '@typescript-eslint/utils/ts-eslint';
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
3
+
4
+ /**
5
+ * Helper to create an ESLint rule with a consistent format.
6
+ */
7
+ declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, {
8
+ description: string;
9
+ recommended?: boolean;
10
+ requiresTypeChecking?: boolean;
11
+ }>>) => ESLintUtils.RuleModule<MessageIds, Options, {
12
+ description: string;
13
+ recommended?: boolean;
14
+ requiresTypeChecking?: boolean;
15
+ }, ESLintUtils.RuleListener> & {
16
+ name: string;
17
+ };
18
+
19
+ /**
20
+ * ESLint plugin for Bemoje projects.
21
+ */
22
+ declare function eslintPluginBemoje(): {
23
+ configs: {
24
+ readonly recommended: {
25
+ plugins: {
26
+ readonly 'eslint-plugin-bemoje': any;
27
+ };
28
+ rules: {
29
+ 'no-blank-line-between-comment-and-declaration': _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
30
+ description: string;
31
+ recommended?: boolean;
32
+ requiresTypeChecking?: boolean;
33
+ }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
34
+ name: string;
35
+ };
36
+ 'split-imports': _typescript_eslint_utils_ts_eslint.RuleModule<"split-import", readonly unknown[], {
37
+ description: string;
38
+ recommended?: boolean;
39
+ requiresTypeChecking?: boolean;
40
+ }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
41
+ name: string;
42
+ };
43
+ };
44
+ };
45
+ };
46
+ meta: {
47
+ name: string;
48
+ version: string;
49
+ };
50
+ rules: {
51
+ 'no-blank-line-between-comment-and-declaration': _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
52
+ description: string;
53
+ recommended?: boolean;
54
+ requiresTypeChecking?: boolean;
55
+ }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
56
+ name: string;
57
+ };
58
+ 'split-imports': _typescript_eslint_utils_ts_eslint.RuleModule<"split-import", readonly unknown[], {
59
+ description: string;
60
+ recommended?: boolean;
61
+ requiresTypeChecking?: boolean;
62
+ }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
63
+ name: string;
64
+ };
65
+ };
66
+ };
67
+
68
+ /**
69
+ * Enforce no blank lines between block comments and the next declaration.
70
+ */
71
+ declare const noBlankLineBetweenCommentAndDeclaration: _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
72
+ description: string;
73
+ recommended?: boolean;
74
+ requiresTypeChecking?: boolean;
75
+ }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
76
+ name: string;
77
+ };
78
+
79
+ /**
80
+ * Enforce no blank lines between block comments and the next declaration.
81
+ */
82
+ declare const splitImports: _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;
88
+ };
89
+
90
+ export { createRule, eslintPluginBemoje, noBlankLineBetweenCommentAndDeclaration, splitImports };
package/lib/index.js CHANGED
@@ -66,10 +66,65 @@ var noBlankLineBetweenCommentAndDeclaration = createRule({
66
66
  }
67
67
  });
68
68
 
69
+ // src/rules/splitImports.ts
70
+ var splitImports = createRule({
71
+ name: "split-imports",
72
+ meta: {
73
+ docs: {
74
+ description: "Require one line per import, disallow multiple imports"
75
+ },
76
+ fixable: "code",
77
+ messages: {
78
+ "split-import": "Split multi-import into seperate import declarations."
79
+ },
80
+ type: "suggestion",
81
+ schema: []
82
+ },
83
+ create(context) {
84
+ return {
85
+ ImportDeclaration(node) {
86
+ if (node.specifiers.length > 1) {
87
+ const sourceCode = context.sourceCode;
88
+ const insideBraces = sourceCode.getText(node).match(/{([^{}]+)}/)?.[1]?.split(",").map((s) => {
89
+ return s.trim();
90
+ }).filter((s) => {
91
+ return !!s;
92
+ }) ?? [];
93
+ const maybeWrapInBraces = /* @__PURE__ */ __name((code) => {
94
+ return insideBraces.includes(code) ? `{ ${code} }` : code;
95
+ }, "maybeWrapInBraces");
96
+ const isType = /* @__PURE__ */ __name((code) => {
97
+ return node.importKind === "type" || code.startsWith("type ");
98
+ }, "isType");
99
+ const stripTypeKeyword = /* @__PURE__ */ __name((code) => {
100
+ return code.replace(/\btype\s+\b/, "").trim();
101
+ }, "stripTypeKeyword");
102
+ const importStrings = node.specifiers.map((specifier) => {
103
+ const code = sourceCode.getText(specifier).trim();
104
+ return [
105
+ isType(code) ? "import type" : "import",
106
+ maybeWrapInBraces(stripTypeKeyword(code)),
107
+ `from "${node.source.value}";`
108
+ ].join(" ");
109
+ });
110
+ context.report({
111
+ fix: /* @__PURE__ */ __name((fixer) => {
112
+ return fixer.replaceText(node, importStrings.join("\n"));
113
+ }, "fix"),
114
+ messageId: "split-import",
115
+ node
116
+ });
117
+ }
118
+ }
119
+ };
120
+ }
121
+ });
122
+
69
123
  // src/lib/eslintPluginBemoje.ts
70
124
  function eslintPluginBemoje() {
71
125
  const rules = {
72
- "no-blank-line-between-comment-and-declaration": noBlankLineBetweenCommentAndDeclaration
126
+ "no-blank-line-between-comment-and-declaration": noBlankLineBetweenCommentAndDeclaration,
127
+ "split-imports": splitImports
73
128
  };
74
129
  const plugins = {
75
130
  get "eslint-plugin-bemoje"() {
@@ -87,11 +142,11 @@ function eslintPluginBemoje() {
87
142
  },
88
143
  meta: {
89
144
  name: "eslint-plugin-bemoje",
90
- version: "1.0.1"
145
+ version: "1.2.0"
91
146
  },
92
147
  rules
93
148
  };
94
149
  }
95
150
  __name(eslintPluginBemoje, "eslintPluginBemoje");
96
151
 
97
- export { createRule, eslintPluginBemoje, noBlankLineBetweenCommentAndDeclaration };
152
+ export { createRule, eslintPluginBemoje, noBlankLineBetweenCommentAndDeclaration, splitImports };
package/package.json CHANGED
@@ -1,7 +1,15 @@
1
1
  {
2
2
  "name": "@bemoje/eslint",
3
- "version": "1.1.4",
3
+ "version": "1.2.0",
4
4
  "description": "Custom ESLint plugin and rule utilities for consistent code style in TypeScript projects.",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "dependencies": {
11
+ "@typescript-eslint/utils": "^8.56.1"
12
+ },
5
13
  "keywords": [
6
14
  "eslint",
7
15
  "eslint-plugin",
@@ -11,17 +19,15 @@
11
19
  "utilities",
12
20
  "typescript"
13
21
  ],
14
- "dependencies": {
15
- "@typescript-eslint/utils": "^8.56.1"
16
- },
17
- "type": "module",
18
- "sideEffects": false,
19
- "publishConfig": {
20
- "access": "public"
21
- },
22
22
  "main": "./lib/index.cjs",
23
23
  "module": "./lib/index.js",
24
24
  "types": "./lib/index.d.ts",
25
+ "files": [
26
+ "./lib/index.js",
27
+ "./lib/index.d.ts",
28
+ "./lib/index.cjs",
29
+ "./lib/index.d.cts"
30
+ ],
25
31
  "exports": {
26
32
  ".": {
27
33
  "import": {
@@ -33,55 +39,17 @@
33
39
  "default": "./lib/index.cjs"
34
40
  }
35
41
  },
36
- "./lib/createRule": {
37
- "import": {
38
- "types": "./lib/lib/createRule.d.ts",
39
- "default": "./lib/lib/createRule.js"
40
- },
41
- "require": {
42
- "types": "./lib/lib/createRule.d.cts",
43
- "default": "./lib/lib/createRule.cjs"
44
- }
45
- },
46
- "./lib/eslintPluginBemoje": {
47
- "import": {
48
- "types": "./lib/lib/eslintPluginBemoje.d.ts",
49
- "default": "./lib/lib/eslintPluginBemoje.js"
50
- },
51
- "require": {
52
- "types": "./lib/lib/eslintPluginBemoje.d.cts",
53
- "default": "./lib/lib/eslintPluginBemoje.cjs"
54
- }
55
- },
56
- "./rules/noBlankLineBetweenCommentAndDeclaration": {
42
+ "./*": {
57
43
  "import": {
58
- "types": "./lib/rules/noBlankLineBetweenCommentAndDeclaration.d.ts",
59
- "default": "./lib/rules/noBlankLineBetweenCommentAndDeclaration.js"
44
+ "types": "./lib/index.d.ts",
45
+ "default": "./lib/index.js"
60
46
  },
61
47
  "require": {
62
- "types": "./lib/rules/noBlankLineBetweenCommentAndDeclaration.d.cts",
63
- "default": "./lib/rules/noBlankLineBetweenCommentAndDeclaration.cjs"
48
+ "types": "./lib/index.d.cts",
49
+ "default": "./lib/index.cjs"
64
50
  }
65
51
  }
66
52
  },
67
- "files": [
68
- "./lib/index.js",
69
- "./lib/index.d.ts",
70
- "./lib/index.cjs",
71
- "./lib/index.d.cts",
72
- "./lib/lib/createRule.js",
73
- "./lib/lib/createRule.d.ts",
74
- "./lib/lib/createRule.cjs",
75
- "./lib/lib/createRule.d.cts",
76
- "./lib/lib/eslintPluginBemoje.js",
77
- "./lib/lib/eslintPluginBemoje.d.ts",
78
- "./lib/lib/eslintPluginBemoje.cjs",
79
- "./lib/lib/eslintPluginBemoje.d.cts",
80
- "./lib/rules/noBlankLineBetweenCommentAndDeclaration.js",
81
- "./lib/rules/noBlankLineBetweenCommentAndDeclaration.d.ts",
82
- "./lib/rules/noBlankLineBetweenCommentAndDeclaration.cjs",
83
- "./lib/rules/noBlankLineBetweenCommentAndDeclaration.d.cts"
84
- ],
85
53
  "repository": {
86
54
  "type": "git",
87
55
  "url": "git+https://github.com/bemoje/mono.git",
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- var utils = require('@typescript-eslint/utils');
4
-
5
- // src/lib/createRule.ts
6
- var createRule = utils.ESLintUtils.RuleCreator((name) => {
7
- return `https://github.com/bemoje/mono/blob/dev/libs/eslint/README.md#${name}`;
8
- });
9
-
10
- exports.createRule = createRule;
@@ -1,18 +0,0 @@
1
- import { ESLintUtils } from '@typescript-eslint/utils';
2
-
3
- /**
4
- * Helper to create an ESLint rule with a consistent format.
5
- */
6
- declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, {
7
- description: string;
8
- recommended?: boolean;
9
- requiresTypeChecking?: boolean;
10
- }>>) => ESLintUtils.RuleModule<MessageIds, Options, {
11
- description: string;
12
- recommended?: boolean;
13
- requiresTypeChecking?: boolean;
14
- }, ESLintUtils.RuleListener> & {
15
- name: string;
16
- };
17
-
18
- export { createRule };
@@ -1,18 +0,0 @@
1
- import { ESLintUtils } from '@typescript-eslint/utils';
2
-
3
- /**
4
- * Helper to create an ESLint rule with a consistent format.
5
- */
6
- declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, {
7
- description: string;
8
- recommended?: boolean;
9
- requiresTypeChecking?: boolean;
10
- }>>) => ESLintUtils.RuleModule<MessageIds, Options, {
11
- description: string;
12
- recommended?: boolean;
13
- requiresTypeChecking?: boolean;
14
- }, ESLintUtils.RuleListener> & {
15
- name: string;
16
- };
17
-
18
- export { createRule };
@@ -1,8 +0,0 @@
1
- import { ESLintUtils } from '@typescript-eslint/utils';
2
-
3
- // src/lib/createRule.ts
4
- var createRule = ESLintUtils.RuleCreator((name) => {
5
- return `https://github.com/bemoje/mono/blob/dev/libs/eslint/README.md#${name}`;
6
- });
7
-
8
- export { createRule };
@@ -1,101 +0,0 @@
1
- 'use strict';
2
-
3
- var utils = require('@typescript-eslint/utils');
4
-
5
- var __defProp = Object.defineProperty;
6
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- var createRule = utils.ESLintUtils.RuleCreator((name) => {
8
- return `https://github.com/bemoje/mono/blob/dev/libs/eslint/README.md#${name}`;
9
- });
10
-
11
- // src/rules/noBlankLineBetweenCommentAndDeclaration.ts
12
- var noBlankLineBetweenCommentAndDeclaration = createRule({
13
- name: "no-blank-line-between-comment-and-declaration",
14
- meta: {
15
- fixable: "whitespace",
16
- docs: {
17
- description: "Consistant whitespace ",
18
- recommended: true
19
- },
20
- messages: {
21
- "no-blank-line-between-comment-and-declaration": "Block comments for a declaration must not leave blank lines between them."
22
- },
23
- type: "problem",
24
- schema: []
25
- },
26
- defaultOptions: [
27
- "error"
28
- ],
29
- create(context) {
30
- return {
31
- Program(program) {
32
- program.comments?.forEach((comment) => {
33
- if (comment.type !== utils.AST_TOKEN_TYPES.Block) {
34
- return;
35
- }
36
- if (Math.abs(comment.loc.start.line - comment.loc.end.line) < 2) {
37
- return;
38
- }
39
- const nextToken = context.sourceCode.getTokenAfter(comment);
40
- if (!nextToken) {
41
- return;
42
- }
43
- const actualNextTokenStartLine = nextToken.loc.start.line;
44
- const expectedTokenStartLine = comment.loc.end.line + 1;
45
- if (!(actualNextTokenStartLine > expectedTokenStartLine)) {
46
- return;
47
- }
48
- const lineBeforeNextToken = context.sourceCode.lines[nextToken.loc.start.line - 1 - 1];
49
- const hasLineCommentBetween = lineBeforeNextToken.trim().startsWith("//");
50
- if (hasLineCommentBetween) {
51
- return;
52
- }
53
- return context.report({
54
- node: program,
55
- messageId: "no-blank-line-between-comment-and-declaration",
56
- fix(fixer) {
57
- const start = comment.range[0];
58
- const end = nextToken.range[1];
59
- const rangeCode = context.sourceCode.text.slice(start, end);
60
- const rangeCodeFixed = rangeCode.replaceAll(/\*\/\n\n+/gi, "*/\n");
61
- return fixer.replaceTextRange([
62
- start,
63
- end
64
- ], rangeCodeFixed);
65
- }
66
- });
67
- });
68
- }
69
- };
70
- }
71
- });
72
-
73
- // src/lib/eslintPluginBemoje.ts
74
- function eslintPluginBemoje() {
75
- const rules = {
76
- "no-blank-line-between-comment-and-declaration": noBlankLineBetweenCommentAndDeclaration
77
- };
78
- const plugins = {
79
- get "eslint-plugin-bemoje"() {
80
- return eslintPluginBemoje();
81
- }
82
- };
83
- return {
84
- configs: {
85
- get recommended() {
86
- return {
87
- plugins,
88
- rules
89
- };
90
- }
91
- },
92
- meta: {
93
- name: "eslint-plugin-bemoje",
94
- version: "1.0.1"
95
- },
96
- rules
97
- };
98
- }
99
- __name(eslintPluginBemoje, "eslintPluginBemoje");
100
-
101
- exports.eslintPluginBemoje = eslintPluginBemoje;
@@ -1,38 +0,0 @@
1
- import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
2
-
3
- /**
4
- * ESLint plugin for Bemoje projects.
5
- */
6
- declare function eslintPluginBemoje(): {
7
- configs: {
8
- readonly recommended: {
9
- plugins: {
10
- readonly 'eslint-plugin-bemoje': any;
11
- };
12
- rules: {
13
- 'no-blank-line-between-comment-and-declaration': _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
14
- description: string;
15
- recommended?: boolean;
16
- requiresTypeChecking?: boolean;
17
- }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
18
- name: string;
19
- };
20
- };
21
- };
22
- };
23
- meta: {
24
- name: string;
25
- version: string;
26
- };
27
- rules: {
28
- 'no-blank-line-between-comment-and-declaration': _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
29
- description: string;
30
- recommended?: boolean;
31
- requiresTypeChecking?: boolean;
32
- }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
33
- name: string;
34
- };
35
- };
36
- };
37
-
38
- export { eslintPluginBemoje };
@@ -1,38 +0,0 @@
1
- import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
2
-
3
- /**
4
- * ESLint plugin for Bemoje projects.
5
- */
6
- declare function eslintPluginBemoje(): {
7
- configs: {
8
- readonly recommended: {
9
- plugins: {
10
- readonly 'eslint-plugin-bemoje': any;
11
- };
12
- rules: {
13
- 'no-blank-line-between-comment-and-declaration': _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
14
- description: string;
15
- recommended?: boolean;
16
- requiresTypeChecking?: boolean;
17
- }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
18
- name: string;
19
- };
20
- };
21
- };
22
- };
23
- meta: {
24
- name: string;
25
- version: string;
26
- };
27
- rules: {
28
- 'no-blank-line-between-comment-and-declaration': _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
29
- description: string;
30
- recommended?: boolean;
31
- requiresTypeChecking?: boolean;
32
- }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
33
- name: string;
34
- };
35
- };
36
- };
37
-
38
- export { eslintPluginBemoje };
@@ -1,99 +0,0 @@
1
- import { ESLintUtils, AST_TOKEN_TYPES } from '@typescript-eslint/utils';
2
-
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- var createRule = ESLintUtils.RuleCreator((name) => {
6
- return `https://github.com/bemoje/mono/blob/dev/libs/eslint/README.md#${name}`;
7
- });
8
-
9
- // src/rules/noBlankLineBetweenCommentAndDeclaration.ts
10
- var noBlankLineBetweenCommentAndDeclaration = createRule({
11
- name: "no-blank-line-between-comment-and-declaration",
12
- meta: {
13
- fixable: "whitespace",
14
- docs: {
15
- description: "Consistant whitespace ",
16
- recommended: true
17
- },
18
- messages: {
19
- "no-blank-line-between-comment-and-declaration": "Block comments for a declaration must not leave blank lines between them."
20
- },
21
- type: "problem",
22
- schema: []
23
- },
24
- defaultOptions: [
25
- "error"
26
- ],
27
- create(context) {
28
- return {
29
- Program(program) {
30
- program.comments?.forEach((comment) => {
31
- if (comment.type !== AST_TOKEN_TYPES.Block) {
32
- return;
33
- }
34
- if (Math.abs(comment.loc.start.line - comment.loc.end.line) < 2) {
35
- return;
36
- }
37
- const nextToken = context.sourceCode.getTokenAfter(comment);
38
- if (!nextToken) {
39
- return;
40
- }
41
- const actualNextTokenStartLine = nextToken.loc.start.line;
42
- const expectedTokenStartLine = comment.loc.end.line + 1;
43
- if (!(actualNextTokenStartLine > expectedTokenStartLine)) {
44
- return;
45
- }
46
- const lineBeforeNextToken = context.sourceCode.lines[nextToken.loc.start.line - 1 - 1];
47
- const hasLineCommentBetween = lineBeforeNextToken.trim().startsWith("//");
48
- if (hasLineCommentBetween) {
49
- return;
50
- }
51
- return context.report({
52
- node: program,
53
- messageId: "no-blank-line-between-comment-and-declaration",
54
- fix(fixer) {
55
- const start = comment.range[0];
56
- const end = nextToken.range[1];
57
- const rangeCode = context.sourceCode.text.slice(start, end);
58
- const rangeCodeFixed = rangeCode.replaceAll(/\*\/\n\n+/gi, "*/\n");
59
- return fixer.replaceTextRange([
60
- start,
61
- end
62
- ], rangeCodeFixed);
63
- }
64
- });
65
- });
66
- }
67
- };
68
- }
69
- });
70
-
71
- // src/lib/eslintPluginBemoje.ts
72
- function eslintPluginBemoje() {
73
- const rules = {
74
- "no-blank-line-between-comment-and-declaration": noBlankLineBetweenCommentAndDeclaration
75
- };
76
- const plugins = {
77
- get "eslint-plugin-bemoje"() {
78
- return eslintPluginBemoje();
79
- }
80
- };
81
- return {
82
- configs: {
83
- get recommended() {
84
- return {
85
- plugins,
86
- rules
87
- };
88
- }
89
- },
90
- meta: {
91
- name: "eslint-plugin-bemoje",
92
- version: "1.0.1"
93
- },
94
- rules
95
- };
96
- }
97
- __name(eslintPluginBemoje, "eslintPluginBemoje");
98
-
99
- export { eslintPluginBemoje };
@@ -1,72 +0,0 @@
1
- 'use strict';
2
-
3
- var utils = require('@typescript-eslint/utils');
4
-
5
- // src/rules/noBlankLineBetweenCommentAndDeclaration.ts
6
- var createRule = utils.ESLintUtils.RuleCreator((name) => {
7
- return `https://github.com/bemoje/mono/blob/dev/libs/eslint/README.md#${name}`;
8
- });
9
-
10
- // src/rules/noBlankLineBetweenCommentAndDeclaration.ts
11
- var noBlankLineBetweenCommentAndDeclaration = createRule({
12
- name: "no-blank-line-between-comment-and-declaration",
13
- meta: {
14
- fixable: "whitespace",
15
- docs: {
16
- description: "Consistant whitespace ",
17
- recommended: true
18
- },
19
- messages: {
20
- "no-blank-line-between-comment-and-declaration": "Block comments for a declaration must not leave blank lines between them."
21
- },
22
- type: "problem",
23
- schema: []
24
- },
25
- defaultOptions: [
26
- "error"
27
- ],
28
- create(context) {
29
- return {
30
- Program(program) {
31
- program.comments?.forEach((comment) => {
32
- if (comment.type !== utils.AST_TOKEN_TYPES.Block) {
33
- return;
34
- }
35
- if (Math.abs(comment.loc.start.line - comment.loc.end.line) < 2) {
36
- return;
37
- }
38
- const nextToken = context.sourceCode.getTokenAfter(comment);
39
- if (!nextToken) {
40
- return;
41
- }
42
- const actualNextTokenStartLine = nextToken.loc.start.line;
43
- const expectedTokenStartLine = comment.loc.end.line + 1;
44
- if (!(actualNextTokenStartLine > expectedTokenStartLine)) {
45
- return;
46
- }
47
- const lineBeforeNextToken = context.sourceCode.lines[nextToken.loc.start.line - 1 - 1];
48
- const hasLineCommentBetween = lineBeforeNextToken.trim().startsWith("//");
49
- if (hasLineCommentBetween) {
50
- return;
51
- }
52
- return context.report({
53
- node: program,
54
- messageId: "no-blank-line-between-comment-and-declaration",
55
- fix(fixer) {
56
- const start = comment.range[0];
57
- const end = nextToken.range[1];
58
- const rangeCode = context.sourceCode.text.slice(start, end);
59
- const rangeCodeFixed = rangeCode.replaceAll(/\*\/\n\n+/gi, "*/\n");
60
- return fixer.replaceTextRange([
61
- start,
62
- end
63
- ], rangeCodeFixed);
64
- }
65
- });
66
- });
67
- }
68
- };
69
- }
70
- });
71
-
72
- exports.noBlankLineBetweenCommentAndDeclaration = noBlankLineBetweenCommentAndDeclaration;
@@ -1,14 +0,0 @@
1
- import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
2
-
3
- /**
4
- * Enforce no blank lines between block comments and the next declaration.
5
- */
6
- declare const noBlankLineBetweenCommentAndDeclaration: _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
7
- description: string;
8
- recommended?: boolean;
9
- requiresTypeChecking?: boolean;
10
- }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
11
- name: string;
12
- };
13
-
14
- export { noBlankLineBetweenCommentAndDeclaration };
@@ -1,14 +0,0 @@
1
- import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
2
-
3
- /**
4
- * Enforce no blank lines between block comments and the next declaration.
5
- */
6
- declare const noBlankLineBetweenCommentAndDeclaration: _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
7
- description: string;
8
- recommended?: boolean;
9
- requiresTypeChecking?: boolean;
10
- }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
11
- name: string;
12
- };
13
-
14
- export { noBlankLineBetweenCommentAndDeclaration };
@@ -1,70 +0,0 @@
1
- import { ESLintUtils, AST_TOKEN_TYPES } from '@typescript-eslint/utils';
2
-
3
- // src/rules/noBlankLineBetweenCommentAndDeclaration.ts
4
- var createRule = ESLintUtils.RuleCreator((name) => {
5
- return `https://github.com/bemoje/mono/blob/dev/libs/eslint/README.md#${name}`;
6
- });
7
-
8
- // src/rules/noBlankLineBetweenCommentAndDeclaration.ts
9
- var noBlankLineBetweenCommentAndDeclaration = createRule({
10
- name: "no-blank-line-between-comment-and-declaration",
11
- meta: {
12
- fixable: "whitespace",
13
- docs: {
14
- description: "Consistant whitespace ",
15
- recommended: true
16
- },
17
- messages: {
18
- "no-blank-line-between-comment-and-declaration": "Block comments for a declaration must not leave blank lines between them."
19
- },
20
- type: "problem",
21
- schema: []
22
- },
23
- defaultOptions: [
24
- "error"
25
- ],
26
- create(context) {
27
- return {
28
- Program(program) {
29
- program.comments?.forEach((comment) => {
30
- if (comment.type !== AST_TOKEN_TYPES.Block) {
31
- return;
32
- }
33
- if (Math.abs(comment.loc.start.line - comment.loc.end.line) < 2) {
34
- return;
35
- }
36
- const nextToken = context.sourceCode.getTokenAfter(comment);
37
- if (!nextToken) {
38
- return;
39
- }
40
- const actualNextTokenStartLine = nextToken.loc.start.line;
41
- const expectedTokenStartLine = comment.loc.end.line + 1;
42
- if (!(actualNextTokenStartLine > expectedTokenStartLine)) {
43
- return;
44
- }
45
- const lineBeforeNextToken = context.sourceCode.lines[nextToken.loc.start.line - 1 - 1];
46
- const hasLineCommentBetween = lineBeforeNextToken.trim().startsWith("//");
47
- if (hasLineCommentBetween) {
48
- return;
49
- }
50
- return context.report({
51
- node: program,
52
- messageId: "no-blank-line-between-comment-and-declaration",
53
- fix(fixer) {
54
- const start = comment.range[0];
55
- const end = nextToken.range[1];
56
- const rangeCode = context.sourceCode.text.slice(start, end);
57
- const rangeCodeFixed = rangeCode.replaceAll(/\*\/\n\n+/gi, "*/\n");
58
- return fixer.replaceTextRange([
59
- start,
60
- end
61
- ], rangeCodeFixed);
62
- }
63
- });
64
- });
65
- }
66
- };
67
- }
68
- });
69
-
70
- export { noBlankLineBetweenCommentAndDeclaration };