@harness-engineering/eslint-plugin 0.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/LICENSE +21 -0
- package/README.md +91 -0
- package/dist/configs/index.d.ts +5 -0
- package/dist/configs/index.d.ts.map +1 -0
- package/dist/configs/index.js +8 -0
- package/dist/configs/index.js.map +1 -0
- package/dist/configs/recommended.d.ts +4 -0
- package/dist/configs/recommended.d.ts.map +1 -0
- package/dist/configs/recommended.js +16 -0
- package/dist/configs/recommended.js.map +1 -0
- package/dist/configs/strict.d.ts +4 -0
- package/dist/configs/strict.d.ts.map +1 -0
- package/dist/configs/strict.js +16 -0
- package/dist/configs/strict.js.map +1 -0
- package/dist/index.d.ts +134 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/rules/enforce-doc-exports.d.ts +12 -0
- package/dist/rules/enforce-doc-exports.d.ts.map +1 -0
- package/dist/rules/enforce-doc-exports.js +78 -0
- package/dist/rules/enforce-doc-exports.js.map +1 -0
- package/dist/rules/index.d.ts +21 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +14 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/no-circular-deps.d.ts +20 -0
- package/dist/rules/no-circular-deps.d.ts.map +1 -0
- package/dist/rules/no-circular-deps.js +110 -0
- package/dist/rules/no-circular-deps.js.map +1 -0
- package/dist/rules/no-forbidden-imports.d.ts +6 -0
- package/dist/rules/no-forbidden-imports.d.ts.map +1 -0
- package/dist/rules/no-forbidden-imports.js +58 -0
- package/dist/rules/no-forbidden-imports.js.map +1 -0
- package/dist/rules/no-layer-violation.d.ts +6 -0
- package/dist/rules/no-layer-violation.d.ts.map +1 -0
- package/dist/rules/no-layer-violation.js +62 -0
- package/dist/rules/no-layer-violation.js.map +1 -0
- package/dist/rules/require-boundary-schema.d.ts +6 -0
- package/dist/rules/require-boundary-schema.d.ts.map +1 -0
- package/dist/rules/require-boundary-schema.js +53 -0
- package/dist/rules/require-boundary-schema.js.map +1 -0
- package/dist/utils/ast-helpers.d.ts +14 -0
- package/dist/utils/ast-helpers.d.ts.map +1 -0
- package/dist/utils/ast-helpers.js +94 -0
- package/dist/utils/ast-helpers.js.map +1 -0
- package/dist/utils/config-loader.d.ts +10 -0
- package/dist/utils/config-loader.d.ts.map +1 -0
- package/dist/utils/config-loader.js +56 -0
- package/dist/utils/config-loader.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/path-utils.d.ts +24 -0
- package/dist/utils/path-utils.d.ts.map +1 -0
- package/dist/utils/path-utils.js +62 -0
- package/dist/utils/path-utils.js.map +1 -0
- package/dist/utils/schema.d.ts +117 -0
- package/dist/utils/schema.d.ts.map +1 -0
- package/dist/utils/schema.js +34 -0
- package/dist/utils/schema.js.map +1 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Intense Visions, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# @harness-engineering/eslint-plugin
|
|
2
|
+
|
|
3
|
+
ESLint plugin for enforcing harness engineering architectural constraints.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -D @harness-engineering/eslint-plugin
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### ESLint 9.x (Flat Config)
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
// eslint.config.js
|
|
17
|
+
import harness from '@harness-engineering/eslint-plugin';
|
|
18
|
+
|
|
19
|
+
export default [harness.configs.recommended];
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### ESLint 8.x (Legacy Config)
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
// .eslintrc.js
|
|
26
|
+
module.exports = {
|
|
27
|
+
plugins: ['@harness-engineering'],
|
|
28
|
+
extends: ['plugin:@harness-engineering/recommended'],
|
|
29
|
+
};
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Configuration
|
|
33
|
+
|
|
34
|
+
Create `harness.config.json` in your project root:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"version": 1,
|
|
39
|
+
"layers": [
|
|
40
|
+
{ "name": "types", "pattern": "src/types/**", "allowedDependencies": [] },
|
|
41
|
+
{ "name": "domain", "pattern": "src/domain/**", "allowedDependencies": ["types"] },
|
|
42
|
+
{
|
|
43
|
+
"name": "services",
|
|
44
|
+
"pattern": "src/services/**",
|
|
45
|
+
"allowedDependencies": ["types", "domain"]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "api",
|
|
49
|
+
"pattern": "src/api/**",
|
|
50
|
+
"allowedDependencies": ["types", "domain", "services"]
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"forbiddenImports": [
|
|
54
|
+
{ "from": "src/services/**", "disallow": ["react"], "message": "Services cannot import React" }
|
|
55
|
+
],
|
|
56
|
+
"boundaries": {
|
|
57
|
+
"requireSchema": ["src/api/**/*.ts"]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Rules
|
|
63
|
+
|
|
64
|
+
### Architecture Rules
|
|
65
|
+
|
|
66
|
+
| Rule | Description | Default |
|
|
67
|
+
| ---------------------- | ------------------------------- | ------- |
|
|
68
|
+
| `no-layer-violation` | Enforce layer boundary imports | error |
|
|
69
|
+
| `no-circular-deps` | Detect circular dependencies | error |
|
|
70
|
+
| `no-forbidden-imports` | Block forbidden import patterns | error |
|
|
71
|
+
|
|
72
|
+
### Boundary Rules
|
|
73
|
+
|
|
74
|
+
| Rule | Description | Default |
|
|
75
|
+
| ------------------------- | ---------------------------------------- | ------- |
|
|
76
|
+
| `require-boundary-schema` | Require Zod validation at API boundaries | warn |
|
|
77
|
+
|
|
78
|
+
### Documentation Rules
|
|
79
|
+
|
|
80
|
+
| Rule | Description | Default |
|
|
81
|
+
| --------------------- | ------------------------ | ------- |
|
|
82
|
+
| `enforce-doc-exports` | Require JSDoc on exports | warn |
|
|
83
|
+
|
|
84
|
+
## Configs
|
|
85
|
+
|
|
86
|
+
- **recommended**: Architecture rules as errors, others as warnings
|
|
87
|
+
- **strict**: All rules as errors
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configs/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,OAAO;;;CAGnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/configs/index.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,WAAW;IACX,MAAM;CACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommended.d.ts","sourceRoot":"","sources":["../../src/configs/recommended.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD,QAAA,MAAM,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,MAajC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const config = {
|
|
2
|
+
plugins: {
|
|
3
|
+
'@harness-engineering': {
|
|
4
|
+
rules: {}, // Will be populated by index.ts
|
|
5
|
+
},
|
|
6
|
+
},
|
|
7
|
+
rules: {
|
|
8
|
+
'@harness-engineering/no-layer-violation': 'error',
|
|
9
|
+
'@harness-engineering/no-circular-deps': 'error',
|
|
10
|
+
'@harness-engineering/no-forbidden-imports': 'error',
|
|
11
|
+
'@harness-engineering/require-boundary-schema': 'warn',
|
|
12
|
+
'@harness-engineering/enforce-doc-exports': 'warn',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export default config;
|
|
16
|
+
//# sourceMappingURL=recommended.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommended.js","sourceRoot":"","sources":["../../src/configs/recommended.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,GAA+B;IACzC,OAAO,EAAE;QACP,sBAAsB,EAAE;YACtB,KAAK,EAAE,EAAE,EAAE,gCAAgC;SACd;KAChC;IACD,KAAK,EAAE;QACL,yCAAyC,EAAE,OAAO;QAClD,uCAAuC,EAAE,OAAO;QAChD,2CAA2C,EAAE,OAAO;QACpD,8CAA8C,EAAE,MAAM;QACtD,0CAA0C,EAAE,MAAM;KACnD;CACF,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strict.d.ts","sourceRoot":"","sources":["../../src/configs/strict.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD,QAAA,MAAM,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,MAajC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const config = {
|
|
2
|
+
plugins: {
|
|
3
|
+
'@harness-engineering': {
|
|
4
|
+
rules: {}, // Will be populated by index.ts
|
|
5
|
+
},
|
|
6
|
+
},
|
|
7
|
+
rules: {
|
|
8
|
+
'@harness-engineering/no-layer-violation': 'error',
|
|
9
|
+
'@harness-engineering/no-circular-deps': 'error',
|
|
10
|
+
'@harness-engineering/no-forbidden-imports': 'error',
|
|
11
|
+
'@harness-engineering/require-boundary-schema': 'error',
|
|
12
|
+
'@harness-engineering/enforce-doc-exports': 'error',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export default config;
|
|
16
|
+
//# sourceMappingURL=strict.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strict.js","sourceRoot":"","sources":["../../src/configs/strict.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,GAA+B;IACzC,OAAO,EAAE;QACP,sBAAsB,EAAE;YACtB,KAAK,EAAE,EAAE,EAAE,gCAAgC;SACd;KAChC;IACD,KAAK,EAAE;QACL,yCAAyC,EAAE,OAAO;QAClD,uCAAuC,EAAE,OAAO;QAChD,2CAA2C,EAAE,OAAO;QACpD,8CAA8C,EAAE,OAAO;QACvD,0CAA0C,EAAE,OAAO;KACpD;CACF,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { rules } from './rules';
|
|
2
|
+
declare const plugin: {
|
|
3
|
+
meta: {
|
|
4
|
+
name: string;
|
|
5
|
+
version: string;
|
|
6
|
+
};
|
|
7
|
+
rules: {
|
|
8
|
+
'enforce-doc-exports': import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingJSDoc", [{
|
|
9
|
+
ignoreTypes?: boolean;
|
|
10
|
+
ignoreInternal?: boolean;
|
|
11
|
+
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
'no-circular-deps': import("@typescript-eslint/utils/ts-eslint").RuleModule<"circularDep", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
15
|
+
name: string;
|
|
16
|
+
};
|
|
17
|
+
'no-forbidden-imports': import("@typescript-eslint/utils/ts-eslint").RuleModule<"forbiddenImport", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
18
|
+
name: string;
|
|
19
|
+
};
|
|
20
|
+
'no-layer-violation': import("@typescript-eslint/utils/ts-eslint").RuleModule<"layerViolation", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
21
|
+
name: string;
|
|
22
|
+
};
|
|
23
|
+
'require-boundary-schema': import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingSchema", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
configs: {
|
|
28
|
+
recommended: {
|
|
29
|
+
plugins: {
|
|
30
|
+
readonly '@harness-engineering': /*elided*/ any;
|
|
31
|
+
};
|
|
32
|
+
rules: {
|
|
33
|
+
'@harness-engineering/no-layer-violation': string;
|
|
34
|
+
'@harness-engineering/no-circular-deps': string;
|
|
35
|
+
'@harness-engineering/no-forbidden-imports': string;
|
|
36
|
+
'@harness-engineering/require-boundary-schema': string;
|
|
37
|
+
'@harness-engineering/enforce-doc-exports': string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
strict: {
|
|
41
|
+
plugins: {
|
|
42
|
+
readonly '@harness-engineering': /*elided*/ any;
|
|
43
|
+
};
|
|
44
|
+
rules: {
|
|
45
|
+
'@harness-engineering/no-layer-violation': string;
|
|
46
|
+
'@harness-engineering/no-circular-deps': string;
|
|
47
|
+
'@harness-engineering/no-forbidden-imports': string;
|
|
48
|
+
'@harness-engineering/require-boundary-schema': string;
|
|
49
|
+
'@harness-engineering/enforce-doc-exports': string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
export default plugin;
|
|
55
|
+
export { rules };
|
|
56
|
+
export declare const configs: {
|
|
57
|
+
recommended: {
|
|
58
|
+
plugins: {
|
|
59
|
+
readonly '@harness-engineering': {
|
|
60
|
+
meta: {
|
|
61
|
+
name: string;
|
|
62
|
+
version: string;
|
|
63
|
+
};
|
|
64
|
+
rules: {
|
|
65
|
+
'enforce-doc-exports': import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingJSDoc", [{
|
|
66
|
+
ignoreTypes?: boolean;
|
|
67
|
+
ignoreInternal?: boolean;
|
|
68
|
+
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
69
|
+
name: string;
|
|
70
|
+
};
|
|
71
|
+
'no-circular-deps': import("@typescript-eslint/utils/ts-eslint").RuleModule<"circularDep", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
72
|
+
name: string;
|
|
73
|
+
};
|
|
74
|
+
'no-forbidden-imports': import("@typescript-eslint/utils/ts-eslint").RuleModule<"forbiddenImport", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
75
|
+
name: string;
|
|
76
|
+
};
|
|
77
|
+
'no-layer-violation': import("@typescript-eslint/utils/ts-eslint").RuleModule<"layerViolation", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
78
|
+
name: string;
|
|
79
|
+
};
|
|
80
|
+
'require-boundary-schema': import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingSchema", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
81
|
+
name: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
configs: /*elided*/ any;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
rules: {
|
|
88
|
+
'@harness-engineering/no-layer-violation': string;
|
|
89
|
+
'@harness-engineering/no-circular-deps': string;
|
|
90
|
+
'@harness-engineering/no-forbidden-imports': string;
|
|
91
|
+
'@harness-engineering/require-boundary-schema': string;
|
|
92
|
+
'@harness-engineering/enforce-doc-exports': string;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
strict: {
|
|
96
|
+
plugins: {
|
|
97
|
+
readonly '@harness-engineering': {
|
|
98
|
+
meta: {
|
|
99
|
+
name: string;
|
|
100
|
+
version: string;
|
|
101
|
+
};
|
|
102
|
+
rules: {
|
|
103
|
+
'enforce-doc-exports': import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingJSDoc", [{
|
|
104
|
+
ignoreTypes?: boolean;
|
|
105
|
+
ignoreInternal?: boolean;
|
|
106
|
+
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
107
|
+
name: string;
|
|
108
|
+
};
|
|
109
|
+
'no-circular-deps': import("@typescript-eslint/utils/ts-eslint").RuleModule<"circularDep", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
110
|
+
name: string;
|
|
111
|
+
};
|
|
112
|
+
'no-forbidden-imports': import("@typescript-eslint/utils/ts-eslint").RuleModule<"forbiddenImport", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
113
|
+
name: string;
|
|
114
|
+
};
|
|
115
|
+
'no-layer-violation': import("@typescript-eslint/utils/ts-eslint").RuleModule<"layerViolation", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
116
|
+
name: string;
|
|
117
|
+
};
|
|
118
|
+
'require-boundary-schema': import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingSchema", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
119
|
+
name: string;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
configs: /*elided*/ any;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
rules: {
|
|
126
|
+
'@harness-engineering/no-layer-violation': string;
|
|
127
|
+
'@harness-engineering/no-circular-deps': string;
|
|
128
|
+
'@harness-engineering/no-forbidden-imports': string;
|
|
129
|
+
'@harness-engineering/require-boundary-schema': string;
|
|
130
|
+
'@harness-engineering/enforce-doc-exports': string;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCX,CAAC;AAGF,eAAe,MAAM,CAAC;AAGtB,OAAO,EAAE,KAAK,EAAE,CAAC;AACjB,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { rules } from './rules';
|
|
3
|
+
// Define the plugin object
|
|
4
|
+
const plugin = {
|
|
5
|
+
meta: {
|
|
6
|
+
name: '@harness-engineering/eslint-plugin',
|
|
7
|
+
version: '0.1.0',
|
|
8
|
+
},
|
|
9
|
+
rules,
|
|
10
|
+
configs: {
|
|
11
|
+
recommended: {
|
|
12
|
+
plugins: {
|
|
13
|
+
get '@harness-engineering'() {
|
|
14
|
+
return plugin;
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
rules: {
|
|
18
|
+
'@harness-engineering/no-layer-violation': 'error',
|
|
19
|
+
'@harness-engineering/no-circular-deps': 'error',
|
|
20
|
+
'@harness-engineering/no-forbidden-imports': 'error',
|
|
21
|
+
'@harness-engineering/require-boundary-schema': 'warn',
|
|
22
|
+
'@harness-engineering/enforce-doc-exports': 'warn',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
strict: {
|
|
26
|
+
plugins: {
|
|
27
|
+
get '@harness-engineering'() {
|
|
28
|
+
return plugin;
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
rules: {
|
|
32
|
+
'@harness-engineering/no-layer-violation': 'error',
|
|
33
|
+
'@harness-engineering/no-circular-deps': 'error',
|
|
34
|
+
'@harness-engineering/no-forbidden-imports': 'error',
|
|
35
|
+
'@harness-engineering/require-boundary-schema': 'error',
|
|
36
|
+
'@harness-engineering/enforce-doc-exports': 'error',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
// ESM default export
|
|
42
|
+
export default plugin;
|
|
43
|
+
// Named exports for flexibility
|
|
44
|
+
export { rules };
|
|
45
|
+
export const configs = plugin.configs;
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,2BAA2B;AAC3B,MAAM,MAAM,GAAG;IACb,IAAI,EAAE;QACJ,IAAI,EAAE,oCAAoC;QAC1C,OAAO,EAAE,OAAO;KACjB;IACD,KAAK;IACL,OAAO,EAAE;QACP,WAAW,EAAE;YACX,OAAO,EAAE;gBACP,IAAI,sBAAsB;oBACxB,OAAO,MAAM,CAAC;gBAChB,CAAC;aACF;YACD,KAAK,EAAE;gBACL,yCAAyC,EAAE,OAAO;gBAClD,uCAAuC,EAAE,OAAO;gBAChD,2CAA2C,EAAE,OAAO;gBACpD,8CAA8C,EAAE,MAAM;gBACtD,0CAA0C,EAAE,MAAM;aACnD;SACF;QACD,MAAM,EAAE;YACN,OAAO,EAAE;gBACP,IAAI,sBAAsB;oBACxB,OAAO,MAAM,CAAC;gBAChB,CAAC;aACF;YACD,KAAK,EAAE;gBACL,yCAAyC,EAAE,OAAO;gBAClD,uCAAuC,EAAE,OAAO;gBAChD,2CAA2C,EAAE,OAAO;gBACpD,8CAA8C,EAAE,OAAO;gBACvD,0CAA0C,EAAE,OAAO;aACpD;SACF;KACF;CACF,CAAC;AAEF,qBAAqB;AACrB,eAAe,MAAM,CAAC;AAEtB,gCAAgC;AAChC,OAAO,EAAE,KAAK,EAAE,CAAC;AACjB,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
type Options = [
|
|
3
|
+
{
|
|
4
|
+
ignoreTypes?: boolean;
|
|
5
|
+
ignoreInternal?: boolean;
|
|
6
|
+
}
|
|
7
|
+
];
|
|
8
|
+
declare const _default: ESLintUtils.RuleModule<"missingJSDoc", Options, unknown, ESLintUtils.RuleListener> & {
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
12
|
+
//# sourceMappingURL=enforce-doc-exports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enforce-doc-exports.d.ts","sourceRoot":"","sources":["../../src/rules/enforce-doc-exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAiC,MAAM,0BAA0B,CAAC;AAOtF,KAAK,OAAO,GAAG;IACb;QACE,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B;CACF,CAAC;;;;AAIF,wBAyEG"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// src/rules/enforce-doc-exports.ts
|
|
2
|
+
import { ESLintUtils, AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
3
|
+
import { hasJSDocComment, isMarkedInternal } from '../utils/ast-helpers';
|
|
4
|
+
const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/harness-engineering/eslint-plugin/blob/main/docs/rules/${name}.md`);
|
|
5
|
+
export default createRule({
|
|
6
|
+
name: 'enforce-doc-exports',
|
|
7
|
+
meta: {
|
|
8
|
+
type: 'suggestion',
|
|
9
|
+
docs: {
|
|
10
|
+
description: 'Require JSDoc comments on public exports',
|
|
11
|
+
},
|
|
12
|
+
messages: {
|
|
13
|
+
missingJSDoc: 'Exported {{kind}} "{{name}}" is missing JSDoc documentation',
|
|
14
|
+
},
|
|
15
|
+
schema: [
|
|
16
|
+
{
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
ignoreTypes: { type: 'boolean', default: false },
|
|
20
|
+
ignoreInternal: { type: 'boolean', default: true },
|
|
21
|
+
},
|
|
22
|
+
additionalProperties: false,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
defaultOptions: [{ ignoreTypes: false, ignoreInternal: true }],
|
|
27
|
+
create(context, [options]) {
|
|
28
|
+
const sourceCode = context.sourceCode.getText();
|
|
29
|
+
function checkExport(node, kind, name) {
|
|
30
|
+
// Skip if marked @internal and ignoreInternal is true
|
|
31
|
+
if (options.ignoreInternal && isMarkedInternal(node, sourceCode)) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (!hasJSDocComment(node, sourceCode)) {
|
|
35
|
+
context.report({
|
|
36
|
+
node,
|
|
37
|
+
messageId: 'missingJSDoc',
|
|
38
|
+
data: { kind, name },
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
ExportNamedDeclaration(node) {
|
|
44
|
+
const decl = node.declaration;
|
|
45
|
+
if (!decl)
|
|
46
|
+
return;
|
|
47
|
+
const declType = decl.type;
|
|
48
|
+
if (declType === AST_NODE_TYPES.FunctionDeclaration) {
|
|
49
|
+
const fn = decl;
|
|
50
|
+
if (fn.id)
|
|
51
|
+
checkExport(node, 'function', fn.id.name);
|
|
52
|
+
}
|
|
53
|
+
else if (declType === AST_NODE_TYPES.ClassDeclaration) {
|
|
54
|
+
const cls = decl;
|
|
55
|
+
if (cls.id)
|
|
56
|
+
checkExport(node, 'class', cls.id.name);
|
|
57
|
+
}
|
|
58
|
+
else if (declType === AST_NODE_TYPES.VariableDeclaration) {
|
|
59
|
+
const varDecl = decl;
|
|
60
|
+
for (const declarator of varDecl.declarations) {
|
|
61
|
+
if (declarator.id.type === AST_NODE_TYPES.Identifier) {
|
|
62
|
+
checkExport(node, 'variable', declarator.id.name);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else if (declType === AST_NODE_TYPES.TSTypeAliasDeclaration && !options.ignoreTypes) {
|
|
67
|
+
const typeAlias = decl;
|
|
68
|
+
checkExport(node, 'type', typeAlias.id.name);
|
|
69
|
+
}
|
|
70
|
+
else if (declType === AST_NODE_TYPES.TSInterfaceDeclaration && !options.ignoreTypes) {
|
|
71
|
+
const iface = decl;
|
|
72
|
+
checkExport(node, 'interface', iface.id.name);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=enforce-doc-exports.js.map
|
|
@@ -0,0 +1 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B,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;oBACtF,MAAM,SAAS,GAAG,IAAuC,CAAC;oBAC1D,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBAC/C,CAAC;qBAAM,IAAI,QAAQ,KAAK,cAAc,CAAC,sBAAsB,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;oBACtF,MAAM,KAAK,GAAG,IAAuC,CAAC;oBACtD,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBAChD,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const rules: {
|
|
2
|
+
'enforce-doc-exports': import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingJSDoc", [{
|
|
3
|
+
ignoreTypes?: boolean;
|
|
4
|
+
ignoreInternal?: boolean;
|
|
5
|
+
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
'no-circular-deps': import("@typescript-eslint/utils/ts-eslint").RuleModule<"circularDep", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
'no-forbidden-imports': import("@typescript-eslint/utils/ts-eslint").RuleModule<"forbiddenImport", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
'no-layer-violation': import("@typescript-eslint/utils/ts-eslint").RuleModule<"layerViolation", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
15
|
+
name: string;
|
|
16
|
+
};
|
|
17
|
+
'require-boundary-schema': import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingSchema", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
18
|
+
name: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;CAMjB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/rules/index.ts
|
|
2
|
+
import enforceDocExports from './enforce-doc-exports';
|
|
3
|
+
import noCircularDeps from './no-circular-deps';
|
|
4
|
+
import noForbiddenImports from './no-forbidden-imports';
|
|
5
|
+
import noLayerViolation from './no-layer-violation';
|
|
6
|
+
import requireBoundarySchema from './require-boundary-schema';
|
|
7
|
+
export const rules = {
|
|
8
|
+
'enforce-doc-exports': enforceDocExports,
|
|
9
|
+
'no-circular-deps': noCircularDeps,
|
|
10
|
+
'no-forbidden-imports': noForbiddenImports,
|
|
11
|
+
'no-layer-violation': noLayerViolation,
|
|
12
|
+
'require-boundary-schema': requireBoundarySchema,
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,OAAO,iBAAiB,MAAM,uBAAuB,CAAC;AACtD,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,kBAAkB,MAAM,wBAAwB,CAAC;AACxD,OAAO,gBAAgB,MAAM,sBAAsB,CAAC;AACpD,OAAO,qBAAqB,MAAM,2BAA2B,CAAC;AAE9D,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,qBAAqB,EAAE,iBAAiB;IACxC,kBAAkB,EAAE,cAAc;IAClC,sBAAsB,EAAE,kBAAkB;IAC1C,oBAAoB,EAAE,gBAAgB;IACtC,yBAAyB,EAAE,qBAAqB;CACjD,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Clear the import graph (for testing)
|
|
4
|
+
*/
|
|
5
|
+
export declare function clearImportGraph(): void;
|
|
6
|
+
/**
|
|
7
|
+
* Add an edge to the import graph (exported for testing)
|
|
8
|
+
*/
|
|
9
|
+
export declare function addEdge(from: string, to: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* Check if adding edge from -> to creates a cycle
|
|
12
|
+
* Returns the cycle path if found, null otherwise
|
|
13
|
+
* Exported for testing
|
|
14
|
+
*/
|
|
15
|
+
export declare function detectCycle(from: string, to: string): string[] | null;
|
|
16
|
+
declare const _default: ESLintUtils.RuleModule<"circularDep", [], unknown, ESLintUtils.RuleListener> & {
|
|
17
|
+
name: string;
|
|
18
|
+
};
|
|
19
|
+
export default _default;
|
|
20
|
+
//# sourceMappingURL=no-circular-deps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-circular-deps.d.ts","sourceRoot":"","sources":["../../src/rules/no-circular-deps.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAiB,MAAM,0BAA0B,CAAC;AAUtE;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAKtD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CA+BrE;;;;AAgBD,wBA+CG"}
|