mirror of
https://github.com/evdboom/Bindery.git
synced 2026-07-22 06:49:36 +00:00
Address review feedback: fix ESLint config, remove dead code, add TFile guard test
Agent-Logs-Url: https://github.com/evdboom/Bindery/sessions/1fce634d-cca8-46c3-ba46-914a81b2924d Co-authored-by: evdboom <18037882+evdboom@users.noreply.github.com>
This commit is contained in:
parent
2a691d248a
commit
6245f167a3
5 changed files with 35 additions and 2794 deletions
|
|
@ -1,8 +1,8 @@
|
|||
import js from '@eslint/js';
|
||||
import tsPlugin from '@typescript-eslint/eslint-plugin';
|
||||
import tsParser from '@typescript-eslint/parser';
|
||||
const js = require('@eslint/js');
|
||||
const tsPlugin = require('@typescript-eslint/eslint-plugin');
|
||||
const tsParser = require('@typescript-eslint/parser');
|
||||
|
||||
export default [
|
||||
module.exports = [
|
||||
{
|
||||
ignores: ['**/node_modules/**', '**/dist/**', '**/out/**', '**/.vscode/**'],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
{
|
||||
"root": true,
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": "latest",
|
||||
"sourceType": "module",
|
||||
"tsconfigRootDir": ".",
|
||||
"project": ["./tsconfig.json"]
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["**/*.ts"],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||||
"@typescript-eslint/no-require-imports": "warn",
|
||||
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -22,7 +22,6 @@
|
|||
"@vitest/coverage-v8": "^4.1.5",
|
||||
"esbuild": "^0.28.0",
|
||||
"eslint": "^9.39.4",
|
||||
"eslint-plugin-obsidianmd": "github:obsidianmd/eslint-plugin",
|
||||
"typescript": "6.0.3",
|
||||
"vitest": "^4.1.5"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -221,6 +221,33 @@ describe('formatOnSave bookRoot scoping', () => {
|
|||
expect(app.vault.modify).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('does not invoke formatFile when modify event arg is not a TFile', async () => {
|
||||
const app = makeApp('/vault', 'MyVault');
|
||||
const bp = new BinderyPlugin(app);
|
||||
|
||||
let savedCallback: ((...args: unknown[]) => void) | undefined;
|
||||
vi.spyOn(app.vault, 'on').mockImplementation((_event: string, cb: (...args: unknown[]) => unknown) => {
|
||||
savedCallback = cb as (...args: unknown[]) => void;
|
||||
return {};
|
||||
});
|
||||
|
||||
await bp.onload();
|
||||
bp.settings.formatOnSave = true;
|
||||
bp.settings.bookRoot = 'MyNovel';
|
||||
|
||||
// Confirm the callback was registered
|
||||
expect(savedCallback).toBeDefined();
|
||||
|
||||
// Pass a non-TFile argument (e.g. a plain string or null)
|
||||
savedCallback!('not-a-tfile');
|
||||
savedCallback!(null);
|
||||
savedCallback!(42);
|
||||
savedCallback!({ noPath: true }); // object missing required TFile fields
|
||||
|
||||
expect(app.vault.modify).not.toHaveBeenCalled();
|
||||
expect(app.vault.read).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('invokes formatFile for files inside bookRoot', async () => {
|
||||
const vaultPath = fs.mkdtempSync(path.join(os.tmpdir(), 'bindery-scope-'));
|
||||
const app = makeApp(vaultPath, 'MyVault');
|
||||
|
|
|
|||
2761
package-lock.json
generated
2761
package-lock.json
generated
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue