Files
upstream-zulip/patches/eslint-plugin-import-x.patch
upstream-mirror 64898b2c79
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
2026-09-15 15:05:30 +05:00

127 lines
6.1 KiB
Diff

diff --git a/lib/index.cjs b/lib/index.cjs
index b04314774bb93ff76872fd3a54229f0c5189c04c..4ba475083a031781e8bb88fa97085a3e5e0f45d6 100644
--- a/lib/index.cjs
+++ b/lib/index.cjs
@@ -1584,10 +1584,9 @@ var ExportMap = class ExportMap {
}
for (const s of n.specifiers) processSpecifier(s, n, m);
}
- const exports$1 = ["TSExportAssignment"];
- if (isEsModuleInteropTrue()) exports$1.push("TSNamespaceExportDeclaration");
- if (exports$1.includes(n.type)) {
- const exportedName = n.type === "TSNamespaceExportDeclaration" ? (n.id || n.name).name : "expression" in n && n.expression && ("name" in n.expression && n.expression.name || "id" in n.expression && n.expression.id && n.expression.id.name) || null;
+ if (n.type === "TSExportAssignment") {
+ m.hasExportAssignment = true;
+ const exportedName = "expression" in n && n.expression && ("name" in n.expression && n.expression.name || "id" in n.expression && n.expression.id && n.expression.id.name) || null;
const getRoot = (node) => {
if (node.left.type === "TSQualifiedName") return getRoot(node.left);
return node.left;
@@ -1660,6 +1659,8 @@ var ExportMap = class ExportMap {
/** Dependencies of this module that are not explicitly re-exported */
imports = new Map();
exports = new Map();
+ /** Whether this module has an `export = ns` assignment */
+ hasExportAssignment = false;
errors = [];
parseGoal = "ambiguous";
constructor(path$21) {
@@ -4828,6 +4829,7 @@ var no_named_as_default_member_default = createRule({
if (fileImport == null) continue;
for (const { propName, node } of lookups) {
if (propName === "default") continue;
+ if (fileImport.exportMap.hasExportAssignment) continue;
if (!fileImport.exportMap.namespace.has(propName)) continue;
context.report({
node,
@@ -4873,6 +4875,7 @@ var no_named_as_default_default = createRule({
}
if (!exportMapOfImported.hasDefault) return;
if (!exportMapOfImported.has(nameValue)) return;
+ if (exportMapOfImported.hasExportAssignment) return;
if (exportMapOfImported.exports.has("default") && exportMapOfImported.exports.has(nameValue)) context.report({
node: defaultSpecifier,
messageId: "default",
diff --git a/lib/rules/no-named-as-default-member.js b/lib/rules/no-named-as-default-member.js
index 3aae00046b68d3ac47549b9570529e867e3c1a88..59452aa7fa42b592c28ccf415c1bba5972f1b027 100644
--- a/lib/rules/no-named-as-default-member.js
+++ b/lib/rules/no-named-as-default-member.js
@@ -68,6 +68,9 @@ export default createRule({
if (propName === 'default') {
continue;
}
+ if (fileImport.exportMap.hasExportAssignment) {
+ continue;
+ }
if (!fileImport.exportMap.namespace.has(propName)) {
continue;
}
diff --git a/lib/rules/no-named-as-default.js b/lib/rules/no-named-as-default.js
index cc08f38f05647d150e24e0b596c2caeeecdd362f..5b79fe484ac6ca4975f07c3ce2c8127188d01d07 100644
--- a/lib/rules/no-named-as-default.js
+++ b/lib/rules/no-named-as-default.js
@@ -35,6 +35,9 @@ export default createRule({
if (!exportMapOfImported.has(nameValue)) {
return;
}
+ if (exportMapOfImported.hasExportAssignment) {
+ return;
+ }
if (exportMapOfImported.exports.has('default') &&
exportMapOfImported.exports.has(nameValue)) {
context.report({
diff --git a/lib/utils/export-map.d.ts b/lib/utils/export-map.d.ts
index 2c93f36928ba2aa7ffd4e78ebc3111833c9e09d4..0133cac6af6d40734715f987141835ea2e4f8d7a 100644
--- a/lib/utils/export-map.d.ts
+++ b/lib/utils/export-map.d.ts
@@ -29,6 +29,7 @@ export declare class ExportMap {
dependencies: Set<() => ExportMap | null>;
imports: Map<string, ModuleImport>;
exports: Map<string, TSESTree.Identifier | TSESTree.ProgramStatement>;
+ hasExportAssignment: boolean;
errors: ParseError[];
parseGoal: 'ambiguous' | 'Module' | 'Script';
visitorKeys: TSESLint.SourceCode.VisitorKeys | null;
diff --git a/lib/utils/export-map.js b/lib/utils/export-map.js
index 1595cf11112adf7d40cf947e8b92c489ef386bd2..c1cf2cb33081b314298ece64267be95744ad346e 100644
--- a/lib/utils/export-map.js
+++ b/lib/utils/export-map.js
@@ -343,21 +343,15 @@ export class ExportMap {
processSpecifier(s, n, m);
}
}
- const exports = ['TSExportAssignment'];
- if (isEsModuleInteropTrue()) {
- exports.push('TSNamespaceExportDeclaration');
- }
- if (exports.includes(n.type)) {
- const exportedName = n.type === 'TSNamespaceExportDeclaration'
- ? (n.id ||
- n.name).name
- : ('expression' in n &&
- n.expression &&
- (('name' in n.expression && n.expression.name) ||
- ('id' in n.expression &&
- n.expression.id &&
- n.expression.id.name))) ||
- null;
+ if (n.type === 'TSExportAssignment') {
+ m.hasExportAssignment = true;
+ const exportedName = ('expression' in n &&
+ n.expression &&
+ (('name' in n.expression && n.expression.name) ||
+ ('id' in n.expression &&
+ n.expression.id &&
+ n.expression.id.name))) ||
+ null;
const getRoot = (node) => {
if (node.left.type === 'TSQualifiedName') {
return getRoot(node.left);
@@ -470,6 +464,7 @@ export class ExportMap {
this.dependencies = new Set();
this.imports = new Map();
this.exports = new Map();
+ this.hasExportAssignment = false;
this.errors = [];
this.parseGoal = 'ambiguous';
}