@bemoje/eslint 1.0.0 → 1.1.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 +52 -68
- package/lib/index.cjs +26 -0
- package/lib/index.d.cts +5 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +3 -0
- package/lib/lib/createRule.cjs +9 -0
- package/lib/lib/createRule.d.cts +18 -0
- package/lib/lib/createRule.d.ts +18 -0
- package/lib/lib/createRule.js +8 -0
- package/lib/lib/eslintPluginBemoje.cjs +34 -0
- package/lib/lib/eslintPluginBemoje.d.cts +38 -0
- package/lib/lib/eslintPluginBemoje.d.ts +38 -0
- package/lib/lib/eslintPluginBemoje.js +31 -0
- package/lib/rules/noBlankLineBetweenCommentAndDeclaration.cjs +67 -0
- package/lib/rules/noBlankLineBetweenCommentAndDeclaration.d.cts +14 -0
- package/lib/rules/noBlankLineBetweenCommentAndDeclaration.d.ts +14 -0
- package/{index.mjs → lib/rules/noBlankLineBetweenCommentAndDeclaration.js} +9 -15
- package/package.json +80 -18
- package/index.d.ts +0 -17
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @bemoje/eslint
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Custom ESLint plugin and rule utilities for consistent code style in TypeScript projects.
|
|
4
4
|
|
|
5
5
|
[](https://www.typescriptlang.org/)
|
|
6
6
|
[](https://nodejs.org/api/esm.html)
|
|
@@ -8,95 +8,79 @@ TypeScript eslint for lazy property initialization and method memoization.
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
|
-
npm install @bemoje/eslint
|
|
11
|
+
npm install --save-dev @bemoje/eslint
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## Features
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
- Custom ESLint plugin with a recommended config
|
|
17
|
+
- Auto-fixable rules for consistent whitespace formatting
|
|
18
|
+
- Built on `@typescript-eslint/utils` for TypeScript-aware linting
|
|
19
|
+
- ESM flat config compatible
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
## Usage
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
import { lazyProp } from '@bemoje/eslint'
|
|
22
|
-
|
|
23
|
-
class Config {
|
|
24
|
-
@lazyProp
|
|
25
|
-
get expensiveValue() {
|
|
26
|
-
console.log('Computing...')
|
|
27
|
-
return Array.from({ length: 1000 }, (_, i) => i * i)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
23
|
+
### Plugin Setup (Flat Config)
|
|
30
24
|
|
|
31
|
-
|
|
32
|
-
config.
|
|
33
|
-
|
|
25
|
+
```js
|
|
26
|
+
// eslint.config.mjs
|
|
27
|
+
import { eslintPluginBemoje } from '@bemoje/eslint'
|
|
28
|
+
|
|
29
|
+
export default [
|
|
30
|
+
{
|
|
31
|
+
plugins: { 'eslint-plugin-bemoje': eslintPluginBemoje() },
|
|
32
|
+
rules: { 'eslint-plugin-bemoje/no-blank-line-between-comment-and-declaration': 'error' },
|
|
33
|
+
},
|
|
34
|
+
]
|
|
34
35
|
```
|
|
35
36
|
|
|
36
|
-
###
|
|
37
|
+
### Using the Recommended Config
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
```js
|
|
40
|
+
import { eslintPluginBemoje } from '@bemoje/eslint'
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
@lazyProp('5 min') // re-fetches after 5 minutes
|
|
45
|
-
get cachedData() {
|
|
46
|
-
return fetchFromDatabase()
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@lazyProp(30000) // re-fetches after 30 seconds
|
|
50
|
-
get frequentlyUpdated() {
|
|
51
|
-
return getLatestMetrics()
|
|
52
|
-
}
|
|
53
|
-
}
|
|
42
|
+
const plugin = eslintPluginBemoje()
|
|
43
|
+
const { plugins, rules } = plugin.configs.recommended
|
|
44
|
+
|
|
45
|
+
export default [{ plugins, rules }]
|
|
54
46
|
```
|
|
55
47
|
|
|
56
|
-
|
|
48
|
+
## Rules
|
|
57
49
|
|
|
58
|
-
|
|
50
|
+
### no-blank-line-between-comment-and-declaration
|
|
51
|
+
|
|
52
|
+
Enforces that there are no blank lines between a block comment (JSDoc or multi-line) and the declaration it
|
|
53
|
+
documents. Auto-fixable.
|
|
54
|
+
|
|
55
|
+
**Incorrect:**
|
|
59
56
|
|
|
60
57
|
```ts
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
@memoizeSync()
|
|
65
|
-
fibonacci(n: number): number {
|
|
66
|
-
if (n <= 1) return n
|
|
67
|
-
return this.fibonacci(n - 1) + this.fibonacci(n - 2)
|
|
68
|
-
}
|
|
69
|
-
}
|
|
58
|
+
/**
|
|
59
|
+
* Adds two numbers.
|
|
60
|
+
*/
|
|
70
61
|
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
export function add(a: number, b: number) {
|
|
63
|
+
return a + b
|
|
64
|
+
}
|
|
73
65
|
```
|
|
74
66
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
Cache async method results with optional TTL:
|
|
67
|
+
**Correct:**
|
|
78
68
|
|
|
79
69
|
```ts
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const res = await fetch(`/api/users/${id}`)
|
|
86
|
-
return res.json()
|
|
87
|
-
}
|
|
70
|
+
/**
|
|
71
|
+
* Adds two numbers.
|
|
72
|
+
*/
|
|
73
|
+
export function add(a: number, b: number) {
|
|
74
|
+
return a + b
|
|
88
75
|
}
|
|
89
|
-
|
|
90
|
-
const client = new ApiClient()
|
|
91
|
-
await client.fetchUser('123') // fetches from API
|
|
92
|
-
await client.fetchUser('123') // returns cached result
|
|
93
76
|
```
|
|
94
77
|
|
|
78
|
+
Single-line block comments and line comments between the block comment and the declaration are ignored.
|
|
79
|
+
|
|
95
80
|
## API Reference
|
|
96
81
|
|
|
97
|
-
| Export
|
|
98
|
-
|
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `assertDescriptorValueIsFunction` | Guard asserting a descriptor value is a function |
|
|
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
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var createRule = require('./lib/createRule');
|
|
4
|
+
var eslintPluginBemoje = require('./lib/eslintPluginBemoje');
|
|
5
|
+
var noBlankLineBetweenCommentAndDeclaration = require('./rules/noBlankLineBetweenCommentAndDeclaration');
|
|
6
|
+
|
|
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
|
+
});
|
|
20
|
+
});
|
|
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
|
+
});
|
|
26
|
+
});
|
package/lib/index.d.cts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
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';
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
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';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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 };
|
|
@@ -0,0 +1,18 @@
|
|
|
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 };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var noBlankLineBetweenCommentAndDeclaration = require('../rules/noBlankLineBetweenCommentAndDeclaration');
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
function eslintPluginBemoje() {
|
|
8
|
+
const rules = {
|
|
9
|
+
"no-blank-line-between-comment-and-declaration": noBlankLineBetweenCommentAndDeclaration.noBlankLineBetweenCommentAndDeclaration
|
|
10
|
+
};
|
|
11
|
+
const plugins = {
|
|
12
|
+
get "eslint-plugin-bemoje"() {
|
|
13
|
+
return eslintPluginBemoje();
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
configs: {
|
|
18
|
+
get recommended() {
|
|
19
|
+
return {
|
|
20
|
+
plugins,
|
|
21
|
+
rules
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
meta: {
|
|
26
|
+
name: "eslint-plugin-bemoje",
|
|
27
|
+
version: "1.0.1"
|
|
28
|
+
},
|
|
29
|
+
rules
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
__name(eslintPluginBemoje, "eslintPluginBemoje");
|
|
33
|
+
|
|
34
|
+
exports.eslintPluginBemoje = eslintPluginBemoje;
|
|
@@ -0,0 +1,38 @@
|
|
|
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 };
|
|
@@ -0,0 +1,38 @@
|
|
|
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 };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { __name } from '../chunk-SHUYVCID.js';
|
|
2
|
+
import { noBlankLineBetweenCommentAndDeclaration } from '../rules/noBlankLineBetweenCommentAndDeclaration';
|
|
3
|
+
|
|
4
|
+
function eslintPluginBemoje() {
|
|
5
|
+
const rules = {
|
|
6
|
+
"no-blank-line-between-comment-and-declaration": noBlankLineBetweenCommentAndDeclaration
|
|
7
|
+
};
|
|
8
|
+
const plugins = {
|
|
9
|
+
get "eslint-plugin-bemoje"() {
|
|
10
|
+
return eslintPluginBemoje();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
configs: {
|
|
15
|
+
get recommended() {
|
|
16
|
+
return {
|
|
17
|
+
plugins,
|
|
18
|
+
rules
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
meta: {
|
|
23
|
+
name: "eslint-plugin-bemoje",
|
|
24
|
+
version: "1.0.1"
|
|
25
|
+
},
|
|
26
|
+
rules
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
__name(eslintPluginBemoje, "eslintPluginBemoje");
|
|
30
|
+
|
|
31
|
+
export { eslintPluginBemoje };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('@typescript-eslint/utils');
|
|
4
|
+
var createRule_js = require('../lib/createRule.js');
|
|
5
|
+
|
|
6
|
+
const noBlankLineBetweenCommentAndDeclaration = createRule_js.createRule({
|
|
7
|
+
name: "no-blank-line-between-comment-and-declaration",
|
|
8
|
+
meta: {
|
|
9
|
+
fixable: "whitespace",
|
|
10
|
+
docs: {
|
|
11
|
+
description: "Consistant whitespace ",
|
|
12
|
+
recommended: true
|
|
13
|
+
},
|
|
14
|
+
messages: {
|
|
15
|
+
"no-blank-line-between-comment-and-declaration": "Block comments for a declaration must not leave blank lines between them."
|
|
16
|
+
},
|
|
17
|
+
type: "problem",
|
|
18
|
+
schema: []
|
|
19
|
+
},
|
|
20
|
+
defaultOptions: [
|
|
21
|
+
"error"
|
|
22
|
+
],
|
|
23
|
+
create(context) {
|
|
24
|
+
return {
|
|
25
|
+
Program(program) {
|
|
26
|
+
program.comments?.forEach((comment) => {
|
|
27
|
+
if (comment.type !== utils.AST_TOKEN_TYPES.Block) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (Math.abs(comment.loc.start.line - comment.loc.end.line) < 2) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const nextToken = context.sourceCode.getTokenAfter(comment);
|
|
34
|
+
if (!nextToken) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const actualNextTokenStartLine = nextToken.loc.start.line;
|
|
38
|
+
const expectedTokenStartLine = comment.loc.end.line + 1;
|
|
39
|
+
if (!(actualNextTokenStartLine > expectedTokenStartLine)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const lineBeforeNextToken = context.sourceCode.lines[nextToken.loc.start.line - 1 - 1];
|
|
43
|
+
const hasLineCommentBetween = lineBeforeNextToken.trim().startsWith("//");
|
|
44
|
+
if (hasLineCommentBetween) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
return context.report({
|
|
48
|
+
node: program,
|
|
49
|
+
messageId: "no-blank-line-between-comment-and-declaration",
|
|
50
|
+
fix(fixer) {
|
|
51
|
+
const start = comment.range[0];
|
|
52
|
+
const end = nextToken.range[1];
|
|
53
|
+
const rangeCode = context.sourceCode.text.slice(start, end);
|
|
54
|
+
const rangeCodeFixed = rangeCode.replaceAll(/\*\/\n\n+/gi, "*/\n");
|
|
55
|
+
return fixer.replaceTextRange([
|
|
56
|
+
start,
|
|
57
|
+
end
|
|
58
|
+
], rangeCodeFixed);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
exports.noBlankLineBetweenCommentAndDeclaration = noBlankLineBetweenCommentAndDeclaration;
|
|
@@ -0,0 +1,14 @@
|
|
|
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 };
|
|
@@ -0,0 +1,14 @@
|
|
|
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,22 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../chunk-SHUYVCID.js';
|
|
2
|
+
import { AST_TOKEN_TYPES } from '@typescript-eslint/utils';
|
|
3
|
+
import { createRule } from '../lib/createRule.js';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
var createRule = ESLintUtils.RuleCreator((name) => {
|
|
5
|
-
return `https://github.com/bemoje/tsmono/libs/eslint-plugin-bemoje/docs/rules/${name}.md`;
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
// src/rules/noBlankLineBetweenCommentAndDeclaration.ts
|
|
9
|
-
var noBlankLineBetweenCommentAndDeclaration = createRule({
|
|
5
|
+
const noBlankLineBetweenCommentAndDeclaration = createRule({
|
|
10
6
|
name: "no-blank-line-between-comment-and-declaration",
|
|
11
7
|
meta: {
|
|
12
8
|
fixable: "whitespace",
|
|
13
9
|
docs: {
|
|
14
|
-
description: "Consistant whitespace "
|
|
10
|
+
description: "Consistant whitespace ",
|
|
11
|
+
recommended: true
|
|
15
12
|
},
|
|
16
13
|
messages: {
|
|
17
14
|
"no-blank-line-between-comment-and-declaration": "Block comments for a declaration must not leave blank lines between them."
|
|
18
15
|
},
|
|
19
|
-
type: "
|
|
16
|
+
type: "problem",
|
|
20
17
|
schema: []
|
|
21
18
|
},
|
|
22
19
|
defaultOptions: [
|
|
@@ -25,10 +22,7 @@ var noBlankLineBetweenCommentAndDeclaration = createRule({
|
|
|
25
22
|
create(context) {
|
|
26
23
|
return {
|
|
27
24
|
Program(program) {
|
|
28
|
-
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
program.comments.forEach((comment) => {
|
|
25
|
+
program.comments?.forEach((comment) => {
|
|
32
26
|
if (comment.type !== AST_TOKEN_TYPES.Block) {
|
|
33
27
|
return;
|
|
34
28
|
}
|
|
@@ -69,4 +63,4 @@ var noBlankLineBetweenCommentAndDeclaration = createRule({
|
|
|
69
63
|
}
|
|
70
64
|
});
|
|
71
65
|
|
|
72
|
-
export {
|
|
66
|
+
export { noBlankLineBetweenCommentAndDeclaration };
|
package/package.json
CHANGED
|
@@ -1,34 +1,96 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemoje/eslint",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
5
|
-
"type": "module",
|
|
6
|
-
"sideEffects": false,
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Custom ESLint plugin and rule utilities for consistent code style in TypeScript projects.",
|
|
7
5
|
"keywords": [
|
|
8
|
-
"eslint"
|
|
6
|
+
"eslint",
|
|
7
|
+
"eslint-plugin",
|
|
8
|
+
"linting",
|
|
9
|
+
"rules",
|
|
10
|
+
"code-style",
|
|
11
|
+
"utilities",
|
|
12
|
+
"typescript"
|
|
9
13
|
],
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"types": "./index.d.ts",
|
|
13
|
-
"import": "./index.mjs",
|
|
14
|
-
"default": "./index.mjs"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
14
|
"dependencies": {
|
|
18
15
|
"@typescript-eslint/utils": "^8.56.1"
|
|
19
16
|
},
|
|
17
|
+
"type": "module",
|
|
18
|
+
"sideEffects": false,
|
|
20
19
|
"publishConfig": {
|
|
21
20
|
"access": "public"
|
|
22
21
|
},
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
22
|
+
"main": "./lib/index.cjs",
|
|
23
|
+
"module": "./lib/index.js",
|
|
24
|
+
"types": "./lib/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"import": {
|
|
28
|
+
"types": "./lib/index.d.ts",
|
|
29
|
+
"default": "./lib/index.js"
|
|
30
|
+
},
|
|
31
|
+
"require": {
|
|
32
|
+
"types": "./lib/index.d.cts",
|
|
33
|
+
"default": "./lib/index.cjs"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
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": {
|
|
57
|
+
"import": {
|
|
58
|
+
"types": "./lib/rules/noBlankLineBetweenCommentAndDeclaration.d.ts",
|
|
59
|
+
"default": "./lib/rules/noBlankLineBetweenCommentAndDeclaration.js"
|
|
60
|
+
},
|
|
61
|
+
"require": {
|
|
62
|
+
"types": "./lib/rules/noBlankLineBetweenCommentAndDeclaration.d.cts",
|
|
63
|
+
"default": "./lib/rules/noBlankLineBetweenCommentAndDeclaration.cjs"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
28
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
|
+
],
|
|
29
85
|
"repository": {
|
|
30
86
|
"type": "git",
|
|
31
87
|
"url": "git+https://github.com/bemoje/mono.git",
|
|
32
88
|
"directory": "libs/eslint"
|
|
33
|
-
}
|
|
89
|
+
},
|
|
90
|
+
"author": {
|
|
91
|
+
"name": "Benjamin Møller Jensen",
|
|
92
|
+
"email": "bemoje@bemoje.net",
|
|
93
|
+
"url": "https://github.com/bemoje/"
|
|
94
|
+
},
|
|
95
|
+
"license": "MIT"
|
|
34
96
|
}
|
package/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
2
|
-
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
3
|
-
|
|
4
|
-
interface ExampleTypedLintingRuleDocs {
|
|
5
|
-
description: string;
|
|
6
|
-
recommended?: boolean;
|
|
7
|
-
requiresTypeChecking?: boolean;
|
|
8
|
-
}
|
|
9
|
-
declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, ExampleTypedLintingRuleDocs>>) => ESLintUtils.RuleModule<MessageIds, Options, ExampleTypedLintingRuleDocs, ESLintUtils.RuleListener> & {
|
|
10
|
-
name: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
declare const noBlankLineBetweenCommentAndDeclaration: _typescript_eslint_utils_ts_eslint.RuleModule<"no-blank-line-between-comment-and-declaration", [string], ExampleTypedLintingRuleDocs, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
14
|
-
name: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export { type ExampleTypedLintingRuleDocs, createRule, noBlankLineBetweenCommentAndDeclaration };
|