@interlace/eslint-devkit 2.1.2 → 2.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/package.json +1 -6
- package/src/ast/ast-utils.d.ts +1 -1
- package/src/ast/module-binding.d.ts +1 -1
- package/src/ast/spellings.d.ts +1 -1
- package/src/ast/static-expression.d.ts +1 -1
- package/src/ast/type-syntax.d.ts +1 -1
- package/src/ast-node-types.d.ts +1 -1
- package/src/index.d.ts +6 -3
- package/src/resolver/dependency-analysis.d.ts +29 -0
- package/src/resolver/dependency-analysis.js +1 -1
- package/src/rule-creation/browser-escape-hatch-rule.d.ts +1 -1
- package/src/rule-creation/connection-config.d.ts +1 -1
- package/src/rule-creation/driver-origin.d.ts +1 -1
- package/src/rule-creation/generated-file.d.ts +1 -1
- package/src/rule-creation/hardcoded-credentials-rule.d.ts +9 -2
- package/src/rule-creation/mass-assignment-rule.d.ts +9 -2
- package/src/rule-creation/message-source.d.ts +1 -1
- package/src/rule-creation/minified-file.d.ts +1 -1
- package/src/rule-creation/mock-context.d.ts +1 -1
- package/src/rule-creation/module-evidence.d.ts +1 -1
- package/src/rule-creation/raw-identifier-rule.d.ts +9 -2
- package/src/rule-creation/request-source.d.ts +1 -1
- package/src/rule-creation/require-tls-rule.d.ts +8 -2
- package/src/rule-creation/rule-creator.d.ts +1 -1
- package/src/rule-creation/rule-creator.js +1 -1
- package/src/rule-creation/sdk-api-key-rule.d.ts +1 -1
- package/src/rule-creation/sdk-flow.d.ts +1 -1
- package/src/rule-creation/sql-injection-rule.d.ts +8 -2
- package/src/rule-creation/sql-position.d.ts +1 -1
- package/src/rule-creation/sql-safety.d.ts +1 -1
- package/src/rule-creation/system-prompt-injection-rule.d.ts +1 -1
- package/src/rule-creation/unscoped-mutation-rule.d.ts +9 -2
- package/src/rule-creation/value-follow.d.ts +1 -1
- package/src/security/security-utils.d.ts +1 -1
- package/src/types/estree/project-service/createProjectService.d.ts +67 -0
- package/src/types/estree/project-service/index.d.ts +3 -0
- package/src/types/estree/scope-manager/ScopeManager.d.ts +77 -0
- package/src/types/estree/scope-manager/analyze.d.ts +55 -0
- package/src/types/estree/scope-manager/definition/CatchClauseDefinition.d.ts +10 -0
- package/src/types/estree/scope-manager/definition/ClassNameDefinition.d.ts +10 -0
- package/src/types/estree/scope-manager/definition/Definition.d.ts +14 -0
- package/src/types/estree/scope-manager/definition/DefinitionBase.d.ts +35 -0
- package/src/types/estree/scope-manager/definition/DefinitionType.d.ts +15 -0
- package/src/types/estree/scope-manager/definition/FunctionNameDefinition.d.ts +10 -0
- package/src/types/estree/scope-manager/definition/ImplicitGlobalVariableDefinition.d.ts +10 -0
- package/src/types/estree/scope-manager/definition/ImportBindingDefinition.d.ts +11 -0
- package/src/types/estree/scope-manager/definition/ParameterDefinition.d.ts +14 -0
- package/src/types/estree/scope-manager/definition/TSEnumMemberDefinition.d.ts +10 -0
- package/src/types/estree/scope-manager/definition/TSEnumNameDefinition.d.ts +10 -0
- package/src/types/estree/scope-manager/definition/TSModuleNameDefinition.d.ts +10 -0
- package/src/types/estree/scope-manager/definition/TypeDefinition.d.ts +10 -0
- package/src/types/estree/scope-manager/definition/VariableDefinition.d.ts +10 -0
- package/src/types/estree/scope-manager/definition/index.d.ts +15 -0
- package/src/types/estree/scope-manager/index.d.ts +10 -0
- package/src/types/estree/scope-manager/referencer/PatternVisitor.d.ts +16 -0
- package/src/types/estree/scope-manager/referencer/Reference.d.ts +88 -0
- package/src/types/estree/scope-manager/referencer/Referencer.d.ts +28 -0
- package/src/types/estree/scope-manager/referencer/Visitor.d.ts +13 -0
- package/src/types/estree/scope-manager/referencer/VisitorBase.d.ts +22 -0
- package/src/types/estree/scope-manager/referencer/index.d.ts +3 -0
- package/src/types/estree/scope-manager/scope/BlockScope.d.ts +10 -0
- package/src/types/estree/scope-manager/scope/CatchScope.d.ts +10 -0
- package/src/types/estree/scope-manager/scope/ClassFieldInitializerScope.d.ts +10 -0
- package/src/types/estree/scope-manager/scope/ClassScope.d.ts +10 -0
- package/src/types/estree/scope-manager/scope/ClassStaticBlockScope.d.ts +10 -0
- package/src/types/estree/scope-manager/scope/ConditionalTypeScope.d.ts +10 -0
- package/src/types/estree/scope-manager/scope/ForScope.d.ts +10 -0
- package/src/types/estree/scope-manager/scope/FunctionExpressionNameScope.d.ts +11 -0
- package/src/types/estree/scope-manager/scope/FunctionScope.d.ts +12 -0
- package/src/types/estree/scope-manager/scope/FunctionTypeScope.d.ts +10 -0
- package/src/types/estree/scope-manager/scope/GlobalScope.d.ts +18 -0
- package/src/types/estree/scope-manager/scope/MappedTypeScope.d.ts +10 -0
- package/src/types/estree/scope-manager/scope/ModuleScope.d.ts +10 -0
- package/src/types/estree/scope-manager/scope/Scope.d.ts +21 -0
- package/src/types/estree/scope-manager/scope/ScopeBase.d.ts +91 -0
- package/src/types/estree/scope-manager/scope/ScopeType.d.ts +22 -0
- package/src/types/estree/scope-manager/scope/SwitchScope.d.ts +10 -0
- package/src/types/estree/scope-manager/scope/TSEnumScope.d.ts +10 -0
- package/src/types/estree/scope-manager/scope/TSModuleScope.d.ts +10 -0
- package/src/types/estree/scope-manager/scope/TypeScope.d.ts +10 -0
- package/src/types/estree/scope-manager/scope/WithScope.d.ts +11 -0
- package/src/types/estree/scope-manager/scope/index.d.ts +22 -0
- package/src/types/estree/scope-manager/variable/ESLintScopeVariable.d.ts +34 -0
- package/src/types/estree/scope-manager/variable/ImplicitLibVariable.d.ts +29 -0
- package/src/types/estree/scope-manager/variable/Variable.d.ts +18 -0
- package/src/types/estree/scope-manager/variable/VariableBase.d.ts +44 -0
- package/src/types/estree/scope-manager/variable/index.d.ts +8 -0
- package/src/types/estree/types/generated/ast-spec.d.ts +2215 -0
- package/src/types/estree/types/index.d.ts +6 -0
- package/src/types/estree/types/lib.d.ts +3 -0
- package/src/types/estree/types/parser-options.d.ts +83 -0
- package/src/types/estree/types/ts-estree.d.ts +190 -0
- package/src/types/estree/typescript-estree/clear-caches.d.ts +11 -0
- package/src/types/estree/typescript-estree/create-program/getScriptKind.d.ts +5 -0
- package/src/types/estree/typescript-estree/create-program/shared.d.ts +29 -0
- package/src/types/estree/typescript-estree/create-program/useProvidedPrograms.d.ts +13 -0
- package/src/types/estree/typescript-estree/getModifiers.d.ts +5 -0
- package/src/types/estree/typescript-estree/index.d.ts +16 -0
- package/src/types/estree/typescript-estree/node-utils.d.ts +191 -0
- package/src/types/estree/typescript-estree/parseSettings/ExpiringCache.d.ts +17 -0
- package/src/types/estree/typescript-estree/parseSettings/candidateTSConfigRootDirs.d.ts +5 -0
- package/src/types/estree/typescript-estree/parseSettings/index.d.ts +128 -0
- package/src/types/estree/typescript-estree/parser-options.d.ts +220 -0
- package/src/types/estree/typescript-estree/parser.d.ts +19 -0
- package/src/types/estree/typescript-estree/simple-traverse.d.ts +13 -0
- package/src/types/estree/typescript-estree/ts-estree/estree-to-ts-node-types.d.ts +180 -0
- package/src/types/estree/typescript-estree/ts-estree/index.d.ts +5 -0
- package/src/types/estree/typescript-estree/ts-estree/ts-nodes.d.ts +19 -0
- package/src/types/estree/typescript-estree/version-check.d.ts +6 -0
- package/src/types/estree/typescript-estree/version.d.ts +3 -0
- package/src/types/estree/typescript-estree/withoutProjectParserOptions.d.ts +11 -0
- package/src/types/estree/utils/ast-utils/eslint-utils/PatternMatcher.d.ts +49 -0
- package/src/types/estree/utils/ast-utils/eslint-utils/ReferenceTracker.d.ts +73 -0
- package/src/types/estree/utils/ast-utils/eslint-utils/astUtilities.d.ts +85 -0
- package/src/types/estree/utils/ast-utils/eslint-utils/index.d.ts +7 -0
- package/src/types/estree/utils/ast-utils/eslint-utils/predicates.d.ts +33 -0
- package/src/types/estree/utils/ast-utils/eslint-utils/scopeAnalysis.d.ts +18 -0
- package/src/types/estree/utils/ast-utils/helpers.d.ts +20 -0
- package/src/types/estree/utils/ast-utils/index.d.ts +6 -0
- package/src/types/estree/utils/ast-utils/misc.d.ts +12 -0
- package/src/types/estree/utils/ast-utils/predicates.d.ts +70 -0
- package/src/types/estree/utils/eslint-utils/InferTypesFromRule.d.ts +11 -0
- package/src/types/estree/utils/eslint-utils/RuleCreator.d.ts +34 -0
- package/src/types/estree/utils/eslint-utils/applyDefault.d.ts +10 -0
- package/src/types/estree/utils/eslint-utils/deepMerge.d.ts +16 -0
- package/src/types/estree/utils/eslint-utils/getParserServices.d.ts +24 -0
- package/src/types/estree/utils/eslint-utils/index.d.ts +8 -0
- package/src/types/estree/utils/eslint-utils/nullThrows.d.ts +14 -0
- package/src/types/estree/utils/index.d.ts +8 -0
- package/src/types/estree/utils/json-schema.d.ts +389 -0
- package/src/types/estree/utils/ts-eslint/AST.d.ts +10 -0
- package/src/types/estree/utils/ts-eslint/Config.d.ts +293 -0
- package/src/types/estree/utils/ts-eslint/ESLint.d.ts +9 -0
- package/src/types/estree/utils/ts-eslint/Linter.d.ts +257 -0
- package/src/types/estree/utils/ts-eslint/Parser.d.ts +96 -0
- package/src/types/estree/utils/ts-eslint/ParserOptions.d.ts +3 -0
- package/src/types/estree/utils/ts-eslint/Processor.d.ts +65 -0
- package/src/types/estree/utils/ts-eslint/Rule.d.ts +633 -0
- package/src/types/estree/utils/ts-eslint/RuleTester.d.ts +185 -0
- package/src/types/estree/utils/ts-eslint/Scope.d.ts +44 -0
- package/src/types/estree/utils/ts-eslint/SourceCode.d.ts +356 -0
- package/src/types/estree/utils/ts-eslint/eslint/ESLintShared.d.ts +383 -0
- package/src/types/estree/utils/ts-eslint/eslint/FlatESLint.d.ts +89 -0
- package/src/types/estree/utils/ts-eslint/eslint/LegacyESLint.d.ts +74 -0
- package/src/types/estree/utils/ts-eslint/index.d.ts +13 -0
- package/src/types/estree/utils/ts-estree.d.ts +5 -0
- package/src/types/estree/utils/ts-utils/NoInfer.d.ts +11 -0
- package/src/types/estree/utils/ts-utils/index.d.ts +4 -0
- package/src/types/estree/utils/ts-utils/isArray.d.ts +3 -0
- package/src/types/estree/visitor-keys/get-keys.d.ts +4 -0
- package/src/types/estree/visitor-keys/index.d.ts +4 -0
- package/src/types/estree/visitor-keys/visitor-keys.d.ts +4 -0
- package/src/types/meta-augmentation.d.ts +1 -1
- package/src/types/type-utils.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interlace/eslint-devkit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "ESLint plugin toolkit for building ESLint plugins in TypeScript — AST helpers, type utilities, rule-creation scaffolding, security benchmarks, and SARIF output.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
"custom-rules",
|
|
47
47
|
"rule-authoring",
|
|
48
48
|
"typescript",
|
|
49
|
-
"typescript-eslint",
|
|
50
49
|
"utilities",
|
|
51
50
|
"ast",
|
|
52
51
|
"ast-utils",
|
|
@@ -66,7 +65,6 @@
|
|
|
66
65
|
"node": "^20.19.0 || ^22.13.0 || >=24"
|
|
67
66
|
},
|
|
68
67
|
"peerDependencies": {
|
|
69
|
-
"@typescript-eslint/utils": "^7.0.0 || ^8.0.0",
|
|
70
68
|
"eslint": "^8.40.0 || ^9.0.0 || ^10.0.0",
|
|
71
69
|
"oxc-resolver": "^11.24.2",
|
|
72
70
|
"typescript": ">=4.8.4"
|
|
@@ -75,9 +73,6 @@
|
|
|
75
73
|
"eslint": {
|
|
76
74
|
"optional": true
|
|
77
75
|
},
|
|
78
|
-
"@typescript-eslint/utils": {
|
|
79
|
-
"optional": true
|
|
80
|
-
},
|
|
81
76
|
"oxc-resolver": {
|
|
82
77
|
"optional": true
|
|
83
78
|
},
|
package/src/ast/ast-utils.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Inspired by typescript-eslint's ast-utils
|
|
10
10
|
* Provides common utilities for traversing and analyzing AST nodes
|
|
11
11
|
*/
|
|
12
|
-
import type { TSESTree } from '
|
|
12
|
+
import type { TSESTree } from '../types/estree/utils/index';
|
|
13
13
|
/**
|
|
14
14
|
* Check if a node is a specific type of node
|
|
15
15
|
*/
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* // => { module: 'fs', path: ['promises', 'readFile'] }
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
import type { TSESLint, TSESTree } from '
|
|
30
|
+
import type { TSESLint, TSESTree } from '../types/estree/utils/index';
|
|
31
31
|
export interface ModuleBinding {
|
|
32
32
|
/** Module specifier, `node:` stripped and equivalents applied (e.g. `fs`). */
|
|
33
33
|
module: string;
|
package/src/ast/spellings.d.ts
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
* node type and say why in a comment — that is a position, and positions are
|
|
35
35
|
* fine. Silence by omission is not.
|
|
36
36
|
*/
|
|
37
|
-
import type { TSESTree, TSESLint } from '
|
|
37
|
+
import type { TSESTree, TSESLint } from '../types/estree/utils/index';
|
|
38
38
|
/**
|
|
39
39
|
* The string a node names, in either spelling, or `null` if it does not name
|
|
40
40
|
* one statically.
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* Deliberately conservative: anything not proven static is reported as dynamic, so a
|
|
23
23
|
* gap here costs a false positive, never a missed vulnerability.
|
|
24
24
|
*/
|
|
25
|
-
import type { TSESLint, TSESTree } from '
|
|
25
|
+
import type { TSESLint, TSESTree } from '../types/estree/utils/index';
|
|
26
26
|
export interface StaticExpressionOptions {
|
|
27
27
|
/**
|
|
28
28
|
* Treat a `const` binding with a static initializer as static.
|
package/src/ast/type-syntax.d.ts
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
* unwrapping is always sound for provenance: `x as string` reads exactly what
|
|
35
35
|
* `x` reads.
|
|
36
36
|
*/
|
|
37
|
-
import type { TSESTree } from '
|
|
37
|
+
import type { TSESTree } from '../types/estree/utils/index';
|
|
38
38
|
/**
|
|
39
39
|
* Return the innermost expression, stripping every type-only wrapper.
|
|
40
40
|
*
|
package/src/ast-node-types.d.ts
CHANGED
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
* directions, so an upstream addition or rename fails the build rather than
|
|
26
26
|
* silently shipping a node type our rules can never match.
|
|
27
27
|
*/
|
|
28
|
-
import type { AST_NODE_TYPES as UpstreamASTNodeTypes } from '
|
|
28
|
+
import type { AST_NODE_TYPES as UpstreamASTNodeTypes } from './types/estree/utils/index';
|
|
29
29
|
export declare const AST_NODE_TYPES: typeof UpstreamASTNodeTypes;
|
package/src/index.d.ts
CHANGED
|
@@ -43,9 +43,12 @@ export { CVSS_RANGES, CWE_MAPPING, CWE_COMPLIANCE_MAPPING, OWASP_DETAILS, OWASP_
|
|
|
43
43
|
* and so pulled a 24 MB compiler into every consumer install. `AST_NODE_TYPES`
|
|
44
44
|
* is now an inlined table (`./ast-node-types`) and `ESLintUtils` is our own
|
|
45
45
|
* ported shim (`./rule-creation/rule-creator`). Together they take this
|
|
46
|
-
* package to zero runtime dependencies. The type-only re-exports below
|
|
47
|
-
*
|
|
46
|
+
* package to zero runtime dependencies. The type-only re-exports below point
|
|
47
|
+
* at devkit's own vendored declarations (`./types/estree`, generated from the
|
|
48
|
+
* pinned typescript-eslint packages by scripts/vendor-estree-types.ts), so a
|
|
49
|
+
* consumer type-checks without `@typescript-eslint/utils` installed.
|
|
48
50
|
*/
|
|
49
51
|
export { AST_NODE_TYPES } from './ast-node-types';
|
|
50
52
|
export { ESLintUtils } from './rule-creation/rule-creator';
|
|
51
|
-
export type { TSESLint, TSESTree, ParserServices, } from '
|
|
53
|
+
export type { TSESLint, TSESTree, ParserServices, } from './types/estree/utils/index';
|
|
54
|
+
export type { JSONSchema4 } from './types/estree/utils/json-schema';
|
|
@@ -146,6 +146,19 @@ export interface FileSystemCache {
|
|
|
146
146
|
minimalCycle: string[];
|
|
147
147
|
cycleHash: string;
|
|
148
148
|
}>>;
|
|
149
|
+
/**
|
|
150
|
+
* Targets the graph must not contain: an import that resolves to a path for
|
|
151
|
+
* which this returns true is dropped from the file's edges, so every walker
|
|
152
|
+
* (components, shortest path, breadth-first search) agrees without being
|
|
153
|
+
* told. eslint-plugin-import's `import/extensions` and `import/ignore`
|
|
154
|
+
* settings are this: a file it does not read has no imports, and a cycle
|
|
155
|
+
* through it is invisible.
|
|
156
|
+
*
|
|
157
|
+
* The edges a cache holds depend on this function, so one cache must be used
|
|
158
|
+
* with one function. The caller keys its caches by the settings it builds
|
|
159
|
+
* the function from.
|
|
160
|
+
*/
|
|
161
|
+
ignoreTarget?: (resolvedPath: string) => boolean;
|
|
149
162
|
}
|
|
150
163
|
/**
|
|
151
164
|
* Create a new empty cache
|
|
@@ -240,6 +253,22 @@ export interface GetImportsOptions {
|
|
|
240
253
|
/** External resolver settings */
|
|
241
254
|
resolverSettings?: ResolverSetting;
|
|
242
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Replace every comment in `source` with spaces (newlines kept, so offsets
|
|
258
|
+
* and line numbers do not move).
|
|
259
|
+
*
|
|
260
|
+
* The import regexes read text, and text has comments: a doc comment that
|
|
261
|
+
* shows `import "core/Engines/x"` made the regex find an edge that the module
|
|
262
|
+
* does not have. eslint-plugin-import parses the file and never sees one.
|
|
263
|
+
*
|
|
264
|
+
* The scan has to know where a comment can NOT start, or it blanks real
|
|
265
|
+
* imports: inside a string (`"http://x"`), a template literal (`` `a/*b` ``,
|
|
266
|
+
* including its `${ }` holes, which are code again), and a regular expression
|
|
267
|
+
* literal (`/'/`). A `/` is a regular expression when the token before it
|
|
268
|
+
* cannot end an expression. A string is closed by a newline, so an apostrophe
|
|
269
|
+
* in JSX text spoils one line, not the file.
|
|
270
|
+
*/
|
|
271
|
+
export declare function blankComments(source: string): string;
|
|
243
272
|
/**
|
|
244
273
|
* Get all imports from a file
|
|
245
274
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.PERFORMANCE_DOCS=void 0;exports.clearExportKindCache=clearExportKindCache;exports.exportKindsOf=exportKindsOf;exports.createLRUCache=createLRUCache;exports.isDefinitelyExternal=isDefinitelyExternal;exports.createFileSystemCache=createFileSystemCache;exports.clearCache=clearCache;exports.invalidateSCCCache=invalidateSCCCache;exports.getFileHash=getFileHash;exports.isCacheValid=isCacheValid;exports.fileExists=fileExists;exports.patternToRegexWithCache=patternToRegexWithCache;exports.shouldIgnoreFileWithCache=shouldIgnoreFileWithCache;exports.resolveImportPath=resolveImportPath;exports.getFileImports=getFileImports;exports.hasOnlyTypeImports=hasOnlyTypeImports;exports.computeSCCsFromFile=computeSCCsFromFile;exports.isFileInCycle=isFileInCycle;exports.findShortestCyclePath=findShortestCyclePath;exports.getCycleForFile=getCycleForFile;exports.detectCycleFromImport=detectCycleFromImport;exports.findAllCircularDependencies=findAllCircularDependencies;exports.getMinimalCycle=getMinimalCycle;exports.getCycleHash=getCycleHash;exports.saveCacheToDisk=saveCacheToDisk;exports.loadCacheFromDisk=loadCacheFromDisk;exports.getFilesNeedingReanalysis=getFilesNeedingReanalysis;exports.isIncrementalAvailable=isIncrementalAvailable;const resolver_1=require("./resolver");const node_fs_1=require("node:fs");const fs_1=require("../node/fs");const path_1=require("../node/path");const LRU_MAX_SIZE=5e4;const EXTERNAL_MODULE_PATTERNS=[/^node:/,/^[a-z@][^/]*$/,/node_modules/];const KNOWN_EXTERNAL_PACKAGES=new Set(["react","react-dom","vue","angular","svelte","lodash","underscore","ramda","rxjs","express","koa","fastify","hapi","axios","fetch","node-fetch","got","fs","path","url","http","https","crypto","util","os","child_process","typescript","eslint","prettier","jest","vitest","mocha","webpack","rollup","vite","esbuild","parcel"]);const IMPORT_REGEX=/import\s+(?:(?:(?!\bfrom\s+['"])[\w*{}\s,]|'[^'\n]*'|"[^"\n]*")+\s+from\s+)?['"]([^'"]+)['"]/g;const DYNAMIC_IMPORT_REGEX=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;const TYPE_IMPORT_REGEX=/import\s+type\s/;const EXPORT_FROM_REGEX=/export\s+\{[\s\S]*?\}\s+from\s+['"]([^'"]+)['"]/g;const BRACED_CLAUSE_ONLY=/^import\s+\{([^}]*)\}\s+from\s+['"]/;const INLINE_TYPE_BINDING=/^type\s+(?!as(?:\s|$))/;function importsOnlyInlineTypes(statement){const clause=BRACED_CLAUSE_ONLY.exec(statement);if(!clause)return false;const bindings=clause[1].split(",").map(binding=>binding.trim()).filter(Boolean);if(!bindings.length)return false;return bindings.every(binding=>INLINE_TYPE_BINDING.test(binding))}const EXPORT_ALL_REGEX=/export\s*\*\s*(?:as\s+[\w$]+\s+)?from\s+['"]([^'"]+)['"]/g;const TOP_LEVEL_REQUIRE_REGEX=/^(?:(?:const|let|var)\s+[\w${}\s,:]+=\s*|import\s+[\w$]+\s*=\s*)?require\s*\(\s*['"]([^'"]+)['"]\s*\)/gm;const exportKindCache=new Map;function clearExportKindCache(){exportKindCache.clear()}function exportKindsOf(target,resolve,visiting=new Set){const hit=exportKindCache.get(target);if(hit)return hit;const kinds=new Map;if(visiting.has(target))return kinds;visiting.add(target);const source=(0,fs_1.readFileSync)(target,"utf-8")??"";const set=(name,kind)=>{if(kinds.get(name)!=="value")kinds.set(name,kind)};for(const m of source.matchAll(/export\s+(?:declare\s+)?(?:abstract\s+)?(?:const|let|var|function|class|enum|namespace|module)\s+([A-Za-z_$][\w$]*)/g)){set(m[1],"value")}for(const m of source.matchAll(/export\s+(?:declare\s+)?(?:interface|type)\s+([A-Za-z_$][\w$]*)/g)){set(m[1],"type")}if(resolve){const local=new Map;for(const m of source.matchAll(/^(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:(const|let|var|function|class|enum|namespace|module)|(interface|type))\s+([A-Za-z_$][\w$]*)/gm)){if(local.get(m[3])!=="value")local.set(m[3],m[1]?"value":"type")}const kindIn=(from,name)=>{if(from===void 0)return local.get(name);const file=resolve(from,target);return file?exportKindsOf(file,resolve,visiting).get(name):void 0};for(const m of source.matchAll(/export\s+(type\s+)?\{([^}]*)\}(?:\s*from\s*['"]([^'"]+)['"])?/g)){for(const raw of m[2].split(",")){const spec=raw.trim();if(!spec)continue;const inlineType=/^type\s+(?!as(?:\s|$))/.test(spec);const[orig,alias]=spec.replace(/^type\s+(?!as(?:\s|$))/,"").split(/\s+as\s+/);const exported=(alias??orig).trim();const kind=m[1]||inlineType?"type":kindIn(m[3],orig.trim());if(kind)set(exported,kind)}}for(const m of source.matchAll(/export\s+(type\s+)?\*\s*from\s*['"]([^'"]+)['"]/g)){const file=resolve(m[2],target);if(!file)continue;for(const[name,kind]of exportKindsOf(file,resolve,visiting)){if(!kinds.has(name))kinds.set(name,m[1]?"type":kind)}}}visiting.delete(target);exportKindCache.set(target,kinds);return kinds}function importsOnlyTypesFrom(statement,target,resolve){const clause=BRACED_CLAUSE_ONLY.exec(statement);if(!clause)return false;const bindings=clause[1].split(",").map(binding=>binding.trim()).filter(Boolean);if(!bindings.length)return false;const kinds=exportKindsOf(target,resolve);return bindings.every(binding=>INLINE_TYPE_BINDING.test(binding)||kinds.get(binding.split(/\s+as\s+/)[0])==="type")}const DEFAULT_EXTENSIONS=[".ts",".tsx",".js",".jsx"];class LRUCache{cache=new Map;maxSize;constructor(maxSize=LRU_MAX_SIZE){this.maxSize=maxSize}get(key){const value=this.cache.get(key);if(value!==void 0){this.cache.delete(key);this.cache.set(key,value)}return value}set(key,value){if(this.cache.has(key)){this.cache.delete(key)}else if(this.cache.size>=this.maxSize){const firstKey=this.cache.keys().next().value;if(firstKey!==void 0){this.cache.delete(firstKey)}}this.cache.set(key,value)}has(key){return this.cache.has(key)}delete(key){return this.cache.delete(key)}clear(){this.cache.clear()}get size(){return this.cache.size}}function createLRUCache(maxSize=LRU_MAX_SIZE){return new LRUCache(maxSize)}function isDefinitelyExternal(importPath){const packageName=importPath.split("/")[0].replace(/^@[^/]+\//,"");if(KNOWN_EXTERNAL_PACKAGES.has(packageName)){return true}return EXTERNAL_MODULE_PATTERNS.some(pattern=>pattern.test(importPath))}function createFileSystemCache(){return{dependencies:new Map,fileExists:new Map,fileHashes:new Map,compiledPatterns:(0,path_1.createPatternCache)(),reportedCycles:new Set,sccIndex:new Map,sccs:[],sccComputed:false,graphHash:"",resolvedPaths:new Map,nonCyclicFiles:new Set,pendingCycleReports:new Map}}function clearCache(cache){cache.dependencies.clear();cache.fileExists.clear();cache.fileHashes.clear();cache.compiledPatterns.clear();cache.reportedCycles.clear();cache.sccIndex.clear();cache.sccs=[];cache.sccComputed=false;cache.graphHash="";cache.resolvedPaths=new Map;cache.nonCyclicFiles.clear();cache.pendingCycleReports.clear()}function invalidateSCCCache(cache){cache.sccIndex.clear();cache.sccs=[];cache.sccComputed=false;cache.nonCyclicFiles.clear()}function getFileHash(filePath){const stats=(0,fs_1.statSync)(filePath);if(!stats){return null}return`${stats.mtimeMs}-${stats.size}`}function isCacheValid(filePath,cache){const cachedHash=cache.fileHashes.get(filePath);if(!cachedHash)return false;const currentHash=getFileHash(filePath);return cachedHash===currentHash}function fileExists(filePath,cache){const cached=cache.fileExists.get(filePath);if(cached!==void 0){return cached}const exists=(0,fs_1.fileExistsSync)(filePath);cache.fileExists.set(filePath,exists);return exists}function patternToRegexWithCache(pattern,cache){return(0,path_1.patternToRegex)(pattern,cache.compiledPatterns)}function shouldIgnoreFileWithCache(file,patterns,cache){return(0,path_1.shouldIgnoreFile)(file,patterns,cache.compiledPatterns)}function resolveImportPath(importPath,options){const fromFile=options.fromFile;const extensions=options.extensions||DEFAULT_EXTENSIONS;const cache=options.cache;const resolverSettings=options.resolverSettings;if(isDefinitelyExternal(importPath)){if(!importPath.startsWith("@")){return null}}const isRelative=importPath.startsWith(".");if(!isRelative){const globalCached=cache.resolvedPaths.get(importPath);if(globalCached!==void 0){return globalCached}}const cacheKey=isRelative?`${fromFile}::${importPath}`:importPath;const cached=cache.resolvedPaths.get(cacheKey);if(cached!==void 0){return cached}let result=(0,resolver_1.resolveModule)(importPath,fromFile,{extensions,mainFields:["module","main"],resolverSettings});if(result&&!isRelative&&result.includes("node_modules")){try{const realPath=(0,node_fs_1.realpathSync)(result);if(realPath.includes("node_modules")){cache.resolvedPaths.set(cacheKey,null);return null}result=realPath}catch{cache.resolvedPaths.set(cacheKey,null);return null}}if(!result&&isRelative){result=(0,path_1.resolvePath)((0,path_1.getDirname)(fromFile),importPath)}cache.resolvedPaths.set(cacheKey,result);return result}function getFileImports(file,options){const{workspaceRoot,barrelExports,cache,resolverSettings}=options;const cached=cache.dependencies.get(file);if(cached){return cached}const imports=[];try{if(!fileExists(file,cache)){return imports}const content=(0,fs_1.readFileSync)(file,"utf-8");if(content===null){return imports}const resolveOpts={fromFile:file,workspaceRoot,barrelExports,cache,extensions:DEFAULT_EXTENSIONS,resolverSettings};IMPORT_REGEX.lastIndex=0;DYNAMIC_IMPORT_REGEX.lastIndex=0;EXPORT_FROM_REGEX.lastIndex=0;let match;const seen=new Map;const pushImport=(importPath,dynamic=false,typeOnly=false,inlineTypeOnly=false)=>{const resolved=resolveImportPath(importPath,resolveOpts);if(!resolved||!fileExists(resolved,cache))return;const existing=seen.get(resolved);if(existing){if(dynamic)return;if(!typeOnly&&!inlineTypeOnly){delete existing.typeOnly;delete existing.inlineTypeOnly}else if(inlineTypeOnly&&existing.typeOnly){delete existing.typeOnly;existing.inlineTypeOnly=true}return}const info={path:resolved,source:importPath};if(dynamic)info.dynamic=true;if(typeOnly)info.typeOnly=true;if(inlineTypeOnly)info.inlineTypeOnly=true;seen.set(resolved,info);imports.push(info)};while((match=IMPORT_REGEX.exec(content))!==null){const isTypeImport=/^import\s+type[\s{]/.test(match[0]);let inlineTypeOnly=false;if(!isTypeImport){const target=resolveImportPath(match[1],resolveOpts);inlineTypeOnly=importsOnlyInlineTypes(match[0])||target!==null&&importsOnlyTypesFrom(match[0],target,(spec,fromFile)=>resolveImportPath(spec,{...resolveOpts,fromFile}))}pushImport(match[1],false,isTypeImport,inlineTypeOnly)}while((match=EXPORT_FROM_REGEX.exec(content))!==null)pushImport(match[1]);EXPORT_ALL_REGEX.lastIndex=0;while((match=EXPORT_ALL_REGEX.exec(content))!==null)pushImport(match[1]);TOP_LEVEL_REQUIRE_REGEX.lastIndex=0;while((match=TOP_LEVEL_REQUIRE_REGEX.exec(content))!==null)pushImport(match[1]);while((match=DYNAMIC_IMPORT_REGEX.exec(content))!==null)pushImport(match[1],true);const hash=getFileHash(file);if(hash){const oldHash=cache.fileHashes.get(file);if(oldHash!==hash){invalidateSCCCache(cache)}cache.fileHashes.set(file,hash)}}catch{}cache.dependencies.set(file,imports);return imports}function hasOnlyTypeImports(cycle,cache){for(const file of cycle){if(!fileExists(file,cache))continue;const content=(0,fs_1.readFileSync)(file,"utf-8");if(content===null)return false;const hasRuntimeImport=!TYPE_IMPORT_REGEX.test(content)&&IMPORT_REGEX.test(content);IMPORT_REGEX.lastIndex=0;if(hasRuntimeImport){return false}}return true}function computeSCCsFromFile(startFile,options){try{startFile=(0,node_fs_1.realpathSync)(startFile)}catch{}const{workspaceRoot,barrelExports,cache,resolverSettings}=options;if(cache.sccComputed&&cache.sccs.length>0&&cache.sccIndex.has(startFile)){return cache.sccs}const state={index:0,stack:[],onStack:new Set,indices:new Map,lowlinks:new Map,sccs:[]};const visited=new Set;const filesToProcess=[startFile];while(filesToProcess.length>0){const file=filesToProcess.pop();if(visited.has(file))continue;visited.add(file);const imports=getFileImports(file,{workspaceRoot,barrelExports,cache,resolverSettings});for(const imp of imports){if(!imp.dynamic&&!isErasedEdge(imp,options)&&!visited.has(imp.path)){filesToProcess.push(imp.path)}}}for(const file of visited){if(!state.indices.has(file)){tarjanStrongConnect(file,state,options,0)}}const newResults=state.sccs.map(files=>({files,hasCycle:files.length>1}));const offset=cache.sccs.length;cache.sccs.push(...newResults);cache.sccComputed=true;for(let i=0;i<newResults.length;i++){for(const file of newResults[i].files){if(!cache.sccIndex.has(file)){cache.sccIndex.set(file,offset+i)}}}for(const result of newResults){if(result.hasCycle){for(const file of result.files){cache.nonCyclicFiles.delete(file)}}else{for(const file of result.files){cache.nonCyclicFiles.add(file)}}}return cache.sccs}function tarjanStrongConnect(file,state,options,depth){const{maxDepth,workspaceRoot,barrelExports,cache,resolverSettings}=options;if(depth>maxDepth){return}const enter=(node,nodeDepth)=>{state.indices.set(node,state.index);state.lowlinks.set(node,state.index);state.index++;state.stack.push(node);state.onStack.add(node);const imports=getFileImports(node,{workspaceRoot,barrelExports,cache,resolverSettings});const successors=[];for(const imp of imports){if(imp.dynamic||isErasedEdge(imp,options))continue;successors.push(imp.path)}return{file:node,depth:nodeDepth,successors,next:0}};const relax=(node,candidate)=>{state.lowlinks.set(node,Math.min(state.lowlinks.get(node),candidate))};const frames=[enter(file,depth)];while(frames.length>0){const frame=frames[frames.length-1];if(frame.next<frame.successors.length){const successor=frame.successors[frame.next++];if(!state.indices.has(successor)){if(frame.depth+1>maxDepth){relax(frame.file,0);continue}frames.push(enter(successor,frame.depth+1))}else if(state.onStack.has(successor)){relax(frame.file,state.indices.get(successor))}continue}frames.pop();const lowlink=state.lowlinks.get(frame.file);const index=state.indices.get(frame.file);if(lowlink===index){const scc=[];let w;do{w=state.stack.pop();state.onStack.delete(w);scc.push(w)}while(w!==frame.file);state.sccs.push(scc)}const parent=frames[frames.length-1];if(parent){relax(parent.file,state.lowlinks.get(frame.file))}}}function isFileInCycle(file,cache){const sccIndex=cache.sccIndex.get(file);if(sccIndex===void 0)return false;const scc=cache.sccs[sccIndex];return scc&&scc.hasCycle}function findShortestCyclePath(sourceFile,targetFile,options){const{workspaceRoot,barrelExports,cache,resolverSettings}=options;const maxDepth=options.maxDepth??Infinity;const srcSCC=cache.sccIndex.get(sourceFile);if(srcSCC===void 0)return null;const queue=[[targetFile]];const visited=new Set([targetFile]);while(queue.length>0){const path=queue.shift();if(path.length>maxDepth)break;const current=path[path.length-1];const imports=getFileImports(current,{workspaceRoot,barrelExports,cache,resolverSettings});for(const imp of imports){if(imp.dynamic||isErasedEdge(imp,options))continue;if(imp.path===sourceFile){return[...path,sourceFile]}if(visited.has(imp.path))continue;if(cache.sccIndex.get(imp.path)!==srcSCC)continue;visited.add(imp.path);queue.push([...path,imp.path])}}return null}function getCycleForFile(file,cache){const sccIndex=cache.sccIndex.get(file);if(sccIndex===void 0)return null;const scc=cache.sccs[sccIndex];if(!scc||!scc.hasCycle)return null;return scc.files}function isErasedEdge(imp,options){if(imp.typeOnly)return true;return Boolean(imp.inlineTypeOnly)&&!options.verbatimModuleSyntax}function detectCycleFromImport(sourceFile,targetFile,options){try{sourceFile=(0,node_fs_1.realpathSync)(sourceFile)}catch{}try{targetFile=(0,node_fs_1.realpathSync)(targetFile)}catch{}const{maxDepth,reportAllCycles,workspaceRoot,barrelExports,cache,resolverSettings}=options;if(cache.nonCyclicFiles.has(targetFile)){return[]}const allCycles=[];const pathStack=[sourceFile];let depthLimitHit=false;function dfs(file,depth,visited2){if(file===sourceFile){allCycles.push([...pathStack,file]);return}if(depth>=maxDepth){depthLimitHit=true;return}if(visited2.has(file))return;if(cache.nonCyclicFiles.has(file))return;visited2.add(file);pathStack.push(file);const imports=getFileImports(file,{workspaceRoot,barrelExports,cache,resolverSettings});for(const imp of imports){if(imp.dynamic)continue;if(!reportAllCycles&&allCycles.length>0)break;dfs(imp.path,depth+1,visited2)}pathStack.pop()}const visited=new Set;dfs(targetFile,1,visited);if(allCycles.length===0&&!depthLimitHit){cache.nonCyclicFiles.add(targetFile)}return allCycles}function findAllCircularDependencies(file,options,currentPath=[],depth=0,visited=new Set){const{maxDepth,reportAllCycles,workspaceRoot,barrelExports,cache,resolverSettings}=options;if(depth===0){try{file=(0,node_fs_1.realpathSync)(file)}catch{}}if(cache.nonCyclicFiles.has(file)){return[]}if(depth===0){computeSCCsFromFile(file,{maxDepth,workspaceRoot,barrelExports,cache,resolverSettings});if(!isFileInCycle(file,cache)){cache.nonCyclicFiles.add(file);return[]}}if(depth>maxDepth){return[]}if(currentPath.includes(file)){return[[...currentPath,file]]}if(visited.has(file)){return[]}visited.add(file);const imports=getFileImports(file,{workspaceRoot,barrelExports,cache,resolverSettings});const newPath=[...currentPath,file];const allCycles=[];for(const imp of imports){if(imp.dynamic){continue}if(!reportAllCycles&&allCycles.length>0){break}const cycles=findAllCircularDependencies(imp.path,options,newPath,depth+1,visited);allCycles.push(...cycles)}if(depth===0&&allCycles.length===0){cache.nonCyclicFiles.add(file)}return allCycles}function getMinimalCycle(cycle){if(cycle.length<2)return cycle;const seen=new Map;for(let i=0;i<cycle.length;i++){const file=cycle[i];if(seen.has(file)){const cycleStart=seen?.get?.(file);return cycle.slice(cycleStart,i+1)}seen.set(file,i)}return cycle}function getCycleHash(cycle){const minimalCycle=getMinimalCycle(cycle);const minIndex=minimalCycle.indexOf(minimalCycle.reduce((min,curr)=>curr<min?curr:min,minimalCycle[0]));const normalized=[...minimalCycle.slice(minIndex),...minimalCycle.slice(0,minIndex)];return normalized.join("->")}const CACHE_VERSION=1;const DEFAULT_CACHE_FILE="node_modules/.cache/forge-eslint/cycles.json";const DEFAULT_MAX_CACHE_AGE=24*60*60*1e3;function saveCacheToDisk(cache,options,workspaceRoot){if(!options.enabled)return;const cacheFile=(0,path_1.resolvePath)(workspaceRoot,options.cacheFile||DEFAULT_CACHE_FILE);const data={version:CACHE_VERSION,createdAt:Date.now(),fileHashes:Object.fromEntries(cache.fileHashes),sccs:cache.sccs,sccIndex:Object.fromEntries(cache.sccIndex),nonCyclicFiles:Array.from(cache.nonCyclicFiles),graphHash:cache.graphHash};const cacheDir=(0,path_1.getDirname)(cacheFile);if(!(0,fs_1.fileExistsSync)(cacheDir)){(0,fs_1.mkdirSync)(cacheDir,{recursive:true})}(0,fs_1.writeFileSync)(cacheFile,JSON.stringify(data),"utf-8")}function loadCacheFromDisk(cache,options,workspaceRoot){if(!options.enabled)return false;const cacheFile=(0,path_1.resolvePath)(workspaceRoot,options.cacheFile||DEFAULT_CACHE_FILE);if(!(0,fs_1.fileExistsSync)(cacheFile)){return false}const content=(0,fs_1.readFileSync)(cacheFile,"utf-8");if(content===null){return false}try{const data=JSON.parse(content);if(data.version!==CACHE_VERSION){return false}const maxAge=options.maxCacheAge??DEFAULT_MAX_CACHE_AGE;if(Date.now()-data.createdAt>maxAge){return false}cache.fileHashes=new Map(Object.entries(data.fileHashes));cache.sccs=data.sccs;cache.sccIndex=new Map(Object.entries(data.sccIndex).map(([k,v])=>[k,v]));cache.nonCyclicFiles=new Set(data.nonCyclicFiles);cache.graphHash=data.graphHash;cache.sccComputed=true;return true}catch{return false}}function getFilesNeedingReanalysis(files,cache,options){if(!options.enabled||!cache.sccComputed){return files}const changedFiles=[];for(const file of files){const cachedHash=cache.fileHashes.get(file);const currentHash=getFileHash(file);if(!cachedHash||cachedHash!==currentHash){changedFiles.push(file)}}if(changedFiles.length>0){const affectedSCCIndices=new Set;for(const file of changedFiles){const sccIndex=cache.sccIndex.get(file);if(sccIndex!==void 0){affectedSCCIndices.add(sccIndex)}}const affectedFiles=new Set(changedFiles);for(const scc of cache.sccs){const sccIndex=cache.sccIndex.get(scc.files[0]);if(sccIndex!==void 0&&affectedSCCIndices.has(sccIndex)){for(const file of scc.files){affectedFiles.add(file);cache.nonCyclicFiles.delete(file)}}}for(const[file,imports]of cache.dependencies){for(const imp of imports){if(changedFiles.includes(imp.path)){affectedFiles.add(file);cache.nonCyclicFiles.delete(file);break}}}return Array.from(affectedFiles)}return[]}function isIncrementalAvailable(cache,options){return Boolean(options?.enabled&&cache.sccComputed&&cache.sccs.length>0)}exports.PERFORMANCE_DOCS={algorithm:"Tarjan SCC + DFS hybrid",timeComplexity:"O(V + E)",spaceComplexity:"O(V)",guaranteedComplete:true};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.PERFORMANCE_DOCS=void 0;exports.clearExportKindCache=clearExportKindCache;exports.exportKindsOf=exportKindsOf;exports.createLRUCache=createLRUCache;exports.isDefinitelyExternal=isDefinitelyExternal;exports.createFileSystemCache=createFileSystemCache;exports.clearCache=clearCache;exports.invalidateSCCCache=invalidateSCCCache;exports.getFileHash=getFileHash;exports.isCacheValid=isCacheValid;exports.fileExists=fileExists;exports.patternToRegexWithCache=patternToRegexWithCache;exports.shouldIgnoreFileWithCache=shouldIgnoreFileWithCache;exports.resolveImportPath=resolveImportPath;exports.blankComments=blankComments;exports.getFileImports=getFileImports;exports.hasOnlyTypeImports=hasOnlyTypeImports;exports.computeSCCsFromFile=computeSCCsFromFile;exports.isFileInCycle=isFileInCycle;exports.findShortestCyclePath=findShortestCyclePath;exports.getCycleForFile=getCycleForFile;exports.detectCycleFromImport=detectCycleFromImport;exports.findAllCircularDependencies=findAllCircularDependencies;exports.getMinimalCycle=getMinimalCycle;exports.getCycleHash=getCycleHash;exports.saveCacheToDisk=saveCacheToDisk;exports.loadCacheFromDisk=loadCacheFromDisk;exports.getFilesNeedingReanalysis=getFilesNeedingReanalysis;exports.isIncrementalAvailable=isIncrementalAvailable;const resolver_1=require("./resolver");const node_fs_1=require("node:fs");const fs_1=require("../node/fs");const path_1=require("../node/path");const LRU_MAX_SIZE=5e4;const EXTERNAL_MODULE_PATTERNS=[/^node:/,/^[a-z@][^/]*$/,/node_modules/];const KNOWN_EXTERNAL_PACKAGES=new Set(["react","react-dom","vue","angular","svelte","lodash","underscore","ramda","rxjs","express","koa","fastify","hapi","axios","fetch","node-fetch","got","fs","path","url","http","https","crypto","util","os","child_process","typescript","eslint","prettier","jest","vitest","mocha","webpack","rollup","vite","esbuild","parcel"]);const IMPORT_REGEX=/import\s+(?:(?:(?!\bfrom\s+['"])[\w*{}\s,]|'[^'\n]*'|"[^"\n]*")+\s+from\s+)?['"]([^'"]+)['"]/g;const DYNAMIC_IMPORT_REGEX=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;const TYPE_IMPORT_REGEX=/import\s+type\s/;const EXPORT_FROM_REGEX=/export\s+\{[\s\S]*?\}\s+from\s+['"]([^'"]+)['"]/g;const BRACED_CLAUSE_ONLY=/^import\s+\{([^}]*)\}\s+from\s+['"]/;const INLINE_TYPE_BINDING=/^type\s+(?!as(?:\s|$))/;function importsOnlyInlineTypes(statement){const clause=BRACED_CLAUSE_ONLY.exec(statement);if(!clause)return false;const bindings=clause[1].split(",").map(binding=>binding.trim()).filter(Boolean);if(!bindings.length)return false;return bindings.every(binding=>INLINE_TYPE_BINDING.test(binding))}const EXPORT_ALL_REGEX=/export\s*\*\s*(?:as\s+[\w$]+\s+)?from\s+['"]([^'"]+)['"]/g;const TOP_LEVEL_REQUIRE_REGEX=/^(?:(?:const|let|var)\s+[\w${}\s,:]+=\s*|import\s+[\w$]+\s*=\s*)?require\s*\(\s*['"]([^'"]+)['"]\s*\)/gm;const exportKindCache=new Map;function clearExportKindCache(){exportKindCache.clear()}function exportKindsOf(target,resolve,visiting=new Set){const hit=exportKindCache.get(target);if(hit)return hit;const kinds=new Map;if(visiting.has(target))return kinds;visiting.add(target);const source=(0,fs_1.readFileSync)(target,"utf-8")??"";const set=(name,kind)=>{if(kinds.get(name)!=="value")kinds.set(name,kind)};for(const m of source.matchAll(/export\s+(?:declare\s+)?(?:abstract\s+)?(?:const|let|var|function|class|enum|namespace|module)\s+([A-Za-z_$][\w$]*)/g)){set(m[1],"value")}for(const m of source.matchAll(/export\s+(?:declare\s+)?(?:interface|type)\s+([A-Za-z_$][\w$]*)/g)){set(m[1],"type")}if(resolve){const local=new Map;for(const m of source.matchAll(/^(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:(const|let|var|function|class|enum|namespace|module)|(interface|type))\s+([A-Za-z_$][\w$]*)/gm)){if(local.get(m[3])!=="value")local.set(m[3],m[1]?"value":"type")}const kindIn=(from,name)=>{if(from===void 0)return local.get(name);const file=resolve(from,target);return file?exportKindsOf(file,resolve,visiting).get(name):void 0};for(const m of source.matchAll(/export\s+(type\s+)?\{([^}]*)\}(?:\s*from\s*['"]([^'"]+)['"])?/g)){for(const raw of m[2].split(",")){const spec=raw.trim();if(!spec)continue;const inlineType=/^type\s+(?!as(?:\s|$))/.test(spec);const[orig,alias]=spec.replace(/^type\s+(?!as(?:\s|$))/,"").split(/\s+as\s+/);const exported=(alias??orig).trim();const kind=m[1]||inlineType?"type":kindIn(m[3],orig.trim());if(kind)set(exported,kind)}}for(const m of source.matchAll(/export\s+(type\s+)?\*\s*from\s*['"]([^'"]+)['"]/g)){const file=resolve(m[2],target);if(!file)continue;for(const[name,kind]of exportKindsOf(file,resolve,visiting)){if(!kinds.has(name))kinds.set(name,m[1]?"type":kind)}}}visiting.delete(target);exportKindCache.set(target,kinds);return kinds}function importsOnlyTypesFrom(statement,target,resolve){const clause=BRACED_CLAUSE_ONLY.exec(statement);if(!clause)return false;const bindings=clause[1].split(",").map(binding=>binding.trim()).filter(Boolean);if(!bindings.length)return false;const kinds=exportKindsOf(target,resolve);return bindings.every(binding=>INLINE_TYPE_BINDING.test(binding)||kinds.get(binding.split(/\s+as\s+/)[0])==="type")}const DEFAULT_EXTENSIONS=[".ts",".tsx",".js",".jsx"];class LRUCache{cache=new Map;maxSize;constructor(maxSize=LRU_MAX_SIZE){this.maxSize=maxSize}get(key){const value=this.cache.get(key);if(value!==void 0){this.cache.delete(key);this.cache.set(key,value)}return value}set(key,value){if(this.cache.has(key)){this.cache.delete(key)}else if(this.cache.size>=this.maxSize){const firstKey=this.cache.keys().next().value;if(firstKey!==void 0){this.cache.delete(firstKey)}}this.cache.set(key,value)}has(key){return this.cache.has(key)}delete(key){return this.cache.delete(key)}clear(){this.cache.clear()}get size(){return this.cache.size}}function createLRUCache(maxSize=LRU_MAX_SIZE){return new LRUCache(maxSize)}function isDefinitelyExternal(importPath){const packageName=importPath.split("/")[0].replace(/^@[^/]+\//,"");if(KNOWN_EXTERNAL_PACKAGES.has(packageName)){return true}return EXTERNAL_MODULE_PATTERNS.some(pattern=>pattern.test(importPath))}function createFileSystemCache(){return{dependencies:new Map,fileExists:new Map,fileHashes:new Map,compiledPatterns:(0,path_1.createPatternCache)(),reportedCycles:new Set,sccIndex:new Map,sccs:[],sccComputed:false,graphHash:"",resolvedPaths:new Map,nonCyclicFiles:new Set,pendingCycleReports:new Map}}function clearCache(cache){cache.dependencies.clear();cache.fileExists.clear();cache.fileHashes.clear();cache.compiledPatterns.clear();cache.reportedCycles.clear();cache.sccIndex.clear();cache.sccs=[];cache.sccComputed=false;cache.graphHash="";cache.resolvedPaths=new Map;cache.nonCyclicFiles.clear();cache.pendingCycleReports.clear()}function invalidateSCCCache(cache){cache.sccIndex.clear();cache.sccs=[];cache.sccComputed=false;cache.nonCyclicFiles.clear()}function getFileHash(filePath){const stats=(0,fs_1.statSync)(filePath);if(!stats){return null}return`${stats.mtimeMs}-${stats.size}`}function isCacheValid(filePath,cache){const cachedHash=cache.fileHashes.get(filePath);if(!cachedHash)return false;const currentHash=getFileHash(filePath);return cachedHash===currentHash}function fileExists(filePath,cache){const cached=cache.fileExists.get(filePath);if(cached!==void 0){return cached}const exists=(0,fs_1.fileExistsSync)(filePath);cache.fileExists.set(filePath,exists);return exists}function patternToRegexWithCache(pattern,cache){return(0,path_1.patternToRegex)(pattern,cache.compiledPatterns)}function shouldIgnoreFileWithCache(file,patterns,cache){return(0,path_1.shouldIgnoreFile)(file,patterns,cache.compiledPatterns)}function resolveImportPath(importPath,options){const fromFile=options.fromFile;const extensions=options.extensions||DEFAULT_EXTENSIONS;const cache=options.cache;const resolverSettings=options.resolverSettings;if(isDefinitelyExternal(importPath)){if(!importPath.startsWith("@")){return null}}const isRelative=importPath.startsWith(".");if(!isRelative){const globalCached=cache.resolvedPaths.get(importPath);if(globalCached!==void 0){return globalCached}}const cacheKey=isRelative?`${fromFile}::${importPath}`:importPath;const cached=cache.resolvedPaths.get(cacheKey);if(cached!==void 0){return cached}let result=(0,resolver_1.resolveModule)(importPath,fromFile,{extensions,mainFields:["module","main"],resolverSettings});if(result&&!isRelative&&result.includes("node_modules")){try{const realPath=(0,node_fs_1.realpathSync)(result);if(realPath.includes("node_modules")){cache.resolvedPaths.set(cacheKey,null);return null}result=realPath}catch{cache.resolvedPaths.set(cacheKey,null);return null}}if(!result&&isRelative){result=(0,path_1.resolvePath)((0,path_1.getDirname)(fromFile),importPath)}cache.resolvedPaths.set(cacheKey,result);return result}const REGEX_AFTER_WORD=new Set(["return","typeof","case","do","else","in","of","void","delete","throw","new","yield","await","instanceof"]);function blankComments(source){if(!source.includes("/*")&&!source.includes("//"))return source;const n=source.length;const ranges=[];let prev="";let word="";function skipQuoted(from){const quote=source[from];let i=from+1;while(i<n&&source[i]!==quote&&source[i]!=="\n"){i+=source[i]==="\\"?2:1}return i+1}function skipRegex(from){let i=from+1;let inClass=false;while(i<n&&source[i]!=="\n"){const c=source[i];if(c==="\\")i++;else if(c==="[")inClass=true;else if(c==="]")inClass=false;else if(c==="/"&&!inClass)return i+1;i++}return i}function scanCode(from,inHole){let i=from;let depth=0;while(i<n){const c=source[i];const next=source[i+1];if(c==="/"&&next==="/"){const end=source.indexOf("\n",i);const stop=end===-1?n:end;ranges.push([i,stop]);i=stop}else if(c==="/"&&next==="*"){const end=source.indexOf("*/",i+2);const stop=end===-1?n:end+2;ranges.push([i,stop]);i=stop}else if(c==='"'||c==="'"){i=skipQuoted(i);prev=c;word=""}else if(c==="`"){i=scanTemplate(i+1);prev=c;word=""}else if(c==="/"&&("(,=:[!&|?{};+-*%<>~^".includes(prev)||REGEX_AFTER_WORD.has(word))){i=skipRegex(i);prev=")";word=""}else if(c==="}"&&inHole&&depth===0){return i}else{if(c==="{")depth++;else if(c==="}")depth--;if(!/\s/.test(c)){if(/[\w$]/.test(c))word=/[\w$]/.test(prev)?word+c:c;else word="";prev=c}i++}}return i}function scanTemplate(from){let i=from;while(i<n&&source[i]!=="`"){if(source[i]==="\\")i+=2;else if(source[i]==="$"&&source[i+1]==="{")i=scanCode(i+2,true)+1;else i++}return i+1}scanCode(0,false);let out="";let at=0;for(const[from,to]of ranges){out+=source.slice(at,from)+source.slice(from,to).replace(/[^\n]/g," ");at=to}return out+source.slice(at)}function getFileImports(file,options){const{workspaceRoot,barrelExports,cache,resolverSettings}=options;const cached=cache.dependencies.get(file);if(cached){return cached}const imports=[];try{if(!fileExists(file,cache)){return imports}const text=(0,fs_1.readFileSync)(file,"utf-8");if(text===null){return imports}const content=blankComments(text);const resolveOpts={fromFile:file,workspaceRoot,barrelExports,cache,extensions:DEFAULT_EXTENSIONS,resolverSettings};IMPORT_REGEX.lastIndex=0;DYNAMIC_IMPORT_REGEX.lastIndex=0;EXPORT_FROM_REGEX.lastIndex=0;let match;const seen=new Map;const pushImport=(importPath,dynamic=false,typeOnly=false,inlineTypeOnly=false)=>{const resolved=resolveImportPath(importPath,resolveOpts);if(!resolved||!fileExists(resolved,cache))return;if(cache.ignoreTarget?.(resolved))return;const existing=seen.get(resolved);if(existing){if(dynamic)return;if(!typeOnly&&!inlineTypeOnly){delete existing.typeOnly;delete existing.inlineTypeOnly}else if(inlineTypeOnly&&existing.typeOnly){delete existing.typeOnly;existing.inlineTypeOnly=true}return}const info={path:resolved,source:importPath};if(dynamic)info.dynamic=true;if(typeOnly)info.typeOnly=true;if(inlineTypeOnly)info.inlineTypeOnly=true;seen.set(resolved,info);imports.push(info)};while((match=IMPORT_REGEX.exec(content))!==null){const isTypeImport=/^import\s+type[\s{]/.test(match[0]);let inlineTypeOnly=false;if(!isTypeImport){const target=resolveImportPath(match[1],resolveOpts);inlineTypeOnly=importsOnlyInlineTypes(match[0])||target!==null&&importsOnlyTypesFrom(match[0],target,(spec,fromFile)=>resolveImportPath(spec,{...resolveOpts,fromFile}))}pushImport(match[1],false,isTypeImport,inlineTypeOnly)}while((match=EXPORT_FROM_REGEX.exec(content))!==null)pushImport(match[1]);EXPORT_ALL_REGEX.lastIndex=0;while((match=EXPORT_ALL_REGEX.exec(content))!==null)pushImport(match[1]);TOP_LEVEL_REQUIRE_REGEX.lastIndex=0;while((match=TOP_LEVEL_REQUIRE_REGEX.exec(content))!==null)pushImport(match[1]);while((match=DYNAMIC_IMPORT_REGEX.exec(content))!==null)pushImport(match[1],true);const hash=getFileHash(file);if(hash){const oldHash=cache.fileHashes.get(file);if(oldHash!==hash){invalidateSCCCache(cache)}cache.fileHashes.set(file,hash)}}catch{}cache.dependencies.set(file,imports);return imports}function hasOnlyTypeImports(cycle,cache){for(const file of cycle){if(!fileExists(file,cache))continue;const content=(0,fs_1.readFileSync)(file,"utf-8");if(content===null)return false;const hasRuntimeImport=!TYPE_IMPORT_REGEX.test(content)&&IMPORT_REGEX.test(content);IMPORT_REGEX.lastIndex=0;if(hasRuntimeImport){return false}}return true}function computeSCCsFromFile(startFile,options){try{startFile=(0,node_fs_1.realpathSync)(startFile)}catch{}const{workspaceRoot,barrelExports,cache,resolverSettings}=options;if(cache.sccComputed&&cache.sccs.length>0&&cache.sccIndex.has(startFile)){return cache.sccs}const state={index:0,stack:[],onStack:new Set,indices:new Map,lowlinks:new Map,sccs:[]};const visited=new Set;const filesToProcess=[startFile];while(filesToProcess.length>0){const file=filesToProcess.pop();if(visited.has(file))continue;visited.add(file);const imports=getFileImports(file,{workspaceRoot,barrelExports,cache,resolverSettings});for(const imp of imports){if(!imp.dynamic&&!isErasedEdge(imp,options)&&!visited.has(imp.path)){filesToProcess.push(imp.path)}}}for(const file of visited){if(!state.indices.has(file)){tarjanStrongConnect(file,state,options,0)}}const newResults=state.sccs.map(files=>({files,hasCycle:files.length>1}));const offset=cache.sccs.length;cache.sccs.push(...newResults);cache.sccComputed=true;for(let i=0;i<newResults.length;i++){for(const file of newResults[i].files){if(!cache.sccIndex.has(file)){cache.sccIndex.set(file,offset+i)}}}for(const result of newResults){if(result.hasCycle){for(const file of result.files){cache.nonCyclicFiles.delete(file)}}else{for(const file of result.files){cache.nonCyclicFiles.add(file)}}}return cache.sccs}function tarjanStrongConnect(file,state,options,depth){const{maxDepth,workspaceRoot,barrelExports,cache,resolverSettings}=options;if(depth>maxDepth){return}const enter=(node,nodeDepth)=>{state.indices.set(node,state.index);state.lowlinks.set(node,state.index);state.index++;state.stack.push(node);state.onStack.add(node);const imports=getFileImports(node,{workspaceRoot,barrelExports,cache,resolverSettings});const successors=[];for(const imp of imports){if(imp.dynamic||isErasedEdge(imp,options))continue;successors.push(imp.path)}return{file:node,depth:nodeDepth,successors,next:0}};const relax=(node,candidate)=>{state.lowlinks.set(node,Math.min(state.lowlinks.get(node),candidate))};const frames=[enter(file,depth)];while(frames.length>0){const frame=frames[frames.length-1];if(frame.next<frame.successors.length){const successor=frame.successors[frame.next++];if(!state.indices.has(successor)){if(frame.depth+1>maxDepth){relax(frame.file,0);continue}frames.push(enter(successor,frame.depth+1))}else if(state.onStack.has(successor)){relax(frame.file,state.indices.get(successor))}continue}frames.pop();const lowlink=state.lowlinks.get(frame.file);const index=state.indices.get(frame.file);if(lowlink===index){const scc=[];let w;do{w=state.stack.pop();state.onStack.delete(w);scc.push(w)}while(w!==frame.file);state.sccs.push(scc)}const parent=frames[frames.length-1];if(parent){relax(parent.file,state.lowlinks.get(frame.file))}}}function isFileInCycle(file,cache){const sccIndex=cache.sccIndex.get(file);if(sccIndex===void 0)return false;const scc=cache.sccs[sccIndex];return scc&&scc.hasCycle}function findShortestCyclePath(sourceFile,targetFile,options){const{workspaceRoot,barrelExports,cache,resolverSettings}=options;const maxDepth=options.maxDepth??Infinity;const srcSCC=cache.sccIndex.get(sourceFile);if(srcSCC===void 0)return null;const queue=[[targetFile]];const visited=new Set([targetFile]);while(queue.length>0){const path=queue.shift();if(path.length>maxDepth)break;const current=path[path.length-1];const imports=getFileImports(current,{workspaceRoot,barrelExports,cache,resolverSettings});for(const imp of imports){if(imp.dynamic||isErasedEdge(imp,options))continue;if(imp.path===sourceFile){return[...path,sourceFile]}if(visited.has(imp.path))continue;if(cache.sccIndex.get(imp.path)!==srcSCC)continue;visited.add(imp.path);queue.push([...path,imp.path])}}return null}function getCycleForFile(file,cache){const sccIndex=cache.sccIndex.get(file);if(sccIndex===void 0)return null;const scc=cache.sccs[sccIndex];if(!scc||!scc.hasCycle)return null;return scc.files}function isErasedEdge(imp,options){if(imp.typeOnly)return true;return Boolean(imp.inlineTypeOnly)&&!options.verbatimModuleSyntax}function detectCycleFromImport(sourceFile,targetFile,options){try{sourceFile=(0,node_fs_1.realpathSync)(sourceFile)}catch{}try{targetFile=(0,node_fs_1.realpathSync)(targetFile)}catch{}const{maxDepth,reportAllCycles,workspaceRoot,barrelExports,cache,resolverSettings}=options;if(cache.nonCyclicFiles.has(targetFile)){return[]}const allCycles=[];const pathStack=[sourceFile];let depthLimitHit=false;function dfs(file,depth,visited2){if(file===sourceFile){allCycles.push([...pathStack,file]);return}if(depth>=maxDepth){depthLimitHit=true;return}if(visited2.has(file))return;if(cache.nonCyclicFiles.has(file))return;visited2.add(file);pathStack.push(file);const imports=getFileImports(file,{workspaceRoot,barrelExports,cache,resolverSettings});for(const imp of imports){if(imp.dynamic)continue;if(!reportAllCycles&&allCycles.length>0)break;dfs(imp.path,depth+1,visited2)}pathStack.pop()}const visited=new Set;dfs(targetFile,1,visited);if(allCycles.length===0&&!depthLimitHit){cache.nonCyclicFiles.add(targetFile)}return allCycles}function findAllCircularDependencies(file,options,currentPath=[],depth=0,visited=new Set){const{maxDepth,reportAllCycles,workspaceRoot,barrelExports,cache,resolverSettings}=options;if(depth===0){try{file=(0,node_fs_1.realpathSync)(file)}catch{}}if(cache.nonCyclicFiles.has(file)){return[]}if(depth===0){computeSCCsFromFile(file,{maxDepth,workspaceRoot,barrelExports,cache,resolverSettings});if(!isFileInCycle(file,cache)){cache.nonCyclicFiles.add(file);return[]}}if(depth>maxDepth){return[]}if(currentPath.includes(file)){return[[...currentPath,file]]}if(visited.has(file)){return[]}visited.add(file);const imports=getFileImports(file,{workspaceRoot,barrelExports,cache,resolverSettings});const newPath=[...currentPath,file];const allCycles=[];for(const imp of imports){if(imp.dynamic){continue}if(!reportAllCycles&&allCycles.length>0){break}const cycles=findAllCircularDependencies(imp.path,options,newPath,depth+1,visited);allCycles.push(...cycles)}if(depth===0&&allCycles.length===0){cache.nonCyclicFiles.add(file)}return allCycles}function getMinimalCycle(cycle){if(cycle.length<2)return cycle;const seen=new Map;for(let i=0;i<cycle.length;i++){const file=cycle[i];if(seen.has(file)){const cycleStart=seen?.get?.(file);return cycle.slice(cycleStart,i+1)}seen.set(file,i)}return cycle}function getCycleHash(cycle){const minimalCycle=getMinimalCycle(cycle);const minIndex=minimalCycle.indexOf(minimalCycle.reduce((min,curr)=>curr<min?curr:min,minimalCycle[0]));const normalized=[...minimalCycle.slice(minIndex),...minimalCycle.slice(0,minIndex)];return normalized.join("->")}const CACHE_VERSION=1;const DEFAULT_CACHE_FILE="node_modules/.cache/forge-eslint/cycles.json";const DEFAULT_MAX_CACHE_AGE=24*60*60*1e3;function saveCacheToDisk(cache,options,workspaceRoot){if(!options.enabled)return;const cacheFile=(0,path_1.resolvePath)(workspaceRoot,options.cacheFile||DEFAULT_CACHE_FILE);const data={version:CACHE_VERSION,createdAt:Date.now(),fileHashes:Object.fromEntries(cache.fileHashes),sccs:cache.sccs,sccIndex:Object.fromEntries(cache.sccIndex),nonCyclicFiles:Array.from(cache.nonCyclicFiles),graphHash:cache.graphHash};const cacheDir=(0,path_1.getDirname)(cacheFile);if(!(0,fs_1.fileExistsSync)(cacheDir)){(0,fs_1.mkdirSync)(cacheDir,{recursive:true})}(0,fs_1.writeFileSync)(cacheFile,JSON.stringify(data),"utf-8")}function loadCacheFromDisk(cache,options,workspaceRoot){if(!options.enabled)return false;const cacheFile=(0,path_1.resolvePath)(workspaceRoot,options.cacheFile||DEFAULT_CACHE_FILE);if(!(0,fs_1.fileExistsSync)(cacheFile)){return false}const content=(0,fs_1.readFileSync)(cacheFile,"utf-8");if(content===null){return false}try{const data=JSON.parse(content);if(data.version!==CACHE_VERSION){return false}const maxAge=options.maxCacheAge??DEFAULT_MAX_CACHE_AGE;if(Date.now()-data.createdAt>maxAge){return false}cache.fileHashes=new Map(Object.entries(data.fileHashes));cache.sccs=data.sccs;cache.sccIndex=new Map(Object.entries(data.sccIndex).map(([k,v])=>[k,v]));cache.nonCyclicFiles=new Set(data.nonCyclicFiles);cache.graphHash=data.graphHash;cache.sccComputed=true;return true}catch{return false}}function getFilesNeedingReanalysis(files,cache,options){if(!options.enabled||!cache.sccComputed){return files}const changedFiles=[];for(const file of files){const cachedHash=cache.fileHashes.get(file);const currentHash=getFileHash(file);if(!cachedHash||cachedHash!==currentHash){changedFiles.push(file)}}if(changedFiles.length>0){const affectedSCCIndices=new Set;for(const file of changedFiles){const sccIndex=cache.sccIndex.get(file);if(sccIndex!==void 0){affectedSCCIndices.add(sccIndex)}}const affectedFiles=new Set(changedFiles);for(const scc of cache.sccs){const sccIndex=cache.sccIndex.get(scc.files[0]);if(sccIndex!==void 0&&affectedSCCIndices.has(sccIndex)){for(const file of scc.files){affectedFiles.add(file);cache.nonCyclicFiles.delete(file)}}}for(const[file,imports]of cache.dependencies){for(const imp of imports){if(changedFiles.includes(imp.path)){affectedFiles.add(file);cache.nonCyclicFiles.delete(file);break}}}return Array.from(affectedFiles)}return[]}function isIncrementalAvailable(cache,options){return Boolean(options?.enabled&&cache.sccComputed&&cache.sccs.length>0)}exports.PERFORMANCE_DOCS={algorithm:"Tarjan SCC + DFS hybrid",timeComplexity:"O(V + E)",spaceComplexity:"O(V)",guaranteedComplete:true};
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
* taxonomy contract keeps it in the SDK's plugin rather than in
|
|
34
34
|
* `browser-security`.
|
|
35
35
|
*/
|
|
36
|
-
import type { TSESLint, TSESTree } from '
|
|
36
|
+
import type { TSESLint, TSESTree } from '../types/estree/utils/index';
|
|
37
37
|
/** The opt-in both SDKs spell identically. */
|
|
38
38
|
export declare const BROWSER_ESCAPE_FLAG = "dangerouslyAllowBrowser";
|
|
39
39
|
export interface BrowserEscapeHatchRuleConfig {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* - a value is followed to where it is written, so `ssl: sslOptions` and
|
|
21
21
|
* `password: process.env.DB_PASSWORD || 'root'` are read, not skipped.
|
|
22
22
|
*/
|
|
23
|
-
import type { TSESTree } from '
|
|
23
|
+
import type { TSESTree } from '../types/estree/utils/index';
|
|
24
24
|
import { type Origin } from './driver-origin';
|
|
25
25
|
import { type ExtraEvidence } from './module-evidence';
|
|
26
26
|
import { type Env, type Value } from './value-follow';
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* the linter cannot read — is `'unknown'`, and the caller decides how much
|
|
26
26
|
* the call's own shape has to prove before it reports.
|
|
27
27
|
*/
|
|
28
|
-
import type { TSESTree } from '
|
|
28
|
+
import type { TSESTree } from '../types/estree/utils/index';
|
|
29
29
|
import { type Value } from './value-follow';
|
|
30
30
|
/** Where a value comes from, relative to one plugin's driver modules. */
|
|
31
31
|
export type Origin = 'ours' | 'foreign' | 'unknown';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
4
|
* MIT license that can be found in the LICENSE file.
|
|
5
5
|
*/
|
|
6
|
-
import type { TSESLint } from '
|
|
6
|
+
import type { TSESLint } from '../types/estree/utils/index';
|
|
7
7
|
/**
|
|
8
8
|
* Does this file declare itself machine-generated?
|
|
9
9
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TSESLint, TSESTree } from '
|
|
1
|
+
import type { TSESLint, TSESTree } from '../types/estree/utils/index';
|
|
2
2
|
import { type ConfigShape } from './connection-config';
|
|
3
3
|
/**
|
|
4
4
|
* Two ids because the fixes differ in shape.
|
|
@@ -84,8 +84,15 @@ export declare function staticStringValue(node: TSESTree.Node): string | undefin
|
|
|
84
84
|
* teaches people the rule cries wolf.
|
|
85
85
|
*/
|
|
86
86
|
export declare function isLiteralSecret(node: TSESTree.Node): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* The rule createHardcodedCredentialsRule returns, by a name plugins can reach through
|
|
89
|
+
* `@interlace/eslint-devkit`: a plugin's declarations then refer to this
|
|
90
|
+
* alias instead of to devkit's vendored typescript-eslint types.
|
|
91
|
+
*/
|
|
92
|
+
export type HardcodedCredentialsRule = TSESLint.RuleModule<HardcodedCredentialsMessageIds, [
|
|
93
|
+
]>;
|
|
87
94
|
/** Build a CWE-798 rule for one driver's connection surface. */
|
|
88
|
-
export declare function createHardcodedCredentialsRule(config: HardcodedCredentialsRuleConfig):
|
|
95
|
+
export declare function createHardcodedCredentialsRule(config: HardcodedCredentialsRuleConfig): HardcodedCredentialsRule;
|
|
89
96
|
/**
|
|
90
97
|
* The text a connection URL starts with: a string literal's value, or the
|
|
91
98
|
* head of a template up to its first hole. `mysql://root:s3cret@${host}/db`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TSESLint, TSESTree } from '
|
|
1
|
+
import type { TSESLint, TSESTree } from '../types/estree/utils/index';
|
|
2
2
|
import { type Env } from './value-follow';
|
|
3
3
|
/**
|
|
4
4
|
* Two ids because the shapes read differently at the call site, and a reader
|
|
@@ -75,5 +75,12 @@ export interface MassAssignmentRuleConfig {
|
|
|
75
75
|
* comes from (`request-source.ts`), never by what it is called.
|
|
76
76
|
*/
|
|
77
77
|
export declare function classifyPayload(node: TSESTree.Node, env: Env, isOurs?: (node: TSESTree.Node) => boolean): MassAssignmentMessageIds | false;
|
|
78
|
+
/**
|
|
79
|
+
* The rule createMassAssignmentRule returns, by a name plugins can reach through
|
|
80
|
+
* `@interlace/eslint-devkit`: a plugin's declarations then refer to this
|
|
81
|
+
* alias instead of to devkit's vendored typescript-eslint types.
|
|
82
|
+
*/
|
|
83
|
+
export type MassAssignmentRule = TSESLint.RuleModule<MassAssignmentMessageIds, [
|
|
84
|
+
]>;
|
|
78
85
|
/** Build a CWE-915 rule for one driver's write surface. */
|
|
79
|
-
export declare function createMassAssignmentRule(config: MassAssignmentRuleConfig):
|
|
86
|
+
export declare function createMassAssignmentRule(config: MassAssignmentRuleConfig): MassAssignmentRule;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
4
|
* MIT license that can be found in the LICENSE file.
|
|
5
5
|
*/
|
|
6
|
-
import type { TSESLint, TSESTree } from '
|
|
6
|
+
import type { TSESLint, TSESTree } from '../types/estree/utils/index';
|
|
7
7
|
/** A source whose messages are attacker-influenced, and which owns its own rule. */
|
|
8
8
|
export type MessageSource = 'websocket' | 'worker' | 'filereader' | 'postmessage';
|
|
9
9
|
/**
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
4
|
* MIT license that can be found in the LICENSE file.
|
|
5
5
|
*/
|
|
6
|
-
import type { TSESLint } from '
|
|
6
|
+
import type { TSESLint } from '../types/estree/utils/index';
|
|
7
7
|
/**
|
|
8
8
|
* Is this file machine-packed output rather than something a person edits?
|
|
9
9
|
*
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* Call the returned `listeners` directly with synthetic nodes and assert on
|
|
12
12
|
* the recorded `reports`.
|
|
13
13
|
*/
|
|
14
|
-
import type { TSESLint } from '
|
|
14
|
+
import type { TSESLint } from '../types/estree/utils/index';
|
|
15
15
|
/** Anything shaped like an ESLint rule module (`{ create(context) }`). */
|
|
16
16
|
export interface RuleLike {
|
|
17
17
|
create(context: never): Record<string, unknown>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
4
|
* MIT license that can be found in the LICENSE file.
|
|
5
5
|
*/
|
|
6
|
-
import type { TSESTree } from '
|
|
6
|
+
import type { TSESTree } from '../types/estree/utils/index';
|
|
7
7
|
/**
|
|
8
8
|
* Extra evidence a plugin accepts beyond an import.
|
|
9
9
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TSESLint, TSESTree } from '
|
|
1
|
+
import type { TSESLint, TSESTree } from '../types/estree/utils/index';
|
|
2
2
|
/**
|
|
3
3
|
* Two ids because the remediations are genuinely different.
|
|
4
4
|
*
|
|
@@ -126,5 +126,12 @@ export declare function calleeText(node: TSESTree.Node): string;
|
|
|
126
126
|
export declare function isExemptExpression(expr: TSESTree.Expression, identifierHelpers: readonly string[], tags: readonly string[]): boolean;
|
|
127
127
|
/** The matched name of a template tag: `sql` or `$queryRaw`. */
|
|
128
128
|
export declare function tagName(tag: TSESTree.Node): string | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* The rule createRawIdentifierRule returns, by a name plugins can reach through
|
|
131
|
+
* `@interlace/eslint-devkit`: a plugin's declarations then refer to this
|
|
132
|
+
* alias instead of to devkit's vendored typescript-eslint types.
|
|
133
|
+
*/
|
|
134
|
+
export type RawIdentifierRule = TSESLint.RuleModule<RawIdentifierMessageIds, [
|
|
135
|
+
]>;
|
|
129
136
|
/** Build a CWE-89 identifier-interpolation rule for one driver's template API. */
|
|
130
|
-
export declare function createRawIdentifierRule(config: RawIdentifierRuleConfig):
|
|
137
|
+
export declare function createRawIdentifierRule(config: RawIdentifierRuleConfig): RawIdentifierRule;
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* The property names are the frameworks' API (Express, Koa, Fastify, Lambda
|
|
27
27
|
* proxy events), not a guess about what a variable is called.
|
|
28
28
|
*/
|
|
29
|
-
import type { TSESTree } from '
|
|
29
|
+
import type { TSESTree } from '../types/estree/utils/index';
|
|
30
30
|
import { type Env } from './value-follow';
|
|
31
31
|
/** Is this name the runtime global — no binding in the file, or a TS lib one? */
|
|
32
32
|
export declare function isGlobal(node: TSESTree.Identifier, env: Env): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TSESLint, TSESTree } from '
|
|
1
|
+
import type { TSESLint, TSESTree } from '../types/estree/utils/index';
|
|
2
2
|
import { type ConfigShape } from './connection-config';
|
|
3
3
|
/** Message ids every rule built by this factory reports. */
|
|
4
4
|
export type RequireTlsMessageIds = 'tlsDisabled' | 'certificateValidationDisabled';
|
|
@@ -112,6 +112,12 @@ export declare function within(inner: TSESTree.Node, outer: TSESTree.Node): bool
|
|
|
112
112
|
* built in one statement and passed in another.
|
|
113
113
|
*/
|
|
114
114
|
export declare function inConnectionPosition(node: TSESTree.Literal | TSESTree.TemplateLiteral, connectionKeys: readonly string[], isDriverCallee: (callee: TSESTree.Node) => boolean): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* The rule createRequireTlsRule returns, by a name plugins can reach through
|
|
117
|
+
* `@interlace/eslint-devkit`: a plugin's declarations then refer to this
|
|
118
|
+
* alias instead of to devkit's vendored typescript-eslint types.
|
|
119
|
+
*/
|
|
120
|
+
export type RequireTlsRule = TSESLint.RuleModule<RequireTlsMessageIds, []>;
|
|
115
121
|
/**
|
|
116
122
|
* Build a CWE-319 rule for the given driver.
|
|
117
123
|
*
|
|
@@ -119,4 +125,4 @@ export declare function inConnectionPosition(node: TSESTree.Literal | TSESTree.T
|
|
|
119
125
|
* readable literal AND the object reads as a connection config. An unreadable
|
|
120
126
|
* value is a deliberate false negative.
|
|
121
127
|
*/
|
|
122
|
-
export declare function createRequireTlsRule(config: RequireTlsRuleConfig):
|
|
128
|
+
export declare function createRequireTlsRule(config: RequireTlsRuleConfig): RequireTlsRule;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
4
|
* MIT license that can be found in the LICENSE file.
|
|
5
5
|
*/
|
|
6
|
-
import type { TSESLint } from '
|
|
6
|
+
import type { TSESLint } from '../types/estree/utils/index';
|
|
7
7
|
/**
|
|
8
8
|
* Documentation URL resolver function type
|
|
9
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.docsUrlFor=exports.ESLintUtils=exports.createRule=void 0;exports.applyDefault=applyDefault;exports.isTestFilePath=isTestFilePath;exports.RuleCreator=RuleCreator;exports.createRuleCreator=createRuleCreator;exports.withCanonicalDocsUrls=withCanonicalDocsUrls;const generated_file_1=require("./generated-file");const minified_file_1=require("./minified-file");function isObjectNotArray(obj){return typeof obj==="object"&&obj!=null&&!Array.isArray(obj)}function deepMerge(first,second){const keys=new Set([...Object.keys(first),...Object.keys(second)]);return Object.fromEntries([...keys].map(key=>{const firstHasKey=key in first;const secondHasKey=key in second;const firstValue=first[key];const secondValue=second[key];if(firstHasKey&&secondHasKey){return[key,isObjectNotArray(firstValue)&&isObjectNotArray(secondValue)?deepMerge(firstValue,secondValue):secondValue]}return[key,firstHasKey?firstValue:secondValue]}))}function applyDefault(defaultOptions,userOptions){const options=structuredClone(defaultOptions);if(userOptions==null){return options}options.forEach((opt,i)=>{if(userOptions[i]!==void 0){const userOpt=userOptions[i];options[i]=isObjectNotArray(userOpt)&&isObjectNotArray(opt)?deepMerge(opt,userOpt):userOpt}});return options}const TEST_DIR_SEGMENTS=new Set(["__tests__","__test__","test","tests","spec","specs","e2e","__mocks__","mocks","fixtures","__fixtures__"]);const TEST_BASENAME=/\.(test|spec|fixture|mock|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.docsUrlFor=exports.ESLintUtils=exports.createRule=void 0;exports.applyDefault=applyDefault;exports.isTestFilePath=isTestFilePath;exports.RuleCreator=RuleCreator;exports.createRuleCreator=createRuleCreator;exports.withCanonicalDocsUrls=withCanonicalDocsUrls;const generated_file_1=require("./generated-file");const minified_file_1=require("./minified-file");function isObjectNotArray(obj){return typeof obj==="object"&&obj!=null&&!Array.isArray(obj)}function deepMerge(first,second){const keys=new Set([...Object.keys(first),...Object.keys(second)]);return Object.fromEntries([...keys].map(key=>{const firstHasKey=key in first;const secondHasKey=key in second;const firstValue=first[key];const secondValue=second[key];if(firstHasKey&&secondHasKey){return[key,isObjectNotArray(firstValue)&&isObjectNotArray(secondValue)?deepMerge(firstValue,secondValue):secondValue]}return[key,firstHasKey?firstValue:secondValue]}))}function applyDefault(defaultOptions,userOptions){const options=structuredClone(defaultOptions);if(userOptions==null){return options}options.forEach((opt,i)=>{if(userOptions[i]!==void 0){const userOpt=userOptions[i];options[i]=isObjectNotArray(userOpt)&&isObjectNotArray(opt)?deepMerge(opt,userOpt):userOpt}});return options}const TEST_DIR_SEGMENTS=new Set(["__tests__","__test__","test","tests","spec","specs","e2e","__mocks__","mocks","fixtures","__fixtures__"]);const TEST_BASENAME=/\.(?:(?:[a-z0-9]+[-_])?(?:test|spec)|fixture|mock|stories|story)\.[cm]?[jt]sx?$/;const TEST_DIR_SUFFIX=/[-_](tests?|specs?)$/;const TEST_SUPPORT_DIR=/^test(?:[-_]?(?:utils?|helpers?|support|data|doubles?|factories|fixtures?|setup))$|^testing$/i;function isTestFilePath(filename){if(!filename||filename==="<input>"||filename==="<text>")return false;const slash=Math.max(filename.lastIndexOf("/"),filename.lastIndexOf("\\"));if(TEST_BASENAME.test(filename.slice(slash+1)))return true;if(slash<0)return false;return filename.slice(0,slash).split(/[\\/]/).some(segment=>TEST_DIR_SEGMENTS.has(segment)||TEST_DIR_SUFFIX.test(segment)||TEST_SUPPORT_DIR.test(segment))}function createRuleInternal(rule){const{defaultOptions,meta,name}=rule;const{skipTestFiles,skipGeneratedFiles,skipMinifiedFiles}=rule;const resolvedDefaultOptions=defaultOptions??[];const skipsFile=context=>skipTestFiles&&isTestFilePath(context.filename)||skipGeneratedFiles&&(0,generated_file_1.isGeneratedFile)(context.sourceCode)||skipMinifiedFiles&&(0,minified_file_1.isMinifiedFile)(context.sourceCode);const module={defaultOptions:resolvedDefaultOptions,meta,name};const{createOnce}=rule;if(!createOnce){const{create}=rule;module.create=context=>skipsFile(context)?{}:create(context,applyDefault(resolvedDefaultOptions,context.options));return module}module.createOnce=raw=>{const context=raw;let options=resolvedDefaultOptions;const{before,...visitor}=createOnce(context,()=>options);return{...visitor,before(){if(skipsFile(context))return false;options=applyDefault(resolvedDefaultOptions,context.options);return before?.()}}};module.create=context=>{if(skipsFile(context))return{};const options=applyDefault(resolvedDefaultOptions,context.options);const{before,after,...visitor}=createOnce(context,()=>options);if(before?.()===false)return{};if(!after)return visitor;const exit=visitor["Program:exit"];return{...visitor,"Program:exit"(node){exit?.(node);after()}}};return module}function RuleCreator(urlCreator){return({meta,name,...rule})=>createRuleInternal({meta:{...meta,docs:{...meta.docs,url:urlCreator(name)}},name,...rule})}RuleCreator.withoutDocs=args=>createRuleInternal(args);function createRuleCreator(urlCreator){return RuleCreator(urlCreator)}exports.createRule=RuleCreator(()=>void 0);exports.ESLintUtils={RuleCreator,applyDefault};const PLUGIN_DOCS_CATEGORY={"plugin-anthropic-security":"security","plugin-gemini-security":"security","plugin-mcp-sdk-security":"security","plugin-supabase-security":"security","plugin-openai-security":"security","plugin-browser-security":"security","plugin-drizzle-security":"security","plugin-express-security":"security","plugin-jwt-security":"security","plugin-knex-security":"security","plugin-lambda-security":"security","plugin-mongodb-security":"security","plugin-mysql-security":"security","plugin-nestjs-security":"security","plugin-node-security":"security","plugin-postgresql-security":"security","plugin-prisma-security":"security","plugin-secure-coding":"security","plugin-sequelize-security":"security","plugin-sqlite-security":"security","plugin-typeorm-security":"security","plugin-vercel-ai-security":"security","plugin-cli-floor":"quality","plugin-conventions":"quality","plugin-import-next":"quality","plugin-maintainability":"quality","plugin-modernization":"quality","plugin-modularity":"quality","plugin-operability":"quality","plugin-react-a11y":"quality","plugin-react-features":"quality","plugin-reliability":"quality"};const docsUrlFor=(pluginSlug,ruleName)=>{const category=PLUGIN_DOCS_CATEGORY[pluginSlug];return category?`https://eslint.interlace.tools/docs/${category}/${pluginSlug}/rules/${ruleName}`:null};exports.docsUrlFor=docsUrlFor;function withCanonicalDocsUrls(pluginSlug,rules){if(!PLUGIN_DOCS_CATEGORY[pluginSlug]){console.warn(`[eslint-devkit] withCanonicalDocsUrls('${pluginSlug}'): slug is not registered in PLUGIN_DOCS_CATEGORY, so no rule in this plugin gets a meta.docs.url. Register it in packages/eslint-devkit/src/rule-creation/rule-creator.ts.`)}for(const name of Object.keys(rules)){const descriptor=Object.getOwnPropertyDescriptor(rules,name);const{get}=descriptor;if(get){Object.defineProperty(rules,name,{...descriptor,get(){const rule=get.call(this);stampDocsUrl(pluginSlug,name,rule);return rule}});continue}stampDocsUrl(pluginSlug,name,descriptor.value)}return rules}function stampDocsUrl(pluginSlug,name,rule){const docs=rule?.meta?.docs;if(!docs)return;const url=(0,exports.docsUrlFor)(pluginSlug,name);if(url)docs.url=url}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* The logic is shared because the three SDKs differ only in the module name,
|
|
22
22
|
* the option names, and the remediation copy.
|
|
23
23
|
*/
|
|
24
|
-
import type { TSESTree } from '
|
|
24
|
+
import type { TSESTree } from '../types/estree/utils/index';
|
|
25
25
|
export interface SdkApiKeyRuleConfig {
|
|
26
26
|
/** Rule id, e.g. `no-hardcoded-api-key`. */
|
|
27
27
|
ruleName: string;
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* given, or `undefined` — whenever a binding is reassigned, imported from a
|
|
32
32
|
* file it cannot see, or a parameter.
|
|
33
33
|
*/
|
|
34
|
-
import type { TSESLint, TSESTree } from '
|
|
34
|
+
import type { TSESLint, TSESTree } from '../types/estree/utils/index';
|
|
35
35
|
type SourceCode = Readonly<TSESLint.SourceCode>;
|
|
36
36
|
type Variable = TSESLint.Scope.Variable;
|
|
37
37
|
/** How many bindings a single question may follow before it gives up. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TSESLint } from '
|
|
1
|
+
import type { TSESLint } from '../types/estree/utils/index';
|
|
2
2
|
/** Message ids every rule built by this factory reports. */
|
|
3
3
|
export type SqlInjectionMessageIds = 'noUnsafeQuery' | 'unsafeTemplateLiteral';
|
|
4
4
|
/** A raw-SQL fragment sink: a method whose argument at `arg` is SQL text. */
|
|
@@ -132,6 +132,12 @@ export interface SqlInjectionRuleConfig {
|
|
|
132
132
|
}
|
|
133
133
|
/** Whether a string's static half reads as a SQL statement. */
|
|
134
134
|
export declare function looksLikeSqlStatement(text: string): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* The rule createSqlInjectionRule returns, by a name plugins can reach through
|
|
137
|
+
* `@interlace/eslint-devkit`: a plugin's declarations then refer to this
|
|
138
|
+
* alias instead of to devkit's vendored typescript-eslint types.
|
|
139
|
+
*/
|
|
140
|
+
export type SqlInjectionRule = TSESLint.RuleModule<SqlInjectionMessageIds, []>;
|
|
135
141
|
/**
|
|
136
142
|
* Build a CWE-89 rule for the given sinks and remediation copy.
|
|
137
143
|
*
|
|
@@ -141,4 +147,4 @@ export declare function looksLikeSqlStatement(text: string): boolean;
|
|
|
141
147
|
* itself; and either of those passed to a same-file helper that forwards the
|
|
142
148
|
* argument into a sink.
|
|
143
149
|
*/
|
|
144
|
-
export declare function createSqlInjectionRule(config: SqlInjectionRuleConfig):
|
|
150
|
+
export declare function createSqlInjectionRule(config: SqlInjectionRuleConfig): SqlInjectionRule;
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* the inbound request — `ORDER BY ${req.query.sort}` — not merely because it
|
|
19
19
|
* is unproven.
|
|
20
20
|
*/
|
|
21
|
-
import type { TSESTree } from '
|
|
21
|
+
import type { TSESTree } from '../types/estree/utils/index';
|
|
22
22
|
import { type Env } from './value-follow';
|
|
23
23
|
/** One interpolated value, with the SQL text written before it. */
|
|
24
24
|
export interface SqlHole {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
* Anything else — a parameter, request data, an unknown call — is unproven,
|
|
34
34
|
* and an unproven value in a raw SQL string is the finding.
|
|
35
35
|
*/
|
|
36
|
-
import type { TSESTree } from '
|
|
36
|
+
import type { TSESTree } from '../types/estree/utils/index';
|
|
37
37
|
import { type OriginClassifier } from './driver-origin';
|
|
38
38
|
import { type Value } from './value-follow';
|
|
39
39
|
export interface SqlSafetyOptions {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
4
|
* MIT license that can be found in the LICENSE file.
|
|
5
5
|
*/
|
|
6
|
-
import type { TSESLint, TSESTree } from '
|
|
6
|
+
import type { TSESLint, TSESTree } from '../types/estree/utils/index';
|
|
7
7
|
type SourceCode = Readonly<TSESLint.SourceCode>;
|
|
8
8
|
/**
|
|
9
9
|
* Configuration for one vendor's instantiation of the CWE-1427 detector.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TSESLint, TSESTree } from '
|
|
1
|
+
import type { TSESLint, TSESTree } from '../types/estree/utils/index';
|
|
2
2
|
import { type Env } from './value-follow';
|
|
3
3
|
/** Message ids every rule built by this factory reports. */
|
|
4
4
|
export type UnscopedMutationMessageIds = 'unscopedMutation' | 'explicitTruncate';
|
|
@@ -171,7 +171,14 @@ export declare function driverBindings(program: TSESTree.Program, modules: reado
|
|
|
171
171
|
* `this.db.delete(t)` → `db`, since `this` carries no name of its own.
|
|
172
172
|
*/
|
|
173
173
|
export declare function receiverBaseName(node: TSESTree.MemberExpression): string | undefined;
|
|
174
|
-
|
|
174
|
+
/**
|
|
175
|
+
* The rule createUnscopedMutationRule returns, by a name plugins can reach through
|
|
176
|
+
* `@interlace/eslint-devkit`: a plugin's declarations then refer to this
|
|
177
|
+
* alias instead of to devkit's vendored typescript-eslint types.
|
|
178
|
+
*/
|
|
179
|
+
export type UnscopedMutationRule = TSESLint.RuleModule<UnscopedMutationMessageIds, [
|
|
180
|
+
]>;
|
|
181
|
+
export declare function createUnscopedMutationRule(config: UnscopedMutationRuleConfig): UnscopedMutationRule;
|
|
175
182
|
/** Does this receiver chain begin by naming a table (`x('t')`, `x.from('t')`)? */
|
|
176
183
|
export declare function startsWithTable(receiver: TSESTree.Node): boolean;
|
|
177
184
|
/** Is `node` inside any of `functions`? */
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
4
|
* MIT license that can be found in the LICENSE file.
|
|
5
5
|
*/
|
|
6
|
-
import type { TSESLint, TSESTree } from '
|
|
6
|
+
import type { TSESLint, TSESTree } from '../types/estree/utils/index';
|
|
7
7
|
/** A parsed module on disk, with the scope analysis its own parser produced. */
|
|
8
8
|
export interface ModuleInfo {
|
|
9
9
|
readonly file: string;
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* }
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
import type { TSESTree, TSESLint } from '
|
|
28
|
+
import type { TSESTree, TSESLint } from '../types/estree/utils/index';
|
|
29
29
|
/**
|
|
30
30
|
* Common sanitization function names
|
|
31
31
|
* These functions are typically used to sanitize/escape user input
|