first commit
This commit is contained in:
1
node_modules/eslint-plugin-import-x/lib/utils/apply-default.d.ts
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/apply-default.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function applyDefault<User extends readonly unknown[], Default extends User>(defaultOptions: Readonly<Default>, userOptions: Readonly<User> | null): Default;
|
||||
18
node_modules/eslint-plugin-import-x/lib/utils/apply-default.js
generated
vendored
Normal file
18
node_modules/eslint-plugin-import-x/lib/utils/apply-default.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { deepMerge, isObjectNotArray } from './deep-merge.js';
|
||||
export function applyDefault(defaultOptions, userOptions) {
|
||||
const options = structuredClone(defaultOptions);
|
||||
if (userOptions == null) {
|
||||
return options;
|
||||
}
|
||||
for (const [i, opt] of options.entries()) {
|
||||
if (userOptions[i] !== undefined) {
|
||||
const userOpt = userOptions[i];
|
||||
options[i] =
|
||||
isObjectNotArray(userOpt) && isObjectNotArray(opt)
|
||||
? deepMerge(opt, userOpt)
|
||||
: userOpt;
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
//# sourceMappingURL=apply-default.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/apply-default.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/apply-default.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"apply-default.js","sourceRoot":"","sources":["../../src/utils/apply-default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAU7D,MAAM,UAAU,YAAY,CAI1B,cAAiC,EACjC,WAAkC;IAGlC,MAAM,OAAO,GAAG,eAAe,CAAC,cAAc,CAAuB,CAAA;IAErE,IAAI,WAAW,IAAI,IAAI,EAAE,CAAC;QACxB,OAAO,OAAO,CAAA;IAChB,CAAC;IAID,KAAK,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,IAAK,OAAqB,CAAC,OAAO,EAAE,EAAE,CAAC;QACxD,IAAI,WAAW,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;YACjC,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;YAC9B,OAAO,CAAC,CAAC,CAAC;gBACR,gBAAgB,CAAC,OAAO,CAAC,IAAI,gBAAgB,CAAC,GAAG,CAAC;oBAChD,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC;oBACzB,CAAC,CAAC,OAAO,CAAA;QACf,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/arraify.d.ts
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/arraify.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const arraify: <T>(value?: T | readonly T[]) => T[] | undefined;
|
||||
2
node_modules/eslint-plugin-import-x/lib/utils/arraify.js
generated
vendored
Normal file
2
node_modules/eslint-plugin-import-x/lib/utils/arraify.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export const arraify = (value) => value ? (Array.isArray(value) ? value : [value]) : undefined;
|
||||
//# sourceMappingURL=arraify.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/arraify.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/arraify.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"arraify.js","sourceRoot":"","sources":["../../src/utils/arraify.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,CAAI,KAAwB,EAAmB,EAAE,CACtE,KAAK,CAAC,CAAC,CAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAS,CAAC,CAAC,CAAC,SAAS,CAAA"}
|
||||
7
node_modules/eslint-plugin-import-x/lib/utils/create-rule.d.ts
generated
vendored
Normal file
7
node_modules/eslint-plugin-import-x/lib/utils/create-rule.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { ESLintUtils, TSESLint } from '@typescript-eslint/utils';
|
||||
export declare function RuleCreator<PluginDocs = unknown>(urlCreator: (ruleName: string) => string): <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, PluginDocs>>) => TSESLint.RuleModule<MessageIds, Options, PluginDocs>;
|
||||
export interface ImportXPluginDocs {
|
||||
category?: string;
|
||||
recommended?: true;
|
||||
}
|
||||
export declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, ImportXPluginDocs>>) => ESLintUtils.RuleModule<MessageIds, Options, ImportXPluginDocs, ESLintUtils.RuleListener>;
|
||||
28
node_modules/eslint-plugin-import-x/lib/utils/create-rule.js
generated
vendored
Normal file
28
node_modules/eslint-plugin-import-x/lib/utils/create-rule.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { applyDefault } from './apply-default.js';
|
||||
import { docsUrl } from './docs-url.js';
|
||||
export function RuleCreator(urlCreator) {
|
||||
return function createNamedRule({ meta, name, ...rule }) {
|
||||
return createRule_({
|
||||
meta: {
|
||||
...meta,
|
||||
docs: {
|
||||
...meta.docs,
|
||||
url: urlCreator(name),
|
||||
},
|
||||
},
|
||||
...rule,
|
||||
});
|
||||
};
|
||||
}
|
||||
function createRule_({ create, defaultOptions, meta, }) {
|
||||
return {
|
||||
create(context) {
|
||||
const optionsWithDefault = applyDefault(defaultOptions, context.options);
|
||||
return create(context, optionsWithDefault);
|
||||
},
|
||||
defaultOptions,
|
||||
meta,
|
||||
};
|
||||
}
|
||||
export const createRule = RuleCreator(docsUrl);
|
||||
//# sourceMappingURL=create-rule.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/create-rule.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/create-rule.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"create-rule.js","sourceRoot":"","sources":["../../src/utils/create-rule.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAQvC,MAAM,UAAU,WAAW,CACzB,UAAwC;IAIxC,OAAO,SAAS,eAAe,CAG7B,EACA,IAAI,EACJ,IAAI,EACJ,GAAG,IAAI,EAGR;QACC,OAAO,WAAW,CAAkC;YAClD,IAAI,EAAE;gBACJ,GAAG,IAAI;gBACP,IAAI,EAAE;oBACJ,GAAG,IAAI,CAAC,IAAI;oBACZ,GAAG,EAAE,UAAU,CAAC,IAAI,CAAC;iBACtB;aACF;YACD,GAAG,IAAI;SACR,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC;AAED,SAAS,WAAW,CAIlB,EACA,MAAM,EACN,cAAc,EACd,IAAI,GAGL;IACC,OAAO;QACL,MAAM,CACJ,OAA4D;YAE5D,MAAM,kBAAkB,GAAG,YAAY,CAAC,cAAc,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;YACxE,OAAO,MAAM,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAA;QAC5C,CAAC;QACD,cAAc;QACd,IAAI;KACL,CAAA;AACH,CAAC;AASD,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAoB,OAAO,CAAC,CAAA"}
|
||||
3
node_modules/eslint-plugin-import-x/lib/utils/declared-scope.d.ts
generated
vendored
Normal file
3
node_modules/eslint-plugin-import-x/lib/utils/declared-scope.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { TSESTree } from '@typescript-eslint/utils';
|
||||
import type { RuleContext } from '../types.js';
|
||||
export declare function declaredScope(context: RuleContext, node: TSESTree.Node, name: string): import("@typescript-eslint/scope-manager").ScopeType | undefined;
|
||||
6
node_modules/eslint-plugin-import-x/lib/utils/declared-scope.js
generated
vendored
Normal file
6
node_modules/eslint-plugin-import-x/lib/utils/declared-scope.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export function declaredScope(context, node, name) {
|
||||
const references = context.sourceCode.getScope(node).references;
|
||||
const reference = references.find(x => x.identifier.name === name);
|
||||
return reference?.resolved?.scope.type;
|
||||
}
|
||||
//# sourceMappingURL=declared-scope.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/declared-scope.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/declared-scope.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"declared-scope.js","sourceRoot":"","sources":["../../src/utils/declared-scope.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,aAAa,CAC3B,OAAoB,EACpB,IAAmB,EACnB,IAAY;IAEZ,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,UAAU,CAAA;IAC/D,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,KAAK,IAAI,CAAC,CAAA;IAClE,OAAO,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAA;AACxC,CAAC"}
|
||||
3
node_modules/eslint-plugin-import-x/lib/utils/deep-merge.d.ts
generated
vendored
Normal file
3
node_modules/eslint-plugin-import-x/lib/utils/deep-merge.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export type ObjectLike<T = unknown> = Record<string, T>;
|
||||
export declare function isObjectNotArray(obj: unknown): obj is ObjectLike;
|
||||
export declare function deepMerge(first?: ObjectLike, second?: ObjectLike): Record<string, unknown>;
|
||||
28
node_modules/eslint-plugin-import-x/lib/utils/deep-merge.js
generated
vendored
Normal file
28
node_modules/eslint-plugin-import-x/lib/utils/deep-merge.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
export function isObjectNotArray(obj) {
|
||||
return typeof obj === 'object' && obj != null && !Array.isArray(obj);
|
||||
}
|
||||
export 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];
|
||||
let value;
|
||||
if (firstHasKey && secondHasKey) {
|
||||
value =
|
||||
isObjectNotArray(firstValue) && isObjectNotArray(secondValue)
|
||||
? deepMerge(firstValue, secondValue)
|
||||
:
|
||||
secondValue;
|
||||
}
|
||||
else if (firstHasKey) {
|
||||
value = firstValue;
|
||||
}
|
||||
else {
|
||||
value = secondValue;
|
||||
}
|
||||
return [key, value];
|
||||
}));
|
||||
}
|
||||
//# sourceMappingURL=deep-merge.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/deep-merge.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/deep-merge.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"deep-merge.js","sourceRoot":"","sources":["../../src/utils/deep-merge.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,gBAAgB,CAAC,GAAY;IAC3C,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;AACtE,CAAC;AAUD,MAAM,UAAU,SAAS,CACvB,QAAoB,EAAE,EACtB,SAAqB,EAAE;IAGvB,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAErE,OAAO,MAAM,CAAC,WAAW,CACvB,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QAClB,MAAM,WAAW,GAAG,GAAG,IAAI,KAAK,CAAA;QAChC,MAAM,YAAY,GAAG,GAAG,IAAI,MAAM,CAAA;QAClC,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;QAC7B,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;QAE/B,IAAI,KAAK,CAAA;QACT,IAAI,WAAW,IAAI,YAAY,EAAE,CAAC;YAChC,KAAK;gBAEH,gBAAgB,CAAC,UAAU,CAAC,IAAI,gBAAgB,CAAC,WAAW,CAAC;oBAC3D,CAAC,CAAC,SAAS,CAAC,UAAU,EAAE,WAAW,CAAC;oBACpC,CAAC;wBACC,WAAW,CAAA;QACnB,CAAC;aAAM,IAAI,WAAW,EAAE,CAAC;YACvB,KAAK,GAAG,UAAU,CAAA;QACpB,CAAC;aAAM,CAAC;YACN,KAAK,GAAG,WAAW,CAAA;QACrB,CAAC;QACD,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACrB,CAAC,CAAC,CACH,CAAA;AACH,CAAC"}
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/docs-url.d.ts
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/docs-url.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const docsUrl: (ruleName: string, commitish?: string) => string;
|
||||
4
node_modules/eslint-plugin-import-x/lib/utils/docs-url.js
generated
vendored
Normal file
4
node_modules/eslint-plugin-import-x/lib/utils/docs-url.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { version } from '../meta.js';
|
||||
const repoUrl = 'https://github.com/un-ts/eslint-plugin-import-x';
|
||||
export const docsUrl = (ruleName, commitish = `v${version}`) => `${repoUrl}/blob/${commitish}/docs/rules/${ruleName}.md`;
|
||||
//# sourceMappingURL=docs-url.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/docs-url.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/docs-url.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"docs-url.js","sourceRoot":"","sources":["../../src/utils/docs-url.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,MAAM,OAAO,GAAG,iDAAiD,CAAA;AAEjE,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,QAAgB,EAAE,SAAS,GAAG,IAAI,OAAO,EAAE,EAAE,EAAE,CACrE,GAAG,OAAO,SAAS,SAAS,eAAe,QAAQ,KAAK,CAAA"}
|
||||
52
node_modules/eslint-plugin-import-x/lib/utils/export-map.d.ts
generated
vendored
Normal file
52
node_modules/eslint-plugin-import-x/lib/utils/export-map.d.ts
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
|
||||
import type * as commentParser from 'comment-parser';
|
||||
import type { ChildContext, DocStyle, ParseError, RuleContext } from '../types.js';
|
||||
export type DocStyleParsers = Record<DocStyle, (comments: TSESTree.Comment[]) => commentParser.Block | undefined>;
|
||||
export interface DeclarationMetadata {
|
||||
source: Pick<TSESTree.Literal, 'value' | 'loc'>;
|
||||
importedSpecifiers?: Set<string>;
|
||||
dynamic?: boolean;
|
||||
isOnlyImportingTypes?: boolean;
|
||||
}
|
||||
export interface ModuleNamespace {
|
||||
doc?: commentParser.Block;
|
||||
namespace?: ExportMap | null;
|
||||
}
|
||||
export interface ModuleImport {
|
||||
getter: () => ExportMap | null;
|
||||
declarations: Set<DeclarationMetadata>;
|
||||
}
|
||||
export declare class ExportMap {
|
||||
path: string;
|
||||
static for(context: ChildContext): ExportMap | null;
|
||||
static get(source: string, context: RuleContext): ExportMap | null;
|
||||
static parse(filepath: string, content: string, context: ChildContext): ExportMap | null;
|
||||
namespace: Map<string, ModuleNamespace>;
|
||||
reexports: Map<string, {
|
||||
local: string;
|
||||
getImport(): ExportMap | null;
|
||||
}>;
|
||||
dependencies: Set<() => ExportMap | null>;
|
||||
imports: Map<string, ModuleImport>;
|
||||
exports: Map<string, TSESTree.Identifier | TSESTree.ProgramStatement>;
|
||||
errors: ParseError[];
|
||||
parseGoal: 'ambiguous' | 'Module' | 'Script';
|
||||
visitorKeys: TSESLint.SourceCode.VisitorKeys | null;
|
||||
private mtime;
|
||||
doc: commentParser.Block | undefined;
|
||||
constructor(path: string);
|
||||
get hasDefault(): boolean;
|
||||
get size(): number;
|
||||
has(name: string): boolean;
|
||||
hasDeep(name: string): {
|
||||
found: boolean;
|
||||
path: ExportMap[];
|
||||
};
|
||||
get(name: string): ModuleNamespace | null | undefined;
|
||||
$forEach(callback: (value: ModuleNamespace | null | undefined, name: string, map: ExportMap) => void, thisArg?: unknown): void;
|
||||
reportErrors(context: RuleContext, declaration: {
|
||||
source: TSESTree.Literal | null;
|
||||
}): void;
|
||||
}
|
||||
export declare function recursivePatternCapture(pattern: TSESTree.Node, callback: (node: TSESTree.DestructuringPattern) => void): void;
|
||||
export declare function makeContextCacheKey(context: RuleContext | ChildContext): string;
|
||||
764
node_modules/eslint-plugin-import-x/lib/utils/export-map.js
generated
vendored
Normal file
764
node_modules/eslint-plugin-import-x/lib/utils/export-map.js
generated
vendored
Normal file
@@ -0,0 +1,764 @@
|
||||
import fs from 'node:fs';
|
||||
import debug from 'debug';
|
||||
import { SourceCode } from 'eslint';
|
||||
import { getTsconfigWithContext } from 'eslint-import-context';
|
||||
import { stableHash } from 'stable-hash-x';
|
||||
import { cjsRequire } from '../require.js';
|
||||
import { getValue } from './get-value.js';
|
||||
import { hasValidExtension, ignore } from './ignore.js';
|
||||
import { lazy, defineLazyProperty } from './lazy-value.js';
|
||||
import { parse } from './parse.js';
|
||||
import { relative, resolve } from './resolve.js';
|
||||
import { isMaybeUnambiguousModule, isUnambiguousModule } from './unambiguous.js';
|
||||
import { visit } from './visit.js';
|
||||
const log = debug('eslint-plugin-import-x:ExportMap');
|
||||
const exportCache = new Map();
|
||||
const declTypes = new Set([
|
||||
'VariableDeclaration',
|
||||
'ClassDeclaration',
|
||||
'TSDeclareFunction',
|
||||
'TSEnumDeclaration',
|
||||
'TSTypeAliasDeclaration',
|
||||
'TSInterfaceDeclaration',
|
||||
'TSAbstractClassDeclaration',
|
||||
'TSModuleDeclaration',
|
||||
]);
|
||||
const fixup = new Set(['deprecated', 'module']);
|
||||
let parseComment_;
|
||||
const parseComment = (comment) => {
|
||||
parseComment_ ??= cjsRequire('comment-parser').parse;
|
||||
const restored = `/**${comment.split(/\r?\n/).reduce((acc, line) => {
|
||||
line = line.trim();
|
||||
return line && line !== '*' ? acc + '\n ' + line : acc;
|
||||
}, '')}
|
||||
*/`;
|
||||
const [doc] = parseComment_(restored);
|
||||
return {
|
||||
...doc,
|
||||
tags: doc.tags.map(t => t.name && fixup.has(t.tag)
|
||||
? { ...t, description: `${t.name} ${t.description}` }
|
||||
: t),
|
||||
};
|
||||
};
|
||||
export class ExportMap {
|
||||
static for(context) {
|
||||
const filepath = context.path;
|
||||
const cacheKey = context.cacheKey;
|
||||
let exportMap = exportCache.get(cacheKey);
|
||||
const stats = lazy(() => fs.statSync(filepath));
|
||||
if (exportCache.has(cacheKey)) {
|
||||
const exportMap = exportCache.get(cacheKey);
|
||||
if (exportMap === null) {
|
||||
return null;
|
||||
}
|
||||
if (exportMap != null &&
|
||||
exportMap.mtime - stats().mtime.valueOf() === 0) {
|
||||
return exportMap;
|
||||
}
|
||||
}
|
||||
if (!hasValidExtension(filepath, context)) {
|
||||
exportCache.set(cacheKey, null);
|
||||
return null;
|
||||
}
|
||||
if (ignore(filepath, context, true)) {
|
||||
log('ignored path due to ignore settings:', filepath);
|
||||
exportCache.set(cacheKey, null);
|
||||
return null;
|
||||
}
|
||||
const content = fs.readFileSync(filepath, { encoding: 'utf8' });
|
||||
if (!isMaybeUnambiguousModule(content)) {
|
||||
log('ignored path due to unambiguous regex:', filepath);
|
||||
exportCache.set(cacheKey, null);
|
||||
return null;
|
||||
}
|
||||
log('cache miss', cacheKey, 'for path', filepath);
|
||||
exportMap = ExportMap.parse(filepath, content, context);
|
||||
if (exportMap === null) {
|
||||
log('ignored path due to ambiguous parse:', filepath);
|
||||
exportCache.set(cacheKey, null);
|
||||
return null;
|
||||
}
|
||||
exportMap.mtime = stats().mtime.valueOf();
|
||||
if (exportMap.visitorKeys) {
|
||||
exportCache.set(cacheKey, exportMap);
|
||||
}
|
||||
return exportMap;
|
||||
}
|
||||
static get(source, context) {
|
||||
const path = resolve(source, context);
|
||||
if (path == null) {
|
||||
return null;
|
||||
}
|
||||
return ExportMap.for(childContext(path, context));
|
||||
}
|
||||
static parse(filepath, content, context) {
|
||||
const m = new ExportMap(filepath);
|
||||
const tsconfig = lazy(() => getTsconfigWithContext(context));
|
||||
const isEsModuleInteropTrue = lazy(() => tsconfig()?.compilerOptions?.esModuleInterop ?? false);
|
||||
let ast;
|
||||
let visitorKeys;
|
||||
try {
|
||||
;
|
||||
({ ast, visitorKeys } = parse(filepath, content, context));
|
||||
}
|
||||
catch (error) {
|
||||
m.errors.push(error);
|
||||
return m;
|
||||
}
|
||||
m.visitorKeys = visitorKeys;
|
||||
let hasDynamicImports = false;
|
||||
function processDynamicImport(source) {
|
||||
hasDynamicImports = true;
|
||||
if (source.type !== 'Literal') {
|
||||
return null;
|
||||
}
|
||||
const p = remotePath(source.value);
|
||||
if (p == null) {
|
||||
return null;
|
||||
}
|
||||
const getter = thunkFor(p, context);
|
||||
m.imports.set(p, {
|
||||
getter,
|
||||
declarations: new Set([
|
||||
{
|
||||
source: {
|
||||
value: source.value,
|
||||
loc: source.loc,
|
||||
},
|
||||
importedSpecifiers: new Set(['ImportNamespaceSpecifier']),
|
||||
dynamic: true,
|
||||
},
|
||||
]),
|
||||
});
|
||||
}
|
||||
visit(ast, visitorKeys, {
|
||||
ImportExpression(node) {
|
||||
processDynamicImport(node.source);
|
||||
},
|
||||
CallExpression(_node) {
|
||||
const node = _node;
|
||||
if (node.callee.type === 'Import') {
|
||||
processDynamicImport(node.arguments[0]);
|
||||
}
|
||||
},
|
||||
});
|
||||
const unambiguouslyESM = lazy(() => isUnambiguousModule(ast));
|
||||
if (!hasDynamicImports && !unambiguouslyESM()) {
|
||||
return null;
|
||||
}
|
||||
const docStyles = (context.settings &&
|
||||
context.settings['import-x/docstyle']) || ['jsdoc'];
|
||||
const docStyleParsers = {};
|
||||
for (const style of docStyles) {
|
||||
docStyleParsers[style] = availableDocStyleParsers[style];
|
||||
}
|
||||
const namespaces = new Map();
|
||||
function remotePath(value) {
|
||||
return relative(value, filepath, context.settings, context);
|
||||
}
|
||||
function resolveImport(value) {
|
||||
const rp = remotePath(value);
|
||||
if (rp == null) {
|
||||
return null;
|
||||
}
|
||||
return ExportMap.for(childContext(rp, context));
|
||||
}
|
||||
function getNamespace(namespace) {
|
||||
if (!namespaces.has(namespace)) {
|
||||
return;
|
||||
}
|
||||
return function () {
|
||||
return resolveImport(namespaces.get(namespace));
|
||||
};
|
||||
}
|
||||
function addNamespace(object, identifier) {
|
||||
const nsfn = getNamespace(getValue(identifier));
|
||||
if (nsfn) {
|
||||
Object.defineProperty(object, 'namespace', { get: nsfn });
|
||||
}
|
||||
return object;
|
||||
}
|
||||
function processSpecifier(s, n, m) {
|
||||
const nsource = ('source' in n &&
|
||||
n.source &&
|
||||
n.source.value);
|
||||
const exportMeta = {};
|
||||
let local;
|
||||
switch (s.type) {
|
||||
case 'ExportDefaultSpecifier': {
|
||||
if (!nsource) {
|
||||
return;
|
||||
}
|
||||
local = 'default';
|
||||
break;
|
||||
}
|
||||
case 'ExportNamespaceSpecifier': {
|
||||
m.exports.set(s.exported.name, n);
|
||||
m.namespace.set(s.exported.name, Object.defineProperty(exportMeta, 'namespace', {
|
||||
get() {
|
||||
return resolveImport(nsource);
|
||||
},
|
||||
}));
|
||||
return;
|
||||
}
|
||||
case 'ExportAllDeclaration': {
|
||||
m.exports.set(getValue(s.exported), n);
|
||||
m.namespace.set(getValue(s.exported), addNamespace(exportMeta, s.exported));
|
||||
return;
|
||||
}
|
||||
case 'ExportSpecifier': {
|
||||
if (!('source' in n && n.source)) {
|
||||
m.exports.set(getValue(s.exported), n);
|
||||
m.namespace.set(getValue(s.exported), addNamespace(exportMeta, s.local));
|
||||
return;
|
||||
}
|
||||
}
|
||||
default: {
|
||||
if ('local' in s) {
|
||||
local = getValue(s.local);
|
||||
}
|
||||
else {
|
||||
throw new Error('Unknown export specifier type');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ('exported' in s) {
|
||||
m.reexports.set(getValue(s.exported), {
|
||||
local,
|
||||
getImport: () => resolveImport(nsource),
|
||||
});
|
||||
}
|
||||
}
|
||||
function captureDependencyWithSpecifiers(n) {
|
||||
const declarationIsType = 'importKind' in n &&
|
||||
(n.importKind === 'type' ||
|
||||
n.importKind === 'typeof');
|
||||
let specifiersOnlyImportingTypes = n.specifiers.length > 0;
|
||||
const importedSpecifiers = new Set();
|
||||
for (const specifier of n.specifiers) {
|
||||
if (specifier.type === 'ImportSpecifier') {
|
||||
importedSpecifiers.add(getValue(specifier.imported));
|
||||
}
|
||||
else if (supportedImportTypes.has(specifier.type)) {
|
||||
importedSpecifiers.add(specifier.type);
|
||||
}
|
||||
specifiersOnlyImportingTypes =
|
||||
specifiersOnlyImportingTypes &&
|
||||
'importKind' in specifier &&
|
||||
(specifier.importKind === 'type' ||
|
||||
specifier.importKind === 'typeof');
|
||||
}
|
||||
captureDependency(n, declarationIsType || specifiersOnlyImportingTypes, importedSpecifiers);
|
||||
}
|
||||
function captureDependency({ source, }, isOnlyImportingTypes, importedSpecifiers = new Set()) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
const p = remotePath(source.value);
|
||||
if (p == null) {
|
||||
return null;
|
||||
}
|
||||
const declarationMetadata = {
|
||||
source: {
|
||||
value: source.value,
|
||||
loc: source.loc,
|
||||
},
|
||||
isOnlyImportingTypes,
|
||||
importedSpecifiers,
|
||||
};
|
||||
const existing = m.imports.get(p);
|
||||
if (existing != null) {
|
||||
existing.declarations.add(declarationMetadata);
|
||||
return existing.getter;
|
||||
}
|
||||
const getter = thunkFor(p, context);
|
||||
m.imports.set(p, { getter, declarations: new Set([declarationMetadata]) });
|
||||
return getter;
|
||||
}
|
||||
const source = new SourceCode({ text: content, ast: ast });
|
||||
for (const n of ast.body) {
|
||||
if (n.type === 'ExportDefaultDeclaration') {
|
||||
const exportMeta = captureDoc(source, docStyleParsers, n);
|
||||
if (n.declaration.type === 'Identifier') {
|
||||
addNamespace(exportMeta, n.declaration);
|
||||
}
|
||||
m.exports.set('default', n);
|
||||
m.namespace.set('default', exportMeta);
|
||||
continue;
|
||||
}
|
||||
if (n.type === 'ExportAllDeclaration') {
|
||||
if (n.exported) {
|
||||
namespaces.set(n.exported.name, n.source.value);
|
||||
processSpecifier(n, n.exported, m);
|
||||
}
|
||||
else {
|
||||
const getter = captureDependency(n, n.exportKind === 'type');
|
||||
if (getter) {
|
||||
m.dependencies.add(getter);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (n.type === 'ImportDeclaration') {
|
||||
captureDependencyWithSpecifiers(n);
|
||||
const ns = n.specifiers.find(s => s.type === 'ImportNamespaceSpecifier');
|
||||
if (ns) {
|
||||
namespaces.set(ns.local.name, n.source.value);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (n.type === 'ExportNamedDeclaration') {
|
||||
captureDependencyWithSpecifiers(n);
|
||||
if (n.declaration != null) {
|
||||
switch (n.declaration.type) {
|
||||
case 'FunctionDeclaration':
|
||||
case 'ClassDeclaration':
|
||||
case 'TypeAlias':
|
||||
case 'InterfaceDeclaration':
|
||||
case 'DeclareFunction':
|
||||
case 'TSDeclareFunction':
|
||||
case 'TSEnumDeclaration':
|
||||
case 'TSTypeAliasDeclaration':
|
||||
case 'TSInterfaceDeclaration':
|
||||
case 'TSAbstractClassDeclaration':
|
||||
case 'TSModuleDeclaration': {
|
||||
m.exports.set(n.declaration.id.name, n);
|
||||
m.namespace.set(n.declaration.id.name, captureDoc(source, docStyleParsers, n));
|
||||
break;
|
||||
}
|
||||
case 'VariableDeclaration': {
|
||||
for (const d of n.declaration.declarations) {
|
||||
recursivePatternCapture(d.id, id => {
|
||||
m.exports.set(id.name, n);
|
||||
m.namespace.set(id.name, captureDoc(source, docStyleParsers, d, n));
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
}
|
||||
}
|
||||
for (const s of n.specifiers) {
|
||||
processSpecifier(s, n, m);
|
||||
}
|
||||
}
|
||||
const exports = ['TSExportAssignment'];
|
||||
if (isEsModuleInteropTrue()) {
|
||||
exports.push('TSNamespaceExportDeclaration');
|
||||
}
|
||||
if (exports.includes(n.type)) {
|
||||
const exportedName = n.type === 'TSNamespaceExportDeclaration'
|
||||
? (n.id ||
|
||||
n.name).name
|
||||
: ('expression' in n &&
|
||||
n.expression &&
|
||||
(('name' in n.expression && n.expression.name) ||
|
||||
('id' in n.expression &&
|
||||
n.expression.id &&
|
||||
n.expression.id.name))) ||
|
||||
null;
|
||||
const getRoot = (node) => {
|
||||
if (node.left.type === 'TSQualifiedName') {
|
||||
return getRoot(node.left);
|
||||
}
|
||||
return node.left;
|
||||
};
|
||||
const exportedDecls = ast.body.filter(node => {
|
||||
return (declTypes.has(node.type) &&
|
||||
(('id' in node &&
|
||||
node.id &&
|
||||
('name' in node.id
|
||||
? node.id.name === exportedName
|
||||
: 'left' in node.id &&
|
||||
getRoot(node.id).name === exportedName)) ||
|
||||
('declarations' in node &&
|
||||
node.declarations.find(d => 'name' in d.id && d.id.name === exportedName))));
|
||||
});
|
||||
if (exportedDecls.length === 0) {
|
||||
m.exports.set('default', n);
|
||||
m.namespace.set('default', captureDoc(source, docStyleParsers, n));
|
||||
continue;
|
||||
}
|
||||
if (isEsModuleInteropTrue() &&
|
||||
!m.namespace.has('default')) {
|
||||
m.exports.set('default', n);
|
||||
m.namespace.set('default', {});
|
||||
}
|
||||
for (const decl of exportedDecls) {
|
||||
if (decl.type === 'TSModuleDeclaration') {
|
||||
const type = decl.body?.type;
|
||||
if (type === 'TSModuleDeclaration') {
|
||||
m.exports.set(decl.body.id.name, n);
|
||||
m.namespace.set(decl.body.id.name, captureDoc(source, docStyleParsers, decl.body));
|
||||
continue;
|
||||
}
|
||||
else if (type === 'TSModuleBlock' && decl.kind === 'namespace') {
|
||||
const metadata = captureDoc(source, docStyleParsers, decl.body);
|
||||
if ('name' in decl.id) {
|
||||
m.namespace.set(decl.id.name, metadata);
|
||||
}
|
||||
else {
|
||||
m.namespace.set(decl.id.right.name, metadata);
|
||||
}
|
||||
}
|
||||
if (decl.body?.body) {
|
||||
for (const moduleBlockNode of decl.body.body) {
|
||||
const namespaceDecl = moduleBlockNode.type === 'ExportNamedDeclaration'
|
||||
? moduleBlockNode.declaration
|
||||
: moduleBlockNode;
|
||||
if (!namespaceDecl) {
|
||||
}
|
||||
else if (namespaceDecl.type === 'VariableDeclaration') {
|
||||
for (const d of namespaceDecl.declarations)
|
||||
recursivePatternCapture(d.id, id => {
|
||||
m.exports.set(id.name, n);
|
||||
m.namespace.set(id.name, captureDoc(source, docStyleParsers, decl, namespaceDecl, moduleBlockNode));
|
||||
});
|
||||
}
|
||||
else if ('id' in namespaceDecl) {
|
||||
m.exports.set(namespaceDecl.id.name, n);
|
||||
m.namespace.set(namespaceDecl.id.name, captureDoc(source, docStyleParsers, moduleBlockNode));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
m.exports.set('default', n);
|
||||
m.namespace.set('default', captureDoc(source, docStyleParsers, decl));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
defineLazyProperty(m, 'doc', () => {
|
||||
if (!ast.comments?.length) {
|
||||
return;
|
||||
}
|
||||
for (const c of ast.comments) {
|
||||
if (c.type !== 'Block') {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
const doc = parseComment(c.value);
|
||||
if (doc.tags.some(t => t.tag === 'module')) {
|
||||
return doc;
|
||||
}
|
||||
}
|
||||
catch {
|
||||
}
|
||||
}
|
||||
});
|
||||
if (isEsModuleInteropTrue() &&
|
||||
m.namespace.size > 0 &&
|
||||
!m.namespace.has('default')) {
|
||||
m.exports.set('default', ast.body[0]);
|
||||
m.namespace.set('default', {});
|
||||
}
|
||||
const prevParseGoal = m.parseGoal;
|
||||
defineLazyProperty(m, 'parseGoal', () => {
|
||||
if (prevParseGoal !== 'Module' && unambiguouslyESM()) {
|
||||
return 'Module';
|
||||
}
|
||||
return prevParseGoal;
|
||||
});
|
||||
return m;
|
||||
}
|
||||
constructor(path) {
|
||||
this.path = path;
|
||||
this.namespace = new Map();
|
||||
this.reexports = new Map();
|
||||
this.dependencies = new Set();
|
||||
this.imports = new Map();
|
||||
this.exports = new Map();
|
||||
this.errors = [];
|
||||
this.parseGoal = 'ambiguous';
|
||||
}
|
||||
get hasDefault() {
|
||||
return this.get('default') != null;
|
||||
}
|
||||
get size() {
|
||||
let size = this.namespace.size + this.reexports.size;
|
||||
for (const dep of this.dependencies) {
|
||||
const d = dep();
|
||||
if (d == null) {
|
||||
continue;
|
||||
}
|
||||
size += d.size;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
has(name) {
|
||||
if (this.namespace.has(name)) {
|
||||
return true;
|
||||
}
|
||||
if (this.reexports.has(name)) {
|
||||
return true;
|
||||
}
|
||||
if (name !== 'default') {
|
||||
for (const dep of this.dependencies) {
|
||||
const innerMap = dep();
|
||||
if (!innerMap) {
|
||||
continue;
|
||||
}
|
||||
if (innerMap.has(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
hasDeep(name) {
|
||||
if (this.namespace.has(name)) {
|
||||
return { found: true, path: [this] };
|
||||
}
|
||||
if (this.reexports.has(name)) {
|
||||
const reexports = this.reexports.get(name);
|
||||
const imported = reexports.getImport();
|
||||
if (imported == null) {
|
||||
return { found: true, path: [this] };
|
||||
}
|
||||
if (imported.path === this.path && reexports.local === name) {
|
||||
return { found: false, path: [this] };
|
||||
}
|
||||
const deep = imported.hasDeep(reexports.local);
|
||||
deep.path.unshift(this);
|
||||
return deep;
|
||||
}
|
||||
if (name !== 'default') {
|
||||
for (const dep of this.dependencies) {
|
||||
const innerMap = dep();
|
||||
if (innerMap == null) {
|
||||
return { found: true, path: [this] };
|
||||
}
|
||||
if (!innerMap) {
|
||||
continue;
|
||||
}
|
||||
if (innerMap.path === this.path) {
|
||||
continue;
|
||||
}
|
||||
const innerValue = innerMap.hasDeep(name);
|
||||
if (innerValue.found) {
|
||||
innerValue.path.unshift(this);
|
||||
return innerValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return { found: false, path: [this] };
|
||||
}
|
||||
get(name) {
|
||||
if (this.namespace.has(name)) {
|
||||
return this.namespace.get(name);
|
||||
}
|
||||
if (this.reexports.has(name)) {
|
||||
const reexports = this.reexports.get(name);
|
||||
const imported = reexports.getImport();
|
||||
if (imported == null) {
|
||||
return null;
|
||||
}
|
||||
if (imported.path === this.path && reexports.local === name) {
|
||||
return undefined;
|
||||
}
|
||||
return imported.get(reexports.local);
|
||||
}
|
||||
if (name !== 'default') {
|
||||
for (const dep of this.dependencies) {
|
||||
const innerMap = dep();
|
||||
if (!innerMap) {
|
||||
continue;
|
||||
}
|
||||
if (innerMap.path === this.path) {
|
||||
continue;
|
||||
}
|
||||
const innerValue = innerMap.get(name);
|
||||
if (innerValue !== undefined) {
|
||||
return innerValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$forEach(callback, thisArg) {
|
||||
for (const [n, v] of this.namespace.entries()) {
|
||||
callback.call(thisArg, v, n, this);
|
||||
}
|
||||
for (const [name, reexports] of this.reexports.entries()) {
|
||||
const reexported = reexports.getImport();
|
||||
callback.call(thisArg, reexported?.get(reexports.local), name, this);
|
||||
}
|
||||
this.dependencies.forEach(dep => {
|
||||
const d = dep();
|
||||
if (d == null) {
|
||||
return;
|
||||
}
|
||||
d.$forEach((v, n) => {
|
||||
if (n !== 'default') {
|
||||
callback.call(thisArg, v, n, this);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
reportErrors(context, declaration) {
|
||||
if (!declaration.source) {
|
||||
throw new Error('declaration.source is null');
|
||||
}
|
||||
const msg = this.errors
|
||||
.map(err => `${err.message} (${err.lineNumber}:${err.column})`)
|
||||
.join(', ');
|
||||
context.report({
|
||||
node: declaration.source,
|
||||
message: `Parse errors in imported module '${declaration.source.value}': ${msg}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
function captureDoc(source, docStyleParsers, ...nodes) {
|
||||
const metadata = {};
|
||||
defineLazyProperty(metadata, 'doc', () => {
|
||||
for (let i = 0, len = nodes.length; i < len; i++) {
|
||||
const n = nodes[i];
|
||||
if (!n) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
let leadingComments;
|
||||
if ('leadingComments' in n && Array.isArray(n.leadingComments)) {
|
||||
leadingComments = n.leadingComments;
|
||||
}
|
||||
else if (n.range) {
|
||||
leadingComments = source.getCommentsBefore(n);
|
||||
}
|
||||
if (!leadingComments || leadingComments.length === 0) {
|
||||
continue;
|
||||
}
|
||||
for (const parser of Object.values(docStyleParsers)) {
|
||||
const doc = parser(leadingComments);
|
||||
if (doc) {
|
||||
return doc;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
});
|
||||
return metadata;
|
||||
}
|
||||
const availableDocStyleParsers = {
|
||||
jsdoc: captureJsDoc,
|
||||
tomdoc: captureTomDoc,
|
||||
};
|
||||
function captureJsDoc(comments) {
|
||||
for (let i = comments.length - 1; i >= 0; i--) {
|
||||
const comment = comments[i];
|
||||
if (comment.type !== 'Block') {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
return parseComment(comment.value);
|
||||
}
|
||||
catch {
|
||||
}
|
||||
}
|
||||
}
|
||||
function captureTomDoc(comments) {
|
||||
const lines = [];
|
||||
for (const comment of comments) {
|
||||
if (/^\s*$/.test(comment.value)) {
|
||||
break;
|
||||
}
|
||||
lines.push(comment.value.trim());
|
||||
}
|
||||
const statusMatch = lines
|
||||
.join(' ')
|
||||
.match(/^(Public|Internal|Deprecated):\s*(.+)/);
|
||||
if (statusMatch) {
|
||||
return {
|
||||
description: statusMatch[2],
|
||||
tags: [
|
||||
{
|
||||
tag: statusMatch[1].toLowerCase(),
|
||||
description: statusMatch[2],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
const supportedImportTypes = new Set([
|
||||
'ImportDefaultSpecifier',
|
||||
'ImportNamespaceSpecifier',
|
||||
]);
|
||||
function thunkFor(p, context) {
|
||||
return () => ExportMap.for(childContext(p, context));
|
||||
}
|
||||
export function recursivePatternCapture(pattern, callback) {
|
||||
switch (pattern.type) {
|
||||
case 'Identifier': {
|
||||
callback(pattern);
|
||||
break;
|
||||
}
|
||||
case 'ObjectPattern': {
|
||||
for (const p of pattern.properties) {
|
||||
if (p.type === 'ExperimentalRestProperty' ||
|
||||
p.type === 'RestElement') {
|
||||
callback(p.argument);
|
||||
continue;
|
||||
}
|
||||
recursivePatternCapture(p.value, callback);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'ArrayPattern': {
|
||||
for (const element of pattern.elements) {
|
||||
if (element == null) {
|
||||
continue;
|
||||
}
|
||||
if (element.type === 'ExperimentalRestProperty' ||
|
||||
element.type === 'RestElement') {
|
||||
callback(element.argument);
|
||||
continue;
|
||||
}
|
||||
recursivePatternCapture(element, callback);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'AssignmentPattern': {
|
||||
callback(pattern.left);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
}
|
||||
}
|
||||
function childContext(path, context) {
|
||||
const { settings, parserOptions, parserPath, languageOptions, cwd, filename, physicalFilename, } = context;
|
||||
return {
|
||||
cacheKey: makeContextCacheKey(context) + '\0' + path,
|
||||
settings,
|
||||
parserOptions,
|
||||
parserPath,
|
||||
languageOptions,
|
||||
path,
|
||||
cwd,
|
||||
filename,
|
||||
physicalFilename,
|
||||
};
|
||||
}
|
||||
export function makeContextCacheKey(context) {
|
||||
const { settings, parserPath, parserOptions, languageOptions, cwd } = context;
|
||||
let hash = cwd +
|
||||
'\0' +
|
||||
stableHash(settings) +
|
||||
'\0' +
|
||||
stableHash(languageOptions?.parserOptions ?? parserOptions);
|
||||
if (languageOptions) {
|
||||
hash +=
|
||||
'\0' +
|
||||
String(languageOptions.ecmaVersion) +
|
||||
'\0' +
|
||||
String(languageOptions.sourceType);
|
||||
}
|
||||
hash +=
|
||||
'\0' +
|
||||
stableHash(parserPath ?? languageOptions?.parser?.meta ?? languageOptions?.parser);
|
||||
return hash;
|
||||
}
|
||||
//# sourceMappingURL=export-map.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/export-map.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/export-map.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/eslint-plugin-import-x/lib/utils/get-value.d.ts
generated
vendored
Normal file
2
node_modules/eslint-plugin-import-x/lib/utils/get-value.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { TSESTree } from '@typescript-eslint/types';
|
||||
export declare const getValue: (node: TSESTree.Identifier | TSESTree.StringLiteral) => string;
|
||||
15
node_modules/eslint-plugin-import-x/lib/utils/get-value.js
generated
vendored
Normal file
15
node_modules/eslint-plugin-import-x/lib/utils/get-value.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { TSESTree } from '@typescript-eslint/types';
|
||||
export const getValue = (node) => {
|
||||
switch (node.type) {
|
||||
case TSESTree.AST_NODE_TYPES.Identifier: {
|
||||
return node.name;
|
||||
}
|
||||
case TSESTree.AST_NODE_TYPES.Literal: {
|
||||
return node.value;
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Unsupported node type: ${node.type}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=get-value.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/get-value.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/get-value.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"get-value.js","sourceRoot":"","sources":["../../src/utils/get-value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAEnD,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,IAAkD,EAClD,EAAE;IACF,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;YACxC,OAAO,IAAI,CAAC,IAAI,CAAA;QAClB,CAAC;QACD,KAAK,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;YACrC,OAAO,IAAI,CAAC,KAAK,CAAA;QACnB,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,IAAI,KAAK,CAAC,0BAA2B,IAAsB,CAAC,IAAI,EAAE,CAAC,CAAA;QAC3E,CAAC;IACH,CAAC;AACH,CAAC,CAAA"}
|
||||
4
node_modules/eslint-plugin-import-x/lib/utils/ignore.d.ts
generated
vendored
Normal file
4
node_modules/eslint-plugin-import-x/lib/utils/ignore.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { ChildContext, FileExtension, PluginSettings, RuleContext } from '../types.js';
|
||||
export declare function getFileExtensions(settings: PluginSettings): Set<`.${string}`>;
|
||||
export declare function ignore(filepath: string, context: ChildContext | RuleContext, skipExtensionCheck?: boolean): boolean;
|
||||
export declare function hasValidExtension(filepath: string, context: ChildContext | RuleContext): filepath is `${string}${FileExtension}`;
|
||||
49
node_modules/eslint-plugin-import-x/lib/utils/ignore.js
generated
vendored
Normal file
49
node_modules/eslint-plugin-import-x/lib/utils/ignore.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
import path from 'node:path';
|
||||
import debug from 'debug';
|
||||
const log = debug('eslint-plugin-import-x:utils:ignore');
|
||||
let cachedSet;
|
||||
let lastSettings;
|
||||
function validExtensions(context) {
|
||||
if (cachedSet && context.settings === lastSettings) {
|
||||
return cachedSet;
|
||||
}
|
||||
lastSettings = context.settings;
|
||||
cachedSet = getFileExtensions(context.settings);
|
||||
return cachedSet;
|
||||
}
|
||||
export function getFileExtensions(settings) {
|
||||
const exts = new Set(settings['import-x/extensions'] || ['.js', '.mjs', '.cjs']);
|
||||
if ('import-x/parsers' in settings) {
|
||||
for (const parser in settings['import-x/parsers']) {
|
||||
const parserSettings = settings['import-x/parsers'][parser];
|
||||
if (!Array.isArray(parserSettings)) {
|
||||
throw new TypeError(`"settings" for ${parser} must be an array`);
|
||||
}
|
||||
for (const ext of parserSettings)
|
||||
exts.add(ext);
|
||||
}
|
||||
}
|
||||
return exts;
|
||||
}
|
||||
export function ignore(filepath, context, skipExtensionCheck = false) {
|
||||
if (!skipExtensionCheck && !hasValidExtension(filepath, context)) {
|
||||
return true;
|
||||
}
|
||||
const ignoreStrings = context.settings['import-x/ignore'];
|
||||
if (!ignoreStrings?.length) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0, len = ignoreStrings.length; i < len; i++) {
|
||||
const ignoreString = ignoreStrings[i];
|
||||
const regex = new RegExp(ignoreString);
|
||||
if (regex.test(filepath)) {
|
||||
log(`ignoring ${filepath}, matched pattern /${ignoreString}/`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
export function hasValidExtension(filepath, context) {
|
||||
return validExtensions(context).has(path.extname(filepath));
|
||||
}
|
||||
//# sourceMappingURL=ignore.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/ignore.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/ignore.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":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AG,KAAK;IAG1B,IAAI,CAAC,kBAAkB,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC;QACjE,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAA;IAEzD,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAA;IACd,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QACzD,MAAM,YAAY,GAAG,aAAa,CAAC,CAAC,CAAC,CAAA;QACrC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,CAAA;QACtC,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACzB,GAAG,CAAC,YAAY,QAAQ,sBAAsB,YAAY,GAAG,CAAC,CAAA;YAC9D,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,QAAgB,EAChB,OAAmC;IAEnC,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAkB,CAAC,CAAA;AAC9E,CAAC"}
|
||||
3
node_modules/eslint-plugin-import-x/lib/utils/import-declaration.d.ts
generated
vendored
Normal file
3
node_modules/eslint-plugin-import-x/lib/utils/import-declaration.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { TSESTree } from '@typescript-eslint/utils';
|
||||
import type { RuleContext } from '../types.js';
|
||||
export declare const importDeclaration: (context: RuleContext, node: TSESTree.ImportDefaultSpecifier) => TSESTree.ImportDeclaration;
|
||||
9
node_modules/eslint-plugin-import-x/lib/utils/import-declaration.js
generated
vendored
Normal file
9
node_modules/eslint-plugin-import-x/lib/utils/import-declaration.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
||||
export const importDeclaration = (context, node) => {
|
||||
if (node.parent && node.parent.type === AST_NODE_TYPES.ImportDeclaration) {
|
||||
return node.parent;
|
||||
}
|
||||
const ancestors = context.sourceCode.getAncestors(node);
|
||||
return ancestors[ancestors.length - 1];
|
||||
};
|
||||
//# sourceMappingURL=import-declaration.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/import-declaration.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/import-declaration.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"import-declaration.js","sourceRoot":"","sources":["../../src/utils/import-declaration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAKzD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,OAAoB,EACpB,IAAqC,EACrC,EAAE;IACF,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC,iBAAiB,EAAE,CAAC;QACzE,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IACD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IACvD,OAAO,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAA+B,CAAA;AACtE,CAAC,CAAA"}
|
||||
10
node_modules/eslint-plugin-import-x/lib/utils/import-type.d.ts
generated
vendored
Normal file
10
node_modules/eslint-plugin-import-x/lib/utils/import-type.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { LiteralNodeValue, PluginSettings, RuleContext } from '../types.js';
|
||||
export declare function isAbsolute(name?: LiteralNodeValue): boolean;
|
||||
export declare function isBuiltIn(name: string, settings: PluginSettings, modulePath?: string | null): boolean;
|
||||
export declare function isExternalModule(name: string, modulePath: string, context: RuleContext): boolean;
|
||||
export declare function isExternalModuleMain(name: string, modulePath: string, context: RuleContext): boolean;
|
||||
export declare function isScoped(name: string): boolean;
|
||||
export declare function isScopedMain(name: string): boolean;
|
||||
export declare function isExternalLookingName(name: string): boolean;
|
||||
export declare function importType(name: LiteralNodeValue, context: RuleContext): "internal" | "absolute" | "builtin" | "parent" | "index" | "sibling" | "external" | "unknown";
|
||||
export type ImportType = ReturnType<typeof importType>;
|
||||
128
node_modules/eslint-plugin-import-x/lib/utils/import-type.js
generated
vendored
Normal file
128
node_modules/eslint-plugin-import-x/lib/utils/import-type.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
import { isBuiltin } from 'node:module';
|
||||
import path from 'node:path';
|
||||
import { getContextPackagePath } from './package-path.js';
|
||||
import { resolve } from './resolve.js';
|
||||
function baseModule(name) {
|
||||
if (isScoped(name)) {
|
||||
const [scope, pkg] = name.split('/');
|
||||
return `${scope}/${pkg}`;
|
||||
}
|
||||
const [pkg] = name.split('/');
|
||||
return pkg;
|
||||
}
|
||||
function isInternalRegexMatch(name, settings) {
|
||||
const internalScope = settings?.['import-x/internal-regex'];
|
||||
return internalScope && new RegExp(internalScope).test(name);
|
||||
}
|
||||
export function isAbsolute(name) {
|
||||
return typeof name === 'string' && path.isAbsolute(name);
|
||||
}
|
||||
export function isBuiltIn(name, settings, modulePath) {
|
||||
if (modulePath || !name) {
|
||||
return false;
|
||||
}
|
||||
const base = baseModule(name);
|
||||
const extras = (settings && settings['import-x/core-modules']) || [];
|
||||
return isBuiltin(base) || extras.includes(base);
|
||||
}
|
||||
export function isExternalModule(name, modulePath, context) {
|
||||
return ((isModule(name) || isScoped(name)) &&
|
||||
typeTest(name, context, modulePath) === 'external');
|
||||
}
|
||||
export function isExternalModuleMain(name, modulePath, context) {
|
||||
if (arguments.length < 3) {
|
||||
throw new TypeError('isExternalModule: name, path, and context are all required');
|
||||
}
|
||||
return (isModuleMain(name) && typeTest(name, context, modulePath) === 'external');
|
||||
}
|
||||
const moduleRegExp = /^\w/;
|
||||
function isModule(name) {
|
||||
return !!name && moduleRegExp.test(name);
|
||||
}
|
||||
const moduleMainRegExp = /^\w((?!\/).)*$/;
|
||||
function isModuleMain(name) {
|
||||
return !!name && moduleMainRegExp.test(name);
|
||||
}
|
||||
const scopedRegExp = /^@[^/]+\/?[^/]+/;
|
||||
export function isScoped(name) {
|
||||
return !!name && scopedRegExp.test(name);
|
||||
}
|
||||
const scopedMainRegExp = /^@[^/]+\/?[^/]+$/;
|
||||
export function isScopedMain(name) {
|
||||
return !!name && scopedMainRegExp.test(name);
|
||||
}
|
||||
function isRelativeToParent(name) {
|
||||
return /^\.\.$|^\.\.[/\\]/.test(name);
|
||||
}
|
||||
const indexFiles = new Set(['.', './', './index', './index.js']);
|
||||
function isIndex(name) {
|
||||
return indexFiles.has(name);
|
||||
}
|
||||
function isRelativeToSibling(name) {
|
||||
return /^\.[/\\]/.test(name);
|
||||
}
|
||||
function isExternalPath(filepath, context) {
|
||||
if (!filepath) {
|
||||
return false;
|
||||
}
|
||||
const { settings } = context;
|
||||
const packagePath = getContextPackagePath(context);
|
||||
if (path.relative(packagePath, filepath).startsWith('..')) {
|
||||
return true;
|
||||
}
|
||||
const folders = settings?.['import-x/external-module-folders'] || [
|
||||
'node_modules',
|
||||
];
|
||||
return folders.some(folder => {
|
||||
const folderPath = path.resolve(packagePath, folder);
|
||||
const relativePath = path.relative(folderPath, filepath);
|
||||
return !relativePath.startsWith('..');
|
||||
});
|
||||
}
|
||||
function isInternalPath(filepath, context) {
|
||||
if (!filepath) {
|
||||
return false;
|
||||
}
|
||||
const packagePath = getContextPackagePath(context);
|
||||
return !path.relative(packagePath, filepath).startsWith('../');
|
||||
}
|
||||
export function isExternalLookingName(name) {
|
||||
return isModule(name) || isScoped(name);
|
||||
}
|
||||
function typeTest(name, context, path) {
|
||||
const { settings } = context;
|
||||
if (typeof name === 'string') {
|
||||
if (isInternalRegexMatch(name, settings)) {
|
||||
return 'internal';
|
||||
}
|
||||
if (isAbsolute(name)) {
|
||||
return 'absolute';
|
||||
}
|
||||
if (isBuiltIn(name, settings, path)) {
|
||||
return 'builtin';
|
||||
}
|
||||
if (isRelativeToParent(name)) {
|
||||
return 'parent';
|
||||
}
|
||||
if (isIndex(name)) {
|
||||
return 'index';
|
||||
}
|
||||
if (isRelativeToSibling(name)) {
|
||||
return 'sibling';
|
||||
}
|
||||
}
|
||||
if (isExternalPath(path, context)) {
|
||||
return 'external';
|
||||
}
|
||||
if (isInternalPath(path, context)) {
|
||||
return 'internal';
|
||||
}
|
||||
if (typeof name === 'string' && isExternalLookingName(name)) {
|
||||
return 'external';
|
||||
}
|
||||
return 'unknown';
|
||||
}
|
||||
export function importType(name, context) {
|
||||
return typeTest(name, context, typeof name === 'string' ? resolve(name, context) : null);
|
||||
}
|
||||
//# sourceMappingURL=import-type.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/import-type.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/import-type.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"import-type.js","sourceRoot":"","sources":["../../src/utils/import-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,IAAI,MAAM,WAAW,CAAA;AAI5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAetC,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACnB,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACpC,OAAO,GAAG,KAAK,IAAI,GAAG,EAAE,CAAA;IAC1B,CAAC;IACD,MA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,CAAC"}
|
||||
30
node_modules/eslint-plugin-import-x/lib/utils/index.d.ts
generated
vendored
Normal file
30
node_modules/eslint-plugin-import-x/lib/utils/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
export { pluginName } from 'eslint-import-context';
|
||||
export type { PluginName, LegacyResolverName, LegacyResolverResolveImport, LegacyResolverResolve, LegacyResolver, LegacyResolverObject, LegacyResolverRecord, LegacyImportResolver, } from 'eslint-import-context';
|
||||
export * from './apply-default.js';
|
||||
export * from './arraify.js';
|
||||
export * from './create-rule.js';
|
||||
export * from './declared-scope.js';
|
||||
export * from './deep-merge.js';
|
||||
export * from './docs-url.js';
|
||||
export * from './export-map.js';
|
||||
export * from './get-value.js';
|
||||
export * from './ignore.js';
|
||||
export * from './import-declaration.js';
|
||||
export * from './import-type.js';
|
||||
export * from './module-cache.js';
|
||||
export * from './module-require.js';
|
||||
export * from './module-visitor.js';
|
||||
export * from './npm-client.js';
|
||||
export * from './lazy-value.js';
|
||||
export * from './legacy-resolver-settings.js';
|
||||
export * from './package-path.js';
|
||||
export * from './parse.js';
|
||||
export * from './parse-path.js';
|
||||
export * from './pkg-dir.js';
|
||||
export * from './pkg-up.js';
|
||||
export * from './read-pkg-up.js';
|
||||
export * from './resolve.js';
|
||||
export * from './source-type.js';
|
||||
export * from './static-require.js';
|
||||
export * from './unambiguous.js';
|
||||
export * from './visit.js';
|
||||
30
node_modules/eslint-plugin-import-x/lib/utils/index.js
generated
vendored
Normal file
30
node_modules/eslint-plugin-import-x/lib/utils/index.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
export { pluginName } from 'eslint-import-context';
|
||||
export * from './apply-default.js';
|
||||
export * from './arraify.js';
|
||||
export * from './create-rule.js';
|
||||
export * from './declared-scope.js';
|
||||
export * from './deep-merge.js';
|
||||
export * from './docs-url.js';
|
||||
export * from './export-map.js';
|
||||
export * from './get-value.js';
|
||||
export * from './ignore.js';
|
||||
export * from './import-declaration.js';
|
||||
export * from './import-type.js';
|
||||
export * from './module-cache.js';
|
||||
export * from './module-require.js';
|
||||
export * from './module-visitor.js';
|
||||
export * from './npm-client.js';
|
||||
export * from './lazy-value.js';
|
||||
export * from './legacy-resolver-settings.js';
|
||||
export * from './package-path.js';
|
||||
export * from './parse.js';
|
||||
export * from './parse-path.js';
|
||||
export * from './pkg-dir.js';
|
||||
export * from './pkg-up.js';
|
||||
export * from './read-pkg-up.js';
|
||||
export * from './resolve.js';
|
||||
export * from './source-type.js';
|
||||
export * from './static-require.js';
|
||||
export * from './unambiguous.js';
|
||||
export * from './visit.js';
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/index.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAYlD,cAAc,oBAAoB,CAAA;AAClC,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,yBAAyB,CAAA;AACvC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,+BAA+B,CAAA;AAC7C,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA"}
|
||||
3
node_modules/eslint-plugin-import-x/lib/utils/lazy-value.d.ts
generated
vendored
Normal file
3
node_modules/eslint-plugin-import-x/lib/utils/lazy-value.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare const lazy: <T>(cb: () => T) => LazyValue<T>;
|
||||
export type LazyValue<T> = () => Readonly<T>;
|
||||
export declare function defineLazyProperty<ObjectType, PropertyNameType extends string, PropertyValueType>(object: ObjectType, propertyName: PropertyNameType, valueGetter: () => PropertyValueType): ObjectType;
|
||||
32
node_modules/eslint-plugin-import-x/lib/utils/lazy-value.js
generated
vendored
Normal file
32
node_modules/eslint-plugin-import-x/lib/utils/lazy-value.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
export const lazy = (cb) => {
|
||||
let isCalled = false;
|
||||
let result;
|
||||
return (() => {
|
||||
if (!isCalled) {
|
||||
isCalled = true;
|
||||
result = cb();
|
||||
}
|
||||
return result;
|
||||
});
|
||||
};
|
||||
export function defineLazyProperty(object, propertyName, valueGetter) {
|
||||
const define = (value) => Object.defineProperty(object, propertyName, {
|
||||
value,
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
});
|
||||
Object.defineProperty(object, propertyName, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get() {
|
||||
const result = valueGetter();
|
||||
define(result);
|
||||
return result;
|
||||
},
|
||||
set(value) {
|
||||
define(value);
|
||||
},
|
||||
});
|
||||
return object;
|
||||
}
|
||||
//# sourceMappingURL=lazy-value.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/lazy-value.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/lazy-value.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"lazy-value.js","sourceRoot":"","sources":["../../src/utils/lazy-value.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,IAAI,GAAG,CAAI,EAAW,EAAgB,EAAE;IACnD,IAAI,QAAQ,GAAG,KAAK,CAAA;IACpB,IAAI,MAAqB,CAAA;IAEzB,OAAO,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,QAAQ,GAAG,IAAI,CAAA;YACf,MAAM,GAAG,EAAE,EAAE,CAAA;QACf,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC,CAAiB,CAAA;AACpB,CAAC,CAAA;AAID,MAAM,UAAU,kBAAkB,CAKhC,MAAkB,EAClB,YAA8B,EAC9B,WAAoC;IAEpC,MAAM,MAAM,GAAG,CAAC,KAAwB,EAAE,EAAE,CAC1C,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE;QAC1C,KAAK;QACL,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAA;IAEJ,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE;QAC1C,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,IAAI;QAChB,GAAG;YACD,MAAM,MAAM,GAAG,WAAW,EAAE,CAAA;YAC5B,MAAM,CAAC,MAAM,CAAC,CAAA;YACd,OAAO,MAAM,CAAA;QACf,CAAC;QACD,GAAG,CAAC,KAAK;YACP,MAAM,CAAC,KAAK,CAAC,CAAA;QACf,CAAC;KACF,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC"}
|
||||
4
node_modules/eslint-plugin-import-x/lib/utils/legacy-resolver-settings.d.ts
generated
vendored
Normal file
4
node_modules/eslint-plugin-import-x/lib/utils/legacy-resolver-settings.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { LegacyImportResolver, LegacyResolver, LegacyResolverObject, ResolvedResult } from 'eslint-import-context';
|
||||
export declare function resolveWithLegacyResolver(resolver: LegacyResolver, config: unknown, modulePath: string, sourceFile: string): ResolvedResult;
|
||||
export declare function normalizeConfigResolvers(resolvers: LegacyImportResolver, sourceFile: string): Required<LegacyResolverObject>[];
|
||||
export declare const LEGACY_NODE_RESOLVERS: Set<string>;
|
||||
139
node_modules/eslint-plugin-import-x/lib/utils/legacy-resolver-settings.js
generated
vendored
Normal file
139
node_modules/eslint-plugin-import-x/lib/utils/legacy-resolver-settings.js
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
import { createRequire } from 'node:module';
|
||||
import path from 'node:path';
|
||||
import { cjsRequire } from '../require.js';
|
||||
import { pkgDir } from './pkg-dir.js';
|
||||
import { IMPORT_RESOLVE_ERROR_NAME } from './resolve.js';
|
||||
export function resolveWithLegacyResolver(resolver, config, modulePath, sourceFile) {
|
||||
if (resolver.interfaceVersion === 2) {
|
||||
return resolver.resolve(modulePath, sourceFile, config);
|
||||
}
|
||||
try {
|
||||
const resolved = resolver.resolveImport(modulePath, sourceFile, config);
|
||||
if (resolved === undefined) {
|
||||
return {
|
||||
found: false,
|
||||
};
|
||||
}
|
||||
return {
|
||||
found: true,
|
||||
path: resolved,
|
||||
};
|
||||
}
|
||||
catch {
|
||||
return {
|
||||
found: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
export function normalizeConfigResolvers(resolvers, sourceFile) {
|
||||
const resolverArray = Array.isArray(resolvers) ? resolvers : [resolvers];
|
||||
const map = new Map();
|
||||
for (const nameOrRecordOrObject of resolverArray) {
|
||||
if (typeof nameOrRecordOrObject === 'string') {
|
||||
const name = nameOrRecordOrObject;
|
||||
map.set(name, {
|
||||
name,
|
||||
enable: true,
|
||||
options: undefined,
|
||||
resolver: requireResolver(name, sourceFile),
|
||||
});
|
||||
}
|
||||
else if (typeof nameOrRecordOrObject === 'object') {
|
||||
if (nameOrRecordOrObject.name && nameOrRecordOrObject.resolver) {
|
||||
const object = nameOrRecordOrObject;
|
||||
const { name, enable = true, options, resolver } = object;
|
||||
map.set(name, { name, enable, options, resolver });
|
||||
}
|
||||
else {
|
||||
const record = nameOrRecordOrObject;
|
||||
for (const [name, enableOrOptions] of Object.entries(record)) {
|
||||
const resolver = requireResolver(name, sourceFile);
|
||||
if (typeof enableOrOptions === 'boolean') {
|
||||
map.set(name, {
|
||||
name,
|
||||
enable: enableOrOptions,
|
||||
options: undefined,
|
||||
resolver,
|
||||
});
|
||||
}
|
||||
else {
|
||||
map.set(name, {
|
||||
name,
|
||||
enable: true,
|
||||
options: enableOrOptions,
|
||||
resolver,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
const err = new Error('invalid resolver config');
|
||||
err.name = IMPORT_RESOLVE_ERROR_NAME;
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
return [...map.values()];
|
||||
}
|
||||
export const LEGACY_NODE_RESOLVERS = new Set([
|
||||
'node',
|
||||
'eslint-import-resolver-node',
|
||||
]);
|
||||
try {
|
||||
LEGACY_NODE_RESOLVERS.add(cjsRequire.resolve('eslint-import-resolver-node'));
|
||||
}
|
||||
catch {
|
||||
}
|
||||
function requireResolver(name, sourceFile) {
|
||||
const resolver = tryRequire(`eslint-import-resolver-${name}`, sourceFile) ||
|
||||
tryRequire(name, sourceFile) ||
|
||||
tryRequire(path.resolve(getBaseDir(sourceFile), name));
|
||||
if (!resolver) {
|
||||
if (LEGACY_NODE_RESOLVERS.has(name)) {
|
||||
return undefined;
|
||||
}
|
||||
const err = new Error(`unable to load resolver "${name}".`);
|
||||
err.name = IMPORT_RESOLVE_ERROR_NAME;
|
||||
throw err;
|
||||
}
|
||||
if (!isLegacyResolverValid(resolver)) {
|
||||
const err = new Error(`${name} with invalid interface loaded as resolver`);
|
||||
err.name = IMPORT_RESOLVE_ERROR_NAME;
|
||||
throw err;
|
||||
}
|
||||
return resolver;
|
||||
}
|
||||
function isLegacyResolverValid(resolver) {
|
||||
if ('interfaceVersion' in resolver && resolver.interfaceVersion === 2) {
|
||||
return ('resolve' in resolver &&
|
||||
!!resolver.resolve &&
|
||||
typeof resolver.resolve === 'function');
|
||||
}
|
||||
return ('resolveImport' in resolver &&
|
||||
!!resolver.resolveImport &&
|
||||
typeof resolver.resolveImport === 'function');
|
||||
}
|
||||
function tryRequire(target, sourceFile) {
|
||||
let resolved;
|
||||
try {
|
||||
if (sourceFile == null) {
|
||||
resolved = cjsRequire.resolve(target);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
resolved = createRequire(path.resolve(sourceFile)).resolve(target);
|
||||
}
|
||||
catch {
|
||||
resolved = cjsRequire.resolve(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
return cjsRequire(resolved);
|
||||
}
|
||||
function getBaseDir(sourceFile) {
|
||||
return pkgDir(sourceFile) || process.cwd();
|
||||
}
|
||||
//# sourceMappingURL=legacy-resolver-settings.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/legacy-resolver-settings.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/legacy-resolver-settings.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"legacy-resolver-settings.js","sourceRoot":"","sources":["../../src/utils/legacy-resolver-settings.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAA;AAU5B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAExD,MAAM,UAAU,yBAAyB,CACvC,QAAwB,EACxB,MAAe,EACf,UAAkB,EAClB,UAAkB;IAElB,IAAI,QAAQ,CAAC,gBAAgB,KAAK,CAAC,EAAE,CAAC;QACpC,OAAO,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,CAAA;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AAQ,CAAA;IACZ,IAAI,CAAC;QAEH,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;YACvB,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACvC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC;gBACH,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YACpE,CAAC;YAAC,MAAM,CAAC;gBACP,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YACvC,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QAEP,OAAO,SAAS,CAAA;IAClB,CAAC;IAGD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAA;AAC7B,CAAC;AAED,SAAS,UAAU,CAAC,UAAkB;IACpC,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,CAAA;AAC5C,CAAC"}
|
||||
12
node_modules/eslint-plugin-import-x/lib/utils/module-cache.d.ts
generated
vendored
Normal file
12
node_modules/eslint-plugin-import-x/lib/utils/module-cache.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import type { NormalizedCacheSettings, PluginSettings } from '../types.js';
|
||||
export interface CacheObject {
|
||||
result: unknown;
|
||||
lastSeen: ReturnType<typeof process.hrtime>;
|
||||
}
|
||||
export declare class ModuleCache {
|
||||
map: Map<string, CacheObject>;
|
||||
constructor(map?: Map<string, CacheObject>);
|
||||
set(cacheKey: string, result: unknown): unknown;
|
||||
get<T>(cacheKey: string, settings: NormalizedCacheSettings): T | undefined;
|
||||
static getSettings(settings: PluginSettings): NormalizedCacheSettings;
|
||||
}
|
||||
38
node_modules/eslint-plugin-import-x/lib/utils/module-cache.js
generated
vendored
Normal file
38
node_modules/eslint-plugin-import-x/lib/utils/module-cache.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
import debug from 'debug';
|
||||
const log = debug('eslint-plugin-import-x:utils:ModuleCache');
|
||||
export class ModuleCache {
|
||||
constructor(map = new Map()) {
|
||||
this.map = map;
|
||||
}
|
||||
set(cacheKey, result) {
|
||||
this.map.set(cacheKey, {
|
||||
result,
|
||||
lastSeen: process.hrtime(),
|
||||
});
|
||||
log('setting entry for', cacheKey);
|
||||
return result;
|
||||
}
|
||||
get(cacheKey, settings) {
|
||||
const cache = this.map.get(cacheKey);
|
||||
if (cache) {
|
||||
if (process.hrtime(cache.lastSeen)[0] < settings.lifetime) {
|
||||
return cache.result;
|
||||
}
|
||||
}
|
||||
else {
|
||||
log('cache miss for', cacheKey);
|
||||
}
|
||||
}
|
||||
static getSettings(settings) {
|
||||
const cacheSettings = {
|
||||
lifetime: 30,
|
||||
...settings['import-x/cache'],
|
||||
};
|
||||
if (typeof cacheSettings.lifetime === 'string' &&
|
||||
['∞', 'Infinity'].includes(cacheSettings.lifetime)) {
|
||||
cacheSettings.lifetime = Number.POSITIVE_INFINITY;
|
||||
}
|
||||
return cacheSettings;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=module-cache.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/module-cache.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/module-cache.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"module-cache.js","sourceRoot":"","sources":["../../src/utils/module-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,MAAM,GAAG,GAAG,KAAK,CAAC,0CAA0C,CAAC,CAAA;AAO7D,MAAM,OAAO,WAAW;IACtB,YAAmB,MAAgC,IAAI,GAAG,EAAE;QAAzC,QAAG,GAAH,GAAG,CAAsC;IAAG,CAAC;IAEhE,GAAG,CAAC,QAAgB,EAAE,MAAe;QACnC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE;YACrB,MAAM;YACN,QAAQ,EAAE,OAAO,CAAC,MAAM,EAAE;SAC3B,CAAC,CAAA;QACF,GAAG,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAA;QAClC,OAAO,MAAM,CAAA;IACf,CAAC;IAED,GAAG,CAAI,QAAgB,EAAE,QAAiC;QACxD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACpC,IAAI,KAAK,EAAE,CAAC;YAEV,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBAC1D,OAAO,KAAK,CAAC,MAAW,CAAA;YAC1B,CAAC;QACH,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAA;QACjC,CAAC;IAEH,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,QAAwB;QACzC,MAAM,aAAa,GAAG;YACpB,QAAQ,EAAE,EAAE;YACZ,GAAG,QAAQ,CAAC,gBAAgB,CAAC;SAC9B,CAAA;QAGD,IACE,OAAO,aAAa,CAAC,QAAQ,KAAK,QAAQ;YACzC,CAAC,GAAG,EAAE,UAAU,CAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,EAC7D,CAAC;YACD,aAAa,CAAC,QAAQ,GAAG,MAAM,CAAC,iBAAiB,CAAA;QACnD,CAAC;QAED,OAAO,aAAwC,CAAA;IACjD,CAAC;CACF"}
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/module-require.d.ts
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/module-require.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function moduleRequire<T>(p: string, sourceFile: string): T;
|
||||
30
node_modules/eslint-plugin-import-x/lib/utils/module-require.js
generated
vendored
Normal file
30
node_modules/eslint-plugin-import-x/lib/utils/module-require.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import Module, { createRequire } from 'node:module';
|
||||
import path from 'node:path';
|
||||
import { cjsRequire } from '../require.js';
|
||||
function createModule(filename) {
|
||||
const mod = new Module(filename);
|
||||
mod.filename = filename;
|
||||
mod.paths = Module._nodeModulePaths(path.dirname(filename));
|
||||
return mod;
|
||||
}
|
||||
export function moduleRequire(p, sourceFile) {
|
||||
try {
|
||||
const eslintPath = cjsRequire.resolve('eslint');
|
||||
const eslintModule = createModule(eslintPath);
|
||||
return cjsRequire(Module._resolveFilename(p, eslintModule));
|
||||
}
|
||||
catch {
|
||||
}
|
||||
try {
|
||||
return cjsRequire.main.require(p);
|
||||
}
|
||||
catch {
|
||||
}
|
||||
try {
|
||||
return createRequire(sourceFile)(p);
|
||||
}
|
||||
catch {
|
||||
}
|
||||
return cjsRequire(p);
|
||||
}
|
||||
//# sourceMappingURL=module-require.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/module-require.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/module-require.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"module-require.js","sourceRoot":"","sources":["../../src/utils/module-require.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AACnD,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,SAAS,YAAY,CAAC,QAAgB;IACpC,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAA;IAChC,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAEvB,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAA;IAC3D,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,MAAM,UAAU,aAAa,CAAI,CAAS,EAAE,UAAkB;IAC5D,IAAI,CAAC;QAEH,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QAC/C,MAAM,YAAY,GAAG,YAAY,CAAC,UAAU,CAAC,CAAA;QAE7C,OAAO,UAAU,CAEf,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE,YAAY,CAAC,CACzC,CAAA;IACH,CAAC;IAAC,MAAM,CAAC;IAET,CAAC;IAED,IAAI,CAAC;QAEH,OAAO,UAAU,CAAC,IAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IACpC,CAAC;IAAC,MAAM,CAAC;IAET,CAAC;IAED,IAAI,CAAC;QAEH,OAAO,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IACrC,CAAC;IAAC,MAAM,CAAC;IAET,CAAC;IAGD,OAAO,UAAU,CAAC,CAAC,CAAC,CAAA;AACtB,CAAC"}
|
||||
11
node_modules/eslint-plugin-import-x/lib/utils/module-visitor.d.ts
generated
vendored
Normal file
11
node_modules/eslint-plugin-import-x/lib/utils/module-visitor.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import type { JSONSchema, TSESLint, TSESTree } from '@typescript-eslint/utils';
|
||||
export type Visitor = (source: TSESTree.StringLiteral, importer: TSESTree.ImportDeclaration | TSESTree.ExportNamedDeclaration | TSESTree.ExportAllDeclaration | TSESTree.CallExpression | TSESTree.ImportExpression | TSESTree.StringLiteral) => void;
|
||||
export interface ModuleOptions {
|
||||
amd?: boolean;
|
||||
commonjs?: boolean;
|
||||
esmodule?: boolean;
|
||||
ignore?: string[];
|
||||
}
|
||||
export declare function moduleVisitor(visitor: Visitor, options?: ModuleOptions): TSESLint.RuleListener;
|
||||
export declare function makeOptionsSchema(additionalProperties?: Record<string, JSONSchema.JSONSchema4>): JSONSchema.JSONSchema4ObjectSchema;
|
||||
export declare const optionsSchema: JSONSchema.JSONSchema4ObjectSchema;
|
||||
143
node_modules/eslint-plugin-import-x/lib/utils/module-visitor.js
generated
vendored
Normal file
143
node_modules/eslint-plugin-import-x/lib/utils/module-visitor.js
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
export function moduleVisitor(visitor, options) {
|
||||
const ignore = options?.ignore;
|
||||
const amd = !!options?.amd;
|
||||
const commonjs = !!options?.commonjs;
|
||||
const esmodule = !!{ esmodule: true, ...options }.esmodule;
|
||||
const ignoreRegExps = ignore == null ? [] : ignore.map(p => new RegExp(p));
|
||||
function checkSourceValue(source, importer) {
|
||||
if (source == null) {
|
||||
return;
|
||||
}
|
||||
if (ignoreRegExps.some(re => re.test(String(source.value)))) {
|
||||
return;
|
||||
}
|
||||
visitor(source, importer);
|
||||
}
|
||||
function checkSource(node) {
|
||||
checkSourceValue(node.source, node);
|
||||
}
|
||||
function checkImportCall(node) {
|
||||
let modulePath;
|
||||
if (node.type === 'ImportExpression') {
|
||||
modulePath = node.source;
|
||||
}
|
||||
else if (node.type === 'CallExpression') {
|
||||
if (node.callee.type !== 'Import') {
|
||||
return;
|
||||
}
|
||||
if (node.arguments.length !== 1) {
|
||||
return;
|
||||
}
|
||||
modulePath = node.arguments[0];
|
||||
}
|
||||
else {
|
||||
throw new TypeError('this should be unreachable');
|
||||
}
|
||||
if (modulePath.type !== 'Literal') {
|
||||
return;
|
||||
}
|
||||
if (typeof modulePath.value !== 'string') {
|
||||
return;
|
||||
}
|
||||
checkSourceValue(modulePath, node);
|
||||
}
|
||||
function checkCommon(call) {
|
||||
if (call.callee.type !== 'Identifier') {
|
||||
return;
|
||||
}
|
||||
if (call.callee.name !== 'require') {
|
||||
return;
|
||||
}
|
||||
if (call.arguments.length !== 1) {
|
||||
return;
|
||||
}
|
||||
const modulePath = call.arguments[0];
|
||||
if (modulePath.type !== 'Literal') {
|
||||
return;
|
||||
}
|
||||
if (typeof modulePath.value !== 'string') {
|
||||
return;
|
||||
}
|
||||
checkSourceValue(modulePath, call);
|
||||
}
|
||||
function checkAMD(call) {
|
||||
if (call.callee.type !== 'Identifier') {
|
||||
return;
|
||||
}
|
||||
if (call.callee.name !== 'require' && call.callee.name !== 'define') {
|
||||
return;
|
||||
}
|
||||
if (call.arguments.length !== 2) {
|
||||
return;
|
||||
}
|
||||
const modules = call.arguments[0];
|
||||
if (modules.type !== 'ArrayExpression') {
|
||||
return;
|
||||
}
|
||||
for (const element of modules.elements) {
|
||||
if (!element) {
|
||||
continue;
|
||||
}
|
||||
if (element.type !== 'Literal') {
|
||||
continue;
|
||||
}
|
||||
if (typeof element.value !== 'string') {
|
||||
continue;
|
||||
}
|
||||
if (element.value === 'require' || element.value === 'exports') {
|
||||
continue;
|
||||
}
|
||||
checkSourceValue(element, element);
|
||||
}
|
||||
}
|
||||
const visitors = {};
|
||||
if (esmodule) {
|
||||
Object.assign(visitors, {
|
||||
ImportDeclaration: checkSource,
|
||||
ExportNamedDeclaration: checkSource,
|
||||
ExportAllDeclaration: checkSource,
|
||||
CallExpression: checkImportCall,
|
||||
ImportExpression: checkImportCall,
|
||||
});
|
||||
}
|
||||
if (commonjs || amd) {
|
||||
const currentCallExpression = visitors.CallExpression;
|
||||
visitors.CallExpression = function (call) {
|
||||
if (currentCallExpression) {
|
||||
currentCallExpression(call);
|
||||
}
|
||||
if (commonjs) {
|
||||
checkCommon(call);
|
||||
}
|
||||
if (amd) {
|
||||
checkAMD(call);
|
||||
}
|
||||
};
|
||||
}
|
||||
return visitors;
|
||||
}
|
||||
export function makeOptionsSchema(additionalProperties) {
|
||||
const base = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
commonjs: { type: 'boolean' },
|
||||
amd: { type: 'boolean' },
|
||||
esmodule: { type: 'boolean' },
|
||||
ignore: {
|
||||
type: 'array',
|
||||
minItems: 1,
|
||||
items: { type: 'string' },
|
||||
uniqueItems: true,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
};
|
||||
if (additionalProperties) {
|
||||
for (const key in additionalProperties) {
|
||||
base.properties[key] = additionalProperties[key];
|
||||
}
|
||||
}
|
||||
return base;
|
||||
}
|
||||
export const optionsSchema = makeOptionsSchema();
|
||||
//# sourceMappingURL=module-visitor.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/module-visitor.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/module-visitor.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"module-visitor.js","sourceRoot":"","sources":["../../src/utils/module-visitor.ts"],"names":[],"mappings":"AAwBA,MAAM,UAAU,aAAa,CAAC,OAAgB,EAAE,OAAuB;IACrE,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,CAAA;IAC9B,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,EAAE,GAAG,CAAA;IAC1B,MAAM,QAAQ,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAA;IAEpC,MAAM,QAAQ,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,QAAQ,CAAA;IAE1D,MAAM,aAAa,GAAG,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IAE1E,SAAS,gBAAgB,CACvB,MAAiD,EACjD,QAM0B;QAE1B,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YACnB,OAAM;QACR,CAAC;QAGD,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5D,OAAM;QACR,CAAC;QAGD,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAC3B,CAAC;IAGD,SAAS,WAAW,CAClB,IAGiC;QAEjC,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,C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O,IAAI,CAAA;AACb,CAAC;AAMD,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,EAAE,CAAA"}
|
||||
5
node_modules/eslint-plugin-import-x/lib/utils/npm-client.d.ts
generated
vendored
Normal file
5
node_modules/eslint-plugin-import-x/lib/utils/npm-client.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import type { SetValue } from '../types.js';
|
||||
export declare const NPM_CLIENTS: Set<"npm" | "yarn" | "pnpm" | "bun" | "deno">;
|
||||
export type NpmClient = SetValue<typeof NPM_CLIENTS>;
|
||||
export declare const getNpmClient: () => NpmClient;
|
||||
export declare const getNpmInstallCommand: (packageName: string) => string;
|
||||
19
node_modules/eslint-plugin-import-x/lib/utils/npm-client.js
generated
vendored
Normal file
19
node_modules/eslint-plugin-import-x/lib/utils/npm-client.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
const NPM = 'npm';
|
||||
export const NPM_CLIENTS = new Set([
|
||||
NPM,
|
||||
'yarn',
|
||||
'pnpm',
|
||||
'bun',
|
||||
'deno',
|
||||
]);
|
||||
let npmClient;
|
||||
export const getNpmClient = () => {
|
||||
if (npmClient) {
|
||||
return npmClient;
|
||||
}
|
||||
const client = process.env.npm_config_user_agent?.split('/')[0];
|
||||
npmClient = client && NPM_CLIENTS.has(client) ? client : NPM;
|
||||
return npmClient;
|
||||
};
|
||||
export const getNpmInstallCommand = (packageName) => `${getNpmClient()} ${npmClient === NPM ? 'i' : 'add'} ${npmClient === 'deno' ? `${NPM}:` : ''}${packageName}`;
|
||||
//# sourceMappingURL=npm-client.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/npm-client.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/npm-client.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"npm-client.js","sourceRoot":"","sources":["../../src/utils/npm-client.ts"],"names":[],"mappings":"AAEA,MAAM,GAAG,GAAG,KAAK,CAAA;AAEjB,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IACjC,GAAG;IACH,MAAM;IACN,MAAM;IACN,KAAK;IACL,MAAM;CACE,CAAC,CAAA;AAIX,IAAI,SAAgC,CAAA;AAEpC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAc,EAAE;IAC1C,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IAE/D,SAAS,GAAG,MAAM,IAAI,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,MAAoB,CAAC,CAAC,CAAC,GAAG,CAAA;IAE3E,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,WAAmB,EAAE,EAAE,CAC1D,GAAG,YAAY,EAAE,IAAI,SAAS,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,WAAW,EAAE,CAAA"}
|
||||
4
node_modules/eslint-plugin-import-x/lib/utils/package-path.d.ts
generated
vendored
Normal file
4
node_modules/eslint-plugin-import-x/lib/utils/package-path.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { RuleContext } from '../types.js';
|
||||
export declare function getContextPackagePath(context: RuleContext): string;
|
||||
export declare function getFilePackagePath(filename: string): string;
|
||||
export declare function getFilePackageName(filename: string): string | null;
|
||||
17
node_modules/eslint-plugin-import-x/lib/utils/package-path.js
generated
vendored
Normal file
17
node_modules/eslint-plugin-import-x/lib/utils/package-path.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import path from 'node:path';
|
||||
import { pkgUp } from './pkg-up.js';
|
||||
import { readPkgUp } from './read-pkg-up.js';
|
||||
export function getContextPackagePath(context) {
|
||||
return getFilePackagePath(context.physicalFilename);
|
||||
}
|
||||
export function getFilePackagePath(filename) {
|
||||
return path.dirname(pkgUp({ cwd: filename }));
|
||||
}
|
||||
export function getFilePackageName(filename) {
|
||||
const { pkg, path: pkgPath } = readPkgUp({ cwd: filename });
|
||||
if (pkg) {
|
||||
return pkg.name || getFilePackageName(path.resolve(pkgPath, '../..'));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//# sourceMappingURL=package-path.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/package-path.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/package-path.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"package-path.js","sourceRoot":"","sources":["../../src/utils/package-path.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAI5B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C,MAAM,UAAU,qBAAqB,CAAC,OAAoB;IACxD,OAAO,kBAAkB,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;AACrD,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAE,CAAC,CAAA;AAChD,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC3D,IAAI,GAAG,EAAE,CAAC;QAER,OAAO,GAAG,CAAC,IAAI,IAAI,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;IACvE,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
||||
7
node_modules/eslint-plugin-import-x/lib/utils/parse-path.d.ts
generated
vendored
Normal file
7
node_modules/eslint-plugin-import-x/lib/utils/parse-path.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export interface ParsedPath {
|
||||
pathname: string;
|
||||
query: string;
|
||||
hash: string;
|
||||
}
|
||||
export declare const parsePath: (path: string) => ParsedPath;
|
||||
export declare const stringifyPath: ({ pathname, query, hash }: ParsedPath) => string;
|
||||
18
node_modules/eslint-plugin-import-x/lib/utils/parse-path.js
generated
vendored
Normal file
18
node_modules/eslint-plugin-import-x/lib/utils/parse-path.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
export const parsePath = (path) => {
|
||||
const hashIndex = path.indexOf('#');
|
||||
const queryIndex = path.indexOf('?');
|
||||
const hasHash = hashIndex !== -1;
|
||||
const hash = hasHash ? path.slice(hashIndex) : '';
|
||||
const hasQuery = queryIndex !== -1 && (!hasHash || queryIndex < hashIndex);
|
||||
const query = hasQuery
|
||||
? path.slice(queryIndex, hasHash ? hashIndex : undefined)
|
||||
: '';
|
||||
const pathname = hasQuery
|
||||
? path.slice(0, queryIndex)
|
||||
: hasHash
|
||||
? path.slice(0, hashIndex)
|
||||
: path;
|
||||
return { pathname, query, hash };
|
||||
};
|
||||
export const stringifyPath = ({ pathname, query, hash }) => pathname + query + hash;
|
||||
//# sourceMappingURL=parse-path.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/parse-path.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/parse-path.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"parse-path.js","sourceRoot":"","sources":["../../src/utils/parse-path.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAY,EAAc,EAAE;IACpD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IACnC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IACpC,MAAM,OAAO,GAAG,SAAS,KAAK,CAAC,CAAC,CAAA;IAChC,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IACjD,MAAM,QAAQ,GAAG,UAAU,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,IAAI,UAAU,GAAG,SAAS,CAAC,CAAA;IAC1E,MAAM,KAAK,GAAG,QAAQ;QACpB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;QACzD,CAAC,CAAC,EAAE,CAAA;IACN,MAAM,QAAQ,GAAG,QAAQ;QACvB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC;QAC3B,CAAC,CAAC,OAAO;YACP,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC;YAC1B,CAAC,CAAC,IAAI,CAAA;IACV,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;AAClC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAc,EAAE,EAAE,CACrE,QAAQ,GAAG,KAAK,GAAG,IAAI,CAAA"}
|
||||
6
node_modules/eslint-plugin-import-x/lib/utils/parse.d.ts
generated
vendored
Normal file
6
node_modules/eslint-plugin-import-x/lib/utils/parse.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
|
||||
import type { ChildContext, RuleContext } from '../types.js';
|
||||
export declare function parse(path: string, content: string, context: ChildContext | RuleContext): {
|
||||
ast: TSESTree.Program;
|
||||
visitorKeys: TSESLint.Parser.VisitorKeys | null;
|
||||
};
|
||||
110
node_modules/eslint-plugin-import-x/lib/utils/parse.js
generated
vendored
Normal file
110
node_modules/eslint-plugin-import-x/lib/utils/parse.js
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
import path from 'node:path';
|
||||
import debug from 'debug';
|
||||
import { moduleRequire } from './module-require.js';
|
||||
function withoutProjectParserOptions(opts) {
|
||||
const { EXPERIMENTAL_useProjectService, project, projectService, ...rest } = opts;
|
||||
return rest;
|
||||
}
|
||||
const log = debug('eslint-plugin-import-x:parse');
|
||||
function keysFromParser(_parserPath, parserInstance, parsedResult) {
|
||||
if (parsedResult && parsedResult.visitorKeys) {
|
||||
return parsedResult.visitorKeys;
|
||||
}
|
||||
if (parserInstance &&
|
||||
'VisitorKeys' in parserInstance &&
|
||||
parserInstance.VisitorKeys) {
|
||||
return parserInstance.VisitorKeys;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function makeParseReturn(ast, visitorKeys) {
|
||||
return {
|
||||
ast,
|
||||
visitorKeys,
|
||||
};
|
||||
}
|
||||
function stripUnicodeBOM(text) {
|
||||
return text.codePointAt(0) === 0xfe_ff ? text.slice(1) : text;
|
||||
}
|
||||
function transformHashbang(text) {
|
||||
return text.replace(/^#!([^\r\n]+)/u, (_, captured) => `//${captured}`);
|
||||
}
|
||||
export function parse(path, content, context) {
|
||||
if (context == null) {
|
||||
throw new Error('need context to parse properly');
|
||||
}
|
||||
let parserOptions = context.languageOptions?.parserOptions || context.parserOptions;
|
||||
const parserOrPath = getParser(path, context);
|
||||
if (!parserOrPath) {
|
||||
throw new Error('parserPath or languageOptions.parser is required!');
|
||||
}
|
||||
parserOptions = { ...parserOptions };
|
||||
parserOptions.ecmaFeatures = { ...parserOptions.ecmaFeatures };
|
||||
parserOptions.comment = true;
|
||||
parserOptions.attachComment = true;
|
||||
parserOptions.tokens = true;
|
||||
parserOptions.loc = true;
|
||||
parserOptions.range = true;
|
||||
parserOptions.filePath = path;
|
||||
parserOptions = withoutProjectParserOptions(parserOptions);
|
||||
parserOptions.ecmaVersion ??= context.languageOptions?.ecmaVersion;
|
||||
parserOptions.sourceType ??= context.languageOptions?.sourceType;
|
||||
const parser = typeof parserOrPath === 'string'
|
||||
? moduleRequire(parserOrPath, context.physicalFilename)
|
||||
: parserOrPath;
|
||||
content = transformHashbang(stripUnicodeBOM(String(content)));
|
||||
if ('parseForESLint' in parser &&
|
||||
typeof parser.parseForESLint === 'function') {
|
||||
let ast;
|
||||
try {
|
||||
const parserRaw = parser.parseForESLint(content, parserOptions);
|
||||
ast = parserRaw.ast;
|
||||
return makeParseReturn(ast, keysFromParser(parserOrPath, parser, parserRaw));
|
||||
}
|
||||
catch (error_) {
|
||||
const error = error_;
|
||||
console.warn(`Error while parsing ${parserOptions.filePath}`);
|
||||
console.warn(`Line ${error.lineNumber}, column ${error.column}: ${error.message}`);
|
||||
}
|
||||
if (!ast || typeof ast !== 'object') {
|
||||
console.warn(`\`parseForESLint\` from parser \`${typeof parserOrPath === 'string' ? parserOrPath : 'context.languageOptions.parser'}\` is invalid and will just be ignored`, { content, parserMeta: parser.meta });
|
||||
}
|
||||
else {
|
||||
return makeParseReturn(ast, keysFromParser(parserOrPath, parser));
|
||||
}
|
||||
}
|
||||
if ('parse' in parser) {
|
||||
const ast = parser.parse(content, parserOptions);
|
||||
return makeParseReturn(ast, keysFromParser(parserOrPath, parser));
|
||||
}
|
||||
throw new Error('Parser must expose a `parse` or `parseForESLint` method');
|
||||
}
|
||||
function getParser(path, context) {
|
||||
const parserPath = getParserPath(path, context);
|
||||
if (parserPath) {
|
||||
return parserPath;
|
||||
}
|
||||
const parser = 'languageOptions' in context && context.languageOptions?.parser;
|
||||
if (parser &&
|
||||
typeof parser !== 'string' &&
|
||||
(('parse' in parser && typeof parse === 'function') ||
|
||||
('parseForESLint' in parser &&
|
||||
typeof parser.parseForESLint === 'function'))) {
|
||||
return parser;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function getParserPath(filepath, context) {
|
||||
const parsers = context.settings['import-x/parsers'];
|
||||
if (parsers != null) {
|
||||
const extension = path.extname(filepath);
|
||||
for (const parserPath in parsers) {
|
||||
if (parsers[parserPath].includes(extension)) {
|
||||
log('using alt parser:', parserPath);
|
||||
return parserPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
return context.parserPath;
|
||||
}
|
||||
//# sourceMappingURL=parse.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/parse.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/parse.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/utils/parse.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAI5B,OAAO,KAAK,MAAM,OAAO,CAAA;AASzB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGnD,SAAS,2BAA2B,CAClC,IAA4B;IAM5B,MAAM,EAAE,8BAA8B,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GACxE,IAAI,CAAA;IACN,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,GAAG,GAAG,KAAK,CAAC,8BAA8B,CAAC,CAAA;AAEjD,SAAS,cAAc,CACrB,WAAkD,EAClD,cAA4C,EAC5C,YAA0C;IAG1C,IAAI,YAAY,IAAI,YAAY,CAAC,WAAW,EAAE,CAAC;QAC7C,OAAO,YAAY,CAAC,WAAW,CAAA;IACjC,CAAC;IAID,IACE,cAAc;QACd,aAAa,IAAI,cAAc;QAC/B,cAAc,CAAC,WAAW,EAC1B,CAAC;QACD,OAAO,cAAc,CAAC,WAA8C,CAAA;IACtE,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,eAAe,CACtB,GAAqB,EACrB,WAAmD;IAEnD,O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;QACzD,KAAK,MAAM,UAAU,IAAI,OAAO,EAAE,CAAC;YACjC,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBAE5C,GAAG,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAA;gBACpC,OAAO,UAAU,CAAA;YACnB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC,UAAU,CAAA;AAC3B,CAAC"}
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/pkg-dir.d.ts
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/pkg-dir.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function pkgDir(cwd: string): string | null;
|
||||
7
node_modules/eslint-plugin-import-x/lib/utils/pkg-dir.js
generated
vendored
Normal file
7
node_modules/eslint-plugin-import-x/lib/utils/pkg-dir.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import path from 'node:path';
|
||||
import { pkgUp } from './pkg-up.js';
|
||||
export function pkgDir(cwd) {
|
||||
const fp = pkgUp({ cwd });
|
||||
return fp ? path.dirname(fp) : null;
|
||||
}
|
||||
//# sourceMappingURL=pkg-dir.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/pkg-dir.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/pkg-dir.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pkg-dir.js","sourceRoot":"","sources":["../../src/utils/pkg-dir.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC,MAAM,UAAU,MAAM,CAAC,GAAW;IAChC,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,CAAA;IACzB,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACrC,CAAC"}
|
||||
3
node_modules/eslint-plugin-import-x/lib/utils/pkg-up.d.ts
generated
vendored
Normal file
3
node_modules/eslint-plugin-import-x/lib/utils/pkg-up.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare function pkgUp(opts?: {
|
||||
cwd?: string;
|
||||
}): string | null;
|
||||
21
node_modules/eslint-plugin-import-x/lib/utils/pkg-up.js
generated
vendored
Normal file
21
node_modules/eslint-plugin-import-x/lib/utils/pkg-up.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
function findUp(filename, cwd) {
|
||||
let dir = path.resolve(cwd || '');
|
||||
const root = path.parse(dir).root;
|
||||
const filenames = [filename].flat();
|
||||
while (true) {
|
||||
const file = filenames.find(el => fs.existsSync(path.resolve(dir, el)));
|
||||
if (file) {
|
||||
return path.resolve(dir, file);
|
||||
}
|
||||
if (dir === root) {
|
||||
return null;
|
||||
}
|
||||
dir = path.dirname(dir);
|
||||
}
|
||||
}
|
||||
export function pkgUp(opts) {
|
||||
return findUp('package.json', opts && opts.cwd);
|
||||
}
|
||||
//# sourceMappingURL=pkg-up.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/pkg-up.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/pkg-up.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pkg-up.js","sourceRoot":"","sources":["../../src/utils/pkg-up.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,SAAS,MAAM,CAAC,QAA2B,EAAE,GAAY;IACvD,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC,CAAA;IACjC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAA;IAEjC,MAAM,SAAS,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAA;IAEnC,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;QAEvE,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;QAChC,CAAC;QACD,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACjB,OAAO,IAAI,CAAA;QACb,CAAC;QAED,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,IAAuB;IAC3C,OAAO,MAAM,CAAC,cAAc,EAAE,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,CAAA;AACjD,CAAC"}
|
||||
12
node_modules/eslint-plugin-import-x/lib/utils/read-pkg-up.d.ts
generated
vendored
Normal file
12
node_modules/eslint-plugin-import-x/lib/utils/read-pkg-up.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import type { PackageJson } from 'type-fest';
|
||||
export declare function readPkgUp(opts?: {
|
||||
cwd?: string;
|
||||
}): {
|
||||
pkg?: undefined;
|
||||
path?: undefined;
|
||||
} | {
|
||||
pkg: PackageJson & {
|
||||
name: string;
|
||||
};
|
||||
path: string;
|
||||
};
|
||||
21
node_modules/eslint-plugin-import-x/lib/utils/read-pkg-up.js
generated
vendored
Normal file
21
node_modules/eslint-plugin-import-x/lib/utils/read-pkg-up.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import fs from 'node:fs';
|
||||
import { pkgUp } from './pkg-up.js';
|
||||
function stripBOM(str) {
|
||||
return str.replace(/^\uFEFF/, '');
|
||||
}
|
||||
export function readPkgUp(opts) {
|
||||
const fp = pkgUp(opts);
|
||||
if (!fp) {
|
||||
return {};
|
||||
}
|
||||
try {
|
||||
return {
|
||||
pkg: JSON.parse(stripBOM(fs.readFileSync(fp, { encoding: 'utf8' }))),
|
||||
path: fp,
|
||||
};
|
||||
}
|
||||
catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=read-pkg-up.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/read-pkg-up.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/read-pkg-up.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"read-pkg-up.js","sourceRoot":"","sources":["../../src/utils/read-pkg-up.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AAIxB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC,SAAS,QAAQ,CAAC,GAAW;IAC3B,OAAO,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;AACnC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAuB;IAC/C,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,CAAA;IAEtB,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,OAAO,EAAE,CAAA;IACX,CAAC;IAED,IAAI,CAAC;QACH,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,KAAK,CACb,QAAQ,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,CAGpD;YACD,IAAI,EAAE,EAAE;SACT,CAAA;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC"}
|
||||
9
node_modules/eslint-plugin-import-x/lib/utils/resolve.d.ts
generated
vendored
Normal file
9
node_modules/eslint-plugin-import-x/lib/utils/resolve.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { ChildContext, LegacyResolver, NewResolver, NormalizedCacheSettings, PluginSettings, RuleContext } from '../types.js';
|
||||
import { ModuleCache } from './module-cache.js';
|
||||
export declare const CASE_SENSITIVE_FS: boolean;
|
||||
export declare const IMPORT_RESOLVE_ERROR_NAME = "EslintPluginImportResolveError";
|
||||
export declare const fileExistsCache: ModuleCache;
|
||||
export declare function fileExistsWithCaseSync(filepath: string | null, cacheSettings: NormalizedCacheSettings, strict?: boolean, leaf?: boolean): boolean;
|
||||
export declare function relative(modulePath: string, sourceFile: string, settings: PluginSettings, context: ChildContext | RuleContext): string | null | undefined;
|
||||
export declare function resolve(modulePath: string, context: RuleContext): string | null | undefined;
|
||||
export declare function importXResolverCompat(resolver: LegacyResolver | NewResolver, resolverOptions?: unknown): NewResolver;
|
||||
251
node_modules/eslint-plugin-import-x/lib/utils/resolve.js
generated
vendored
Normal file
251
node_modules/eslint-plugin-import-x/lib/utils/resolve.js
generated
vendored
Normal file
@@ -0,0 +1,251 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { setRuleContext } from 'eslint-import-context';
|
||||
import { stableHash } from 'stable-hash-x';
|
||||
import { createNodeResolver } from '../node-resolver.js';
|
||||
import { cjsRequire } from '../require.js';
|
||||
import { arraify } from './arraify.js';
|
||||
import { makeContextCacheKey } from './export-map.js';
|
||||
import { isExternalLookingName } from './import-type.js';
|
||||
import { LEGACY_NODE_RESOLVERS, normalizeConfigResolvers, resolveWithLegacyResolver, } from './legacy-resolver-settings.js';
|
||||
import { ModuleCache } from './module-cache.js';
|
||||
const importMetaUrl = import.meta.url;
|
||||
const _filename = importMetaUrl
|
||||
? fileURLToPath(importMetaUrl)
|
||||
: __filename;
|
||||
const _dirname = path.dirname(_filename);
|
||||
export const CASE_SENSITIVE_FS = !fs.existsSync(path.resolve(_dirname, path.basename(_filename).replace(/^resolve\./, 'reSOLVE.')));
|
||||
export const IMPORT_RESOLVE_ERROR_NAME = 'EslintPluginImportResolveError';
|
||||
export const fileExistsCache = new ModuleCache();
|
||||
export function fileExistsWithCaseSync(filepath, cacheSettings, strict, leaf = true) {
|
||||
if (CASE_SENSITIVE_FS) {
|
||||
return true;
|
||||
}
|
||||
if (filepath === null) {
|
||||
return true;
|
||||
}
|
||||
if (filepath.toLowerCase() === process.cwd().toLowerCase() && !strict) {
|
||||
return true;
|
||||
}
|
||||
const parsedPath = path.parse(filepath);
|
||||
const dir = parsedPath.dir;
|
||||
let result = fileExistsCache.get(filepath, cacheSettings);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
if (dir === '' || parsedPath.root === filepath) {
|
||||
result = true;
|
||||
}
|
||||
else {
|
||||
const filenames = fs.readdirSync(dir);
|
||||
result = filenames.includes(parsedPath.base)
|
||||
? fileExistsWithCaseSync(dir, cacheSettings, strict, false)
|
||||
: !leaf &&
|
||||
!filenames.some(p => p.toLowerCase() === parsedPath.base.toLowerCase());
|
||||
}
|
||||
fileExistsCache.set(filepath, result);
|
||||
return result;
|
||||
}
|
||||
let prevSettings = null;
|
||||
let memoizedHash;
|
||||
function isNamedResolver(resolver) {
|
||||
return !!(typeof resolver === 'object' &&
|
||||
resolver &&
|
||||
'name' in resolver &&
|
||||
typeof resolver.name === 'string' &&
|
||||
resolver.name);
|
||||
}
|
||||
function isValidNewResolver(resolver) {
|
||||
if (typeof resolver !== 'object' || resolver == null) {
|
||||
return false;
|
||||
}
|
||||
if (!('resolve' in resolver) || !('interfaceVersion' in resolver)) {
|
||||
return false;
|
||||
}
|
||||
if (typeof resolver.interfaceVersion !== 'number' ||
|
||||
resolver.interfaceVersion !== 3) {
|
||||
return false;
|
||||
}
|
||||
if (typeof resolver.resolve !== 'function') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function legacyNodeResolve(resolverOptions, context, modulePath, sourceFile) {
|
||||
const { extensions, includeCoreModules, moduleDirectory, paths, preserveSymlinks, package: packageJson, packageFilter, pathFilter, packageIterator, ...rest } = resolverOptions;
|
||||
const normalizedExtensions = arraify(extensions);
|
||||
const modules = arraify(moduleDirectory);
|
||||
const symlinks = preserveSymlinks === false;
|
||||
const resolver = createNodeResolver({
|
||||
extensions: normalizedExtensions,
|
||||
builtinModules: includeCoreModules !== false,
|
||||
modules,
|
||||
symlinks,
|
||||
...rest,
|
||||
});
|
||||
const resolved = setRuleContext(context, () => resolver.resolve(modulePath, sourceFile));
|
||||
if (resolved.found) {
|
||||
return resolved;
|
||||
}
|
||||
const normalizedPaths = arraify(paths);
|
||||
if (normalizedPaths?.length) {
|
||||
const paths = modules?.length
|
||||
? normalizedPaths.filter(p => !modules.includes(p))
|
||||
: normalizedPaths;
|
||||
if (paths.length > 0) {
|
||||
const resolver = createNodeResolver({
|
||||
extensions: normalizedExtensions,
|
||||
builtinModules: includeCoreModules !== false,
|
||||
modules: paths,
|
||||
symlinks,
|
||||
...rest,
|
||||
});
|
||||
const resolved = setRuleContext(context, () => resolver.resolve(modulePath, sourceFile));
|
||||
if (resolved.found) {
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ([packageJson, packageFilter, pathFilter, packageIterator].some(it => it != null)) {
|
||||
let legacyNodeResolver;
|
||||
try {
|
||||
legacyNodeResolver = cjsRequire('eslint-import-resolver-node');
|
||||
}
|
||||
catch {
|
||||
throw new Error([
|
||||
"You're using legacy resolver options which are not supported by the new resolver.",
|
||||
'Please either:',
|
||||
'1. Install `eslint-import-resolver-node` as a fallback, or',
|
||||
'2. Remove legacy options: `package`, `packageFilter`, `pathFilter`, `packageIterator`',
|
||||
].join('\n'));
|
||||
}
|
||||
const resolved = resolveWithLegacyResolver(legacyNodeResolver, resolverOptions, modulePath, sourceFile);
|
||||
if (resolved.found) {
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
}
|
||||
function fullResolve(modulePath, sourceFile, settings, context) {
|
||||
const coreSet = new Set(settings['import-x/core-modules']);
|
||||
if (coreSet.has(modulePath)) {
|
||||
return {
|
||||
found: true,
|
||||
path: null,
|
||||
};
|
||||
}
|
||||
const childContextHashKey = makeContextCacheKey(context);
|
||||
const sourceDir = path.dirname(sourceFile);
|
||||
if (prevSettings !== settings) {
|
||||
memoizedHash = stableHash(settings);
|
||||
prevSettings = settings;
|
||||
}
|
||||
const cacheKey = sourceDir +
|
||||
'\0' +
|
||||
childContextHashKey +
|
||||
'\0' +
|
||||
memoizedHash +
|
||||
'\0' +
|
||||
modulePath;
|
||||
const cacheSettings = ModuleCache.getSettings(settings);
|
||||
const cachedPath = fileExistsCache.get(cacheKey, cacheSettings);
|
||||
if (cachedPath !== undefined) {
|
||||
return { found: true, path: cachedPath };
|
||||
}
|
||||
if (settings['import-x/resolver-next']) {
|
||||
let configResolvers = settings['import-x/resolver-next'];
|
||||
if (!Array.isArray(configResolvers)) {
|
||||
configResolvers = [configResolvers];
|
||||
}
|
||||
for (let i = 0, len = configResolvers.length; i < len; i++) {
|
||||
const resolver = configResolvers[i];
|
||||
const resolverName = isNamedResolver(resolver)
|
||||
? resolver.name
|
||||
: `settings['import-x/resolver-next'][${i}]`;
|
||||
if (!isValidNewResolver(resolver)) {
|
||||
const err = new TypeError(`${resolverName} is not a valid import resolver for eslint-plugin-import-x!`);
|
||||
err.name = IMPORT_RESOLVE_ERROR_NAME;
|
||||
throw err;
|
||||
}
|
||||
const resolved = setRuleContext(context, () => resolver.resolve(modulePath, sourceFile));
|
||||
if (!resolved.found) {
|
||||
continue;
|
||||
}
|
||||
fileExistsCache.set(cacheKey, resolved.path);
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
else {
|
||||
const configResolvers = settings['import-x/resolver-legacy'] ||
|
||||
settings['import-x/resolver'] || {
|
||||
node: settings['import-x/resolve'],
|
||||
};
|
||||
const sourceFiles = context.physicalFilename === sourceFile ||
|
||||
!isExternalLookingName(modulePath)
|
||||
? [sourceFile]
|
||||
: [sourceFile, context.physicalFilename];
|
||||
for (const sourceFile of sourceFiles) {
|
||||
for (const { enable, name, options, resolver, } of normalizeConfigResolvers(configResolvers, sourceFile)) {
|
||||
if (!enable) {
|
||||
continue;
|
||||
}
|
||||
if (LEGACY_NODE_RESOLVERS.has(name)) {
|
||||
const resolverOptions = (options || {});
|
||||
const resolved = legacyNodeResolve(resolverOptions, context, modulePath, sourceFile);
|
||||
if (resolved?.found) {
|
||||
fileExistsCache.set(cacheKey, resolved.path);
|
||||
return resolved;
|
||||
}
|
||||
if (!resolver) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
const resolved = setRuleContext(context, () => resolveWithLegacyResolver(resolver, options, modulePath, sourceFile));
|
||||
if (!resolved?.found) {
|
||||
continue;
|
||||
}
|
||||
fileExistsCache.set(cacheKey, resolved.path);
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
}
|
||||
return { found: false };
|
||||
}
|
||||
export function relative(modulePath, sourceFile, settings, context) {
|
||||
return fullResolve(modulePath, sourceFile, settings, context).path;
|
||||
}
|
||||
const erroredContexts = new Set();
|
||||
export function resolve(modulePath, context) {
|
||||
try {
|
||||
return relative(modulePath, context.physicalFilename, context.settings, context);
|
||||
}
|
||||
catch (error_) {
|
||||
const error = error_;
|
||||
if (!erroredContexts.has(context)) {
|
||||
let errMessage = error.message;
|
||||
if (error.name !== IMPORT_RESOLVE_ERROR_NAME && error.stack) {
|
||||
errMessage = error.stack.replace(/^Error: /, '');
|
||||
}
|
||||
context.report({
|
||||
message: `Resolve error: ${errMessage}`,
|
||||
loc: {
|
||||
line: 1,
|
||||
column: 0,
|
||||
},
|
||||
});
|
||||
erroredContexts.add(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
export function importXResolverCompat(resolver, resolverOptions = {}) {
|
||||
if (isValidNewResolver(resolver)) {
|
||||
return resolver;
|
||||
}
|
||||
return {
|
||||
interfaceVersion: 3,
|
||||
resolve(modulePath, sourceFile) {
|
||||
return resolveWithLegacyResolver(resolver, resolverOptions, modulePath, sourceFile);
|
||||
},
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=resolve.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/resolve.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/resolve.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/eslint-plugin-import-x/lib/utils/source-type.d.ts
generated
vendored
Normal file
2
node_modules/eslint-plugin-import-x/lib/utils/source-type.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { TSESLint } from '@typescript-eslint/utils';
|
||||
export declare function sourceType<MessageIds extends string, Options extends readonly unknown[]>(context: TSESLint.RuleContext<MessageIds, Options>): "module" | "commonjs" | "script" | undefined;
|
||||
9
node_modules/eslint-plugin-import-x/lib/utils/source-type.js
generated
vendored
Normal file
9
node_modules/eslint-plugin-import-x/lib/utils/source-type.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export function sourceType(context) {
|
||||
if ('sourceType' in context.parserOptions) {
|
||||
return context.parserOptions.sourceType;
|
||||
}
|
||||
if ('languageOptions' in context && context.languageOptions) {
|
||||
return context.languageOptions.sourceType;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=source-type.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/source-type.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/source-type.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"source-type.js","sourceRoot":"","sources":["../../src/utils/source-type.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,UAAU,CAGxB,OAAkD;IAClD,IAAI,YAAY,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;QAC1C,OAAO,OAAO,CAAC,aAAa,CAAC,UAAU,CAAA;IACzC,CAAC;IACD,IAAI,iBAAiB,IAAI,OAAO,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;QAC5D,OAAO,OAAO,CAAC,eAAe,CAAC,UAAU,CAAA;IAC3C,CAAC;AACH,CAAC"}
|
||||
2
node_modules/eslint-plugin-import-x/lib/utils/static-require.d.ts
generated
vendored
Normal file
2
node_modules/eslint-plugin-import-x/lib/utils/static-require.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { TSESTree } from '@typescript-eslint/utils';
|
||||
export declare function isStaticRequire(node: TSESTree.CallExpression): boolean;
|
||||
10
node_modules/eslint-plugin-import-x/lib/utils/static-require.js
generated
vendored
Normal file
10
node_modules/eslint-plugin-import-x/lib/utils/static-require.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
export function isStaticRequire(node) {
|
||||
return (node &&
|
||||
node.callee &&
|
||||
node.callee.type === 'Identifier' &&
|
||||
node.callee.name === 'require' &&
|
||||
node.arguments.length === 1 &&
|
||||
node.arguments[0].type === 'Literal' &&
|
||||
typeof node.arguments[0].value === 'string');
|
||||
}
|
||||
//# sourceMappingURL=static-require.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/static-require.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/static-require.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"static-require.js","sourceRoot":"","sources":["../../src/utils/static-require.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,eAAe,CAAC,IAA6B;IAC3D,OAAO,CACL,IAAI;QACJ,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY;QACjC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS;QAC9B,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC;QAC3B,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS;QACpC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,CAC5C,CAAA;AACH,CAAC"}
|
||||
3
node_modules/eslint-plugin-import-x/lib/utils/unambiguous.d.ts
generated
vendored
Normal file
3
node_modules/eslint-plugin-import-x/lib/utils/unambiguous.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { TSESTree } from '@typescript-eslint/utils';
|
||||
export declare function isMaybeUnambiguousModule(content: string): boolean;
|
||||
export declare function isUnambiguousModule(ast: TSESTree.Program): boolean;
|
||||
9
node_modules/eslint-plugin-import-x/lib/utils/unambiguous.js
generated
vendored
Normal file
9
node_modules/eslint-plugin-import-x/lib/utils/unambiguous.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
const pattern = /(^|;)\s*(export|import)((\s+\w)|(\s*[*={]))|import\(/m;
|
||||
export function isMaybeUnambiguousModule(content) {
|
||||
return pattern.test(content);
|
||||
}
|
||||
const unambiguousNodeType = /^(?:(?:Exp|Imp)ort.*Declaration|TSExportAssignment)$/;
|
||||
export function isUnambiguousModule(ast) {
|
||||
return ast.body && ast.body.some(node => unambiguousNodeType.test(node.type));
|
||||
}
|
||||
//# sourceMappingURL=unambiguous.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/unambiguous.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/unambiguous.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"unambiguous.js","sourceRoot":"","sources":["../../src/utils/unambiguous.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAG,uDAAuD,CAAA;AAWvE,MAAM,UAAU,wBAAwB,CAAC,OAAe;IACtD,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AAC9B,CAAC;AAGD,MAAM,mBAAmB,GACvB,sDAAsD,CAAA;AAGxD,MAAM,UAAU,mBAAmB,CAAC,GAAqB;IACvD,OAAO,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;AAC/E,CAAC"}
|
||||
6
node_modules/eslint-plugin-import-x/lib/utils/visit.d.ts
generated
vendored
Normal file
6
node_modules/eslint-plugin-import-x/lib/utils/visit.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { TSESTree } from '@typescript-eslint/utils';
|
||||
export declare function visit(node: TSESTree.Node, keys: {
|
||||
[k in TSESTree.Node['type']]?: Array<keyof TSESTree.Node>;
|
||||
} | undefined | null, visitorSpec: {
|
||||
[k in TSESTree.Node['type'] | `${TSESTree.Node['type']}:Exit`]?: (node: TSESTree.Node) => void;
|
||||
}): void;
|
||||
27
node_modules/eslint-plugin-import-x/lib/utils/visit.js
generated
vendored
Normal file
27
node_modules/eslint-plugin-import-x/lib/utils/visit.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
export function visit(node, keys, visitorSpec) {
|
||||
if (!node || !keys) {
|
||||
return;
|
||||
}
|
||||
const type = node.type;
|
||||
const visitor = visitorSpec[type];
|
||||
if (typeof visitor === 'function') {
|
||||
visitor(node);
|
||||
}
|
||||
const childFields = keys[type];
|
||||
if (!childFields) {
|
||||
return;
|
||||
}
|
||||
for (const fieldName of childFields) {
|
||||
for (const item of [node[fieldName]].flat()) {
|
||||
if (!item || typeof item !== 'object' || !('type' in item)) {
|
||||
continue;
|
||||
}
|
||||
visit(item, keys, visitorSpec);
|
||||
}
|
||||
}
|
||||
const exit = visitorSpec[`${type}:Exit`];
|
||||
if (typeof exit === 'function') {
|
||||
exit(node);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=visit.js.map
|
||||
1
node_modules/eslint-plugin-import-x/lib/utils/visit.js.map
generated
vendored
Normal file
1
node_modules/eslint-plugin-import-x/lib/utils/visit.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"visit.js","sourceRoot":"","sources":["../../src/utils/visit.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,KAAK,CACnB,IAAmB,EACnB,IAGQ,EACR,WAIC;IAED,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACnB,OAAM;IACR,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;IACtB,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,CAAA;IACjC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;QAClC,OAAO,CAAC,IAAI,CAAC,CAAA;IACf,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,CAAA;IAC9B,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAM;IACR,CAAC;IAED,KAAK,MAAM,SAAS,IAAI,WAAW,EAAE,CAAC;QACpC,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YAC5C,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,EAAE,CAAC;gBAC3D,SAAQ;YACV,CAAC;YACD,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,CAAA;QAChC,CAAC;IACH,CAAC;IAED,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,IAAI,OAAO,CAAC,CAAA;IAExC,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,IAAI,CAAC,IAAI,CAAC,CAAA;IACZ,CAAC;AACH,CAAC"}
|
||||
Reference in New Issue
Block a user