@harness-engineering/eslint-plugin 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +95 -32
- package/dist/index.js +929 -43
- package/package.json +4 -3
- package/dist/configs/index.d.ts +0 -5
- package/dist/configs/index.d.ts.map +0 -1
- package/dist/configs/index.js +0 -8
- package/dist/configs/index.js.map +0 -1
- package/dist/configs/recommended.d.ts +0 -4
- package/dist/configs/recommended.d.ts.map +0 -1
- package/dist/configs/recommended.js +0 -16
- package/dist/configs/recommended.js.map +0 -1
- package/dist/configs/strict.d.ts +0 -4
- package/dist/configs/strict.d.ts.map +0 -1
- package/dist/configs/strict.js +0 -16
- package/dist/configs/strict.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/rules/enforce-doc-exports.d.ts +0 -12
- package/dist/rules/enforce-doc-exports.d.ts.map +0 -1
- package/dist/rules/enforce-doc-exports.js +0 -78
- package/dist/rules/enforce-doc-exports.js.map +0 -1
- package/dist/rules/index.d.ts +0 -30
- package/dist/rules/index.d.ts.map +0 -1
- package/dist/rules/index.js +0 -20
- package/dist/rules/index.js.map +0 -1
- package/dist/rules/no-circular-deps.d.ts +0 -20
- package/dist/rules/no-circular-deps.d.ts.map +0 -1
- package/dist/rules/no-circular-deps.js +0 -110
- package/dist/rules/no-circular-deps.js.map +0 -1
- package/dist/rules/no-forbidden-imports.d.ts +0 -6
- package/dist/rules/no-forbidden-imports.d.ts.map +0 -1
- package/dist/rules/no-forbidden-imports.js +0 -58
- package/dist/rules/no-forbidden-imports.js.map +0 -1
- package/dist/rules/no-layer-violation.d.ts +0 -6
- package/dist/rules/no-layer-violation.d.ts.map +0 -1
- package/dist/rules/no-layer-violation.js +0 -62
- package/dist/rules/no-layer-violation.js.map +0 -1
- package/dist/rules/no-nested-loops-in-critical.d.ts +0 -6
- package/dist/rules/no-nested-loops-in-critical.d.ts.map +0 -1
- package/dist/rules/no-nested-loops-in-critical.js +0 -87
- package/dist/rules/no-nested-loops-in-critical.js.map +0 -1
- package/dist/rules/no-sync-io-in-async.d.ts +0 -6
- package/dist/rules/no-sync-io-in-async.d.ts.map +0 -1
- package/dist/rules/no-sync-io-in-async.js +0 -73
- package/dist/rules/no-sync-io-in-async.js.map +0 -1
- package/dist/rules/no-unbounded-array-chains.d.ts +0 -6
- package/dist/rules/no-unbounded-array-chains.d.ts.map +0 -1
- package/dist/rules/no-unbounded-array-chains.js +0 -71
- package/dist/rules/no-unbounded-array-chains.js.map +0 -1
- package/dist/rules/require-boundary-schema.d.ts +0 -6
- package/dist/rules/require-boundary-schema.d.ts.map +0 -1
- package/dist/rules/require-boundary-schema.js +0 -53
- package/dist/rules/require-boundary-schema.js.map +0 -1
- package/dist/utils/ast-helpers.d.ts +0 -14
- package/dist/utils/ast-helpers.d.ts.map +0 -1
- package/dist/utils/ast-helpers.js +0 -94
- package/dist/utils/ast-helpers.js.map +0 -1
- package/dist/utils/config-loader.d.ts +0 -10
- package/dist/utils/config-loader.d.ts.map +0 -1
- package/dist/utils/config-loader.js +0 -56
- package/dist/utils/config-loader.js.map +0 -1
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -6
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/path-utils.d.ts +0 -24
- package/dist/utils/path-utils.d.ts.map +0 -1
- package/dist/utils/path-utils.js +0 -62
- package/dist/utils/path-utils.js.map +0 -1
- package/dist/utils/schema.d.ts +0 -117
- package/dist/utils/schema.d.ts.map +0 -1
- package/dist/utils/schema.js +0 -34
- package/dist/utils/schema.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harness-engineering/eslint-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "ESLint plugin for harness engineering architectural constraints",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"@typescript-eslint/parser": "^8.57.0",
|
|
26
26
|
"@typescript-eslint/rule-tester": "^8.0.0",
|
|
27
27
|
"eslint": "^10.0.0",
|
|
28
|
+
"tsup": "^8.0.0",
|
|
28
29
|
"typescript": "^5.3.3",
|
|
29
30
|
"vitest": "^4.0.18"
|
|
30
31
|
},
|
|
@@ -53,11 +54,11 @@
|
|
|
53
54
|
},
|
|
54
55
|
"homepage": "https://github.com/Intense-Visions/harness-engineering/tree/main/packages/eslint-plugin#readme",
|
|
55
56
|
"scripts": {
|
|
56
|
-
"build": "
|
|
57
|
+
"build": "tsup src/index.ts --format esm --dts --tsconfig tsconfig.build.json",
|
|
57
58
|
"test": "vitest run",
|
|
58
59
|
"test:watch": "vitest",
|
|
59
60
|
"lint": "eslint src",
|
|
60
61
|
"typecheck": "tsc --noEmit",
|
|
61
|
-
"clean": "
|
|
62
|
+
"clean": "node ../../scripts/clean.mjs dist"
|
|
62
63
|
}
|
|
63
64
|
}
|
package/dist/configs/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configs/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,OAAO;;;CAGnB,CAAC"}
|
package/dist/configs/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/configs/strict.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/configs/strict.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,78 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enforce-doc-exports.js","sourceRoot":"","sources":["../../src/rules/enforce-doc-exports.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEzE,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,CACxC,CAAC,IAAI,EAAE,EAAE,CAAC,6EAA6E,IAAI,KAAK,CACjG,CAAC;AAWF,eAAe,UAAU,CAAsB;IAC7C,IAAI,EAAE,qBAAqB;IAC3B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,0CAA0C;SACxD;QACD,QAAQ,EAAE;YACR,YAAY,EAAE,6DAA6D;SAC5E;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,WAAW,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;oBAChD,cAAc,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;iBACnD;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;KACF;IACD,cAAc,EAAE,CAAC,EAAE,WAAW,EA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Ac,CAAC,mBAAmB,EAAE,CAAC;oBAC3D,MAAM,OAAO,GAAG,IAAoC,CAAC;oBACrD,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;wBAC9C,IAAK,UAAU,CAAC,EAAE,CAAC,IAAuB,KAAK,cAAc,CAAC,UAAU,EAAE,CAAC;4BACzE,WAAW,CAAC,IAAI,EAAE,UAAU,EAAG,UAAU,CAAC,EAA0B,CAAC,IAAI,CAAC,CAAC;wBAC7E,CAAC;oBACH,CAAC;gBACH,CAAC;qBAAM,IAAI,QAAQ,KAAK,cAAc,CAAC,sBAAsB,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"}
|
package/dist/rules/index.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
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
|
-
'no-nested-loops-in-critical': import("@typescript-eslint/utils/ts-eslint").RuleModule<"nestedLoopInCritical", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
18
|
-
name: string;
|
|
19
|
-
};
|
|
20
|
-
'no-sync-io-in-async': import("@typescript-eslint/utils/ts-eslint").RuleModule<"syncIoInAsync", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
21
|
-
name: string;
|
|
22
|
-
};
|
|
23
|
-
'no-unbounded-array-chains': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unboundedArrayChain", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
24
|
-
name: string;
|
|
25
|
-
};
|
|
26
|
-
'require-boundary-schema': import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingSchema", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
27
|
-
name: string;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;CASjB,CAAC"}
|
package/dist/rules/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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 noNestedLoopsInCritical from './no-nested-loops-in-critical';
|
|
7
|
-
import noSyncIoInAsync from './no-sync-io-in-async';
|
|
8
|
-
import noUnboundedArrayChains from './no-unbounded-array-chains';
|
|
9
|
-
import requireBoundarySchema from './require-boundary-schema';
|
|
10
|
-
export const rules = {
|
|
11
|
-
'enforce-doc-exports': enforceDocExports,
|
|
12
|
-
'no-circular-deps': noCircularDeps,
|
|
13
|
-
'no-forbidden-imports': noForbiddenImports,
|
|
14
|
-
'no-layer-violation': noLayerViolation,
|
|
15
|
-
'no-nested-loops-in-critical': noNestedLoopsInCritical,
|
|
16
|
-
'no-sync-io-in-async': noSyncIoInAsync,
|
|
17
|
-
'no-unbounded-array-chains': noUnboundedArrayChains,
|
|
18
|
-
'require-boundary-schema': requireBoundarySchema,
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
package/dist/rules/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,uBAAuB,MAAM,+BAA+B,CAAC;AACpE,OAAO,eAAe,MAAM,uBAAuB,CAAC;AACpD,OAAO,sBAAsB,MAAM,6BAA6B,CAAC;AACjE,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,6BAA6B,EAAE,uBAAuB;IACtD,qBAAqB,EAAE,eAAe;IACtC,2BAA2B,EAAE,sBAAsB;IACnD,yBAAyB,EAAE,qBAAqB;CACjD,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
// src/rules/no-circular-deps.ts
|
|
2
|
-
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
3
|
-
import * as path from 'path';
|
|
4
|
-
const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/harness-engineering/eslint-plugin/blob/main/docs/rules/${name}.md`);
|
|
5
|
-
// Module-level import graph (persists per lint run)
|
|
6
|
-
const importGraph = new Map();
|
|
7
|
-
/**
|
|
8
|
-
* Clear the import graph (for testing)
|
|
9
|
-
*/
|
|
10
|
-
export function clearImportGraph() {
|
|
11
|
-
importGraph.clear();
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Add an edge to the import graph (exported for testing)
|
|
15
|
-
*/
|
|
16
|
-
export function addEdge(from, to) {
|
|
17
|
-
if (!importGraph.has(from)) {
|
|
18
|
-
importGraph.set(from, new Set());
|
|
19
|
-
}
|
|
20
|
-
importGraph.get(from).add(to);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Check if adding edge from -> to creates a cycle
|
|
24
|
-
* Returns the cycle path if found, null otherwise
|
|
25
|
-
* Exported for testing
|
|
26
|
-
*/
|
|
27
|
-
export function detectCycle(from, to) {
|
|
28
|
-
// DFS from 'to' back to 'from'
|
|
29
|
-
const visited = new Set();
|
|
30
|
-
const cyclePath = [to];
|
|
31
|
-
function dfs(current) {
|
|
32
|
-
if (current === from) {
|
|
33
|
-
return true; // Found cycle
|
|
34
|
-
}
|
|
35
|
-
if (visited.has(current)) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
visited.add(current);
|
|
39
|
-
const deps = importGraph.get(current);
|
|
40
|
-
if (deps) {
|
|
41
|
-
for (const dep of deps) {
|
|
42
|
-
cyclePath.push(dep);
|
|
43
|
-
if (dfs(dep)) {
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
cyclePath.pop();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
if (dfs(to)) {
|
|
52
|
-
return [from, ...cyclePath];
|
|
53
|
-
}
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Normalize file path to project-relative
|
|
58
|
-
*/
|
|
59
|
-
function normalizePath(filePath) {
|
|
60
|
-
// Extract path from /project/src/... or similar
|
|
61
|
-
const srcIndex = filePath.indexOf('/src/');
|
|
62
|
-
if (srcIndex !== -1) {
|
|
63
|
-
return filePath.slice(srcIndex + 1);
|
|
64
|
-
}
|
|
65
|
-
return path.basename(filePath);
|
|
66
|
-
}
|
|
67
|
-
export default createRule({
|
|
68
|
-
name: 'no-circular-deps',
|
|
69
|
-
meta: {
|
|
70
|
-
type: 'problem',
|
|
71
|
-
docs: {
|
|
72
|
-
description: 'Detect circular import dependencies',
|
|
73
|
-
},
|
|
74
|
-
messages: {
|
|
75
|
-
circularDep: 'Circular dependency detected: {{cycle}}',
|
|
76
|
-
},
|
|
77
|
-
schema: [],
|
|
78
|
-
},
|
|
79
|
-
defaultOptions: [],
|
|
80
|
-
create(context) {
|
|
81
|
-
const currentFile = normalizePath(context.filename);
|
|
82
|
-
return {
|
|
83
|
-
ImportDeclaration(node) {
|
|
84
|
-
const importPath = node.source.value;
|
|
85
|
-
// Skip external imports
|
|
86
|
-
if (!importPath.startsWith('.')) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
// Resolve import to normalized path
|
|
90
|
-
const importingDir = path.dirname(context.filename);
|
|
91
|
-
const resolvedPath = path.resolve(importingDir, importPath);
|
|
92
|
-
const normalizedImport = normalizePath(resolvedPath);
|
|
93
|
-
// Check for cycle before adding edge
|
|
94
|
-
const cycle = detectCycle(currentFile, normalizedImport);
|
|
95
|
-
if (cycle) {
|
|
96
|
-
context.report({
|
|
97
|
-
node,
|
|
98
|
-
messageId: 'circularDep',
|
|
99
|
-
data: {
|
|
100
|
-
cycle: cycle.map((f) => path.basename(f)).join(' → '),
|
|
101
|
-
},
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
// Add edge to graph
|
|
105
|
-
addEdge(currentFile, normalizedImport);
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
//# sourceMappingURL=no-circular-deps.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-circular-deps.js","sourceRoot":"","sources":["../../src/rules/no-circular-deps.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,EAAE,WAAW,EAAiB,MAAM,0BAA0B,CAAC;AACtE,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,CACxC,CAAC,IAAI,EAAE,EAAE,CAAC,6EAA6E,IAAI,KAAK,CACjG,CAAC;AAEF,oDAAoD;AACpD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAuB,CAAC;AAEnD;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,WAAW,CAAC,KAAK,EAAE,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,EAAU;IAC9C,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;IACnC,CAAC;IACD,WAAW,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACjC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,EAAU;IAClD,+BAA+B;IAC/B,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,SAAS,GAAa,CAAC,EAAE,CAAC,CAAC;IAEjC,SAAS,GAAG,CAAC,OAAe;QAC1B,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACrB,OAAO,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A0B,CAAC;;;;AAUtE,wBA6DG"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// src/rules/no-forbidden-imports.ts
|
|
2
|
-
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
3
|
-
import { getConfig } from '../utils/config-loader';
|
|
4
|
-
import { matchesPattern, resolveImportPath, normalizePath } from '../utils/path-utils';
|
|
5
|
-
const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/harness-engineering/eslint-plugin/blob/main/docs/rules/${name}.md`);
|
|
6
|
-
export default createRule({
|
|
7
|
-
name: 'no-forbidden-imports',
|
|
8
|
-
meta: {
|
|
9
|
-
type: 'problem',
|
|
10
|
-
docs: {
|
|
11
|
-
description: 'Block forbidden imports based on configurable patterns',
|
|
12
|
-
},
|
|
13
|
-
messages: {
|
|
14
|
-
forbiddenImport: '{{message}}',
|
|
15
|
-
},
|
|
16
|
-
schema: [],
|
|
17
|
-
},
|
|
18
|
-
defaultOptions: [],
|
|
19
|
-
create(context) {
|
|
20
|
-
const config = getConfig(context.filename);
|
|
21
|
-
if (!config?.forbiddenImports?.length) {
|
|
22
|
-
return {}; // No-op if no config
|
|
23
|
-
}
|
|
24
|
-
// Get file path relative to project
|
|
25
|
-
const filePath = normalizePath(context.filename);
|
|
26
|
-
// Find matching rules for this file
|
|
27
|
-
const applicableRules = config.forbiddenImports.filter((rule) => matchesPattern(filePath, rule.from));
|
|
28
|
-
if (applicableRules.length === 0) {
|
|
29
|
-
return {}; // No rules apply to this file
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
ImportDeclaration(node) {
|
|
33
|
-
const importPath = node.source.value;
|
|
34
|
-
const resolvedImport = resolveImportPath(importPath, context.filename);
|
|
35
|
-
for (const rule of applicableRules) {
|
|
36
|
-
for (const disallowed of rule.disallow) {
|
|
37
|
-
// Check if import matches disallow pattern
|
|
38
|
-
const isMatch = importPath === disallowed ||
|
|
39
|
-
matchesPattern(resolvedImport, disallowed) ||
|
|
40
|
-
matchesPattern(importPath, disallowed);
|
|
41
|
-
if (isMatch) {
|
|
42
|
-
context.report({
|
|
43
|
-
node,
|
|
44
|
-
messageId: 'forbiddenImport',
|
|
45
|
-
data: {
|
|
46
|
-
message: rule.message ||
|
|
47
|
-
`Import "${importPath}" is forbidden in files matching "${rule.from}"`,
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
return; // Report once per import
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
//# sourceMappingURL=no-forbidden-imports.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-forbidden-imports.js","sourceRoot":"","sources":["../../src/rules/no-forbidden-imports.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,OAAO,EAAE,WAAW,EAAiB,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEvF,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,CACxC,CAAC,IAAI,EAAE,EAAE,CAAC,6EAA6E,IAAI,KAAK,CACjG,CAAC;AAIF,eAAe,UAAU,CAAiB;IACxC,IAAI,EAAE,sBAAsB;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,wDAAwD;SACtE;QACD,QAAQ,EAAE;YACR,eAAe,EAAE,aAAa;SAC/B;QACD,MAAM,EAAE,EAAE;KACX;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC3C,IAAI,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC;YACtC,OAAO,EAAE,CAAC,CAAC,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er-violation.d.ts","sourceRoot":"","sources":["../../src/rules/no-layer-violation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAiB,MAAM,0BAA0B,CAAC;;;;AAetE,wBAiEG"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
// src/rules/no-layer-violation.ts
|
|
2
|
-
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
3
|
-
import { getConfig } from '../utils/config-loader';
|
|
4
|
-
import { resolveImportPath, getLayerForFile, getLayerByName, normalizePath, } from '../utils/path-utils';
|
|
5
|
-
const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/harness-engineering/eslint-plugin/blob/main/docs/rules/${name}.md`);
|
|
6
|
-
export default createRule({
|
|
7
|
-
name: 'no-layer-violation',
|
|
8
|
-
meta: {
|
|
9
|
-
type: 'problem',
|
|
10
|
-
docs: {
|
|
11
|
-
description: 'Enforce layer boundary imports',
|
|
12
|
-
},
|
|
13
|
-
messages: {
|
|
14
|
-
layerViolation: 'Layer "{{fromLayer}}" cannot import from layer "{{toLayer}}"',
|
|
15
|
-
},
|
|
16
|
-
schema: [],
|
|
17
|
-
},
|
|
18
|
-
defaultOptions: [],
|
|
19
|
-
create(context) {
|
|
20
|
-
const config = getConfig(context.filename);
|
|
21
|
-
if (!config?.layers?.length) {
|
|
22
|
-
return {}; // No-op if no layers configured
|
|
23
|
-
}
|
|
24
|
-
const filePath = normalizePath(context.filename);
|
|
25
|
-
const currentLayer = getLayerForFile(filePath, config.layers);
|
|
26
|
-
if (!currentLayer) {
|
|
27
|
-
return {}; // File not in any layer
|
|
28
|
-
}
|
|
29
|
-
const currentLayerDef = getLayerByName(currentLayer, config.layers);
|
|
30
|
-
if (!currentLayerDef) {
|
|
31
|
-
return {};
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
ImportDeclaration(node) {
|
|
35
|
-
const importPath = node.source.value;
|
|
36
|
-
// Skip external imports
|
|
37
|
-
if (!importPath.startsWith('.')) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const resolvedImport = resolveImportPath(importPath, context.filename);
|
|
41
|
-
const importLayer = getLayerForFile(resolvedImport, config.layers);
|
|
42
|
-
// Skip if import is not in any layer
|
|
43
|
-
if (!importLayer) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
// Check if import is allowed
|
|
47
|
-
if (importLayer !== currentLayer &&
|
|
48
|
-
!currentLayerDef.allowedDependencies.includes(importLayer)) {
|
|
49
|
-
context.report({
|
|
50
|
-
node,
|
|
51
|
-
messageId: 'layerViolation',
|
|
52
|
-
data: {
|
|
53
|
-
fromLayer: currentLayer,
|
|
54
|
-
toLayer: importLayer,
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
//# sourceMappingURL=no-layer-violation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-layer-violation.js","sourceRoot":"","sources":["../../src/rules/no-layer-violation.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,OAAO,EAAE,WAAW,EAAiB,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,aAAa,GACd,MAAM,qBAAqB,CAAC;AAE7B,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,CACxC,CAAC,IAAI,EAAE,EAAE,CAAC,6EAA6E,IAAI,KAAK,CACjG,CAAC;AAIF,eAAe,UAAU,CAAiB;IACxC,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,gCAAgC;SAC9C;QACD,QAAQ,EAAE;YACR,cAAc,EAAE,8DAA8D;SAC/E;QACD,MAAM,EAAE,EAAE;KACX;IACD,cAAc,EAAE,EAAE;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wBAC3B,IAAI,EAAE;4BACJ,SAAS,EAAE,YAAY;4BACvB,OAAO,EAAE,WAAW;yBACrB;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
-
declare const _default: ESLintUtils.RuleModule<"nestedLoopInCritical", [], unknown, ESLintUtils.RuleListener> & {
|
|
3
|
-
name: string;
|
|
4
|
-
};
|
|
5
|
-
export default _default;
|
|
6
|
-
//# sourceMappingURL=no-nested-loops-in-critical.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-nested-loops-in-critical.d.ts","sourceRoot":"","sources":["../../src/rules/no-nested-loops-in-critical.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAiB,MAAM,0BAA0B,CAAC;;;;AAQtE,wBAoGG"}
|