2025-11-10 10:25:49 +00:00
// eslint.config.js
2026-04-20 19:20:22 +00:00
import { defineConfig } from "eslint/config" ;
2025-11-10 10:25:49 +00:00
import js from "@eslint/js" ;
import tseslint from "typescript-eslint" ;
import obsidianmd from "eslint-plugin-obsidianmd" ;
2026-04-20 19:20:22 +00:00
import eslintComments from "@eslint-community/eslint-plugin-eslint-comments" ;
import globals from "globals" ;
2025-11-10 10:25:49 +00:00
2026-04-20 19:20:22 +00:00
export default defineConfig ( [
2025-11-10 10:25:49 +00:00
{
2026-04-20 19:20:22 +00:00
ignores : [
"node_modules/**" ,
"main.js" ,
"eslint.config.js" ,
"**/__tests__/**" ,
"**/*.test.ts" ,
"esbuild.config.mjs" ,
"version-bump.mjs" ,
"vitest.config.ts" ,
] ,
2025-11-10 10:25:49 +00:00
} ,
js . configs . recommended ,
{
files : [ "**/*.ts" ] ,
2026-04-20 19:20:22 +00:00
extends : [
tseslint . configs . recommendedTypeChecked ,
obsidianmd . configs . recommended ,
] ,
2025-11-10 10:25:49 +00:00
plugins : {
2026-04-20 19:20:22 +00:00
"@eslint-community/eslint-comments" : eslintComments ,
2025-11-10 10:25:49 +00:00
} ,
languageOptions : {
parser : tseslint . parser ,
parserOptions : {
2026-04-20 19:20:22 +00:00
projectService : true ,
sourceType : "module" ,
2025-11-10 11:14:06 +00:00
} ,
globals : {
2026-04-20 19:20:22 +00:00
... globals . browser ,
... globals . node ,
2025-11-10 11:14:06 +00:00
createEl : "readonly" ,
Fuzzysort : "readonly" ,
2026-04-20 19:20:22 +00:00
AsyncGenerator : "readonly" ,
} ,
2025-11-10 10:25:49 +00:00
} ,
rules : {
2025-11-10 11:14:06 +00:00
"@typescript-eslint/require-await" : "error" ,
"@typescript-eslint/no-floating-promises" : "error" ,
"@typescript-eslint/no-namespace" : "error" ,
"@typescript-eslint/no-require-imports" : "error" ,
"@typescript-eslint/switch-exhaustiveness-check" : "error" ,
2025-11-10 21:47:18 +00:00
"@typescript-eslint/no-explicit-any" : "error" ,
2026-04-20 19:20:22 +00:00
"@eslint-community/eslint-comments/require-description" : "error" ,
"@eslint-community/eslint-comments/no-unused-disable" : "error" ,
"@eslint-community/eslint-comments/no-restricted-disable" : [
2025-11-10 21:47:18 +00:00
"error" ,
2025-11-10 22:32:25 +00:00
"@typescript-eslint/no-explicit-any" ,
2026-04-20 19:20:22 +00:00
"no-restricted-globals" ,
2025-11-10 21:47:18 +00:00
] ,
2025-11-10 11:14:06 +00:00
2025-11-10 10:25:49 +00:00
"no-console" : [ "error" , { allow : [ "warn" , "error" , "debug" ] } ] ,
"no-restricted-globals" : [
"error" ,
2026-04-20 19:20:22 +00:00
{ name : "app" , message : "Avoid using the global app object. Instead use the reference provided by your plugin instance." } ,
{ name : "localStorage" , message : "Prefer `App#saveLocalStorage` / `App#loadLocalStorage` functions to write / read localStorage data that's unique to a vault." } ,
2025-11-10 10:25:49 +00:00
] ,
"no-restricted-imports" : [
"error" ,
2026-04-20 19:20:22 +00:00
{ name : "axios" , message : "Use the built-in `requestUrl` function instead of `axios`." } ,
{ name : "superagent" , message : "Use the built-in `requestUrl` function instead of `superagent`." } ,
{ name : "got" , message : "Use the built-in `requestUrl` function instead of `got`." } ,
{ name : "node-fetch" , message : "Use the built-in `requestUrl` function instead of `node-fetch`." } ,
{ name : "moment" , message : "The 'moment' package is bundled with Obsidian. Please import it from 'obsidian' instead." } ,
2025-11-10 10:25:49 +00:00
] ,
2026-04-20 19:20:22 +00:00
} ,
} ,
{
files : [ "**/*.js" , "**/*.mjs" , "**/*.cjs" ] ,
extends : [ tseslint . configs . disableTypeChecked ] ,
} ,
] ) ;