mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
Fix some more eslint issues
This commit is contained in:
parent
aae916aafa
commit
a4951dbd86
5 changed files with 40 additions and 63 deletions
|
|
@ -1,66 +1,36 @@
|
|||
import tseslint from "typescript-eslint";
|
||||
import obsidianmd from "eslint-plugin-obsidianmd";
|
||||
import json from "@eslint/json";
|
||||
import tseslint from "typescript-eslint";
|
||||
|
||||
export default [
|
||||
...obsidianmd.configs.recommended,
|
||||
{
|
||||
files: ["manifest.json"],
|
||||
language: "json/json",
|
||||
plugins: {
|
||||
json
|
||||
},
|
||||
rules: {
|
||||
"no-irregular-whitespace": "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",
|
||||
"obsidianmd/validate-manifest": "error"
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ["package.json"],
|
||||
rules: {
|
||||
"no-irregular-whitespace": "off",
|
||||
"depend/ban-dependencies": "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"
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ["**/*.{js,mjs,cjs}"],
|
||||
...tseslint.configs.disableTypeChecked,
|
||||
rules: {
|
||||
...tseslint.configs.disableTypeChecked.rules,
|
||||
"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"
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ["**/*.ts"],
|
||||
languageOptions: {
|
||||
parser: tseslint.parser,
|
||||
parserOptions: {
|
||||
sourceType: "module",
|
||||
project: "./tsconfig.json"
|
||||
sourceType: "module"
|
||||
}
|
||||
},
|
||||
ignores: [
|
||||
"**/node_modules/**",
|
||||
"**/dist/**"
|
||||
"**/dist/**",
|
||||
],
|
||||
plugins: {
|
||||
"@typescript-eslint": tseslint.plugin
|
||||
"@typescript-eslint": tseslint.plugin,
|
||||
obsidianmd
|
||||
},
|
||||
rules: {
|
||||
"obsidianmd/no-tfile-tfolder-cast": "error",
|
||||
"obsidianmd/rule-custom-message": [
|
||||
"error",
|
||||
{
|
||||
"no-console": {
|
||||
messages: {
|
||||
"Unexpected console statement. Only these console methods are allowed: warn, error, debug.": "Avoid unnecessary logging to console. See https://docs.obsidian.md/Plugins/Releasing/Plugin+guidelines#Avoid+unnecessary+logging+to+console",
|
||||
},
|
||||
options: [{ allow: ["warn", "error", "debug"] }],
|
||||
}
|
||||
}
|
||||
],
|
||||
"no-unused-vars": "off",
|
||||
"quotes": [
|
||||
"error",
|
||||
|
|
@ -204,4 +174,4 @@ export default [
|
|||
],
|
||||
}
|
||||
}
|
||||
];
|
||||
];
|
||||
|
|
@ -375,7 +375,7 @@ function shouldCreateFolderNote(
|
|||
detachedExcludedFolder: ExcludedFolder | undefined,
|
||||
): boolean {
|
||||
return !excludedFolder?.disableFolderNote
|
||||
&& folderName === (newFolder as TFolder)?.name
|
||||
&& folderName === (newFolder)?.name
|
||||
&& !detachedExcludedFolder;
|
||||
}
|
||||
|
||||
|
|
@ -384,7 +384,7 @@ function shouldRemoveFolderNoteClasses(
|
|||
folderName: string,
|
||||
newFolder: TAbstractFile | null,
|
||||
): boolean {
|
||||
return excludedFolder?.disableFolderNote || (folderName !== (newFolder as TFolder)?.name);
|
||||
return excludedFolder?.disableFolderNote || (folderName !== (newFolder)?.name);
|
||||
}
|
||||
|
||||
function handleFolderNoteCreation(
|
||||
|
|
@ -424,8 +424,8 @@ function shouldRenameFolderOnFileRename(
|
|||
): boolean {
|
||||
if (!oldFolder) return false;
|
||||
|
||||
const oldFolderAsFolder = oldFolder as TFolder;
|
||||
const newFolderAsFolder = newFolder as TFolder;
|
||||
const oldFolderAsFolder = oldFolder;
|
||||
const newFolderAsFolder = newFolder;
|
||||
|
||||
return (oldFolderName === oldFolderAsFolder.name
|
||||
&& newFolderAsFolder?.path === oldFolderAsFolder.path)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import {
|
|||
removeCSSClassFromFileExplorerEL,
|
||||
removeActiveFolder,
|
||||
setActiveFolder,
|
||||
updateCSSClassesForFolder,
|
||||
updateCSSClassesForFolderNote,
|
||||
} from 'src/functions/styleFunctions';
|
||||
import {
|
||||
|
|
@ -214,7 +213,8 @@ async function handleTurnNoteIntoFolderNote(
|
|||
): Promise<void> {
|
||||
deleteExcludedFolder(plugin, detachedFolder);
|
||||
removeCSSClassFromFileExplorerEL(folderNote?.path, 'is-folder-note', false, plugin);
|
||||
const folder = plugin.app.vault.getAbstractFileByPath(folderPath) as TFolder;
|
||||
const folder = plugin.app.vault.getAbstractFileByPath(folderPath);
|
||||
if (!(folder instanceof TFolder)) return;
|
||||
if (!folderNote || folderNote.basename !== fileName) return;
|
||||
let count = 1;
|
||||
const baseName = removeExtension(folderNote.path);
|
||||
|
|
|
|||
|
|
@ -89,8 +89,7 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
fvIndexDB!: FvIndexDB;
|
||||
|
||||
async onload(): Promise<void> {
|
||||
// eslint-disable-next-line obsidianmd/rule-custom-message
|
||||
console.log('loading folder notes plugin');
|
||||
console.debug('loading folder notes plugin');
|
||||
await this.loadSettings();
|
||||
this.settingsTab = new SettingsTab(this.app, this);
|
||||
this.addSettingTab(this.settingsTab);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,21 @@
|
|||
import { TFile, TFolder, Vault, AbstractInputSuggest, type TAbstractFile } from 'obsidian';
|
||||
import type FolderNotesPlugin from '../main';
|
||||
import { getTemplatePlugins } from 'src/template';
|
||||
|
||||
interface TemplateSuggestion {
|
||||
path: string;
|
||||
name: string;
|
||||
parent?: {
|
||||
path: string;
|
||||
} | null;
|
||||
}
|
||||
|
||||
export enum FileSuggestMode {
|
||||
TemplateFiles,
|
||||
ScriptFiles,
|
||||
}
|
||||
|
||||
export class TemplateSuggest extends AbstractInputSuggest<TFile> {
|
||||
export class TemplateSuggest extends AbstractInputSuggest<TemplateSuggestion> {
|
||||
constructor(
|
||||
public inputEl: HTMLInputElement,
|
||||
public plugin: FolderNotesPlugin,
|
||||
|
|
@ -24,10 +33,10 @@ export class TemplateSuggest extends AbstractInputSuggest<TFile> {
|
|||
}
|
||||
}
|
||||
|
||||
getSuggestions(input_str: string): TFile[] {
|
||||
getSuggestions(input_str: string): TemplateSuggestion[] {
|
||||
const { templateFolder, templaterPlugin } = getTemplatePlugins(this.app);
|
||||
|
||||
let files: TFile[] = [];
|
||||
let files: TemplateSuggestion[] = [];
|
||||
const lower_input_str = input_str.toLowerCase();
|
||||
|
||||
if ((!templateFolder || templateFolder.trim() === '') && !templaterPlugin) {
|
||||
|
|
@ -48,8 +57,7 @@ export class TemplateSuggest extends AbstractInputSuggest<TFile> {
|
|||
path: '',
|
||||
name:
|
||||
'You need to set the Templates folder in the Templater settings first.',
|
||||
// eslint-disable-next-line obsidianmd/no-tfile-tfolder-cast
|
||||
} as TFile,
|
||||
},
|
||||
];
|
||||
}
|
||||
} else if (templateFolder) {
|
||||
|
|
@ -71,7 +79,7 @@ export class TemplateSuggest extends AbstractInputSuggest<TFile> {
|
|||
}
|
||||
|
||||
|
||||
renderSuggestion(file: TFile, el: HTMLElement): void {
|
||||
renderSuggestion(file: TemplateSuggestion, el: HTMLElement): void {
|
||||
const { templateFolder, templaterPlugin } = getTemplatePlugins(this.app);
|
||||
|
||||
if ((!templateFolder || templateFolder.trim() === '') && !templaterPlugin) {
|
||||
|
|
@ -82,7 +90,7 @@ export class TemplateSuggest extends AbstractInputSuggest<TFile> {
|
|||
}
|
||||
|
||||
|
||||
selectSuggestion(file: TFile): void {
|
||||
selectSuggestion(file: TemplateSuggestion): void {
|
||||
this.inputEl.value = file.name.replace('.md', '');
|
||||
this.inputEl.trigger('input');
|
||||
this.plugin.settings.templatePath = file.path;
|
||||
|
|
|
|||
Loading…
Reference in a new issue