@bemoje/eslint 1.1.0 → 1.1.3

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.cjs CHANGED
@@ -1,26 +1,101 @@
1
1
  'use strict';
2
2
 
3
- var createRule = require('./lib/createRule');
4
- var eslintPluginBemoje = require('./lib/eslintPluginBemoje');
5
- var noBlankLineBetweenCommentAndDeclaration = require('./rules/noBlankLineBetweenCommentAndDeclaration');
3
+ var utils = require('@typescript-eslint/utils');
6
4
 
7
-
8
-
9
- Object.keys(createRule).forEach(function (k) {
10
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
11
- enumerable: true,
12
- get: function () { return createRule[k]; }
13
- });
14
- });
15
- Object.keys(eslintPluginBemoje).forEach(function (k) {
16
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
17
- enumerable: true,
18
- get: function () { return eslintPluginBemoje[k]; }
19
- });
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}`;
20
9
  });
21
- Object.keys(noBlankLineBetweenCommentAndDeclaration).forEach(function (k) {
22
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
23
- enumerable: true,
24
- get: function () { return noBlankLineBetweenCommentAndDeclaration[k]; }
25
- });
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 !== utils.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
+ }
26
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
+ exports.createRule = createRule;
100
+ exports.eslintPluginBemoje = eslintPluginBemoje;
101
+ exports.noBlankLineBetweenCommentAndDeclaration = noBlankLineBetweenCommentAndDeclaration;
package/lib/index.js CHANGED
@@ -1,3 +1,97 @@
1
- export * from './lib/createRule';
2
- export * from './lib/eslintPluginBemoje';
3
- export * from './rules/noBlankLineBetweenCommentAndDeclaration';
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
+ var noBlankLineBetweenCommentAndDeclaration = createRule({
9
+ name: "no-blank-line-between-comment-and-declaration",
10
+ meta: {
11
+ fixable: "whitespace",
12
+ docs: {
13
+ description: "Consistant whitespace ",
14
+ recommended: true
15
+ },
16
+ messages: {
17
+ "no-blank-line-between-comment-and-declaration": "Block comments for a declaration must not leave blank lines between them."
18
+ },
19
+ type: "problem",
20
+ schema: []
21
+ },
22
+ defaultOptions: [
23
+ "error"
24
+ ],
25
+ create(context) {
26
+ return {
27
+ Program(program) {
28
+ program.comments?.forEach((comment) => {
29
+ if (comment.type !== AST_TOKEN_TYPES.Block) {
30
+ return;
31
+ }
32
+ if (Math.abs(comment.loc.start.line - comment.loc.end.line) < 2) {
33
+ return;
34
+ }
35
+ const nextToken = context.sourceCode.getTokenAfter(comment);
36
+ if (!nextToken) {
37
+ return;
38
+ }
39
+ const actualNextTokenStartLine = nextToken.loc.start.line;
40
+ const expectedTokenStartLine = comment.loc.end.line + 1;
41
+ if (!(actualNextTokenStartLine > expectedTokenStartLine)) {
42
+ return;
43
+ }
44
+ const lineBeforeNextToken = context.sourceCode.lines[nextToken.loc.start.line - 1 - 1];
45
+ const hasLineCommentBetween = lineBeforeNextToken.trim().startsWith("//");
46
+ if (hasLineCommentBetween) {
47
+ return;
48
+ }
49
+ return context.report({
50
+ node: program,
51
+ messageId: "no-blank-line-between-comment-and-declaration",
52
+ fix(fixer) {
53
+ const start = comment.range[0];
54
+ const end = nextToken.range[1];
55
+ const rangeCode = context.sourceCode.text.slice(start, end);
56
+ const rangeCodeFixed = rangeCode.replaceAll(/\*\/\n\n+/gi, "*/\n");
57
+ return fixer.replaceTextRange([
58
+ start,
59
+ end
60
+ ], rangeCodeFixed);
61
+ }
62
+ });
63
+ });
64
+ }
65
+ };
66
+ }
67
+ });
68
+
69
+ // src/lib/eslintPluginBemoje.ts
70
+ function eslintPluginBemoje() {
71
+ const rules = {
72
+ "no-blank-line-between-comment-and-declaration": noBlankLineBetweenCommentAndDeclaration
73
+ };
74
+ const plugins = {
75
+ get "eslint-plugin-bemoje"() {
76
+ return eslintPluginBemoje();
77
+ }
78
+ };
79
+ return {
80
+ configs: {
81
+ get recommended() {
82
+ return {
83
+ plugins,
84
+ rules
85
+ };
86
+ }
87
+ },
88
+ meta: {
89
+ name: "eslint-plugin-bemoje",
90
+ version: "1.0.1"
91
+ },
92
+ rules
93
+ };
94
+ }
95
+ __name(eslintPluginBemoje, "eslintPluginBemoje");
96
+
97
+ export { createRule, eslintPluginBemoje, noBlankLineBetweenCommentAndDeclaration };
@@ -2,7 +2,8 @@
2
2
 
3
3
  var utils = require('@typescript-eslint/utils');
4
4
 
5
- const createRule = utils.ESLintUtils.RuleCreator((name) => {
5
+ // src/lib/createRule.ts
6
+ var createRule = utils.ESLintUtils.RuleCreator((name) => {
6
7
  return `https://github.com/bemoje/mono/blob/dev/libs/eslint/README.md#${name}`;
7
8
  });
8
9
 
@@ -1,7 +1,7 @@
1
- import '../chunk-SHUYVCID.js';
2
1
  import { ESLintUtils } from '@typescript-eslint/utils';
3
2
 
4
- const createRule = ESLintUtils.RuleCreator((name) => {
3
+ // src/lib/createRule.ts
4
+ var createRule = ESLintUtils.RuleCreator((name) => {
5
5
  return `https://github.com/bemoje/mono/blob/dev/libs/eslint/README.md#${name}`;
6
6
  });
7
7
 
@@ -1,12 +1,79 @@
1
1
  'use strict';
2
2
 
3
- var noBlankLineBetweenCommentAndDeclaration = require('../rules/noBlankLineBetweenCommentAndDeclaration');
3
+ var utils = require('@typescript-eslint/utils');
4
4
 
5
5
  var __defProp = Object.defineProperty;
6
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
7
74
  function eslintPluginBemoje() {
8
75
  const rules = {
9
- "no-blank-line-between-comment-and-declaration": noBlankLineBetweenCommentAndDeclaration.noBlankLineBetweenCommentAndDeclaration
76
+ "no-blank-line-between-comment-and-declaration": noBlankLineBetweenCommentAndDeclaration
10
77
  };
11
78
  const plugins = {
12
79
  get "eslint-plugin-bemoje"() {
@@ -1,6 +1,74 @@
1
- import { __name } from '../chunk-SHUYVCID.js';
2
- import { noBlankLineBetweenCommentAndDeclaration } from '../rules/noBlankLineBetweenCommentAndDeclaration';
1
+ import { ESLintUtils, AST_TOKEN_TYPES } from '@typescript-eslint/utils';
3
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
4
72
  function eslintPluginBemoje() {
5
73
  const rules = {
6
74
  "no-blank-line-between-comment-and-declaration": noBlankLineBetweenCommentAndDeclaration
@@ -1,9 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  var utils = require('@typescript-eslint/utils');
4
- var createRule_js = require('../lib/createRule.js');
5
4
 
6
- const noBlankLineBetweenCommentAndDeclaration = createRule_js.createRule({
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({
7
12
  name: "no-blank-line-between-comment-and-declaration",
8
13
  meta: {
9
14
  fixable: "whitespace",
@@ -1,8 +1,12 @@
1
- import '../chunk-SHUYVCID.js';
2
- import { AST_TOKEN_TYPES } from '@typescript-eslint/utils';
3
- import { createRule } from '../lib/createRule.js';
1
+ import { ESLintUtils, AST_TOKEN_TYPES } from '@typescript-eslint/utils';
4
2
 
5
- const noBlankLineBetweenCommentAndDeclaration = createRule({
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({
6
10
  name: "no-blank-line-between-comment-and-declaration",
7
11
  meta: {
8
12
  fixable: "whitespace",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bemoje/eslint",
3
- "version": "1.1.0",
3
+ "version": "1.1.3",
4
4
  "description": "Custom ESLint plugin and rule utilities for consistent code style in TypeScript projects.",
5
5
  "keywords": [
6
6
  "eslint",