eCourt-Doc-Edit/addin/eslint.config.mjs

47 lines
1.9 KiB
JavaScript
Raw Permalink Normal View History

2026-08-19 21:35:07 +07:00
import officeAddins from "eslint-plugin-office-addins";
import tsParser from "@typescript-eslint/parser";
import tsPlugin from "@typescript-eslint/eslint-plugin";
import globals from "globals";
// สืบทอดจาก config เริ่มต้นของ office-addin-lint (node_modules/office-addin-lint/config/eslint.config.mjs)
// — office-addin-lint จะใช้ไฟล์นี้แทนถ้ามีอยู่ใน root ของโปรเจกต์
//
// ปิด `no-navigational-load` เพราะ rule ของ plugin เวอร์ชันนี้ (4.0.10):
// (a) crash กับ `context.load(obj)` แบบ 1 อาร์กิวเมนต์ (parsePropertiesArgument(undefined))
// (b) ไม่รู้จัก Word API properties (เช่น `tag`) จึงรายงาน false positive
export default [
...officeAddins.configs.recommended,
{
plugins: {
"office-addins": officeAddins,
},
languageOptions: {
parser: tsParser,
// task pane รันใน browser (Office) แต่ unit test/jest setup ใช้ node globals ด้วย
globals: { ...globals.browser, ...globals.node, ...globals.jest },
},
},
{
rules: {
"office-addins/no-navigational-load": "off",
},
},
{
// ไฟล์ TS: tsc ตรวจ undefined globals อยู่แล้ว (แม่นกว่า no-undef ที่ไม่เข้าใจ types)
// และ no-redeclare ชนกับ /* global */ comments ของ scaffold
files: ["**/*.ts", "**/*.tsx"],
plugins: {
"@typescript-eslint": tsPlugin,
},
rules: {
"no-undef": "off",
"no-redeclare": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
],
},
},
];