@bemoje/eslint 1.1.4 → 1.1.5

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/lib/index.d.cts CHANGED
@@ -1,5 +1,65 @@
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
+ };
37
+ };
38
+ };
39
+ meta: {
40
+ name: string;
41
+ version: string;
42
+ };
43
+ rules: {
44
+ 'no-blank-line-between-comment-and-declaration': _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
45
+ description: string;
46
+ recommended?: boolean;
47
+ requiresTypeChecking?: boolean;
48
+ }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
49
+ name: string;
50
+ };
51
+ };
52
+ };
53
+
54
+ /**
55
+ * Enforce no blank lines between block comments and the next declaration.
56
+ */
57
+ declare const noBlankLineBetweenCommentAndDeclaration: _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
58
+ description: string;
59
+ recommended?: boolean;
60
+ requiresTypeChecking?: boolean;
61
+ }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
62
+ name: string;
63
+ };
64
+
65
+ export { createRule, eslintPluginBemoje, noBlankLineBetweenCommentAndDeclaration };
package/lib/index.d.ts CHANGED
@@ -1,5 +1,65 @@
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
+ };
37
+ };
38
+ };
39
+ meta: {
40
+ name: string;
41
+ version: string;
42
+ };
43
+ rules: {
44
+ 'no-blank-line-between-comment-and-declaration': _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
45
+ description: string;
46
+ recommended?: boolean;
47
+ requiresTypeChecking?: boolean;
48
+ }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
49
+ name: string;
50
+ };
51
+ };
52
+ };
53
+
54
+ /**
55
+ * Enforce no blank lines between block comments and the next declaration.
56
+ */
57
+ declare const noBlankLineBetweenCommentAndDeclaration: _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], {
58
+ description: string;
59
+ recommended?: boolean;
60
+ requiresTypeChecking?: boolean;
61
+ }, _typescript_eslint_utils_ts_eslint.RuleListener> & {
62
+ name: string;
63
+ };
64
+
65
+ export { createRule, eslintPluginBemoje, noBlankLineBetweenCommentAndDeclaration };
package/package.json CHANGED
@@ -1,7 +1,9 @@
1
1
  {
2
2
  "name": "@bemoje/eslint",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "Custom ESLint plugin and rule utilities for consistent code style in TypeScript projects.",
5
+ "type": "module",
6
+ "sideEffects": false,
5
7
  "keywords": [
6
8
  "eslint",
7
9
  "eslint-plugin",
@@ -11,17 +13,15 @@
11
13
  "utilities",
12
14
  "typescript"
13
15
  ],
14
- "dependencies": {
15
- "@typescript-eslint/utils": "^8.56.1"
16
- },
17
- "type": "module",
18
- "sideEffects": false,
19
- "publishConfig": {
20
- "access": "public"
21
- },
22
16
  "main": "./lib/index.cjs",
23
17
  "module": "./lib/index.js",
24
18
  "types": "./lib/index.d.ts",
19
+ "files": [
20
+ "./lib/index.js",
21
+ "./lib/index.d.ts",
22
+ "./lib/index.cjs",
23
+ "./lib/index.d.cts"
24
+ ],
25
25
  "exports": {
26
26
  ".": {
27
27
  "import": {
@@ -33,64 +33,52 @@
33
33
  "default": "./lib/index.cjs"
34
34
  }
35
35
  },
36
- "./lib/createRule": {
36
+ "./createRule": {
37
37
  "import": {
38
- "types": "./lib/lib/createRule.d.ts",
39
- "default": "./lib/lib/createRule.js"
38
+ "types": "./lib/index.d.ts",
39
+ "default": "./lib/index.js"
40
40
  },
41
41
  "require": {
42
- "types": "./lib/lib/createRule.d.cts",
43
- "default": "./lib/lib/createRule.cjs"
42
+ "types": "./lib/index.d.cts",
43
+ "default": "./lib/index.cjs"
44
44
  }
45
45
  },
46
- "./lib/eslintPluginBemoje": {
46
+ "./eslintPluginBemoje": {
47
47
  "import": {
48
- "types": "./lib/lib/eslintPluginBemoje.d.ts",
49
- "default": "./lib/lib/eslintPluginBemoje.js"
48
+ "types": "./lib/index.d.ts",
49
+ "default": "./lib/index.js"
50
50
  },
51
51
  "require": {
52
- "types": "./lib/lib/eslintPluginBemoje.d.cts",
53
- "default": "./lib/lib/eslintPluginBemoje.cjs"
52
+ "types": "./lib/index.d.cts",
53
+ "default": "./lib/index.cjs"
54
54
  }
55
55
  },
56
- "./rules/noBlankLineBetweenCommentAndDeclaration": {
56
+ "./noBlankLineBetweenCommentAndDeclaration": {
57
57
  "import": {
58
- "types": "./lib/rules/noBlankLineBetweenCommentAndDeclaration.d.ts",
59
- "default": "./lib/rules/noBlankLineBetweenCommentAndDeclaration.js"
58
+ "types": "./lib/index.d.ts",
59
+ "default": "./lib/index.js"
60
60
  },
61
61
  "require": {
62
- "types": "./lib/rules/noBlankLineBetweenCommentAndDeclaration.d.cts",
63
- "default": "./lib/rules/noBlankLineBetweenCommentAndDeclaration.cjs"
62
+ "types": "./lib/index.d.cts",
63
+ "default": "./lib/index.cjs"
64
64
  }
65
65
  }
66
66
  },
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
- "repository": {
86
- "type": "git",
87
- "url": "git+https://github.com/bemoje/mono.git",
88
- "directory": "libs/eslint"
67
+ "dependencies": {
68
+ "@typescript-eslint/utils": "^8.56.1"
89
69
  },
70
+ "publishConfig": {
71
+ "access": "public"
72
+ },
73
+ "license": "MIT",
90
74
  "author": {
91
75
  "name": "Benjamin Møller Jensen",
92
76
  "email": "bemoje@bemoje.net",
93
77
  "url": "https://github.com/bemoje/"
94
78
  },
95
- "license": "MIT"
79
+ "repository": {
80
+ "type": "git",
81
+ "url": "git+https://github.com/bemoje/mono.git",
82
+ "directory": "libs/eslint"
83
+ }
96
84
  }
@@ -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 };