chore: add strict ESLint checks for Obsidian review compatibility

Signed-off-by: Zoorpha <aaron@kubedo.com>
This commit is contained in:
Zoorpha 2026-06-22 22:13:10 +02:00
parent 3273d87bb7
commit b572a34caa
7 changed files with 3663 additions and 7 deletions

79
.eslintrc.json Normal file
View file

@ -0,0 +1,79 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"tsconfigRootDir": "."
},
"plugins": [
"@typescript-eslint"
],
"ignorePatterns": [
"vitest.config.ts",
"esbuild.config.mjs",
"node_modules/",
"dist/",
"main.js"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/no-explicit-any": "error",
"no-restricted-globals": [
"error",
{
"name": "navigator",
"message": "Use the Platform API instead of navigator to detect the operating system (e.g. Platform.isMobile, Platform.isDesktop)."
},
{
"name": "setTimeout",
"message": "Use window.setTimeout() instead of setTimeout() for popout window compatibility."
},
{
"name": "setInterval",
"message": "Use window.setInterval() instead of setInterval() for popout window compatibility."
}
],
"no-restricted-properties": [
"error",
{
"property": "navigator",
"message": "Use the Platform API instead of navigator to detect the operating system."
}
],
"no-restricted-syntax": [
"error",
{
"selector": "CallExpression[callee.property.name=/^(createEl|createElement|createDom)$/][arguments.0.type='Literal'][arguments.0.value=/^h[1-6]$/]",
"message": "Do not create HTML heading elements directly. For a consistent UI use new Setting(containerEl).setName(...).setHeading() instead."
}
]
},
"overrides": [
{
"files": ["src/**/*.ts"],
"extends": [
"plugin:@typescript-eslint/recommended-type-checked"
],
"rules": {
"@typescript-eslint/no-unsafe-assignment": "error",
"@typescript-eslint/no-unsafe-member-access": "error",
"@typescript-eslint/no-unsafe-call": "error",
"@typescript-eslint/no-unsafe-argument": "error",
"@typescript-eslint/no-unsafe-return": "error"
}
},
{
"files": ["tests/**/*.ts"],
"parserOptions": {
"project": null
},
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off"
}
}
]
}

View file

@ -2,8 +2,13 @@ name: Build and Release Obsidian Plugin
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
jobs:
release:
@ -27,10 +32,17 @@ jobs:
- name: Install dependencies
run: npm ci
- name: Run lint checks
run: npm run lint
- name: Run tests
run: npm run test
- name: Build plugin
run: npm run build
- name: Generate Release
if: startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
@ -41,8 +53,10 @@ jobs:
--prerelease=false
- name: Attest Build Provenance
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/attest-build-provenance@v2
with:
subject-path: |
main.js
styles.css

11
.gitignore vendored Normal file
View file

@ -0,0 +1,11 @@
# Node modules
node_modules/
# Built plugin files
main.js
# OS / Editor files
.DS_Store
.vscode/
.idea/
*.log

1830
node_modules/.package-lock.json generated vendored

File diff suppressed because it is too large Load diff

1724
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -5,9 +5,10 @@
"main": "main.js",
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"test": "vitest run",
"test:coverage": "vitest run --coverage",
"build": "node node_modules/typescript/bin/tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"lint": "eslint . --ext .ts",
"test": "node node_modules/vitest/vitest.mjs run",
"test:coverage": "node node_modules/vitest/vitest.mjs run --coverage",
"version": "node version-bump.mjs && git add manifest.json versions.json"
},
"keywords": [
@ -19,8 +20,11 @@
"license": "MIT",
"devDependencies": {
"@types/node": "^20.0.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vitest/coverage-v8": "^4.1.8",
"esbuild": "0.24.0",
"eslint": "^8.57.1",
"obsidian": "1.7.2",
"tslib": "2.8.0",
"typescript": "^5.9.3",

View file

@ -67,7 +67,7 @@ export default class RustShareVaultSyncPlugin extends Plugin {
this.syncQueue.start();
// Ribbon icon
this.addRibbonIcon('cloud', 'RustShare Vault Sync', (evt: MouseEvent) => {
this.addRibbonIcon('cloud', 'RustShare Vault Sync', () => {
void this.runManualSync();
});