/* * Copyright 2026 Oliver Herb * SPDX-License-Identifier: MPL-2.0 * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ /* * ESLint flat config: the JSDoc lint gate of "npm run lint" (and therefore * of "npm run check" and "npm run build"). * * Rule sets: @eslint/js recommended plus eslint-plugin-jsdoc recommended, * both reported as errors so that any finding fails the gate. On top of * that every named function needs a JSDoc block with typed @param and * @returns tags. Inline callbacks (functions passed directly as arguments) * stay exempt. * * Environments: * - src/background.js, src/compose/**, src/options/**: classic scripts in * Thunderbird; browser globals plus the WebExtension namespaces * "messenger" and "browser". * - src/lib/**: classic UMD scripts that run in the browser and are also * loaded with require() by the Node tests; browser and Node globals. * - test/**, scripts/**: CommonJS for Node. * - This file: an ES module for Node. */ import js from "@eslint/js"; import jsdoc from "eslint-plugin-jsdoc"; import globals from "globals"; /** The WebExtension namespaces Thunderbird provides to add-on scripts. */ const WEB_EXTENSION_GLOBALS = Object.freeze({ messenger: "readonly", browser: "readonly", }); export default [ { ignores: ["node_modules/**", "dist/**"], }, js.configs.recommended, jsdoc.configs["flat/recommended-error"], { name: "inline-comment/jsdoc-gate", rules: { "jsdoc/require-jsdoc": [ "error", { require: { FunctionDeclaration: true, FunctionExpression: true, ArrowFunctionExpression: true, }, }, ], "jsdoc/require-param": "error", "jsdoc/require-returns": ["error", { checkGetters: false }], "jsdoc/require-param-type": "error", "jsdoc/require-returns-type": "error", "jsdoc/check-param-names": "error", "jsdoc/no-undefined-types": "off", }, }, { name: "inline-comment/extension-scripts", files: ["src/background.js", "src/compose/**/*.js", "src/options/**/*.js"], languageOptions: { sourceType: "script", globals: { ...globals.browser, ...WEB_EXTENSION_GLOBALS, }, }, }, { name: "inline-comment/lib", files: ["src/lib/**/*.js"], languageOptions: { sourceType: "script", globals: { ...globals.browser, ...globals.node, }, }, }, { name: "inline-comment/node", files: ["test/**/*.js", "scripts/**/*.{js,cjs}"], languageOptions: { sourceType: "commonjs", globals: { ...globals.node, }, }, }, { name: "inline-comment/config", files: ["eslint.config.mjs"], languageOptions: { sourceType: "module", globals: { ...globals.node, }, }, }, ];