first commit

This commit is contained in:
2025-10-26 23:10:15 +08:00
commit 8f0345b7be
14961 changed files with 2356381 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
declare const _default: {
settings: {
'import-x/core-modules': string[];
};
};
export default _default;

View File

@@ -0,0 +1,6 @@
export default {
settings: {
'import-x/core-modules': ['electron'],
},
};
//# sourceMappingURL=electron.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"electron.js","sourceRoot":"","sources":["../../src/config/electron.ts"],"names":[],"mappings":"AAGA,eAAe;IACb,QAAQ,EAAE;QACR,uBAAuB,EAAE,CAAC,UAAU,CAAC;KACtC;CACqB,CAAA"}

View File

@@ -0,0 +1,11 @@
declare const _default: {
plugins: ["import-x"];
rules: {
'import-x/no-unresolved': 2;
'import-x/named': 2;
'import-x/namespace': 2;
'import-x/default': 2;
'import-x/export': 2;
};
};
export default _default;

View File

@@ -0,0 +1,11 @@
export default {
plugins: ['import-x'],
rules: {
'import-x/no-unresolved': 2,
'import-x/named': 2,
'import-x/namespace': 2,
'import-x/default': 2,
'import-x/export': 2,
},
};
//# sourceMappingURL=errors.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/config/errors.ts"],"names":[],"mappings":"AAMA,eAAe;IACb,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,KAAK,EAAE;QACL,wBAAwB,EAAE,CAAC;QAC3B,gBAAgB,EAAE,CAAC;QACnB,oBAAoB,EAAE,CAAC;QACvB,kBAAkB,EAAE,CAAC;QACrB,iBAAiB,EAAE,CAAC;KACrB;CACqB,CAAA"}

View File

@@ -0,0 +1,6 @@
declare const _default: {
settings: {
'import-x/core-modules': string[];
};
};
export default _default;

View File

@@ -0,0 +1,6 @@
export default {
settings: {
'import-x/core-modules': ['electron'],
},
};
//# sourceMappingURL=electron.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"electron.js","sourceRoot":"","sources":["../../../src/config/flat/electron.ts"],"names":[],"mappings":"AAGA,eAAe;IACb,QAAQ,EAAE;QACR,uBAAuB,EAAE,CAAC,UAAU,CAAC;KACtC;CACyB,CAAA"}

View File

@@ -0,0 +1,10 @@
declare const _default: {
rules: {
'import-x/no-unresolved': 2;
'import-x/named': 2;
'import-x/namespace': 2;
'import-x/default': 2;
'import-x/export': 2;
};
};
export default _default;

View File

@@ -0,0 +1,10 @@
export default {
rules: {
'import-x/no-unresolved': 2,
'import-x/named': 2,
'import-x/namespace': 2,
'import-x/default': 2,
'import-x/export': 2,
},
};
//# sourceMappingURL=errors.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/config/flat/errors.ts"],"names":[],"mappings":"AAMA,eAAe;IACb,KAAK,EAAE;QACL,wBAAwB,EAAE,CAAC;QAC3B,gBAAgB,EAAE,CAAC;QACnB,oBAAoB,EAAE,CAAC;QACvB,kBAAkB,EAAE,CAAC;QACrB,iBAAiB,EAAE,CAAC;KACrB;CACyB,CAAA"}

View File

@@ -0,0 +1,10 @@
declare const _default: {
settings: {
'import-x/resolver': {
node: {
extensions: string[];
};
};
};
};
export default _default;

View File

@@ -0,0 +1,10 @@
export default {
settings: {
'import-x/resolver': {
node: {
extensions: ['.js', '.web.js', '.ios.js', '.android.js'],
},
},
},
};
//# sourceMappingURL=react-native.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"react-native.js","sourceRoot":"","sources":["../../../src/config/flat/react-native.ts"],"names":[],"mappings":"AAGA,eAAe;IACb,QAAQ,EAAE;QACR,mBAAmB,EAAE;YACnB,IAAI,EAAE;gBAEJ,UAAU,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,CAAC;aACzD;SACF;KACF;CAC6B,CAAA"}

View File

@@ -0,0 +1,13 @@
declare const _default: {
settings: {
'import-x/extensions': (".js" | ".mjs" | ".cjs" | ".jsx")[];
};
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true;
};
};
};
};
export default _default;

View File

@@ -0,0 +1,13 @@
export default {
settings: {
'import-x/extensions': ['.js', '.jsx', '.mjs', '.cjs'],
},
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
};
//# sourceMappingURL=react.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../../src/config/flat/react.ts"],"names":[],"mappings":"AASA,eAAe;IACb,QAAQ,EAAE;QACR,qBAAqB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;KACvD;IACD,eAAe,EAAE;QACf,aAAa,EAAE;YACb,YAAY,EAAE;gBACZ,GAAG,EAAE,IAAI;aACV;SACF;KACF;CAC6B,CAAA"}

View File

@@ -0,0 +1,13 @@
declare const _default: {
rules: {
'import-x/no-unresolved': "error";
'import-x/named': "error";
'import-x/namespace': "error";
'import-x/default': "error";
'import-x/export': "error";
'import-x/no-named-as-default': "warn";
'import-x/no-named-as-default-member': "warn";
'import-x/no-duplicates': "warn";
};
};
export default _default;

View File

@@ -0,0 +1,13 @@
export default {
rules: {
'import-x/no-unresolved': 'error',
'import-x/named': 'error',
'import-x/namespace': 'error',
'import-x/default': 'error',
'import-x/export': 'error',
'import-x/no-named-as-default': 'warn',
'import-x/no-named-as-default-member': 'warn',
'import-x/no-duplicates': 'warn',
},
};
//# sourceMappingURL=recommended.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"recommended.js","sourceRoot":"","sources":["../../../src/config/flat/recommended.ts"],"names":[],"mappings":"AAGA,eAAe;IACb,KAAK,EAAE;QAEL,wBAAwB,EAAE,OAAO;QACjC,gBAAgB,EAAE,OAAO;QACzB,oBAAoB,EAAE,OAAO;QAC7B,kBAAkB,EAAE,OAAO;QAC3B,iBAAiB,EAAE,OAAO;QAG1B,8BAA8B,EAAE,MAAM;QACtC,qCAAqC,EAAE,MAAM;QAC7C,wBAAwB,EAAE,MAAM;KACjC;CAC6B,CAAA"}

View File

@@ -0,0 +1,6 @@
declare const _default: {
rules: {
'import-x/no-deprecated': 1;
};
};
export default _default;

View File

@@ -0,0 +1,6 @@
export default {
rules: {
'import-x/no-deprecated': 1,
},
};
//# sourceMappingURL=stage-0.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"stage-0.js","sourceRoot":"","sources":["../../../src/config/flat/stage-0.ts"],"names":[],"mappings":"AAOA,eAAe;IACb,KAAK,EAAE;QACL,wBAAwB,EAAE,CAAC;KAC5B;CAC6B,CAAA"}

View File

@@ -0,0 +1,16 @@
declare const _default: {
settings: {
'import-x/extensions': readonly [".ts", ".tsx", ".cts", ".mts", ".js", ".jsx", ".cjs", ".mjs"];
'import-x/external-module-folders': string[];
'import-x/parsers': {
'@typescript-eslint/parser': (".ts" | ".tsx" | ".cts" | ".mts")[];
};
'import-x/resolver': {
typescript: true;
};
};
rules: {
'import-x/named': "off";
};
};
export default _default;

View File

@@ -0,0 +1,24 @@
const typeScriptExtensions = ['.ts', '.tsx', '.cts', '.mts'];
const allExtensions = [
...typeScriptExtensions,
'.js',
'.jsx',
'.cjs',
'.mjs',
];
export default {
settings: {
'import-x/extensions': allExtensions,
'import-x/external-module-folders': ['node_modules', 'node_modules/@types'],
'import-x/parsers': {
'@typescript-eslint/parser': [...typeScriptExtensions],
},
'import-x/resolver': {
typescript: true,
},
},
rules: {
'import-x/named': 'off',
},
};
//# sourceMappingURL=typescript.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../../src/config/flat/typescript.ts"],"names":[],"mappings":"AAYA,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAU,CAAA;AAErE,MAAM,aAAa,GAAG;IACpB,GAAG,oBAAoB;IACvB,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;CACE,CAAA;AAEV,eAAe;IACb,QAAQ,EAAE;QACR,qBAAqB,EAAE,aAAa;QACpC,kCAAkC,EAAE,CAAC,cAAc,EAAE,qBAAqB,CAAC;QAC3E,kBAAkB,EAAE;YAClB,2BAA2B,EAAE,CAAC,GAAG,oBAAoB,CAAC;SACvD;QACD,mBAAmB,EAAE;YACnB,UAAU,EAAE,IAAI;SACjB;KACF;IACD,KAAK,EAAE;QAIL,gBAAgB,EAAE,KAAK;KACxB;CAC6B,CAAA"}

View File

@@ -0,0 +1,9 @@
declare const _default: {
rules: {
'import-x/no-named-as-default': 1;
'import-x/no-named-as-default-member': 1;
'import-x/no-rename-default': 1;
'import-x/no-duplicates': 1;
};
};
export default _default;

View File

@@ -0,0 +1,9 @@
export default {
rules: {
'import-x/no-named-as-default': 1,
'import-x/no-named-as-default-member': 1,
'import-x/no-rename-default': 1,
'import-x/no-duplicates': 1,
},
};
//# sourceMappingURL=warnings.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"warnings.js","sourceRoot":"","sources":["../../../src/config/flat/warnings.ts"],"names":[],"mappings":"AAGA,eAAe;IACb,KAAK,EAAE;QACL,8BAA8B,EAAE,CAAC;QACjC,qCAAqC,EAAE,CAAC;QACxC,4BAA4B,EAAE,CAAC;QAC/B,wBAAwB,EAAE,CAAC;KAC5B;CAC6B,CAAA"}

View File

@@ -0,0 +1,10 @@
declare const _default: {
settings: {
'import-x/resolver': {
node: {
extensions: string[];
};
};
};
};
export default _default;

View File

@@ -0,0 +1,10 @@
export default {
settings: {
'import-x/resolver': {
node: {
extensions: ['.js', '.web.js', '.ios.js', '.android.js'],
},
},
},
};
//# sourceMappingURL=react-native.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"react-native.js","sourceRoot":"","sources":["../../src/config/react-native.ts"],"names":[],"mappings":"AAGA,eAAe;IACb,QAAQ,EAAE;QACR,mBAAmB,EAAE;YACnB,IAAI,EAAE;gBAEJ,UAAU,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,CAAC;aACzD;SACF;KACF;CACqB,CAAA"}

View File

@@ -0,0 +1,11 @@
declare const _default: {
settings: {
'import-x/extensions': (".js" | ".jsx")[];
};
parserOptions: {
ecmaFeatures: {
jsx: true;
};
};
};
export default _default;

View File

@@ -0,0 +1,11 @@
export default {
settings: {
'import-x/extensions': ['.js', '.jsx'],
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
};
//# sourceMappingURL=react.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../src/config/react.ts"],"names":[],"mappings":"AASA,eAAe;IACb,QAAQ,EAAE;QACR,qBAAqB,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;KACvC;IACD,aAAa,EAAE;QACb,YAAY,EAAE;YACZ,GAAG,EAAE,IAAI;SACV;KACF;CACqB,CAAA"}

View File

@@ -0,0 +1,18 @@
declare const _default: {
plugins: ["import-x"];
rules: {
'import-x/no-unresolved': "error";
'import-x/named': "error";
'import-x/namespace': "error";
'import-x/default': "error";
'import-x/export': "error";
'import-x/no-named-as-default': "warn";
'import-x/no-named-as-default-member': "warn";
'import-x/no-duplicates': "warn";
};
parserOptions: {
sourceType: "module";
ecmaVersion: 2018;
};
};
export default _default;

View File

@@ -0,0 +1,18 @@
export default {
plugins: ['import-x'],
rules: {
'import-x/no-unresolved': 'error',
'import-x/named': 'error',
'import-x/namespace': 'error',
'import-x/default': 'error',
'import-x/export': 'error',
'import-x/no-named-as-default': 'warn',
'import-x/no-named-as-default-member': 'warn',
'import-x/no-duplicates': 'warn',
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 2018,
},
};
//# sourceMappingURL=recommended.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"recommended.js","sourceRoot":"","sources":["../../src/config/recommended.ts"],"names":[],"mappings":"AAGA,eAAe;IACb,OAAO,EAAE,CAAC,UAAU,CAAC;IAErB,KAAK,EAAE;QAEL,wBAAwB,EAAE,OAAO;QACjC,gBAAgB,EAAE,OAAO;QACzB,oBAAoB,EAAE,OAAO;QAC7B,kBAAkB,EAAE,OAAO;QAC3B,iBAAiB,EAAE,OAAO;QAG1B,8BAA8B,EAAE,MAAM;QACtC,qCAAqC,EAAE,MAAM;QAC7C,wBAAwB,EAAE,MAAM;KACjC;IAID,aAAa,EAAE;QACb,UAAU,EAAE,QAAQ;QACpB,WAAW,EAAE,IAAI;KAClB;CACqB,CAAA"}

View File

@@ -0,0 +1,3 @@
import type { PluginConfig } from '../types.js';
declare const _default: PluginConfig;
export default _default;

View File

@@ -0,0 +1,7 @@
export default {
plugins: ['import-x'],
rules: {
'import-x/no-deprecated': 1,
},
};
//# sourceMappingURL=stage-0.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"stage-0.js","sourceRoot":"","sources":["../../src/config/stage-0.ts"],"names":[],"mappings":"AAOA,eAAe;IACb,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,KAAK,EAAE;QACL,wBAAwB,EAAE,CAAC;KAC5B;CACc,CAAA"}

View File

@@ -0,0 +1,16 @@
declare const _default: {
settings: {
'import-x/extensions': readonly [".ts", ".tsx", ".cts", ".mts", ".js", ".jsx", ".cjs", ".mjs"];
'import-x/external-module-folders': string[];
'import-x/parsers': {
'@typescript-eslint/parser': (".ts" | ".tsx" | ".cts" | ".mts")[];
};
'import-x/resolver': {
typescript: true;
};
};
rules: {
'import-x/named': "off";
};
};
export default _default;

View File

@@ -0,0 +1,24 @@
const typeScriptExtensions = ['.ts', '.tsx', '.cts', '.mts'];
const allExtensions = [
...typeScriptExtensions,
'.js',
'.jsx',
'.cjs',
'.mjs',
];
export default {
settings: {
'import-x/extensions': allExtensions,
'import-x/external-module-folders': ['node_modules', 'node_modules/@types'],
'import-x/parsers': {
'@typescript-eslint/parser': [...typeScriptExtensions],
},
'import-x/resolver': {
typescript: true,
},
},
rules: {
'import-x/named': 'off',
},
};
//# sourceMappingURL=typescript.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../src/config/typescript.ts"],"names":[],"mappings":"AAYA,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAU,CAAA;AAErE,MAAM,aAAa,GAAG;IACpB,GAAG,oBAAoB;IACvB,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;CACE,CAAA;AAEV,eAAe;IACb,QAAQ,EAAE;QACR,qBAAqB,EAAE,aAAa;QACpC,kCAAkC,EAAE,CAAC,cAAc,EAAE,qBAAqB,CAAC;QAC3E,kBAAkB,EAAE;YAClB,2BAA2B,EAAE,CAAC,GAAG,oBAAoB,CAAC;SACvD;QACD,mBAAmB,EAAE;YACnB,UAAU,EAAE,IAAI;SACjB;KACF;IACD,KAAK,EAAE;QAIL,gBAAgB,EAAE,KAAK;KACxB;CACqB,CAAA"}

View File

@@ -0,0 +1,10 @@
declare const _default: {
plugins: ["import-x"];
rules: {
'import-x/no-named-as-default': 1;
'import-x/no-named-as-default-member': 1;
'import-x/no-rename-default': 1;
'import-x/no-duplicates': 1;
};
};
export default _default;

View File

@@ -0,0 +1,10 @@
export default {
plugins: ['import-x'],
rules: {
'import-x/no-named-as-default': 1,
'import-x/no-named-as-default-member': 1,
'import-x/no-rename-default': 1,
'import-x/no-duplicates': 1,
},
};
//# sourceMappingURL=warnings.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"warnings.js","sourceRoot":"","sources":["../../src/config/warnings.ts"],"names":[],"mappings":"AAGA,eAAe;IACb,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,KAAK,EAAE;QACL,8BAA8B,EAAE,CAAC;QACjC,qCAAqC,EAAE,CAAC;QACxC,4BAA4B,EAAE,CAAC;QAC/B,wBAAwB,EAAE,CAAC;KAC5B;CACqB,CAAA"}

7481
node_modules/eslint-plugin-import-x/lib/index.cjs generated vendored Normal file

File diff suppressed because it is too large Load Diff

564
node_modules/eslint-plugin-import-x/lib/index.d.cts generated vendored Normal file
View File

@@ -0,0 +1,564 @@
import { TSESLint, TSESTree } from "@typescript-eslint/utils";
import { ChildContext, DocStyle, FileExtension, ImportSettings, ImportSettings as ImportSettings$1, LegacyImportResolver, LegacyImportResolver as ImportResolver, LegacyResolver, LegacyResolverName, LegacyResolverName as ResolverName, LegacyResolverObject, LegacyResolverObject as ResolverObject, LegacyResolverRecord, LegacyResolverRecord as ResolverRecord, LegacyResolverResolve, LegacyResolverResolve as ResolverResolve, LegacyResolverResolveImport, LegacyResolverResolveImport as ResolverResolveImport, NewResolver, NewResolverResolve, NodeResolverOptions, PluginName, PluginSettings, PluginSettings as PluginSettings$1, ResolvedResult, Resolver, ResultFound, ResultNotFound, RuleContext, TsResolverOptions, WebpackResolverOptions, WithPluginName } from "eslint-import-context";
import { MinimatchOptions } from "minimatch";
import { NapiResolveOptions } from "unrs-resolver";
//#region src/utils/create-rule.d.ts
interface ImportXPluginDocs {
/** The category the rule falls under */
category?: string;
recommended?: true;
}
//#endregion
//#region src/types.d.ts
type ImportType = ImportType$1 | 'object' | 'type';
type Arrayable<T> = T | readonly T[];
interface PluginConfig extends TSESLint.ClassicConfig.Config {
plugins?: [PluginName];
settings?: PluginSettings$1;
rules?: Record<`${PluginName}/${string}`, TSESLint.ClassicConfig.RuleEntry>;
}
interface PluginFlatBaseConfig extends TSESLint.FlatConfig.Config {
settings?: PluginSettings$1;
rules?: Record<`${PluginName}/${string}`, TSESLint.FlatConfig.RuleEntry>;
}
interface PluginFlatConfig extends PluginFlatBaseConfig {
name?: `${PluginName}/${string}`;
}
interface ParseError extends Error {
lineNumber: number;
column: number;
}
interface CustomESTreeNode<Type extends string> extends Omit<TSESTree.BaseNode, 'type'> {
type: Type;
}
type ExportDefaultSpecifier = CustomESTreeNode<'ExportDefaultSpecifier'>;
interface ExportNamespaceSpecifier extends CustomESTreeNode<'ExportNamespaceSpecifier'> {
exported: TSESTree.Identifier;
}
interface PathGroup {
pattern: string;
group: ImportType;
patternOptions?: MinimatchOptions;
position?: 'before' | 'after';
}
type ExportAndImportKind = 'value' | 'type';
type NewLinesOptions = 'always' | 'always-and-inside-groups' | 'ignore' | 'never';
type NamedTypes = 'mixed' | 'types-first' | 'types-last';
interface NamedOptions {
enabled?: boolean;
import?: boolean;
export?: boolean;
require?: boolean;
cjsExports?: boolean;
types?: NamedTypes;
}
interface AlphabetizeOptions {
caseInsensitive: boolean;
order: 'ignore' | 'asc' | 'desc';
orderImportKind: 'ignore' | 'asc' | 'desc';
}
type ImportEntryType = 'import:object' | 'import' | 'require' | 'export';
type LiteralNodeValue = string | number | bigint | boolean | RegExp | null;
interface ImportEntry {
type: ImportEntryType;
node: TSESTree.Node & {
importKind?: ExportAndImportKind;
exportKind?: ExportAndImportKind;
};
value: LiteralNodeValue;
alias?: string;
kind?: ExportAndImportKind;
displayName?: LiteralNodeValue;
}
interface ImportEntryWithRank extends ImportEntry {
rank: number;
isMultiline?: boolean;
}
interface RanksPathGroup {
pattern: string;
patternOptions?: MinimatchOptions;
group: string;
position?: number;
}
type RanksGroups = Record<string, number>;
interface Ranks {
omittedTypes: string[];
groups: RanksGroups;
pathGroups: RanksPathGroup[];
maxPosition: number;
}
interface CjsRequire extends NodeJS.Require {
<T>(id: string): T;
}
type SetValue<T extends Set<unknown>> = T extends Set<infer U> ? U : never;
interface NormalizedCacheSettings extends NonNullable<ImportSettings$1['cache']> {
lifetime: number;
}
//#endregion
//#region src/utils/import-type.d.ts
/**
* Returns the type of the module.
*
* @param name The name of the module to check
* @param context The context of the rule
* @returns The type of the module
*/
declare function importType(name: LiteralNodeValue, context: RuleContext): "absolute" | "builtin" | "internal" | "parent" | "index" | "sibling" | "external" | "unknown";
type ImportType$1 = ReturnType<typeof importType>;
//#endregion
//#region src/utils/module-visitor.d.ts
interface ModuleOptions {
amd?: boolean;
commonjs?: boolean;
esmodule?: boolean;
ignore?: string[];
}
/**
* Returns an object of node visitors that will call 'visitor' with every
* discovered module path.
*/
//#endregion
//#region src/utils/resolve.d.ts
declare function importXResolverCompat(resolver: LegacyResolver | NewResolver, resolverOptions?: unknown): NewResolver;
//#endregion
//#region src/rules/no-unresolved.d.ts
type Options$26 = ModuleOptions & {
caseSensitive?: boolean;
caseSensitiveStrict?: boolean;
};
type MessageId$12 = 'unresolved' | 'casingMismatch';
//#endregion
//#region src/rules/named.d.ts
type MessageId$11 = 'notFound' | 'notFoundDeep';
//#endregion
//#region src/rules/namespace.d.ts
type MessageId$10 = 'noNamesFound' | 'computedReference' | 'namespaceMember' | 'topLevelNames' | 'notFoundInNamespace' | 'notFoundInNamespaceDeep';
interface Options$25 {
allowComputed?: boolean;
}
//#endregion
//#region src/rules/no-namespace.d.ts
interface Options$24 {
ignore?: string[];
}
//#endregion
//#region src/rules/export.d.ts
type MessageId$9 = 'noNamed' | 'multiDefault' | 'multiNamed';
//#endregion
//#region src/rules/extensions.d.ts
declare const modifierValues: readonly ["always", "ignorePackages", "never"];
type Modifier = (typeof modifierValues)[number];
type ModifierByFileExtension = Partial<Record<string, Modifier>>;
interface OptionsItemWithPatternProperty {
ignorePackages?: boolean;
checkTypeImports?: boolean;
pattern: ModifierByFileExtension;
pathGroupOverrides?: PathGroupOverride[];
fix?: boolean;
}
interface PathGroupOverride {
pattern: string;
patternOptions?: Record<string, MinimatchOptions>;
action: 'enforce' | 'ignore';
}
interface OptionsItemWithoutPatternProperty {
ignorePackages?: boolean;
checkTypeImports?: boolean;
pathGroupOverrides?: PathGroupOverride[];
fix?: boolean;
}
type Options$23 = [] | [OptionsItemWithoutPatternProperty] | [OptionsItemWithPatternProperty] | [Modifier] | [Modifier, OptionsItemWithoutPatternProperty] | [Modifier, OptionsItemWithPatternProperty] | [Modifier, ModifierByFileExtension] | [ModifierByFileExtension];
type MessageId$8 = 'missing' | 'missingKnown' | 'unexpected' | 'addMissing' | 'removeUnexpected';
//#endregion
//#region src/rules/no-restricted-paths.d.ts
interface Options$22 {
basePath?: string;
zones?: Array<{
from: Arrayable<string>;
target: Arrayable<string>;
message?: string;
except?: string[];
}>;
}
type MessageId$7 = 'path' | 'mixedGlob' | 'glob' | 'zone';
//#endregion
//#region src/rules/no-internal-modules.d.ts
interface Options$21 {
allow?: string[];
forbid?: string[];
}
//#endregion
//#region src/rules/group-exports.d.ts
type MessageId$6 = 'ExportNamedDeclaration' | 'AssignmentExpression';
//#endregion
//#region src/rules/consistent-type-specifier-style.d.ts
type Options$20 = 'prefer-inline' | 'prefer-top-level';
//#endregion
//#region src/rules/no-cycle.d.ts
interface Options$19 extends ModuleOptions {
allowUnsafeDynamicCyclicDependency?: boolean;
ignoreExternal?: boolean;
maxDepth?: number | '∞';
}
type MessageId$5 = 'cycle' | 'cycleSource';
//#endregion
//#region src/rules/no-anonymous-default-export.d.ts
interface Options$18 {
allowArray?: boolean;
allowArrowFunction?: boolean;
allowCallExpression?: boolean;
allowAnonymousClass?: boolean;
allowAnonymousFunction?: boolean;
allowLiteral?: boolean;
allowObject?: boolean;
allowNew?: boolean;
}
//#endregion
//#region src/rules/no-rename-default.d.ts
type Options$17 = ModuleOptions & {
preventRenamingBindings?: boolean;
};
//#endregion
//#region src/rules/no-unused-modules.d.ts
interface Options$16 {
src?: string[];
ignoreExports?: string[];
missingExports?: true;
unusedExports?: boolean;
ignoreUnusedTypeExports?: boolean;
}
//#endregion
//#region src/rules/no-commonjs.d.ts
interface NormalizedOptions {
allowPrimitiveModules?: boolean;
allowRequire?: boolean;
allowConditionalRequire?: boolean;
}
type Options$15 = 'allow-primitive-modules' | NormalizedOptions;
//#endregion
//#region src/rules/no-duplicates.d.ts
interface Options$14 {
considerQueryString?: boolean;
'prefer-inline'?: boolean;
}
//#endregion
//#region src/rules/first.d.ts
type Options$13 = 'absolute-first' | 'disable-absolute-first';
type MessageId$4 = 'absolute' | 'order';
//#endregion
//#region src/rules/max-dependencies.d.ts
interface Options$12 {
ignoreTypeImports?: boolean;
max?: number;
}
//#endregion
//#region src/rules/no-extraneous-dependencies.d.ts
interface Options$11 {
packageDir?: string | string[];
devDependencies?: boolean | string[];
optionalDependencies?: boolean | string[];
peerDependencies?: boolean | string[];
bundledDependencies?: boolean | string[];
includeInternal?: boolean;
includeTypes?: boolean;
whitelist?: string[];
}
type MessageId$3 = 'pkgNotFound' | 'pkgUnparsable' | 'devDep' | 'optDep' | 'missing';
//#endregion
//#region src/rules/no-nodejs-modules.d.ts
interface Options$10 {
allow?: string[];
}
//#endregion
//#region src/rules/order.d.ts
interface Options$9 {
'newlines-between'?: NewLinesOptions;
'newlines-between-types'?: NewLinesOptions;
named?: boolean | NamedOptions;
alphabetize?: Partial<AlphabetizeOptions>;
consolidateIslands?: 'inside-groups' | 'never';
distinctGroup?: boolean;
groups?: ReadonlyArray<Arrayable<ImportType>>;
pathGroupsExcludedImportTypes?: ImportType[];
pathGroups?: PathGroup[];
sortTypesGroup?: boolean;
warnOnUnassignedImports?: boolean;
}
//#endregion
//#region src/rules/newline-after-import.d.ts
interface Options$8 {
count?: number;
exactCount?: boolean;
considerComments?: boolean;
}
//#endregion
//#region src/rules/prefer-default-export.d.ts
interface Options$7 {
target?: 'single' | 'any';
}
type MessageId$2 = 'single' | 'any';
//#endregion
//#region src/rules/prefer-namespace-import.d.ts
interface Options$6 {
patterns?: readonly string[];
}
//#endregion
//#region src/rules/no-dynamic-require.d.ts
interface Options$5 {
esmodule?: boolean;
}
type MessageId$1 = 'import' | 'require';
//#endregion
//#region src/rules/no-unassigned-import.d.ts
interface Options$4 {
allow?: string[];
}
//#endregion
//#region src/rules/no-useless-path-segments.d.ts
interface Options$3 extends ModuleOptions {
noUselessIndex?: boolean;
}
//#endregion
//#region src/rules/dynamic-import-chunkname.d.ts
interface Options$2 {
allowEmpty?: boolean;
importFunctions?: readonly string[];
webpackChunknameFormat?: string;
}
type MessageId = 'leadingComment' | 'blockComment' | 'paddedSpaces' | 'webpackComment' | 'chunknameFormat' | 'webpackEagerModeNoChunkName' | 'webpackRemoveEagerMode' | 'webpackRemoveChunkName';
//#endregion
//#region src/rules/no-import-module-exports.d.ts
interface Options$1 {
exceptions?: string[];
}
//#endregion
//#region src/meta.d.ts
declare const meta$1: {
name: string;
version: string;
};
//#endregion
//#region src/node-resolver.d.ts
declare function createNodeResolver({
extensions,
conditionNames,
mainFields,
...restOptions
}?: NapiResolveOptions): NewResolver;
//#endregion
//#region src/require.d.ts
declare const cjsRequire: CjsRequire;
//#endregion
//#region src/index.d.ts
declare const rules: {
'no-unresolved': TSESLint.RuleModule<MessageId$12, [Options$26?], ImportXPluginDocs, TSESLint.RuleListener>;
named: TSESLint.RuleModule<MessageId$11, [ModuleOptions?], ImportXPluginDocs, TSESLint.RuleListener>;
default: TSESLint.RuleModule<"noDefaultExport", [], ImportXPluginDocs, TSESLint.RuleListener>;
namespace: TSESLint.RuleModule<MessageId$10, [Options$25], ImportXPluginDocs, TSESLint.RuleListener>;
'no-namespace': TSESLint.RuleModule<"noNamespace", [Options$24?], ImportXPluginDocs, TSESLint.RuleListener>;
export: TSESLint.RuleModule<MessageId$9, [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-mutable-exports': TSESLint.RuleModule<"noMutable", [], ImportXPluginDocs, TSESLint.RuleListener>;
extensions: TSESLint.RuleModule<MessageId$8, Options$23, ImportXPluginDocs, TSESLint.RuleListener>;
'no-restricted-paths': TSESLint.RuleModule<MessageId$7, [Options$22?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-internal-modules': TSESLint.RuleModule<"noAllowed", [Options$21?], ImportXPluginDocs, TSESLint.RuleListener>;
'group-exports': TSESLint.RuleModule<MessageId$6, [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-relative-packages': TSESLint.RuleModule<"noAllowed", [ModuleOptions?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-relative-parent-imports': TSESLint.RuleModule<"noAllowed", [ModuleOptions?], ImportXPluginDocs, TSESLint.RuleListener>;
'consistent-type-specifier-style': TSESLint.RuleModule<"inline" | "topLevel", [Options$20?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-self-import': TSESLint.RuleModule<"self", [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-cycle': TSESLint.RuleModule<MessageId$5, [Options$19?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-named-default': TSESLint.RuleModule<"default", [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-named-as-default': TSESLint.RuleModule<"default", [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-named-as-default-member': TSESLint.RuleModule<"member", [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-anonymous-default-export': TSESLint.RuleModule<"assign" | "anonymous", [Options$18?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-rename-default': TSESLint.RuleModule<"renameDefault", [Options$17?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-unused-modules': TSESLint.RuleModule<"notFound" | "unused", Options$16[], ImportXPluginDocs, TSESLint.RuleListener>;
'no-commonjs': TSESLint.RuleModule<"export" | "import", [Options$15?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-amd': TSESLint.RuleModule<"amd", [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-duplicates': TSESLint.RuleModule<"duplicate", [Options$14?], ImportXPluginDocs, TSESLint.RuleListener>;
first: TSESLint.RuleModule<MessageId$4, [Options$13?], ImportXPluginDocs, TSESLint.RuleListener>;
'max-dependencies': TSESLint.RuleModule<"max", [Options$12?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-extraneous-dependencies': TSESLint.RuleModule<MessageId$3, [Options$11?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-absolute-path': TSESLint.RuleModule<"absolute", [ModuleOptions?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-nodejs-modules': TSESLint.RuleModule<"builtin", [Options$10?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-webpack-loader-syntax': TSESLint.RuleModule<"unexpected", [], ImportXPluginDocs, TSESLint.RuleListener>;
order: TSESLint.RuleModule<"order" | "error" | "noLineWithinGroup" | "noLineBetweenGroups" | "oneLineBetweenGroups" | "oneLineBetweenTheMultiLineImport" | "oneLineBetweenThisMultiLineImport" | "noLineBetweenSingleLineImport", [Options$9?], ImportXPluginDocs, TSESLint.RuleListener>;
'newline-after-import': TSESLint.RuleModule<"newline", [Options$8?], ImportXPluginDocs, TSESLint.RuleListener>;
'prefer-default-export': TSESLint.RuleModule<MessageId$2, [Options$7?], ImportXPluginDocs, TSESLint.RuleListener>;
'prefer-namespace-import': TSESLint.RuleModule<"preferNamespaceImport", [Options$6?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-default-export': TSESLint.RuleModule<"preferNamed" | "noAliasDefault", [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-named-export': TSESLint.RuleModule<"noAllowed", [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-dynamic-require': TSESLint.RuleModule<MessageId$1, [Options$5?], ImportXPluginDocs, TSESLint.RuleListener>;
unambiguous: TSESLint.RuleModule<"module", [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-unassigned-import': TSESLint.RuleModule<"unassigned", [Options$4?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-useless-path-segments': TSESLint.RuleModule<"useless", [Options$3?], ImportXPluginDocs, TSESLint.RuleListener>;
'dynamic-import-chunkname': TSESLint.RuleModule<MessageId, [Options$2?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-import-module-exports': TSESLint.RuleModule<"notAllowed", [Options$1?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-empty-named-blocks': TSESLint.RuleModule<"unused" | "emptyNamed" | "emptyImport", [], ImportXPluginDocs, TSESLint.RuleListener>;
'exports-last': TSESLint.RuleModule<"end", [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-deprecated': TSESLint.RuleModule<"deprecated" | "deprecatedDesc", [], ImportXPluginDocs, TSESLint.RuleListener>;
'imports-first': TSESLint.RuleModule<MessageId$4, [Options$13?], ImportXPluginDocs, TSESLint.RuleListener>;
};
declare const plugin_: {
meta: {
name: string;
version: string;
};
rules: {
'no-unresolved': TSESLint.RuleModule<MessageId$12, [Options$26?], ImportXPluginDocs, TSESLint.RuleListener>;
named: TSESLint.RuleModule<MessageId$11, [ModuleOptions?], ImportXPluginDocs, TSESLint.RuleListener>;
default: TSESLint.RuleModule<"noDefaultExport", [], ImportXPluginDocs, TSESLint.RuleListener>;
namespace: TSESLint.RuleModule<MessageId$10, [Options$25], ImportXPluginDocs, TSESLint.RuleListener>;
'no-namespace': TSESLint.RuleModule<"noNamespace", [Options$24?], ImportXPluginDocs, TSESLint.RuleListener>;
export: TSESLint.RuleModule<MessageId$9, [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-mutable-exports': TSESLint.RuleModule<"noMutable", [], ImportXPluginDocs, TSESLint.RuleListener>;
extensions: TSESLint.RuleModule<MessageId$8, Options$23, ImportXPluginDocs, TSESLint.RuleListener>;
'no-restricted-paths': TSESLint.RuleModule<MessageId$7, [Options$22?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-internal-modules': TSESLint.RuleModule<"noAllowed", [Options$21?], ImportXPluginDocs, TSESLint.RuleListener>;
'group-exports': TSESLint.RuleModule<MessageId$6, [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-relative-packages': TSESLint.RuleModule<"noAllowed", [ModuleOptions?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-relative-parent-imports': TSESLint.RuleModule<"noAllowed", [ModuleOptions?], ImportXPluginDocs, TSESLint.RuleListener>;
'consistent-type-specifier-style': TSESLint.RuleModule<"inline" | "topLevel", [Options$20?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-self-import': TSESLint.RuleModule<"self", [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-cycle': TSESLint.RuleModule<MessageId$5, [Options$19?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-named-default': TSESLint.RuleModule<"default", [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-named-as-default': TSESLint.RuleModule<"default", [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-named-as-default-member': TSESLint.RuleModule<"member", [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-anonymous-default-export': TSESLint.RuleModule<"assign" | "anonymous", [Options$18?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-rename-default': TSESLint.RuleModule<"renameDefault", [Options$17?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-unused-modules': TSESLint.RuleModule<"notFound" | "unused", Options$16[], ImportXPluginDocs, TSESLint.RuleListener>;
'no-commonjs': TSESLint.RuleModule<"export" | "import", [Options$15?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-amd': TSESLint.RuleModule<"amd", [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-duplicates': TSESLint.RuleModule<"duplicate", [Options$14?], ImportXPluginDocs, TSESLint.RuleListener>;
first: TSESLint.RuleModule<MessageId$4, [Options$13?], ImportXPluginDocs, TSESLint.RuleListener>;
'max-dependencies': TSESLint.RuleModule<"max", [Options$12?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-extraneous-dependencies': TSESLint.RuleModule<MessageId$3, [Options$11?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-absolute-path': TSESLint.RuleModule<"absolute", [ModuleOptions?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-nodejs-modules': TSESLint.RuleModule<"builtin", [Options$10?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-webpack-loader-syntax': TSESLint.RuleModule<"unexpected", [], ImportXPluginDocs, TSESLint.RuleListener>;
order: TSESLint.RuleModule<"order" | "error" | "noLineWithinGroup" | "noLineBetweenGroups" | "oneLineBetweenGroups" | "oneLineBetweenTheMultiLineImport" | "oneLineBetweenThisMultiLineImport" | "noLineBetweenSingleLineImport", [Options$9?], ImportXPluginDocs, TSESLint.RuleListener>;
'newline-after-import': TSESLint.RuleModule<"newline", [Options$8?], ImportXPluginDocs, TSESLint.RuleListener>;
'prefer-default-export': TSESLint.RuleModule<MessageId$2, [Options$7?], ImportXPluginDocs, TSESLint.RuleListener>;
'prefer-namespace-import': TSESLint.RuleModule<"preferNamespaceImport", [Options$6?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-default-export': TSESLint.RuleModule<"preferNamed" | "noAliasDefault", [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-named-export': TSESLint.RuleModule<"noAllowed", [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-dynamic-require': TSESLint.RuleModule<MessageId$1, [Options$5?], ImportXPluginDocs, TSESLint.RuleListener>;
unambiguous: TSESLint.RuleModule<"module", [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-unassigned-import': TSESLint.RuleModule<"unassigned", [Options$4?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-useless-path-segments': TSESLint.RuleModule<"useless", [Options$3?], ImportXPluginDocs, TSESLint.RuleListener>;
'dynamic-import-chunkname': TSESLint.RuleModule<MessageId, [Options$2?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-import-module-exports': TSESLint.RuleModule<"notAllowed", [Options$1?], ImportXPluginDocs, TSESLint.RuleListener>;
'no-empty-named-blocks': TSESLint.RuleModule<"unused" | "emptyNamed" | "emptyImport", [], ImportXPluginDocs, TSESLint.RuleListener>;
'exports-last': TSESLint.RuleModule<"end", [], ImportXPluginDocs, TSESLint.RuleListener>;
'no-deprecated': TSESLint.RuleModule<"deprecated" | "deprecatedDesc", [], ImportXPluginDocs, TSESLint.RuleListener>;
'imports-first': TSESLint.RuleModule<MessageId$4, [Options$13?], ImportXPluginDocs, TSESLint.RuleListener>;
};
cjsRequire: CjsRequire;
importXResolverCompat: typeof importXResolverCompat;
createNodeResolver: typeof createNodeResolver;
};
declare const flatConfigs: {
recommended: PluginFlatConfig;
errors: PluginFlatConfig;
warnings: PluginFlatConfig;
'stage-0': PluginFlatConfig;
react: PluginFlatConfig;
'react-native': PluginFlatConfig;
electron: PluginFlatConfig;
typescript: PluginFlatConfig;
};
declare const configs: {
recommended: {
plugins: ["import-x"];
rules: {
'import-x/no-unresolved': "error";
'import-x/named': "error";
'import-x/namespace': "error";
'import-x/default': "error";
'import-x/export': "error";
'import-x/no-named-as-default': "warn";
'import-x/no-named-as-default-member': "warn";
'import-x/no-duplicates': "warn";
};
parserOptions: {
sourceType: "module";
ecmaVersion: 2018;
};
};
errors: {
plugins: ["import-x"];
rules: {
'import-x/no-unresolved': 2;
'import-x/named': 2;
'import-x/namespace': 2;
'import-x/default': 2;
'import-x/export': 2;
};
};
warnings: {
plugins: ["import-x"];
rules: {
'import-x/no-named-as-default': 1;
'import-x/no-named-as-default-member': 1;
'import-x/no-rename-default': 1;
'import-x/no-duplicates': 1;
};
};
'stage-0': PluginConfig;
react: {
settings: {
'import-x/extensions': (".js" | ".jsx")[];
};
parserOptions: {
ecmaFeatures: {
jsx: true;
};
};
};
'react-native': {
settings: {
'import-x/resolver': {
node: {
extensions: string[];
};
};
};
};
electron: {
settings: {
'import-x/core-modules': string[];
};
};
typescript: {
settings: {
'import-x/extensions': readonly [".ts", ".tsx", ".cts", ".mts", ".js", ".jsx", ".cjs", ".mjs"];
'import-x/external-module-folders': string[];
'import-x/parsers': {
'@typescript-eslint/parser': (".ts" | ".tsx" | ".cts" | ".mts")[];
};
'import-x/resolver': {
typescript: true;
};
};
rules: {
'import-x/named': "off";
};
};
'flat/recommended': PluginFlatConfig;
'flat/errors': PluginFlatConfig;
'flat/warnings': PluginFlatConfig;
'flat/stage-0': PluginFlatConfig;
'flat/react': PluginFlatConfig;
'flat/react-native': PluginFlatConfig;
'flat/electron': PluginFlatConfig;
'flat/typescript': PluginFlatConfig;
};
declare const plugin: typeof plugin_ & {
flatConfigs: typeof flatConfigs;
configs: typeof configs;
};
//#endregion
export { AlphabetizeOptions, Arrayable, ChildContext, CjsRequire, CustomESTreeNode, DocStyle, ExportAndImportKind, ExportDefaultSpecifier, ExportNamespaceSpecifier, FileExtension, ImportEntry, ImportEntryType, ImportEntryWithRank, ImportResolver, ImportSettings, ImportType, LegacyImportResolver, LegacyResolver, LegacyResolverName, LegacyResolverObject, LegacyResolverRecord, LegacyResolverResolve, LegacyResolverResolveImport, LiteralNodeValue, NamedOptions, NamedTypes, NewLinesOptions, NewResolver, NewResolverResolve, NodeResolverOptions, NormalizedCacheSettings, ParseError, PathGroup, PluginConfig, PluginFlatBaseConfig, PluginFlatConfig, PluginSettings, Ranks, RanksGroups, RanksPathGroup, ResolvedResult, Resolver, ResolverName, ResolverObject, ResolverRecord, ResolverResolve, ResolverResolveImport, ResultFound, ResultNotFound, RuleContext, SetValue, TsResolverOptions, WebpackResolverOptions, WithPluginName, cjsRequire, configs, createNodeResolver, plugin as default, plugin as importX, flatConfigs, importXResolverCompat, meta$1 as meta, rules };

216
node_modules/eslint-plugin-import-x/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,216 @@
import type { TSESLint } from '@typescript-eslint/utils';
import { meta } from './meta.js';
import { createNodeResolver } from './node-resolver.js';
import { cjsRequire } from './require.js';
import type { PluginConfig, PluginFlatConfig } from './types.js';
import { importXResolverCompat } from './utils/index.js';
declare const rules: {
'no-unresolved': TSESLint.RuleModule<import("./rules/no-unresolved.js").MessageId, [(import("./rules/no-unresolved.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
named: TSESLint.RuleModule<import("./rules/named.js").MessageId, [(import("./utils/module-visitor.ts").ModuleOptions | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
default: TSESLint.RuleModule<"noDefaultExport", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
namespace: TSESLint.RuleModule<import("./rules/namespace.js").MessageId, [import("./rules/namespace.js").Options], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-namespace': TSESLint.RuleModule<"noNamespace", [(import("./rules/no-namespace.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
export: TSESLint.RuleModule<import("./rules/export.js").MessageId, [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-mutable-exports': TSESLint.RuleModule<"noMutable", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
extensions: TSESLint.RuleModule<import("./rules/extensions.js").MessageId, import("./rules/extensions.js").Options, import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-restricted-paths': TSESLint.RuleModule<import("./rules/no-restricted-paths.js").MessageId, [(import("./rules/no-restricted-paths.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-internal-modules': TSESLint.RuleModule<"noAllowed", [(import("./rules/no-internal-modules.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'group-exports': TSESLint.RuleModule<import("./rules/group-exports.js").MessageId, [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-relative-packages': TSESLint.RuleModule<"noAllowed", [(import("./utils/module-visitor.ts").ModuleOptions | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-relative-parent-imports': TSESLint.RuleModule<"noAllowed", [(import("./utils/module-visitor.ts").ModuleOptions | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'consistent-type-specifier-style': TSESLint.RuleModule<"inline" | "topLevel", [(import("./rules/consistent-type-specifier-style.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-self-import': TSESLint.RuleModule<"self", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-cycle': TSESLint.RuleModule<import("./rules/no-cycle.js").MessageId, [(import("./rules/no-cycle.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-named-default': TSESLint.RuleModule<"default", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-named-as-default': TSESLint.RuleModule<"default", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-named-as-default-member': TSESLint.RuleModule<"member", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-anonymous-default-export': TSESLint.RuleModule<"assign" | "anonymous", [(import("./rules/no-anonymous-default-export.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-rename-default': TSESLint.RuleModule<"renameDefault", [(import("./rules/no-rename-default.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-unused-modules': TSESLint.RuleModule<"notFound" | "unused", import("./rules/no-unused-modules.js").Options[], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-commonjs': TSESLint.RuleModule<"import" | "export", [(import("./rules/no-commonjs.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-amd': TSESLint.RuleModule<"amd", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-duplicates': TSESLint.RuleModule<"duplicate", [(import("./rules/no-duplicates.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
first: TSESLint.RuleModule<import("./rules/first.js").MessageId, [(import("./rules/first.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'max-dependencies': TSESLint.RuleModule<"max", [(import("./rules/max-dependencies.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-extraneous-dependencies': TSESLint.RuleModule<import("./rules/no-extraneous-dependencies.js").MessageId, [(import("./rules/no-extraneous-dependencies.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-absolute-path': TSESLint.RuleModule<"absolute", [(import("./utils/module-visitor.ts").ModuleOptions | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-nodejs-modules': TSESLint.RuleModule<"builtin", [(import("./rules/no-nodejs-modules.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-webpack-loader-syntax': TSESLint.RuleModule<"unexpected", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
order: TSESLint.RuleModule<"error" | "order" | "noLineWithinGroup" | "noLineBetweenGroups" | "oneLineBetweenGroups" | "oneLineBetweenTheMultiLineImport" | "oneLineBetweenThisMultiLineImport" | "noLineBetweenSingleLineImport", [(import("./rules/order.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'newline-after-import': TSESLint.RuleModule<"newline", [(import("./rules/newline-after-import.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'prefer-default-export': TSESLint.RuleModule<import("./rules/prefer-default-export.js").MessageId, [(import("./rules/prefer-default-export.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'prefer-namespace-import': TSESLint.RuleModule<"preferNamespaceImport", [(import("./rules/prefer-namespace-import.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-default-export': TSESLint.RuleModule<"preferNamed" | "noAliasDefault", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-named-export': TSESLint.RuleModule<"noAllowed", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-dynamic-require': TSESLint.RuleModule<import("./rules/no-dynamic-require.js").MessageId, [(import("./rules/no-dynamic-require.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
unambiguous: TSESLint.RuleModule<"module", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-unassigned-import': TSESLint.RuleModule<"unassigned", [(import("./rules/no-unassigned-import.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-useless-path-segments': TSESLint.RuleModule<"useless", [(import("./rules/no-useless-path-segments.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'dynamic-import-chunkname': TSESLint.RuleModule<import("./rules/dynamic-import-chunkname.js").MessageId, [(import("./rules/dynamic-import-chunkname.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-import-module-exports': TSESLint.RuleModule<"notAllowed", [(import("./rules/no-import-module-exports.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-empty-named-blocks': TSESLint.RuleModule<"emptyNamed" | "unused" | "emptyImport", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'exports-last': TSESLint.RuleModule<"end", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-deprecated': TSESLint.RuleModule<"deprecated" | "deprecatedDesc", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'imports-first': TSESLint.RuleModule<import("./rules/first.js").MessageId, [(import("./rules/first.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
};
declare const plugin_: {
meta: {
name: string;
version: string;
};
rules: {
'no-unresolved': TSESLint.RuleModule<import("./rules/no-unresolved.js").MessageId, [(import("./rules/no-unresolved.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
named: TSESLint.RuleModule<import("./rules/named.js").MessageId, [(import("./utils/module-visitor.ts").ModuleOptions | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
default: TSESLint.RuleModule<"noDefaultExport", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
namespace: TSESLint.RuleModule<import("./rules/namespace.js").MessageId, [import("./rules/namespace.js").Options], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-namespace': TSESLint.RuleModule<"noNamespace", [(import("./rules/no-namespace.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
export: TSESLint.RuleModule<import("./rules/export.js").MessageId, [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-mutable-exports': TSESLint.RuleModule<"noMutable", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
extensions: TSESLint.RuleModule<import("./rules/extensions.js").MessageId, import("./rules/extensions.js").Options, import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-restricted-paths': TSESLint.RuleModule<import("./rules/no-restricted-paths.js").MessageId, [(import("./rules/no-restricted-paths.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-internal-modules': TSESLint.RuleModule<"noAllowed", [(import("./rules/no-internal-modules.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'group-exports': TSESLint.RuleModule<import("./rules/group-exports.js").MessageId, [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-relative-packages': TSESLint.RuleModule<"noAllowed", [(import("./utils/module-visitor.ts").ModuleOptions | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-relative-parent-imports': TSESLint.RuleModule<"noAllowed", [(import("./utils/module-visitor.ts").ModuleOptions | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'consistent-type-specifier-style': TSESLint.RuleModule<"inline" | "topLevel", [(import("./rules/consistent-type-specifier-style.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-self-import': TSESLint.RuleModule<"self", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-cycle': TSESLint.RuleModule<import("./rules/no-cycle.js").MessageId, [(import("./rules/no-cycle.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-named-default': TSESLint.RuleModule<"default", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-named-as-default': TSESLint.RuleModule<"default", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-named-as-default-member': TSESLint.RuleModule<"member", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-anonymous-default-export': TSESLint.RuleModule<"assign" | "anonymous", [(import("./rules/no-anonymous-default-export.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-rename-default': TSESLint.RuleModule<"renameDefault", [(import("./rules/no-rename-default.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-unused-modules': TSESLint.RuleModule<"notFound" | "unused", import("./rules/no-unused-modules.js").Options[], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-commonjs': TSESLint.RuleModule<"import" | "export", [(import("./rules/no-commonjs.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-amd': TSESLint.RuleModule<"amd", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-duplicates': TSESLint.RuleModule<"duplicate", [(import("./rules/no-duplicates.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
first: TSESLint.RuleModule<import("./rules/first.js").MessageId, [(import("./rules/first.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'max-dependencies': TSESLint.RuleModule<"max", [(import("./rules/max-dependencies.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-extraneous-dependencies': TSESLint.RuleModule<import("./rules/no-extraneous-dependencies.js").MessageId, [(import("./rules/no-extraneous-dependencies.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-absolute-path': TSESLint.RuleModule<"absolute", [(import("./utils/module-visitor.ts").ModuleOptions | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-nodejs-modules': TSESLint.RuleModule<"builtin", [(import("./rules/no-nodejs-modules.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-webpack-loader-syntax': TSESLint.RuleModule<"unexpected", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
order: TSESLint.RuleModule<"error" | "order" | "noLineWithinGroup" | "noLineBetweenGroups" | "oneLineBetweenGroups" | "oneLineBetweenTheMultiLineImport" | "oneLineBetweenThisMultiLineImport" | "noLineBetweenSingleLineImport", [(import("./rules/order.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'newline-after-import': TSESLint.RuleModule<"newline", [(import("./rules/newline-after-import.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'prefer-default-export': TSESLint.RuleModule<import("./rules/prefer-default-export.js").MessageId, [(import("./rules/prefer-default-export.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'prefer-namespace-import': TSESLint.RuleModule<"preferNamespaceImport", [(import("./rules/prefer-namespace-import.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-default-export': TSESLint.RuleModule<"preferNamed" | "noAliasDefault", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-named-export': TSESLint.RuleModule<"noAllowed", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-dynamic-require': TSESLint.RuleModule<import("./rules/no-dynamic-require.js").MessageId, [(import("./rules/no-dynamic-require.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
unambiguous: TSESLint.RuleModule<"module", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-unassigned-import': TSESLint.RuleModule<"unassigned", [(import("./rules/no-unassigned-import.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-useless-path-segments': TSESLint.RuleModule<"useless", [(import("./rules/no-useless-path-segments.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'dynamic-import-chunkname': TSESLint.RuleModule<import("./rules/dynamic-import-chunkname.js").MessageId, [(import("./rules/dynamic-import-chunkname.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-import-module-exports': TSESLint.RuleModule<"notAllowed", [(import("./rules/no-import-module-exports.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-empty-named-blocks': TSESLint.RuleModule<"emptyNamed" | "unused" | "emptyImport", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'exports-last': TSESLint.RuleModule<"end", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'no-deprecated': TSESLint.RuleModule<"deprecated" | "deprecatedDesc", [], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
'imports-first': TSESLint.RuleModule<import("./rules/first.js").MessageId, [(import("./rules/first.js").Options | undefined)?], import("./utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
};
cjsRequire: import("./types.js").CjsRequire;
importXResolverCompat: typeof importXResolverCompat;
createNodeResolver: typeof createNodeResolver;
};
declare const flatConfigs: {
recommended: PluginFlatConfig;
errors: PluginFlatConfig;
warnings: PluginFlatConfig;
'stage-0': PluginFlatConfig;
react: PluginFlatConfig;
'react-native': PluginFlatConfig;
electron: PluginFlatConfig;
typescript: PluginFlatConfig;
};
declare const configs: {
recommended: {
plugins: ["import-x"];
rules: {
'import-x/no-unresolved': "error";
'import-x/named': "error";
'import-x/namespace': "error";
'import-x/default': "error";
'import-x/export': "error";
'import-x/no-named-as-default': "warn";
'import-x/no-named-as-default-member': "warn";
'import-x/no-duplicates': "warn";
};
parserOptions: {
sourceType: "module";
ecmaVersion: 2018;
};
};
errors: {
plugins: ["import-x"];
rules: {
'import-x/no-unresolved': 2;
'import-x/named': 2;
'import-x/namespace': 2;
'import-x/default': 2;
'import-x/export': 2;
};
};
warnings: {
plugins: ["import-x"];
rules: {
'import-x/no-named-as-default': 1;
'import-x/no-named-as-default-member': 1;
'import-x/no-rename-default': 1;
'import-x/no-duplicates': 1;
};
};
'stage-0': PluginConfig;
react: {
settings: {
'import-x/extensions': (".js" | ".jsx")[];
};
parserOptions: {
ecmaFeatures: {
jsx: true;
};
};
};
'react-native': {
settings: {
'import-x/resolver': {
node: {
extensions: string[];
};
};
};
};
electron: {
settings: {
'import-x/core-modules': string[];
};
};
typescript: {
settings: {
'import-x/extensions': readonly [".ts", ".tsx", ".cts", ".mts", ".js", ".jsx", ".cjs", ".mjs"];
'import-x/external-module-folders': string[];
'import-x/parsers': {
'@typescript-eslint/parser': (".ts" | ".tsx" | ".cts" | ".mts")[];
};
'import-x/resolver': {
typescript: true;
};
};
rules: {
'import-x/named': "off";
};
};
'flat/recommended': PluginFlatConfig;
'flat/errors': PluginFlatConfig;
'flat/warnings': PluginFlatConfig;
'flat/stage-0': PluginFlatConfig;
'flat/react': PluginFlatConfig;
'flat/react-native': PluginFlatConfig;
'flat/electron': PluginFlatConfig;
'flat/typescript': PluginFlatConfig;
};
declare const plugin: typeof plugin_ & {
flatConfigs: typeof flatConfigs;
configs: typeof configs;
};
export default plugin;
export { meta, configs, flatConfigs, rules, cjsRequire, importXResolverCompat, createNodeResolver, plugin as importX, };
export type * from './types.js';

162
node_modules/eslint-plugin-import-x/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,162 @@
import electron from './config/electron.js';
import errors from './config/errors.js';
import electronFlat from './config/flat/electron.js';
import errorsFlat from './config/flat/errors.js';
import reactNativeFlat from './config/flat/react-native.js';
import reactFlat from './config/flat/react.js';
import recommendedFlat from './config/flat/recommended.js';
import stage0Flat from './config/flat/stage-0.js';
import typescriptFlat from './config/flat/typescript.js';
import warningsFlat from './config/flat/warnings.js';
import reactNative from './config/react-native.js';
import react from './config/react.js';
import recommended from './config/recommended.js';
import stage0 from './config/stage-0.js';
import typescript from './config/typescript.js';
import warnings from './config/warnings.js';
import { meta } from './meta.js';
import { createNodeResolver } from './node-resolver.js';
import { cjsRequire } from './require.js';
import consistentTypeSpecifierStyle from './rules/consistent-type-specifier-style.js';
import default_ from './rules/default.js';
import dynamicImportChunkname from './rules/dynamic-import-chunkname.js';
import export_ from './rules/export.js';
import exportsLast from './rules/exports-last.js';
import extensions from './rules/extensions.js';
import first from './rules/first.js';
import groupExports from './rules/group-exports.js';
import importsFirst from './rules/imports-first.js';
import maxDependencies from './rules/max-dependencies.js';
import named from './rules/named.js';
import namespace from './rules/namespace.js';
import newlineAfterImport from './rules/newline-after-import.js';
import noAbsolutePath from './rules/no-absolute-path.js';
import noAmd from './rules/no-amd.js';
import noAnonymousDefaultExport from './rules/no-anonymous-default-export.js';
import noCommonjs from './rules/no-commonjs.js';
import noCycle from './rules/no-cycle.js';
import noDefaultExport from './rules/no-default-export.js';
import noDeprecated from './rules/no-deprecated.js';
import noDuplicates from './rules/no-duplicates.js';
import noDynamicRequire from './rules/no-dynamic-require.js';
import noEmptyNamedBlocks from './rules/no-empty-named-blocks.js';
import noExtraneousDependencies from './rules/no-extraneous-dependencies.js';
import noImportModuleExports from './rules/no-import-module-exports.js';
import noInternalModules from './rules/no-internal-modules.js';
import noMutableExports from './rules/no-mutable-exports.js';
import noNamedAsDefaultMember from './rules/no-named-as-default-member.js';
import noNamedAsDefault from './rules/no-named-as-default.js';
import noNamedDefault from './rules/no-named-default.js';
import noNamedExport from './rules/no-named-export.js';
import noNamespace from './rules/no-namespace.js';
import noNodejsModules from './rules/no-nodejs-modules.js';
import noRelativePackages from './rules/no-relative-packages.js';
import noRelativeParentImports from './rules/no-relative-parent-imports.js';
import noRenameDefault from './rules/no-rename-default.js';
import noRestrictedPaths from './rules/no-restricted-paths.js';
import noSelfImport from './rules/no-self-import.js';
import noUnassignedImport from './rules/no-unassigned-import.js';
import noUnresolved from './rules/no-unresolved.js';
import noUnusedModules from './rules/no-unused-modules.js';
import noUselessPathSegments from './rules/no-useless-path-segments.js';
import noWebpackLoaderSyntax from './rules/no-webpack-loader-syntax.js';
import order from './rules/order.js';
import preferDefaultExport from './rules/prefer-default-export.js';
import preferNamespaceImport from './rules/prefer-namespace-import.js';
import unambiguous from './rules/unambiguous.js';
import { importXResolverCompat } from './utils/index.js';
const rules = {
'no-unresolved': noUnresolved,
named,
default: default_,
namespace,
'no-namespace': noNamespace,
export: export_,
'no-mutable-exports': noMutableExports,
extensions,
'no-restricted-paths': noRestrictedPaths,
'no-internal-modules': noInternalModules,
'group-exports': groupExports,
'no-relative-packages': noRelativePackages,
'no-relative-parent-imports': noRelativeParentImports,
'consistent-type-specifier-style': consistentTypeSpecifierStyle,
'no-self-import': noSelfImport,
'no-cycle': noCycle,
'no-named-default': noNamedDefault,
'no-named-as-default': noNamedAsDefault,
'no-named-as-default-member': noNamedAsDefaultMember,
'no-anonymous-default-export': noAnonymousDefaultExport,
'no-rename-default': noRenameDefault,
'no-unused-modules': noUnusedModules,
'no-commonjs': noCommonjs,
'no-amd': noAmd,
'no-duplicates': noDuplicates,
first,
'max-dependencies': maxDependencies,
'no-extraneous-dependencies': noExtraneousDependencies,
'no-absolute-path': noAbsolutePath,
'no-nodejs-modules': noNodejsModules,
'no-webpack-loader-syntax': noWebpackLoaderSyntax,
order,
'newline-after-import': newlineAfterImport,
'prefer-default-export': preferDefaultExport,
'prefer-namespace-import': preferNamespaceImport,
'no-default-export': noDefaultExport,
'no-named-export': noNamedExport,
'no-dynamic-require': noDynamicRequire,
unambiguous,
'no-unassigned-import': noUnassignedImport,
'no-useless-path-segments': noUselessPathSegments,
'dynamic-import-chunkname': dynamicImportChunkname,
'no-import-module-exports': noImportModuleExports,
'no-empty-named-blocks': noEmptyNamedBlocks,
'exports-last': exportsLast,
'no-deprecated': noDeprecated,
'imports-first': importsFirst,
};
const plugin_ = {
meta,
rules,
cjsRequire,
importXResolverCompat,
createNodeResolver,
};
const createFlatConfig = (baseConfig, configName) => ({
...baseConfig,
name: `import-x/${configName}`,
plugins: { 'import-x': plugin_ },
});
const flatConfigs = {
recommended: createFlatConfig(recommendedFlat, 'recommended'),
errors: createFlatConfig(errorsFlat, 'errors'),
warnings: createFlatConfig(warningsFlat, 'warnings'),
'stage-0': createFlatConfig(stage0Flat, 'stage-0'),
react: createFlatConfig(reactFlat, 'react'),
'react-native': createFlatConfig(reactNativeFlat, 'react-native'),
electron: createFlatConfig(electronFlat, 'electron'),
typescript: createFlatConfig(typescriptFlat, 'typescript'),
};
const configs = {
recommended,
errors,
warnings,
'stage-0': stage0,
react,
'react-native': reactNative,
electron,
typescript,
'flat/recommended': flatConfigs.recommended,
'flat/errors': flatConfigs.errors,
'flat/warnings': flatConfigs.warnings,
'flat/stage-0': flatConfigs['stage-0'],
'flat/react': flatConfigs.react,
'flat/react-native': flatConfigs['react-native'],
'flat/electron': flatConfigs.electron,
'flat/typescript': flatConfigs.typescript,
};
const plugin = plugin_;
plugin.flatConfigs = flatConfigs;
plugin.configs = configs;
export default plugin;
export { meta, configs, flatConfigs, rules, cjsRequire, importXResolverCompat, createNodeResolver, plugin as importX, };
//# sourceMappingURL=index.js.map

1
node_modules/eslint-plugin-import-x/lib/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,sBAAsB,CAAA;AAC3C,OAAO,MAAM,MAAM,oBAAoB,CAAA;AACvC,OAAO,YAAY,MAAM,2BAA2B,CAAA;AACpD,OAAO,UAAU,MAAM,yBAAyB,CAAA;AAChD,OAAO,eAAe,MAAM,+BAA+B,CAAA;AAC3D,OAAO,SAAS,MAAM,wBAAwB,CAAA;AAC9C,OAAO,eAAe,MAAM,8BAA8B,CAAA;AAC1D,OAAO,UAA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OAGd,CAAA;AAED,MAAM,CAAC,WAAW,GAAG,WAAW,CAAA;AAChC,MAAM,CAAC,OAAO,GAAG,OAAO,CAAA;AAExB,eAAe,MAAM,CAAA;AAErB,OAAO,EACL,IAAI,EACJ,OAAO,EACP,WAAW,EACX,KAAK,EACL,UAAU,EACV,qBAAqB,EACrB,kBAAkB,EAClB,MAAM,IAAI,OAAO,GAClB,CAAA"}

5
node_modules/eslint-plugin-import-x/lib/meta.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
export declare const name: string, version: string;
export declare const meta: {
name: string;
version: string;
};

4
node_modules/eslint-plugin-import-x/lib/meta.js generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import { cjsRequire } from './require.js';
export const { name, version } = cjsRequire('../package.json');
export const meta = { name, version };
//# sourceMappingURL=meta.js.map

1
node_modules/eslint-plugin-import-x/lib/meta.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"meta.js","sourceRoot":"","sources":["../src/meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,UAAU,CACzC,iBAAiB,CAClB,CAAA;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA"}

View File

@@ -0,0 +1,3 @@
import type { NapiResolveOptions } from 'unrs-resolver';
import type { NewResolver } from './types.js';
export declare function createNodeResolver({ extensions, conditionNames, mainFields, ...restOptions }?: NapiResolveOptions): NewResolver;

View File

@@ -0,0 +1,30 @@
import { isBuiltin } from 'node:module';
import path from 'node:path';
import { ResolverFactory } from 'unrs-resolver';
export function createNodeResolver({ extensions = ['.mjs', '.cjs', '.js', '.json', '.node'], conditionNames = ['import', 'require', 'default'], mainFields = ['module', 'main'], ...restOptions } = {}) {
const resolver = new ResolverFactory({
extensions,
conditionNames,
mainFields,
...restOptions,
});
return {
interfaceVersion: 3,
name: 'eslint-plugin-import-x:node',
resolve(modulePath, sourceFile) {
if (isBuiltin(modulePath) || modulePath.startsWith('data:')) {
return { found: true, path: null };
}
try {
const resolved = resolver.sync(path.dirname(sourceFile), modulePath);
if (resolved.path) {
return { found: true, path: resolved.path };
}
}
catch {
}
return { found: false };
},
};
}
//# sourceMappingURL=node-resolver.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"node-resolver.js","sourceRoot":"","sources":["../src/node-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAK/C,MAAM,UAAU,kBAAkB,CAAC,EACjC,UAAU,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EACtD,cAAc,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,EACjD,UAAU,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,EAC/B,GAAG,WAAW,KACQ,EAAE;IACxB,MAAM,QAAQ,GAAG,IAAI,eAAe,CAAC;QACnC,UAAU;QACV,cAAc;QACd,UAAU;QACV,GAAG,WAAW;KACf,CAAC,CAAA;IAIF,OAAO;QACL,gBAAgB,EAAE,CAAC;QACnB,IAAI,EAAE,6BAA6B;QACnC,OAAO,CAAC,UAAU,EAAE,UAAU;YAC5B,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC5D,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;YACpC,CAAC;YAED,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC,CAAA;gBACpE,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;oBAClB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAA;gBAC7C,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;YAET,CAAC;YACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;QACzB,CAAC;KACF,CAAA;AACH,CAAC"}

2
node_modules/eslint-plugin-import-x/lib/require.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import type { CjsRequire } from './types.js';
export declare const cjsRequire: CjsRequire;

6
node_modules/eslint-plugin-import-x/lib/require.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import { createRequire } from 'node:module';
const importMetaUrl = import.meta.url;
export const cjsRequire = importMetaUrl
? createRequire(importMetaUrl)
: require;
//# sourceMappingURL=require.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"require.js","sourceRoot":"","sources":["../src/require.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAI3C,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAA;AAErC,MAAM,CAAC,MAAM,UAAU,GAAe,aAAa;IACjD,CAAC,CAAC,aAAa,CAAC,aAAa,CAAC;IAC9B,CAAC,CAA4B,OAAO,CAAA"}

View File

@@ -0,0 +1,5 @@
import type { TSESLint } from '@typescript-eslint/utils';
export type Options = 'prefer-inline' | 'prefer-top-level';
type MessageId = 'inline' | 'topLevel';
declare const _default: TSESLint.RuleModule<MessageId, [(Options | undefined)?], import("../utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
export default _default;

View File

@@ -0,0 +1,172 @@
import { createRule, getValue } from '../utils/index.js';
function isComma(token) {
return token.type === 'Punctuator' && token.value === ',';
}
function removeSpecifiers(fixes, fixer, sourceCode, specifiers) {
for (const specifier of specifiers) {
const token = sourceCode.getTokenAfter(specifier);
if (token && isComma(token)) {
fixes.push(fixer.remove(token));
}
fixes.push(fixer.remove(specifier));
}
}
function getImportText(node, sourceCode, specifiers, kind) {
const sourceString = sourceCode.getText(node.source);
if (specifiers.length === 0) {
return '';
}
const names = specifiers.map(s => {
const importedName = getValue(s.imported);
if (importedName === s.local.name) {
return importedName;
}
return `${importedName} as ${s.local.name}`;
});
return `import ${kind} {${names.join(', ')}} from ${sourceString};`;
}
export default createRule({
name: 'consistent-type-specifier-style',
meta: {
type: 'suggestion',
docs: {
category: 'Style guide',
description: 'Enforce or ban the use of inline type-only markers for named imports.',
},
fixable: 'code',
schema: [
{
type: 'string',
enum: ['prefer-top-level', 'prefer-inline'],
default: 'prefer-top-level',
},
],
messages: {
inline: 'Prefer using inline {{kind}} specifiers instead of a top-level {{kind}}-only import.',
topLevel: 'Prefer using a top-level {{kind}}-only import instead of inline {{kind}} specifiers.',
},
},
defaultOptions: [],
create(context) {
const { sourceCode } = context;
if (context.options[0] === 'prefer-inline') {
return {
ImportDeclaration(node) {
if (node.importKind === 'value' || node.importKind == null) {
return;
}
if (node.specifiers.length === 0 ||
(node.specifiers.length === 1 &&
(node.specifiers[0].type === 'ImportDefaultSpecifier' ||
node.specifiers[0].type === 'ImportNamespaceSpecifier'))) {
return;
}
context.report({
node,
messageId: 'inline',
data: {
kind: node.importKind,
},
fix(fixer) {
const kindToken = sourceCode.getFirstToken(node, { skip: 1 });
return [
kindToken ? fixer.remove(kindToken) : [],
node.specifiers.map(specifier => fixer.insertTextBefore(specifier, `${node.importKind} `)),
].flat();
},
});
},
};
}
return {
ImportDeclaration(node) {
if (node.importKind === 'type' ||
node.importKind === 'typeof' ||
node.specifiers.length === 0 ||
(node.specifiers.length === 1 &&
(node.specifiers[0].type === 'ImportDefaultSpecifier' ||
node.specifiers[0].type === 'ImportNamespaceSpecifier'))) {
return;
}
const typeSpecifiers = [];
const typeofSpecifiers = [];
const valueSpecifiers = [];
let defaultSpecifier = null;
for (const specifier of node.specifiers) {
if (specifier.type === 'ImportDefaultSpecifier') {
defaultSpecifier = specifier;
continue;
}
if (!('importKind' in specifier)) {
continue;
}
if (specifier.importKind === 'type') {
typeSpecifiers.push(specifier);
}
else if (specifier.importKind === 'typeof') {
typeofSpecifiers.push(specifier);
}
else if (specifier.importKind === 'value' ||
specifier.importKind == null) {
valueSpecifiers.push(specifier);
}
}
const typeImport = getImportText(node, sourceCode, typeSpecifiers, 'type');
const typeofImport = getImportText(node, sourceCode, typeofSpecifiers, 'typeof');
const newImports = `${typeImport}\n${typeofImport}`.trim();
if (typeSpecifiers.length + typeofSpecifiers.length ===
node.specifiers.length) {
const kind = [
typeSpecifiers.length > 0 ? 'type' : [],
typeofSpecifiers.length > 0 ? 'typeof' : [],
].flat();
context.report({
node,
messageId: 'topLevel',
data: {
kind: kind.join('/'),
},
fix(fixer) {
return fixer.replaceText(node, newImports);
},
});
}
else {
for (const specifier of [...typeSpecifiers, ...typeofSpecifiers]) {
context.report({
node: specifier,
messageId: 'topLevel',
data: {
kind: specifier.importKind,
},
fix(fixer) {
const fixes = [];
if (valueSpecifiers.length > 0) {
removeSpecifiers(fixes, fixer, sourceCode, typeSpecifiers);
removeSpecifiers(fixes, fixer, sourceCode, typeofSpecifiers);
const maybeComma = sourceCode.getTokenAfter(valueSpecifiers[valueSpecifiers.length - 1]);
if (isComma(maybeComma)) {
fixes.push(fixer.remove(maybeComma));
}
}
else if (defaultSpecifier) {
const comma = sourceCode.getTokenAfter(defaultSpecifier, isComma);
const closingBrace = sourceCode.getTokenAfter(node.specifiers[node.specifiers.length - 1], token => token.type === 'Punctuator' && token.value === '}');
fixes.push(fixer.removeRange([
comma.range[0],
closingBrace.range[1],
]));
}
return [
...fixes,
fixer.insertTextAfter(node, `\n${newImports}`),
];
},
});
}
}
},
};
},
});
//# sourceMappingURL=consistent-type-specifier-style.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
export type MessageId = 'noDefaultExport';
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"noDefaultExport", [], import("../utils/create-rule.ts").ImportXPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
export default _default;

View File

@@ -0,0 +1,45 @@
import { ExportMap, createRule } from '../utils/index.js';
export default createRule({
name: 'default',
meta: {
type: 'problem',
docs: {
category: 'Static analysis',
description: 'Ensure a default export is present, given a default import.',
},
schema: [],
messages: {
noDefaultExport: 'No default export found in imported module "{{module}}".',
},
},
defaultOptions: [],
create(context) {
function checkDefault(specifierType, node) {
const defaultSpecifier = node.specifiers.find(specifier => specifier.type === specifierType);
if (!defaultSpecifier) {
return;
}
const imports = ExportMap.get(node.source.value, context);
if (imports == null) {
return;
}
if (imports.errors.length > 0) {
imports.reportErrors(context, node);
}
else if (imports.get('default') === undefined) {
context.report({
node: defaultSpecifier,
messageId: 'noDefaultExport',
data: {
module: node.source.value,
},
});
}
}
return {
ImportDeclaration: checkDefault.bind(null, 'ImportDefaultSpecifier'),
ExportNamedDeclaration: checkDefault.bind(null, 'ExportDefaultSpecifier'),
};
},
});
//# sourceMappingURL=default.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../src/rules/default.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAIzD,eAAe,UAAU,CAAgB;IACvC,IAAI,EAAE,SAAS;IACf,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,QAAQ,EAAE,iBAAiB;YAC3B,WAAW,EACT,6DAA6D;SAChE;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,eAAe,EACb,0DAA0D;SAC7D;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,SAAS,YAAY,CACnB,aAAkE,EAClE,IAAkE;YAElE,MAAM,gBAAgB,GACpB,IAAI,CAAC,UAGN,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,aAAa,CAAC,CAAA;YAErD,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACtB,OAAM;YACR,CAAC;YACD,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,MAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;YAC1D,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;gBACpB,OAAM;YACR,CAAC;YAED,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC9B,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;YACrC,CAAC;iBAAM,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,SAAS,EAAE,CAAC;gBAChD,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,EAAE,gBAAgB;oBACtB,SAAS,EAAE,iBAAiB;oBAC5B,IAAI,EAAE;wBACJ,MAAM,EAAE,IAAI,CAAC,MAAO,CAAC,KAAK;qBAC3B;iBACF,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QAED,OAAO;YACL,iBAAiB,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,wBAAwB,CAAC;YACpE,sBAAsB,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,wBAAwB,CAAC;SAC1E,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}

View File

@@ -0,0 +1,9 @@
import type { TSESLint } from '@typescript-eslint/utils';
export interface Options {
allowEmpty?: boolean;
importFunctions?: readonly string[];
webpackChunknameFormat?: string;
}
export type MessageId = 'leadingComment' | 'blockComment' | 'paddedSpaces' | 'webpackComment' | 'chunknameFormat' | 'webpackEagerModeNoChunkName' | 'webpackRemoveEagerMode' | 'webpackRemoveChunkName';
declare const _default: TSESLint.RuleModule<MessageId, [(Options | undefined)?], import("../utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
export default _default;

View File

@@ -0,0 +1,184 @@
import vm from 'node:vm';
import { createRule } from '../utils/index.js';
export default createRule({
name: 'dynamic-import-chunkname',
meta: {
type: 'suggestion',
docs: {
category: 'Style guide',
description: 'Enforce a leading comment with the webpackChunkName for dynamic imports.',
},
hasSuggestions: true,
schema: [
{
type: 'object',
properties: {
importFunctions: {
type: 'array',
uniqueItems: true,
items: {
type: 'string',
},
},
allowEmpty: {
type: 'boolean',
},
webpackChunknameFormat: {
type: 'string',
},
},
},
],
messages: {
leadingComment: 'dynamic imports require a leading comment with the webpack chunkname',
blockComment: 'dynamic imports require a /* foo */ style comment, not a // foo comment',
paddedSpaces: 'dynamic imports require a block comment padded with spaces - /* foo */',
webpackComment: 'dynamic imports require a "webpack" comment with valid syntax',
chunknameFormat: 'dynamic imports require a leading comment in the form /* {{format}} */',
webpackEagerModeNoChunkName: 'dynamic imports using eager mode do not need a webpackChunkName',
webpackRemoveEagerMode: 'Remove webpackMode',
webpackRemoveChunkName: 'Remove webpackChunkName',
},
},
defaultOptions: [],
create(context) {
const { importFunctions = [], allowEmpty = false, webpackChunknameFormat = String.raw `([0-9a-zA-Z-_/.]|\[(request|index)\])+`, } = context.options[0] || {};
const paddedCommentRegex = /^ (\S[\S\s]+\S) $/;
const commentStyleRegex = /^( (((webpackChunkName|webpackFetchPriority): .+)|((webpackPrefetch|webpackPreload): (true|false|-?\d+))|(webpackIgnore: (true|false))|((webpackInclude|webpackExclude): \/.+\/)|(webpackMode: ["'](lazy|lazy-once|eager|weak)["'])|(webpackExports: (["']\w+["']|\[(["']\w+["'], *)+(["']\w+["']*)]))),?)+ $/;
const chunkSubstrFormat = `webpackChunkName: ["']${webpackChunknameFormat}["'],?`;
const chunkSubstrRegex = new RegExp(chunkSubstrFormat);
const eagerModeFormat = `webpackMode: ["']eager["'],?`;
const eagerModeRegex = new RegExp(eagerModeFormat);
function run(node, arg) {
const { sourceCode } = context;
const leadingComments = sourceCode.getCommentsBefore(arg);
if ((!leadingComments || leadingComments.length === 0) && !allowEmpty) {
context.report({
node,
messageId: 'leadingComment',
});
return;
}
let isChunknamePresent = false;
let isEagerModePresent = false;
for (const comment of leadingComments) {
if (comment.type !== 'Block') {
context.report({
node,
messageId: 'blockComment',
});
return;
}
if (!paddedCommentRegex.test(comment.value)) {
context.report({
node,
messageId: 'paddedSpaces',
});
return;
}
try {
vm.runInNewContext(`(function() {return {${comment.value}}})()`);
}
catch {
context.report({
node,
messageId: 'webpackComment',
});
return;
}
if (!commentStyleRegex.test(comment.value)) {
context.report({
node,
messageId: 'webpackComment',
});
return;
}
if (eagerModeRegex.test(comment.value)) {
isEagerModePresent = true;
}
if (chunkSubstrRegex.test(comment.value)) {
isChunknamePresent = true;
}
}
const removeCommentsAndLeadingSpaces = (fixer, comment) => {
const leftToken = sourceCode.getTokenBefore(comment);
const leftComments = sourceCode.getCommentsBefore(comment);
if (leftToken) {
if (leftComments.length > 0) {
return fixer.removeRange([
Math.max(leftToken.range[1], leftComments[leftComments.length - 1].range[1]),
comment.range[1],
]);
}
return fixer.removeRange([leftToken.range[1], comment.range[1]]);
}
return fixer.remove(comment);
};
if (isChunknamePresent && isEagerModePresent) {
context.report({
node,
messageId: 'webpackEagerModeNoChunkName',
suggest: [
{
messageId: 'webpackRemoveChunkName',
fix(fixer) {
for (const comment of leadingComments) {
if (chunkSubstrRegex.test(comment.value)) {
const replacement = comment.value
.replace(chunkSubstrRegex, '')
.trim()
.replace(/,$/, '');
return replacement === ''
? removeCommentsAndLeadingSpaces(fixer, comment)
: fixer.replaceText(comment, `/* ${replacement} */`);
}
}
return null;
},
},
{
messageId: 'webpackRemoveEagerMode',
fix(fixer) {
for (const comment of leadingComments) {
if (eagerModeRegex.test(comment.value)) {
const replacement = comment.value
.replace(eagerModeRegex, '')
.trim()
.replace(/,$/, '');
return replacement === ''
? removeCommentsAndLeadingSpaces(fixer, comment)
: fixer.replaceText(comment, `/* ${replacement} */`);
}
}
return null;
},
},
],
});
}
if (!isChunknamePresent && !allowEmpty && !isEagerModePresent) {
context.report({
node,
messageId: 'chunknameFormat',
data: {
format: chunkSubstrFormat,
},
});
}
}
return {
ImportExpression(node) {
run(node, node.source);
},
CallExpression(node) {
if (node.callee.type !== 'Import' &&
(!('name' in node.callee) ||
!importFunctions.includes(node.callee.name))) {
return;
}
run(node, node.arguments[0]);
},
};
},
});
//# sourceMappingURL=dynamic-import-chunkname.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
export type MessageId = 'noNamed' | 'multiDefault' | 'multiNamed';
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageId, [], import("../utils/create-rule.ts").ImportXPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
export default _default;

172
node_modules/eslint-plugin-import-x/lib/rules/export.js generated vendored Normal file
View File

@@ -0,0 +1,172 @@
import { AST_NODE_TYPES } from '@typescript-eslint/types';
import { ExportMap, recursivePatternCapture, createRule, getValue, } from '../utils/index.js';
const rootProgram = 'root';
const tsTypePrefix = 'type:';
function removeTypescriptFunctionOverloads(nodes) {
for (const node of nodes) {
const declType = node.type === AST_NODE_TYPES.ExportDefaultDeclaration
? node.declaration.type
: node.parent?.type;
if (declType === AST_NODE_TYPES.TSDeclareFunction) {
nodes.delete(node);
}
}
}
function isTypescriptNamespaceMerging(nodes) {
const types = new Set(Array.from(nodes, node => `${node.parent.type}`));
const noNamespaceNodes = [...nodes].filter(node => node.parent.type !== 'TSModuleDeclaration');
return (types.has('TSModuleDeclaration') &&
(types.size === 1 ||
(types.size === 2 &&
(types.has('FunctionDeclaration') || types.has('TSDeclareFunction'))) ||
(types.size === 3 &&
types.has('FunctionDeclaration') &&
types.has('TSDeclareFunction')) ||
(types.size === 2 &&
(types.has('ClassDeclaration') || types.has('TSEnumDeclaration')) &&
noNamespaceNodes.length === 1)));
}
function shouldSkipTypescriptNamespace(node, nodes) {
const types = new Set(Array.from(nodes, node => `${node.parent.type}`));
return (!isTypescriptNamespaceMerging(nodes) &&
node.parent.type === 'TSModuleDeclaration' &&
(types.has('TSEnumDeclaration') ||
types.has('ClassDeclaration') ||
types.has('FunctionDeclaration') ||
types.has('TSDeclareFunction')));
}
export default createRule({
name: 'export',
meta: {
type: 'problem',
docs: {
category: 'Helpful warnings',
description: 'Forbid any invalid exports, i.e. re-export of the same name.',
},
schema: [],
messages: {
noNamed: "No named exports found in module '{{module}}'.",
multiDefault: 'Multiple default exports.',
multiNamed: "Multiple exports of name '{{name}}'.",
},
},
defaultOptions: [],
create(context) {
const namespace = new Map([[rootProgram, new Map()]]);
function addNamed(name, node, parent, isType) {
if (!namespace.has(parent)) {
namespace.set(parent, new Map());
}
const named = namespace.get(parent);
const key = isType ? `${tsTypePrefix}${name}` : name;
let nodes = named.get(key);
if (nodes == null) {
nodes = new Set();
named.set(key, nodes);
}
nodes.add(node);
}
function getParent(node) {
if (node.parent?.type === 'TSModuleBlock') {
return node.parent.parent;
}
return rootProgram;
}
return {
ExportDefaultDeclaration(node) {
addNamed('default', node, getParent(node));
},
ExportSpecifier(node) {
addNamed(getValue(node.exported), node.exported, getParent(node.parent));
},
ExportNamedDeclaration(node) {
if (node.declaration == null) {
return;
}
const parent = getParent(node);
const isTypeVariableDecl = 'kind' in node.declaration &&
node.declaration.kind === 'type';
if ('id' in node.declaration && node.declaration.id != null) {
const id = node.declaration.id;
addNamed(id.name, id, parent, ['TSTypeAliasDeclaration', 'TSInterfaceDeclaration'].includes(node.declaration.type) || isTypeVariableDecl);
}
if ('declarations' in node.declaration &&
node.declaration.declarations != null) {
for (const declaration of node.declaration.declarations) {
recursivePatternCapture(declaration.id, v => {
addNamed(v.name, v, parent, isTypeVariableDecl);
});
}
}
},
ExportAllDeclaration(node) {
if (node.source == null) {
return;
}
if (node.exported && node.exported.name) {
return;
}
const remoteExports = ExportMap.get(node.source.value, context);
if (remoteExports == null) {
return;
}
if (remoteExports.errors.length > 0) {
remoteExports.reportErrors(context, node);
return;
}
const parent = getParent(node);
let any = false;
remoteExports.$forEach((_, name) => {
if (name !== 'default') {
any = true;
addNamed(name, node, parent);
}
});
if (!any) {
context.report({
node: node.source,
messageId: 'noNamed',
data: { module: node.source.value },
});
}
},
'Program:exit'() {
for (const [, named] of namespace) {
for (const [name, nodes] of named) {
if (nodes.size === 0) {
continue;
}
removeTypescriptFunctionOverloads(nodes);
if (nodes.size <= 1) {
continue;
}
if (isTypescriptNamespaceMerging(nodes)) {
continue;
}
for (const node of nodes) {
if (shouldSkipTypescriptNamespace(node, nodes)) {
continue;
}
if (name === 'default') {
context.report({
node,
messageId: 'multiDefault',
});
}
else {
context.report({
node,
messageId: 'multiNamed',
data: {
name: name.replace(tsTypePrefix, ''),
},
});
}
}
}
}
},
};
},
});
//# sourceMappingURL=export.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"end", [], import("../utils/create-rule.ts").ImportXPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
export default _default;

View File

@@ -0,0 +1,49 @@
import { createRule } from '../utils/index.js';
const findLastIndex = (array, predicate) => {
let i = array.length - 1;
while (i >= 0) {
if (predicate(array[i])) {
return i;
}
i--;
}
return -1;
};
function isNonExportStatement({ type }) {
return (type !== 'ExportDefaultDeclaration' &&
type !== 'ExportNamedDeclaration' &&
type !== 'ExportAllDeclaration');
}
export default createRule({
name: 'exports-last',
meta: {
type: 'suggestion',
docs: {
category: 'Style guide',
description: 'Ensure all exports appear after other statements.',
},
schema: [],
messages: {
end: 'Export statements should appear at the end of the file',
},
},
defaultOptions: [],
create(context) {
return {
Program({ body }) {
const lastNonExportStatementIndex = findLastIndex(body, isNonExportStatement);
if (lastNonExportStatementIndex !== -1) {
for (const node of body.slice(0, lastNonExportStatementIndex)) {
if (!isNonExportStatement(node)) {
context.report({
node,
messageId: 'end',
});
}
}
}
},
};
},
});
//# sourceMappingURL=exports-last.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"exports-last.js","sourceRoot":"","sources":["../../src/rules/exports-last.ts"],"names":[],"mappings":"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;6BACjB,CAAC,CAAA;wBACJ,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}

View File

@@ -0,0 +1,35 @@
import type { TSESLint } from '@typescript-eslint/utils';
import type { MinimatchOptions } from 'minimatch';
declare const modifierValues: readonly ["always", "ignorePackages", "never"];
export type Modifier = (typeof modifierValues)[number];
export type ModifierByFileExtension = Partial<Record<string, Modifier>>;
export interface OptionsItemWithPatternProperty {
ignorePackages?: boolean;
checkTypeImports?: boolean;
pattern: ModifierByFileExtension;
pathGroupOverrides?: PathGroupOverride[];
fix?: boolean;
}
export interface PathGroupOverride {
pattern: string;
patternOptions?: Record<string, MinimatchOptions>;
action: 'enforce' | 'ignore';
}
export interface OptionsItemWithoutPatternProperty {
ignorePackages?: boolean;
checkTypeImports?: boolean;
pathGroupOverrides?: PathGroupOverride[];
fix?: boolean;
}
export type Options = [] | [OptionsItemWithoutPatternProperty] | [OptionsItemWithPatternProperty] | [Modifier] | [Modifier, OptionsItemWithoutPatternProperty] | [Modifier, OptionsItemWithPatternProperty] | [Modifier, ModifierByFileExtension] | [ModifierByFileExtension];
export interface NormalizedOptions {
defaultConfig?: Modifier;
pattern?: Record<string, Modifier>;
ignorePackages?: boolean;
checkTypeImports?: boolean;
pathGroupOverrides?: PathGroupOverride[];
fix?: boolean;
}
export type MessageId = 'missing' | 'missingKnown' | 'unexpected' | 'addMissing' | 'removeUnexpected';
declare const _default: TSESLint.RuleModule<MessageId, Options, import("../utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
export default _default;

View File

@@ -0,0 +1,302 @@
import path from 'node:path';
import { minimatch } from 'minimatch';
import { isBuiltIn, isExternalModule, isScoped, createRule, moduleVisitor, resolve, parsePath, stringifyPath, } from '../utils/index.js';
const modifierValues = ['always', 'ignorePackages', 'never'];
const modifierSchema = {
type: 'string',
enum: [...modifierValues],
};
const modifierByFileExtensionSchema = {
type: 'object',
patternProperties: { '.*': modifierSchema },
};
const properties = {
type: 'object',
properties: {
pattern: modifierByFileExtensionSchema,
ignorePackages: {
type: 'boolean',
},
checkTypeImports: {
type: 'boolean',
},
pathGroupOverrides: {
type: 'array',
items: {
type: 'object',
properties: {
pattern: { type: 'string' },
patternOptions: { type: 'object' },
action: {
type: 'string',
enum: ['enforce', 'ignore'],
},
},
additionalProperties: false,
required: ['pattern', 'action'],
},
},
fix: {
type: 'boolean',
},
},
};
function buildProperties(context) {
const result = {
defaultConfig: 'never',
pattern: {},
ignorePackages: false,
checkTypeImports: false,
pathGroupOverrides: [],
fix: false,
};
for (const obj of context.options) {
if (typeof obj === 'string') {
result.defaultConfig = obj;
continue;
}
if (typeof obj !== 'object' || !obj) {
continue;
}
if (obj.fix != null) {
result.fix = Boolean(obj.fix);
}
if ((!('pattern' in obj) || obj.pattern == null) &&
obj.ignorePackages == null &&
obj.checkTypeImports == null) {
Object.assign(result.pattern, obj);
continue;
}
if ('pattern' in obj && obj.pattern != null) {
Object.assign(result.pattern, obj.pattern);
}
if (typeof obj.ignorePackages === 'boolean') {
result.ignorePackages = obj.ignorePackages;
}
if (typeof obj.checkTypeImports === 'boolean') {
result.checkTypeImports = obj.checkTypeImports;
}
if (Array.isArray(obj.pathGroupOverrides)) {
result.pathGroupOverrides = obj.pathGroupOverrides;
}
}
if (result.defaultConfig === 'ignorePackages') {
result.defaultConfig = 'always';
result.ignorePackages = true;
}
return result;
}
function isExternalRootModule(file) {
if (file === '.' || file === '..') {
return false;
}
const slashCount = file.split('/').length - 1;
return slashCount === 0 || (isScoped(file) && slashCount <= 1);
}
function computeOverrideAction(pathGroupOverrides, path) {
for (const { pattern, patternOptions, action } of pathGroupOverrides) {
if (minimatch(path, pattern, patternOptions || { nocomment: true })) {
return action;
}
}
}
function replaceImportPath(source, importPath) {
return source.replace(/^(['"])(.+)\1$/, (_, quote) => `${quote}${importPath}${quote}`);
}
export default createRule({
name: 'extensions',
meta: {
type: 'suggestion',
docs: {
category: 'Style guide',
description: 'Ensure consistent use of file extension within the import path.',
},
fixable: 'code',
hasSuggestions: true,
schema: {
anyOf: [
{
type: 'array',
items: [modifierSchema],
additionalItems: false,
},
{
type: 'array',
items: [modifierSchema, properties],
additionalItems: false,
},
{
type: 'array',
items: [properties],
additionalItems: false,
},
{
type: 'array',
items: [modifierSchema, modifierByFileExtensionSchema],
additionalItems: false,
},
{
type: 'array',
items: [modifierByFileExtensionSchema],
additionalItems: false,
},
],
},
messages: {
missing: 'Missing file extension for "{{importPath}}"',
missingKnown: 'Missing file extension "{{extension}}" for "{{importPath}}"',
unexpected: 'Unexpected use of file extension "{{extension}}" for "{{importPath}}"',
addMissing: 'Add "{{extension}}" file extension from "{{importPath}}" into "{{fixedImportPath}}"',
removeUnexpected: 'Remove unexpected "{{extension}}" file extension from "{{importPath}}" into "{{fixedImportPath}}"',
},
},
defaultOptions: [],
create(context) {
const props = buildProperties(context);
function getModifier(extension) {
return props.pattern[extension] || props.defaultConfig;
}
function isUseOfExtensionRequired(extension, isPackage) {
return (getModifier(extension) === 'always' &&
(!props.ignorePackages || !isPackage));
}
function isUseOfExtensionForbidden(extension) {
return getModifier(extension) === 'never';
}
function isResolvableWithoutExtension(file) {
const extension = path.extname(file);
const fileWithoutExtension = file.slice(0, -extension.length);
const resolvedFileWithoutExtension = resolve(fileWithoutExtension, context);
return resolvedFileWithoutExtension === resolve(file, context);
}
return moduleVisitor((source, node) => {
if (!source || !source.value) {
return;
}
const importPathWithQueryString = source.value;
const overrideAction = computeOverrideAction(props.pathGroupOverrides || [], importPathWithQueryString);
if (overrideAction === 'ignore') {
return;
}
if (!overrideAction &&
isBuiltIn(importPathWithQueryString, context.settings)) {
return;
}
const { pathname: importPath, query, hash, } = parsePath(importPathWithQueryString);
if (!overrideAction && isExternalRootModule(importPath)) {
return;
}
const resolvedPath = resolve(importPath, context);
const extension = path.extname(resolvedPath || importPath).slice(1);
const isPackage = isExternalModule(importPath, resolve(importPath, context), context) || isScoped(importPath);
if (!extension || !importPath.endsWith(`.${extension}`)) {
if (!props.checkTypeImports &&
(('importKind' in node && node.importKind === 'type') ||
('exportKind' in node && node.exportKind === 'type'))) {
return;
}
const extensionRequired = isUseOfExtensionRequired(extension, !overrideAction && isPackage);
const extensionForbidden = isUseOfExtensionForbidden(extension);
if (extensionRequired && !extensionForbidden) {
const fixedImportPath = stringifyPath({
pathname: `${/([\\/]|[\\/]?\.?\.)$/.test(importPath)
? `${importPath.endsWith('/')
? importPath.slice(0, -1)
: importPath}/index.${extension}`
: `${importPath}.${extension}`}`,
query,
hash,
});
const fixOrSuggest = {
fix(fixer) {
return fixer.replaceText(source, replaceImportPath(source.raw, fixedImportPath));
},
};
context.report({
node: source,
messageId: extension ? 'missingKnown' : 'missing',
data: {
extension,
importPath: importPathWithQueryString,
},
...(extension &&
(props.fix
? fixOrSuggest
: {
suggest: [
{
...fixOrSuggest,
messageId: 'addMissing',
data: {
extension,
importPath: importPathWithQueryString,
fixedImportPath,
},
},
],
})),
});
}
}
else if (extension &&
isUseOfExtensionForbidden(extension) &&
isResolvableWithoutExtension(importPath)) {
const fixedPathname = importPath.slice(0, -(extension.length + 1));
const isIndex = fixedPathname.endsWith('/index');
const fixedImportPath = stringifyPath({
pathname: isIndex ? fixedPathname.slice(0, -6) : fixedPathname,
query,
hash,
});
const fixOrSuggest = {
fix(fixer) {
return fixer.replaceText(source, replaceImportPath(source.raw, fixedImportPath));
},
};
const commonSuggestion = {
...fixOrSuggest,
messageId: 'removeUnexpected',
data: {
extension,
importPath: importPathWithQueryString,
fixedImportPath,
},
};
context.report({
node: source,
messageId: 'unexpected',
data: {
extension,
importPath: importPathWithQueryString,
},
...(props.fix
? fixOrSuggest
: {
suggest: [
commonSuggestion,
isIndex && {
...commonSuggestion,
fix(fixer) {
return fixer.replaceText(source, replaceImportPath(source.raw, stringifyPath({
pathname: fixedPathname,
query,
hash,
})));
},
data: {
...commonSuggestion.data,
fixedImportPath: stringifyPath({
pathname: fixedPathname,
query,
hash,
}),
},
},
].filter(Boolean),
}),
});
}
}, { commonjs: true });
},
});
//# sourceMappingURL=extensions.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
import type { TSESLint } from '@typescript-eslint/utils';
export type Options = 'absolute-first' | 'disable-absolute-first';
export type MessageId = 'absolute' | 'order';
declare const _default: TSESLint.RuleModule<MessageId, [(Options | undefined)?], import("../utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
export default _default;

153
node_modules/eslint-plugin-import-x/lib/rules/first.js generated vendored Normal file
View File

@@ -0,0 +1,153 @@
import { createRule } from '../utils/index.js';
function getImportValue(node) {
return node.type === 'ImportDeclaration'
? node.source.value
: 'moduleReference' in node &&
'expression' in node.moduleReference &&
'value' in node.moduleReference.expression &&
node.moduleReference.expression.value;
}
function isPossibleDirective(node) {
return (node.type === 'ExpressionStatement' &&
node.expression.type === 'Literal' &&
typeof node.expression.value === 'string');
}
export default createRule({
name: 'first',
meta: {
type: 'suggestion',
docs: {
category: 'Style guide',
description: 'Ensure all imports appear before other statements.',
},
fixable: 'code',
schema: [
{
type: 'string',
enum: ['absolute-first', 'disable-absolute-first'],
},
],
messages: {
absolute: 'Absolute imports should come before relative imports.',
order: 'Import in body of module; reorder to top.',
},
},
defaultOptions: [],
create(context) {
return {
Program(n) {
const body = n.body;
if (!body?.length) {
return;
}
const absoluteFirst = context.options[0] === 'absolute-first';
const { sourceCode } = context;
const originSourceCode = sourceCode.getText();
let nonImportCount = 0;
let anyExpressions = false;
let anyRelative = false;
let lastLegalImp = null;
const errorInfos = [];
let shouldSort = true;
let lastSortNodesIndex = 0;
for (const [index, node] of body.entries()) {
if (!anyExpressions && isPossibleDirective(node)) {
continue;
}
anyExpressions = true;
if (node.type === 'ImportDeclaration' ||
node.type === 'TSImportEqualsDeclaration') {
if (absoluteFirst) {
const importValue = getImportValue(node);
if (typeof importValue === 'string' && /^\./.test(importValue)) {
anyRelative = true;
}
else if (anyRelative) {
context.report({
node: node.type === 'ImportDeclaration'
? node.source
: node.moduleReference,
messageId: 'absolute',
});
}
}
if (nonImportCount > 0) {
for (const variable of sourceCode.getDeclaredVariables(node)) {
if (!shouldSort) {
break;
}
for (const reference of variable.references) {
if (reference.identifier.range[0] < node.range[1]) {
shouldSort = false;
break;
}
}
}
if (shouldSort) {
lastSortNodesIndex = errorInfos.length;
}
errorInfos.push({
node,
range: [body[index - 1].range[1], node.range[1]],
});
}
else {
lastLegalImp = node;
}
}
else {
nonImportCount++;
}
}
if (errorInfos.length === 0) {
return;
}
for (const [index, { node }] of errorInfos.entries()) {
let fix;
if (index < lastSortNodesIndex) {
fix = (fixer) => fixer.insertTextAfter(node, '');
}
else if (index === lastSortNodesIndex) {
const sortNodes = errorInfos.slice(0, lastSortNodesIndex + 1);
fix = (fixer) => {
const removeFixers = sortNodes.map(({ range }) => fixer.removeRange(range));
const range = [
0,
removeFixers[removeFixers.length - 1].range[1],
];
let insertSourceCode = sortNodes
.map(({ range }) => {
const nodeSourceCode = originSourceCode.slice(...range);
if (/\S/.test(nodeSourceCode[0])) {
return `\n${nodeSourceCode}`;
}
return nodeSourceCode;
})
.join('');
let replaceSourceCode = '';
if (!lastLegalImp) {
insertSourceCode =
insertSourceCode.trim() + insertSourceCode.match(/^(\s+)/)[0];
}
const insertFixer = lastLegalImp
? fixer.insertTextAfter(lastLegalImp, insertSourceCode)
: fixer.insertTextBefore(body[0], insertSourceCode);
const fixers = [insertFixer, ...removeFixers];
for (const [i, computedFixer] of fixers.entries()) {
replaceSourceCode +=
originSourceCode.slice(fixers[i - 1] ? fixers[i - 1].range[1] : 0, computedFixer.range[0]) + computedFixer.text;
}
return fixer.replaceTextRange(range, replaceSourceCode);
};
}
context.report({
node,
messageId: 'order',
fix,
});
}
},
};
},
});
//# sourceMappingURL=first.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"first.js","sourceRoot":"","sources":["../../src/rules/first.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C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AAA;4BAC7C,KAAK,MAAM,CAAC,CAAC,EAAE,aAAa,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;gCAClD,iBAAiB;oCACf,gBAAgB,CAAC,KAAK,CACpB,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC1C,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CACvB,GAAG,aAAa,CAAC,IAAI,CAAA;4BAC1B,CAAC;4BAED,OAAO,KAAK,CAAC,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAA;wBACzD,CAAC,CAAA;oBACH,CAAC;oBACD,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,SAAS,EAAE,OAAO;wBAClB,GAAG;qBACJ,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}

View File

@@ -0,0 +1,4 @@
export type Literal = string | number | bigint | boolean | RegExp | null;
export type MessageId = 'ExportNamedDeclaration' | 'AssignmentExpression';
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageId, [], import("../utils/create-rule.ts").ImportXPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
export default _default;

View File

@@ -0,0 +1,123 @@
import { createRule } from '../utils/index.js';
function accessorChain(node) {
const chain = [];
let exp = node;
do {
if ('name' in exp.property) {
chain.unshift(exp.property.name);
}
else if ('value' in exp.property) {
chain.unshift(exp.property.value);
}
if (exp.object.type === 'Identifier') {
chain.unshift(exp.object.name);
break;
}
exp = exp.object;
} while (exp.type === 'MemberExpression');
return chain;
}
export default createRule({
name: 'group-exports',
meta: {
type: 'suggestion',
docs: {
category: 'Style guide',
description: 'Prefer named exports to be grouped together in a single export declaration.',
},
schema: [],
messages: {
ExportNamedDeclaration: 'Multiple named export declarations; consolidate all named exports into a single export declaration',
AssignmentExpression: 'Multiple CommonJS exports; consolidate all exports into a single assignment to `module.exports`',
},
},
defaultOptions: [],
create(context) {
const nodes = {
modules: {
set: new Set(),
sources: {},
},
types: {
set: new Set(),
sources: {},
},
commonjs: {
set: new Set(),
},
};
return {
ExportNamedDeclaration(node) {
const target = node.exportKind === 'type' ? nodes.types : nodes.modules;
if (!node.source) {
target.set.add(node);
}
else if (Array.isArray(target.sources[node.source.value])) {
target.sources[node.source.value].push(node);
}
else {
target.sources[node.source.value] = [node];
}
},
AssignmentExpression(node) {
if (node.left.type !== 'MemberExpression') {
return;
}
const chain = accessorChain(node.left);
if (chain[0] === 'module' &&
chain[1] === 'exports' &&
chain.length <= 3) {
nodes.commonjs.set.add(node);
return;
}
if (chain[0] === 'exports' && chain.length === 2) {
nodes.commonjs.set.add(node);
return;
}
},
'Program:exit'() {
if (nodes.modules.set.size > 1) {
for (const node of nodes.modules.set) {
context.report({
node,
messageId: node.type,
});
}
}
for (const node of Object.values(nodes.modules.sources)
.filter(nodesWithSource => Array.isArray(nodesWithSource) && nodesWithSource.length > 1)
.flat()) {
context.report({
node,
messageId: node.type,
});
}
if (nodes.types.set.size > 1) {
for (const node of nodes.types.set) {
context.report({
node,
messageId: node.type,
});
}
}
for (const node of Object.values(nodes.types.sources)
.filter(nodesWithSource => Array.isArray(nodesWithSource) && nodesWithSource.length > 1)
.flat()) {
context.report({
node,
messageId: node.type,
});
}
if (nodes.commonjs.set.size > 1) {
for (const node of nodes.commonjs.set) {
context.report({
node,
messageId: node.type,
});
}
}
},
};
},
});
//# sourceMappingURL=group-exports.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"group-exports.js","sourceRoot":"","sources":["../../src/rules/group-exports.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAc9C,SAAS,aAAa,CAAC,IAA+B;IACpD,MAAM,KAAK,GAAc,EAAE,CAAA;IAE3B,IAAI,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C,MAAM,CAAC;wBACb,IAAI;wBACJ,SAAS,EAAE,IAAI,CAAC,IAAI;qBACrB,CAAC,CAAA;gBACJ,CAAC;gBAGD,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;oBAChC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;wBACtC,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI;4BACJ,SAAS,EAAE,IAAI,CAAC,IAAI;yBACrB,CAAC,CAAA;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}

View File

@@ -0,0 +1,2 @@
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./first.js").MessageId, [(import("./first.js").Options | undefined)?], import("../utils/create-rule.ts").ImportXPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
export default _default;

View File

@@ -0,0 +1,25 @@
import { createRule, docsUrl } from '../utils/index.js';
import first from './first.js';
export default createRule({
...first,
name: 'imports-first',
meta: {
...first.meta,
deprecated: {
message: 'Replaced by `import-x/first`.',
url: 'https://github.com/import-js/eslint-plugin-import/blob/main/CHANGELOG.md#changed-24',
deprecatedSince: '2.0.0',
replacedBy: [
{
message: 'Replaced by `import-x/first`.',
rule: { name: 'first', url: docsUrl('first') },
},
],
},
docs: {
category: 'Style guide',
description: 'Replaced by `import-x/first`.',
},
},
});
//# sourceMappingURL=imports-first.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"imports-first.js","sourceRoot":"","sources":["../../src/rules/imports-first.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEvD,OAAO,KAAK,MAAM,YAAY,CAAA;AAE9B,eAAe,UAAU,CAAC;IACxB,GAAG,KAAK;IACR,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE;QACJ,GAAG,KAAK,CAAC,IAAI;QACb,UAAU,EAAE;YACV,OAAO,EAAE,+BAA+B;YACxC,GAAG,EAAE,qFAAqF;YAC1F,eAAe,EAAE,OAAO;YACxB,UAAU,EAAE;gBACV;oBACE,OAAO,EAAE,+BAA+B;oBACxC,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;iBAC/C;aACF;SACF;QACD,IAAI,EAAE;YACJ,QAAQ,EAAE,aAAa;YACvB,WAAW,EAAE,+BAA+B;SAC7C;KACF;CACF,CAAC,CAAA"}

View File

@@ -0,0 +1,7 @@
export interface Options {
ignoreTypeImports?: boolean;
max?: number;
}
export type MessageId = 'max';
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"max", [(Options | undefined)?], import("../utils/create-rule.ts").ImportXPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
export default _default;

View File

@@ -0,0 +1,53 @@
import { createRule, moduleVisitor } from '../utils/index.js';
export default createRule({
name: 'max-dependencies',
meta: {
type: 'suggestion',
docs: {
category: 'Style guide',
description: 'Enforce the maximum number of dependencies a module can have.',
},
schema: [
{
type: 'object',
properties: {
max: { type: 'number' },
ignoreTypeImports: { type: 'boolean' },
},
additionalProperties: false,
},
],
messages: {
max: 'Maximum number of dependencies ({{max}}) exceeded.',
},
},
defaultOptions: [],
create(context) {
const { ignoreTypeImports } = context.options[0] || {};
const dependencies = new Set();
let lastNode;
return {
'Program:exit'() {
const { max = 10 } = context.options[0] || {};
if (dependencies.size <= max) {
return;
}
context.report({
node: lastNode,
messageId: 'max',
data: {
max,
},
});
},
...moduleVisitor((source, node) => {
if (('importKind' in node && node.importKind !== 'type') ||
!ignoreTypeImports) {
dependencies.add(source.value);
}
lastNode = source;
}, { commonjs: true }),
};
},
});
//# sourceMappingURL=max-dependencies.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"max-dependencies.js","sourceRoot":"","sources":["../../src/rules/max-dependencies.ts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,CAAC,iBAAiB,EAClB,CAAC;oBACD,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;gBAChC,CAAC;gBACD,QAAQ,GAAG,MAAM,CAAA;YACnB,CAAC,EACD,EAAE,QAAQ,EAAE,IAAI,EAAE,CACnB;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}

View File

@@ -0,0 +1,4 @@
import type { ModuleOptions } from '../utils/index.js';
export type MessageId = 'notFound' | 'notFoundDeep';
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageId, [(ModuleOptions | undefined)?], import("../utils/create-rule.ts").ImportXPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
export default _default;

153
node_modules/eslint-plugin-import-x/lib/rules/named.js generated vendored Normal file
View File

@@ -0,0 +1,153 @@
import path from 'node:path';
import { ExportMap, createRule } from '../utils/index.js';
export default createRule({
name: 'named',
meta: {
type: 'problem',
docs: {
category: 'Static analysis',
description: 'Ensure named imports correspond to a named export in the remote file.',
},
schema: [
{
type: 'object',
properties: {
commonjs: {
type: 'boolean',
},
},
additionalProperties: false,
},
],
messages: {
notFound: "{{name}} not found in '{{path}}'",
notFoundDeep: '{{name}} not found via {{deepPath}}',
},
},
defaultOptions: [],
create(context) {
const options = context.options[0] || {};
function checkSpecifiers(key, type, node) {
if (node.source == null ||
('importKind' in node &&
(node.importKind === 'type' ||
node.importKind === 'typeof')) ||
('exportKind' in node && node.exportKind === 'type')) {
return;
}
if (!node.specifiers.some(im => im.type === type)) {
return;
}
const imports = ExportMap.get(node.source.value, context);
if (imports == null || imports.parseGoal === 'ambiguous') {
return;
}
if (imports.errors.length > 0) {
imports.reportErrors(context, node);
return;
}
for (const im of node.specifiers) {
if (im.type !== type ||
('importKind' in im &&
(im.importKind === 'type' ||
im.importKind === 'typeof'))) {
continue;
}
const imNode = im[key];
const name = imNode.name ||
imNode.value;
const deepLookup = imports.hasDeep(name);
if (!deepLookup.found) {
if (deepLookup.path.length > 1) {
const deepPath = deepLookup.path
.map(i => path.relative(path.dirname(context.physicalFilename), i.path))
.join(' -> ');
context.report({
node: imNode,
messageId: 'notFoundDeep',
data: {
name,
deepPath,
},
});
}
else {
context.report({
node: imNode,
messageId: 'notFound',
data: {
name,
path: node.source.value,
},
});
}
}
}
}
return {
ImportDeclaration: checkSpecifiers.bind(null, 'imported', 'ImportSpecifier'),
ExportNamedDeclaration: checkSpecifiers.bind(null, 'local', 'ExportSpecifier'),
VariableDeclarator(node) {
if (!options.commonjs ||
node.type !== 'VariableDeclarator' ||
!node.id ||
node.id.type !== 'ObjectPattern' ||
node.id.properties.length === 0 ||
!node.init ||
node.init.type !== 'CallExpression') {
return;
}
const call = node.init;
const source = call.arguments[0];
const variableImports = node.id.properties;
const variableExports = ExportMap.get(source.value, context);
if (call.callee.type !== 'Identifier' ||
call.callee.name !== 'require' ||
call.arguments.length !== 1 ||
source.type !== 'Literal' ||
variableExports == null ||
variableExports.parseGoal === 'ambiguous') {
return;
}
if (variableExports.errors.length > 0) {
variableExports.reportErrors(context, node);
return;
}
for (const im of variableImports) {
if (im.type !== 'Property' ||
!im.key ||
im.key.type !== 'Identifier') {
continue;
}
const deepLookup = variableExports.hasDeep(im.key.name);
if (!deepLookup.found) {
if (deepLookup.path.length > 1) {
const deepPath = deepLookup.path
.map(i => path.relative(path.dirname(context.filename), i.path))
.join(' -> ');
context.report({
node: im.key,
messageId: 'notFoundDeep',
data: {
name: im.key.name,
deepPath,
},
});
}
else {
context.report({
node: im.key,
messageId: 'notFound',
data: {
name: im.key.name,
path: source.value,
},
});
}
}
}
},
};
},
});
//# sourceMappingURL=named.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"named.js","sourceRoot":"","sources":["../../src/rules/named.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAI5B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAKzD,eAAe,UAAU,CAA8B;IACrD,IA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AA;wBACJ,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}

View File

@@ -0,0 +1,7 @@
import type { TSESLint } from '@typescript-eslint/utils';
export type MessageId = 'noNamesFound' | 'computedReference' | 'namespaceMember' | 'topLevelNames' | 'notFoundInNamespace' | 'notFoundInNamespaceDeep';
export interface Options {
allowComputed?: boolean;
}
declare const _default: TSESLint.RuleModule<MessageId, [Options], import("../utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
export default _default;

View File

@@ -0,0 +1,238 @@
import { importDeclaration, ExportMap, createRule, declaredScope, getValue, } from '../utils/index.js';
function processBodyStatement(context, namespaces, declaration) {
if (declaration.type !== 'ImportDeclaration') {
return;
}
if (declaration.specifiers.length === 0) {
return;
}
const imports = ExportMap.get(declaration.source.value, context);
if (imports == null) {
return;
}
if (imports.errors.length > 0) {
imports.reportErrors(context, declaration);
return;
}
for (const specifier of declaration.specifiers) {
switch (specifier.type) {
case 'ImportNamespaceSpecifier': {
if (imports.size === 0) {
context.report({
node: specifier,
messageId: 'noNamesFound',
data: {
module: declaration.source.value,
},
});
}
namespaces.set(specifier.local.name, imports);
break;
}
case 'ImportDefaultSpecifier':
case 'ImportSpecifier': {
const meta = imports.get('imported' in specifier
? getValue(specifier.imported)
:
'default');
if (!meta || !meta.namespace) {
break;
}
namespaces.set(specifier.local.name, meta.namespace);
break;
}
default:
}
}
}
function makeMessage(last, namepath, node = last) {
const messageId = namepath.length > 1 ? 'notFoundInNamespaceDeep' : 'notFoundInNamespace';
return {
node,
messageId,
data: {
name: last.name,
namepath: namepath.join('.'),
},
};
}
export default createRule({
name: 'namespace',
meta: {
type: 'problem',
docs: {
category: 'Static analysis',
description: 'Ensure imported namespaces contain dereferenced properties as they are dereferenced.',
},
schema: [
{
type: 'object',
properties: {
allowComputed: {
description: 'If `false`, will report computed (and thus, un-lintable) references to namespace members.',
type: 'boolean',
default: false,
},
},
additionalProperties: false,
},
],
messages: {
noNamesFound: "No exported names found in module '{{module}}'.",
computedReference: "Unable to validate computed reference to imported namespace '{{namespace}}'.",
namespaceMember: "Assignment to member of namespace '{{namespace}}'.",
topLevelNames: 'Only destructure top-level names.',
notFoundInNamespace: "'{{name}}' not found in imported namespace '{{namepath}}'.",
notFoundInNamespaceDeep: "'{{name}}' not found in deeply imported namespace '{{namepath}}'.",
},
},
defaultOptions: [
{
allowComputed: false,
},
],
create(context) {
const { allowComputed } = context.options[0] || {};
const namespaces = new Map();
return {
Program({ body }) {
for (const x of body) {
processBodyStatement(context, namespaces, x);
}
},
ExportNamespaceSpecifier(namespace) {
const declaration = importDeclaration(context, namespace);
const imports = ExportMap.get(declaration.source.value, context);
if (imports == null) {
return null;
}
if (imports.errors.length > 0) {
imports.reportErrors(context, declaration);
return;
}
if (imports.size === 0) {
context.report({
node: namespace,
messageId: 'noNamesFound',
data: {
module: declaration.source.value,
},
});
}
},
MemberExpression(dereference) {
if (dereference.object.type !== 'Identifier') {
return;
}
if (!namespaces.has(dereference.object.name)) {
return;
}
if (declaredScope(context, dereference, dereference.object.name) !==
'module') {
return;
}
const parent = dereference.parent;
if (parent?.type === 'AssignmentExpression' &&
parent.left === dereference) {
context.report({
node: parent,
messageId: 'namespaceMember',
data: {
namespace: dereference.object.name,
},
});
}
let namespace = namespaces.get(dereference.object.name);
const namepath = [dereference.object.name];
let deref = dereference;
while (namespace instanceof ExportMap &&
deref?.type === 'MemberExpression') {
if (deref.computed) {
if (!allowComputed) {
context.report({
node: deref.property,
messageId: 'computedReference',
data: {
namespace: 'name' in deref.object && deref.object.name,
},
});
}
return;
}
if (!namespace.has(deref.property.name)) {
context.report(makeMessage(deref.property, namepath));
break;
}
const exported = namespace.get(deref.property.name);
if (exported == null) {
return;
}
namepath.push(deref.property.name);
namespace = exported.namespace;
deref = deref.parent;
}
},
VariableDeclarator(node) {
const { id, init } = node;
if (init == null) {
return;
}
if (init.type !== 'Identifier') {
return;
}
if (!namespaces.has(init.name)) {
return;
}
if (declaredScope(context, node, init.name) !== 'module') {
return;
}
const initName = init.name;
function testKey(pattern, namespace, path = [initName]) {
if (!(namespace instanceof ExportMap)) {
return;
}
if (pattern.type !== 'ObjectPattern') {
return;
}
for (const property of pattern.properties) {
if (property.type === 'ExperimentalRestProperty' ||
property.type === 'RestElement' ||
!property.key) {
continue;
}
if (property.key.type !== 'Identifier') {
context.report({
node: property,
messageId: 'topLevelNames',
});
continue;
}
if (!namespace.has(property.key.name)) {
context.report(makeMessage(property.key, path, property));
continue;
}
path.push(property.key.name);
const dependencyExportMap = namespace.get(property.key.name);
if (dependencyExportMap != null) {
testKey(property.value, dependencyExportMap.namespace, path);
}
path.pop();
}
}
testKey(id, namespaces.get(init.name));
},
JSXMemberExpression({ object, property }) {
if (!('name' in object) ||
typeof object.name !== 'string' ||
!namespaces.has(object.name)) {
return;
}
const namespace = namespaces.get(object.name);
if (!namespace.has(property.name)) {
context.report(makeMessage(property, [object.name]));
}
},
};
},
});
//# sourceMappingURL=namespace.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
import type { TSESLint } from '@typescript-eslint/utils';
export interface Options {
count?: number;
exactCount?: boolean;
considerComments?: boolean;
}
export type MessageId = 'newline';
declare const _default: TSESLint.RuleModule<"newline", [(Options | undefined)?], import("../utils/create-rule.ts").ImportXPluginDocs, TSESLint.RuleListener>;
export default _default;

View File

@@ -0,0 +1,224 @@
import debug from 'debug';
import { isStaticRequire, createRule } from '../utils/index.js';
const log = debug('eslint-plugin-import-x:rules:newline-after-import');
function containsNodeOrEqual(outerNode, innerNode) {
return (outerNode.range[0] <= innerNode.range[0] &&
outerNode.range[1] >= innerNode.range[1]);
}
function getScopeBody(scope) {
if (scope.block.type === 'SwitchStatement') {
log('SwitchStatement scopes not supported');
return [];
}
const body = 'body' in scope.block ? scope.block.body : null;
if (body && 'type' in body && body.type === 'BlockStatement') {
return body.body;
}
return Array.isArray(body) ? body : [];
}
function findNodeIndexInScopeBody(body, nodeToFind) {
return body.findIndex(node => containsNodeOrEqual(node, nodeToFind));
}
function getLineDifference(node, nextNode) {
return nextNode.loc.start.line - node.loc.end.line;
}
function isClassWithDecorator(node) {
return node.type === 'ClassDeclaration' && !!node.decorators?.length;
}
function isExportDefaultClass(node) {
return (node.type === 'ExportDefaultDeclaration' &&
node.declaration.type === 'ClassDeclaration');
}
function isExportNameClass(node) {
return (node.type === 'ExportNamedDeclaration' &&
node.declaration?.type === 'ClassDeclaration');
}
export default createRule({
name: 'newline-after-import',
meta: {
type: 'layout',
docs: {
category: 'Style guide',
description: 'Enforce a newline after import statements.',
},
fixable: 'whitespace',
schema: [
{
type: 'object',
properties: {
count: {
type: 'integer',
minimum: 1,
},
exactCount: { type: 'boolean' },
considerComments: { type: 'boolean' },
},
additionalProperties: false,
},
],
messages: {
newline: 'Expected {{count}} empty line{{lineSuffix}} after {{type}} statement not followed by another {{type}}.',
},
},
defaultOptions: [],
create(context) {
let level = 0;
const requireCalls = [];
const options = {
count: 1,
exactCount: false,
considerComments: false,
...context.options[0],
};
function checkForNewLine(node, nextNode, type) {
if (isExportDefaultClass(nextNode) || isExportNameClass(nextNode)) {
const classNode = nextNode.declaration;
if (isClassWithDecorator(classNode)) {
nextNode = classNode.decorators[0];
}
}
else if (isClassWithDecorator(nextNode)) {
nextNode = nextNode.decorators[0];
}
const lineDifference = getLineDifference(node, nextNode);
const EXPECTED_LINE_DIFFERENCE = options.count + 1;
if (lineDifference < EXPECTED_LINE_DIFFERENCE ||
(options.exactCount && lineDifference !== EXPECTED_LINE_DIFFERENCE)) {
let column = node.loc.start.column;
if (node.loc.start.line !== node.loc.end.line) {
column = 0;
}
context.report({
loc: {
line: node.loc.end.line,
column,
},
messageId: 'newline',
data: {
count: options.count,
lineSuffix: options.count > 1 ? 's' : '',
type,
},
fix: options.exactCount && EXPECTED_LINE_DIFFERENCE < lineDifference
? undefined
: fixer => fixer.insertTextAfter(node, '\n'.repeat(EXPECTED_LINE_DIFFERENCE - lineDifference)),
});
}
}
function commentAfterImport(node, nextComment, type) {
const lineDifference = getLineDifference(node, nextComment);
const EXPECTED_LINE_DIFFERENCE = options.count + 1;
if (lineDifference < EXPECTED_LINE_DIFFERENCE) {
let column = node.loc.start.column;
if (node.loc.start.line !== node.loc.end.line) {
column = 0;
}
context.report({
loc: {
line: node.loc.end.line,
column,
},
messageId: 'newline',
data: {
count: options.count,
lineSuffix: options.count > 1 ? 's' : '',
type,
},
fix: options.exactCount && EXPECTED_LINE_DIFFERENCE < lineDifference
? undefined
: fixer => fixer.insertTextAfter(node, '\n'.repeat(EXPECTED_LINE_DIFFERENCE - lineDifference)),
});
}
}
function incrementLevel() {
level++;
}
function decrementLevel() {
level--;
}
function checkImport(node) {
const { parent } = node;
if (!parent || !('body' in parent) || !parent.body) {
return;
}
const root = parent;
const nodePosition = root.body.indexOf(node);
const nextNode = root.body[nodePosition + 1];
const endLine = node.loc.end.line;
let nextComment;
if (root.comments !== undefined && options.considerComments) {
nextComment = root.comments.find(o => o.loc.start.line >= endLine &&
o.loc.start.line <= endLine + options.count + 1);
}
if (node.type === 'TSImportEqualsDeclaration' &&
node.isExport) {
return;
}
if (nextComment) {
commentAfterImport(node, nextComment, 'import');
}
else if (nextNode &&
nextNode.type !== 'ImportDeclaration' &&
(nextNode.type !== 'TSImportEqualsDeclaration' ||
nextNode.isExport)) {
checkForNewLine(node, nextNode, 'import');
}
}
return {
ImportDeclaration: checkImport,
TSImportEqualsDeclaration: checkImport,
CallExpression(node) {
if (isStaticRequire(node) && level === 0) {
requireCalls.push(node);
}
},
'Program:exit'(node) {
log('exit processing for', context.physicalFilename);
const scopeBody = getScopeBody(context.sourceCode.getScope(node));
log('got scope:', scopeBody);
for (const [index, node] of requireCalls.entries()) {
const nodePosition = findNodeIndexInScopeBody(scopeBody, node);
log('node position in scope:', nodePosition);
const statementWithRequireCall = scopeBody[nodePosition];
const nextStatement = scopeBody[nodePosition + 1];
const nextRequireCall = requireCalls[index + 1];
if (nextRequireCall &&
containsNodeOrEqual(statementWithRequireCall, nextRequireCall)) {
continue;
}
if (nextStatement &&
(!nextRequireCall ||
!containsNodeOrEqual(nextStatement, nextRequireCall))) {
let nextComment;
if ('comments' in statementWithRequireCall.parent &&
statementWithRequireCall.parent.comments !== undefined &&
options.considerComments) {
const endLine = node.loc.end.line;
nextComment = statementWithRequireCall.parent.comments.find(o => o.loc.start.line >= endLine &&
o.loc.start.line <= endLine + options.count + 1);
}
if (nextComment && nextComment !== undefined) {
commentAfterImport(statementWithRequireCall, nextComment, 'require');
}
else {
checkForNewLine(statementWithRequireCall, nextStatement, 'require');
}
}
}
},
FunctionDeclaration: incrementLevel,
FunctionExpression: incrementLevel,
ArrowFunctionExpression: incrementLevel,
BlockStatement: incrementLevel,
ObjectExpression: incrementLevel,
Decorator: incrementLevel,
'FunctionDeclaration:exit': decrementLevel,
'FunctionExpression:exit': decrementLevel,
'ArrowFunctionExpression:exit': decrementLevel,
'BlockStatement:exit': decrementLevel,
'ObjectExpression:exit': decrementLevel,
'Decorator:exit': decrementLevel,
};
},
});
//# sourceMappingURL=newline-after-import.js.map

Some files were not shown because too many files have changed in this diff Show More