From f654fb1b83a6f27adcfa3771544d6bcdc6bf950b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 7 Apr 2025 17:50:25 +0200 Subject: [PATCH] Lint against `export [some declaration]` This disallowd the following types of `export` declaration: - `export class A {}`/`export function A() {}` - `export default class A {}`/`export default function A() {}` - `export let A`/`export const A`/`export var A` While allowing - `export { A }` - `export default A` --- eslint.config.mjs | 10 ++++++++++ src/pdf.sandbox.external.js | 1 + 2 files changed, 11 insertions(+) diff --git a/eslint.config.mjs b/eslint.config.mjs index 7781c7a87..a2fbd20fd 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -306,6 +306,16 @@ export default [ selector: "NewExpression[callee.name='Ref']", message: "Use `Ref.get()` rather than `new Ref()`.", }, + { + selector: "ExportNamedDeclaration[declaration]", + message: + "Separate the declaration and the export statement, using `export { ... }`.", + }, + { + selector: "ExportDefaultDeclaration:has(> :declaration)", + message: + "Separate the declaration and the export statement, using `export default `.", + }, ], "no-unneeded-ternary": "error", "operator-assignment": "error", diff --git a/src/pdf.sandbox.external.js b/src/pdf.sandbox.external.js index 365d94a60..1be8ea60d 100644 --- a/src/pdf.sandbox.external.js +++ b/src/pdf.sandbox.external.js @@ -16,6 +16,7 @@ // In mozilla-central, this file is loaded as non-module script, // so it mustn't have any dependencies. +// eslint-disable-next-line no-restricted-syntax export class SandboxSupportBase { /** * @param {DOMWindow} - win