-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
105 lines (104 loc) · 4.98 KB
/
Copy patheslint.config.mjs
File metadata and controls
105 lines (104 loc) · 4.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Obsidian's own plugin linter — the same rule set the community directory's
// automated review runs against every published version. Run `npm run lint`
// before cutting a release; a failing version is pulled from search within a
// day, so this is cheaper to satisfy here than in a resubmission.
import obsidianmd from "eslint-plugin-obsidianmd";
import tseslint from "typescript-eslint";
export default tseslint.config(
{
ignores: ["dist/**", "build/**", "node_modules/**", "tools/**", "*.mjs"],
},
...obsidianmd.configs.recommended,
{
// The recommended set includes type-aware rules (`await-thenable` and
// friends), which need the program, not just the syntax tree. Scoped to
// TypeScript: the same config also lints manifest.json, which has no
// program to build.
files: ["**/*.ts"],
plugins: { "@typescript-eslint": tseslint.plugin },
languageOptions: {
parserOptions: { project: "./tsconfig.json", tsconfigRootDir: import.meta.dirname },
globals: {
// Build-time constants, `define`d by esbuild (see virtual.d.ts).
__REFLOW_DEV__: "readonly",
__REFLOW_ORT_GLUE_PATCHED__: "readonly",
// `manifest.json` lives at the repository root, because that is where
// the community directory reads it from. This config's base path is
// plugin/, so the obsidianmd rules can no longer find it and fall back
// to assuming a mobile-capable plugin, which makes Electron's `process`
// look undefined. The manifest says `isDesktopOnly: true`; the checks
// that read it directly live in `npm run lint:manifest`. (The
// "Failed to load JSON file ... manifest.json" line eslint prints is
// that same lookup missing, and is harmless.)
process: "readonly",
},
},
rules: {
// "EPUB" is an acronym (Electronic PUBlication) and "Kindle" is a product
// name; both are capitalised everywhere they appear, Amazon's own UI
// included. Without this the rule insists on "Export to epub" and
// "Send to kindle".
//
// `ignoreWords` and not `acronyms`: the rule reads its options as
// `options.acronyms ?? DEFAULT_ACRONYMS`, so supplying that key *replaces*
// the built-in list and silently breaks "PDF" everywhere else. Only
// `ignoreWords` is additive.
"obsidianmd/ui/sentence-case": [
"error",
{
ignoreWords: ["EPUB", "Kindle"],
// "Send to Kindle" is the app's actual name, so the phrase keeps its
// capitals wherever it appears. ignoreRegex is matched against the
// whole UI string and, like ignoreWords, defaults to empty — so it
// adds to the built-in lists rather than replacing them.
ignoreRegex: ["Send to Kindle"],
},
],
// Warnings, not errors: every one of these lands on a *third-party*
// surface with no usable types — transformers.js's `env` bag, ORT's
// wasmPaths, pdf.js internals, and `catch (e: any)`. Typing them properly
// means hand-writing declarations for libraries that change monthly,
// which trades a real maintenance burden for no user-visible safety. They
// stay visible so a new one gets noticed; `npm run lint` fails only on
// the obsidianmd/* rules, which are the ones review acts on.
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unsafe-any": "off",
"@typescript-eslint/no-unsafe-argument": "warn",
"@typescript-eslint/no-unsafe-assignment": "warn",
"@typescript-eslint/no-unsafe-call": "warn",
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/no-unsafe-return": "warn",
"@typescript-eslint/no-unnecessary-type-assertion": "warn",
"@typescript-eslint/no-misused-promises": "warn",
},
},
{
// The conversion worker has no `document` and no `activeDocument` — reading
// `globalThis` is the only way to see what the environment offers — and its
// console mirror is how worker-side diagnostics reach the renderer at all.
files: ["worker.ts"],
rules: {
"obsidianmd/prefer-active-doc": "off",
"obsidianmd/rule-custom-message": "off",
},
},
{
// The bridge that carries worker-side warnings and errors to the renderer's
// console (see the comment at the call site). Configured here rather than
// with an inline `eslint-disable`, which Obsidian's review rejects outright
// for obsidianmd/* rules — and rightly: a rule turned off in a config file
// is visible, one turned off mid-file is not.
files: ["worker-host.ts"],
rules: { "obsidianmd/rule-custom-message": "off" },
},
{
// probe.ts is development-only: release builds resolve it to probe-stub.ts
// (see esbuild.config.mjs), so nothing here reaches an installed plugin.
files: ["probe.ts"],
rules: {
"obsidianmd/prefer-active-doc": "off",
"obsidianmd/rule-custom-message": "off",
"obsidianmd/no-global-app": "off",
},
},
);