mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 07:50:24 +00:00
Removes the deferred "off" override so the rule runs at the recommended severity on .ts/.tsx. With manifest.minAppVersion=1.4.0 and obsidian@1.2.5 (no @since tags) the rule fires on nothing today — it acts as a guard for future obsidian type-stub bumps. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
198 lines
6.9 KiB
JavaScript
198 lines
6.9 KiB
JavaScript
import obsidianmd from "eslint-plugin-obsidianmd";
|
|
import reactPlugin from "eslint-plugin-react";
|
|
import reactHooks from "eslint-plugin-react-hooks";
|
|
import tailwind from "eslint-plugin-tailwindcss";
|
|
import globals from "globals";
|
|
|
|
export default [
|
|
{
|
|
ignores: [
|
|
"node_modules/**",
|
|
"main.js",
|
|
"styles.css",
|
|
"data.json",
|
|
"designdocs/**",
|
|
"docs/**",
|
|
],
|
|
},
|
|
|
|
// obsidianmd recommended brings:
|
|
// - eslint:recommended
|
|
// - typescript-eslint recommendedTypeChecked on .ts/.tsx (recommended on .js/.jsx)
|
|
// - obsidianmd plugin + all obsidianmd-namespaced rules
|
|
// - import / @microsoft/sdl / depend / no-unsanitized
|
|
// - Obsidian-injected globals (activeDocument, createDiv, etc.)
|
|
...obsidianmd.configs.recommended,
|
|
|
|
// React + tailwind plugins ship flat configs with no `files` filter, so
|
|
// they'd cascade onto package.json (which uses the JSON parser) and crash.
|
|
// Constrain them to JS/TS sources.
|
|
{
|
|
files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"],
|
|
...reactPlugin.configs.flat.recommended,
|
|
},
|
|
{
|
|
files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"],
|
|
plugins: { "react-hooks": reactHooks },
|
|
rules: {
|
|
"react-hooks/rules-of-hooks": "error",
|
|
"react-hooks/exhaustive-deps": "error",
|
|
},
|
|
},
|
|
...tailwind.configs["flat/recommended"].map((cfg) => ({
|
|
files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"],
|
|
...cfg,
|
|
})),
|
|
|
|
{
|
|
files: ["**/*.{js,jsx,mjs,cjs,ts,tsx}"],
|
|
languageOptions: {
|
|
globals: {
|
|
// Obsidian plugin runtime injects `app` as a global (see CLAUDE.md).
|
|
app: "readonly",
|
|
},
|
|
},
|
|
settings: {
|
|
react: { version: "detect" },
|
|
tailwindcss: {
|
|
callees: ["classnames", "clsx", "ctl", "cn", "cva"],
|
|
config: "./tailwind.config.js",
|
|
cssFiles: ["**/*.css", "!**/node_modules", "!**/.*", "!**/dist", "!**/build"],
|
|
},
|
|
},
|
|
rules: {
|
|
// Carry-over from legacy .eslintrc
|
|
"no-prototype-builtins": "off",
|
|
"react/prop-types": "off",
|
|
"tailwindcss/classnames-order": "error",
|
|
"tailwindcss/enforces-negative-arbitrary-values": "error",
|
|
"tailwindcss/enforces-shorthand": "error",
|
|
"tailwindcss/migration-from-tailwind-2": "error",
|
|
"tailwindcss/no-arbitrary-value": "off",
|
|
"tailwindcss/no-custom-classname": "error",
|
|
"tailwindcss/no-contradicting-classname": "error",
|
|
|
|
// obsidianmd: defer to follow-up PRs
|
|
"obsidianmd/vault/iterate": "error",
|
|
"obsidianmd/prefer-active-doc": "error",
|
|
"obsidianmd/object-assign": "off",
|
|
"obsidianmd/ui/sentence-case": "off",
|
|
|
|
// obsidianmd: disabled intentionally — Platform.isMacOS branching is on-purpose
|
|
"obsidianmd/platform": "off",
|
|
|
|
// Bundled by obsidianmd/recommended via tseslint.configs.recommendedTypeChecked.
|
|
// Disabled here because the codebase intentionally uses `any` / dynamic typing
|
|
// around Obsidian's untyped APIs and LangChain message shapes — flipping these
|
|
// on would require refactoring thousands of call sites with no functional gain.
|
|
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
"@typescript-eslint/no-unsafe-call": "off",
|
|
"@typescript-eslint/no-unsafe-argument": "off",
|
|
"@typescript-eslint/no-unsafe-return": "off",
|
|
"@typescript-eslint/no-unsafe-enum-comparison": "off",
|
|
"@typescript-eslint/no-base-to-string": "off",
|
|
"@typescript-eslint/no-redundant-type-constituents": "off",
|
|
"@typescript-eslint/restrict-template-expressions": "off",
|
|
"@typescript-eslint/unbound-method": "off",
|
|
"@typescript-eslint/no-misused-promises": "off",
|
|
"@typescript-eslint/no-floating-promises": "off",
|
|
"@typescript-eslint/no-unnecessary-type-assertion": "off",
|
|
"@typescript-eslint/await-thenable": "off",
|
|
// no-deprecated: defer — surface the warnings, but don't fail CI yet
|
|
"@typescript-eslint/no-deprecated": "off",
|
|
|
|
// rule-custom-message wraps no-console; we don't enable no-console in this PR
|
|
// and the codebase enforces logInfo/logWarn/logError via CLAUDE.md.
|
|
"obsidianmd/rule-custom-message": "off",
|
|
|
|
// SDL / import / no-unsanitized / depend: defer — review separately
|
|
"@microsoft/sdl/no-inner-html": "off",
|
|
"no-unsanitized/method": "off",
|
|
"no-unsanitized/property": "off",
|
|
"import/no-nodejs-modules": "off",
|
|
"import/no-extraneous-dependencies": "off",
|
|
"no-restricted-imports": "off",
|
|
"no-restricted-globals": "off",
|
|
// depend/ban-dependencies suggests native replacements for axios/lodash.debounce/etc.
|
|
// — out of scope for this PR; revisit per-dep.
|
|
"depend/ban-dependencies": "off",
|
|
},
|
|
},
|
|
|
|
// Test files need Jest globals
|
|
{
|
|
files: ["**/*.test.{js,jsx,ts,tsx}", "jest.setup.js", "__mocks__/**"],
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.jest,
|
|
...globals.node,
|
|
},
|
|
},
|
|
},
|
|
|
|
// Node-context files (build configs, scripts)
|
|
{
|
|
files: [
|
|
"*.{js,mjs,cjs}",
|
|
"scripts/**",
|
|
"esbuild.config.mjs",
|
|
"version-bump.mjs",
|
|
"wasmPlugin.mjs",
|
|
"nodeModuleShim.mjs",
|
|
"jest.config.js",
|
|
"tailwind.config.js",
|
|
],
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.node,
|
|
},
|
|
},
|
|
},
|
|
|
|
// TypeScript-specific overrides (the @typescript-eslint plugin is registered
|
|
// by obsidianmd's recommended config only for .ts/.tsx files).
|
|
{
|
|
files: ["**/*.ts", "**/*.tsx"],
|
|
languageOptions: {
|
|
parserOptions: {
|
|
project: "./tsconfig.json",
|
|
tsconfigRootDir: import.meta.dirname,
|
|
},
|
|
},
|
|
rules: {
|
|
"@typescript-eslint/no-explicit-any": "off",
|
|
"@typescript-eslint/no-empty-function": "off",
|
|
"@typescript-eslint/ban-ts-comment": "off",
|
|
"@typescript-eslint/no-unused-vars": ["error", { args: "none" }],
|
|
// TypeScript handles undefined-identifier detection (and does so cross-realm
|
|
// correctly); per typescript-eslint's own guidance, disable no-undef on TS.
|
|
"no-undef": "off",
|
|
},
|
|
},
|
|
|
|
// Non-TS files aren't in tsconfig.json — disable type-aware rules that
|
|
// obsidianmd's recommended config enables globally. (The plugin lists some
|
|
// typed rules in its general rule bundle, not just the TS-only bundle, so
|
|
// they cascade to .js / package.json without parser services.)
|
|
{
|
|
files: ["**/*.js", "**/*.mjs", "**/*.cjs", "**/*.jsx", "**/package.json"],
|
|
rules: {
|
|
"@typescript-eslint/no-deprecated": "off",
|
|
"obsidianmd/no-plugin-as-component": "off",
|
|
"obsidianmd/no-view-references-in-plugin": "off",
|
|
"obsidianmd/no-unsupported-api": "off",
|
|
"obsidianmd/prefer-file-manager-trash-file": "off",
|
|
"obsidianmd/prefer-instanceof": "off",
|
|
},
|
|
},
|
|
|
|
// package.json: obsidianmd recommended adds depend/ban-dependencies in a
|
|
// package.json-specific block that we need to override separately.
|
|
{
|
|
files: ["**/package.json"],
|
|
rules: {
|
|
"depend/ban-dependencies": "off",
|
|
},
|
|
},
|
|
];
|