chore: update template from obsidianmd/obsidian-sample-plugin

This commit is contained in:
Kritagya Bhattarai (CalfMoon) 2026-03-28 21:05:58 +05:45
parent b43c8dcafc
commit aa0987082e
9 changed files with 635 additions and 1006 deletions

View file

@ -1,3 +0,0 @@
node_modules/
main.js

View file

@ -1,23 +0,0 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"env": { "node": true },
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"sourceType": "module"
},
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }],
"@typescript-eslint/ban-ts-comment": "off",
"no-prototype-builtins": "off",
"@typescript-eslint/no-empty-function": "off"
}
}

28
.github/workflows/lint.yml vendored Normal file
View file

@ -0,0 +1,28 @@
name: Node.js build
on:
push:
branches: ["**"]
pull_request:
branches: ["**"]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm ci
- run: npm run build --if-present
- run: npm run lint

View file

@ -1,14 +1,15 @@
import esbuild from "esbuild"; import esbuild from "esbuild";
import process from "process"; import process from "process";
import builtins from "builtin-modules"; import { builtinModules } from 'node:module';
const banner = `/* const banner =
`/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin if you want to view the source, please visit the github repository of this plugin
*/ */
`; `;
const prod = process.argv[2] === "production"; const prod = (process.argv[2] === "production");
const context = await esbuild.context({ const context = await esbuild.context({
banner: { banner: {
@ -30,8 +31,7 @@ const context = await esbuild.context({
"@lezer/common", "@lezer/common",
"@lezer/highlight", "@lezer/highlight",
"@lezer/lr", "@lezer/lr",
...builtins, ...builtinModules],
],
format: "cjs", format: "cjs",
target: "es2018", target: "es2018",
logLevel: "info", logLevel: "info",

34
eslint.config.mts Normal file
View file

@ -0,0 +1,34 @@
import tseslint from 'typescript-eslint';
import obsidianmd from "eslint-plugin-obsidianmd";
import globals from "globals";
import { globalIgnores } from "eslint/config";
export default tseslint.config(
{
languageOptions: {
globals: {
...globals.browser,
},
parserOptions: {
projectService: {
allowDefaultProject: [
'eslint.config.js',
'manifest.json'
]
},
tsconfigRootDir: import.meta.dirname,
extraFileExtensions: ['.json']
},
},
},
...obsidianmd.configs.recommended,
globalIgnores([
"node_modules",
"dist",
"esbuild.config.mjs",
"eslint.config.js",
"version-bump.mjs",
"versions.json",
"main.js",
]),
);

1473
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -13,15 +13,16 @@
"author": "CalfMoon", "author": "CalfMoon",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@eslint/js": "9.30.1",
"@types/node": "^16.11.6", "@types/node": "^16.11.6",
"esbuild": "0.25.5", "esbuild": "0.25.5",
"eslint": "^9.39.4",
"eslint-plugin-obsidianmd": "0.1.9", "eslint-plugin-obsidianmd": "0.1.9",
"globals": "14.0.0", "globals": "^14.0.0",
"jiti": "2.6.1",
"tslib": "2.4.0", "tslib": "2.4.0",
"typescript": "^5.8.3", "typescript": "^5.8.3",
"typescript-eslint": "8.35.1", "typescript-eslint": "^8.35.1"
"@eslint/js": "9.30.1",
"jiti": "2.6.1"
}, },
"dependencies": { "dependencies": {
"obsidian": "latest" "obsidian": "latest"

View file

@ -1,24 +1,30 @@
{ {
"compilerOptions": { "compilerOptions": {
"baseUrl": ".", "baseUrl": "src",
"inlineSourceMap": true, "inlineSourceMap": true,
"inlineSources": true, "inlineSources": true,
"module": "ESNext", "module": "ESNext",
"target": "ES6", "target": "ES6",
"allowJs": true, "allowJs": true,
"noImplicitAny": true, "noImplicitAny": true,
"moduleResolution": "node", "noImplicitThis": true,
"importHelpers": true, "noImplicitReturns": true,
"isolatedModules": true, "moduleResolution": "node",
"strictNullChecks": true, "importHelpers": true,
"lib": [ "noUncheckedIndexedAccess": true,
"DOM", "isolatedModules": true,
"ES5", "strictNullChecks": true,
"ES6", "strictBindCallApply": true,
"ES7" "allowSyntheticDefaultImports": true,
] "useUnknownInCatchVariables": true,
}, "lib": [
"include": [ "DOM",
"**/*.ts" "ES5",
] "ES6",
"ES7"
]
},
"include": [
"src/**/*.ts"
]
} }

View file

@ -3,12 +3,15 @@ import { readFileSync, writeFileSync } from "fs";
const targetVersion = process.env.npm_package_version; const targetVersion = process.env.npm_package_version;
// read minAppVersion from manifest.json and bump version to target version // read minAppVersion from manifest.json and bump version to target version
let manifest = JSON.parse(readFileSync("manifest.json", "utf8")); const manifest = JSON.parse(readFileSync("manifest.json", "utf8"));
const { minAppVersion } = manifest; const { minAppVersion } = manifest;
manifest.version = targetVersion; manifest.version = targetVersion;
writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t")); writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t"));
// update versions.json with target version and minAppVersion from manifest.json // update versions.json with target version and minAppVersion from manifest.json
let versions = JSON.parse(readFileSync("versions.json", "utf8")); // but only if the target version is not already in versions.json
versions[targetVersion] = minAppVersion; const versions = JSON.parse(readFileSync('versions.json', 'utf8'));
writeFileSync("versions.json", JSON.stringify(versions, null, "\t")); if (!Object.values(versions).includes(minAppVersion)) {
versions[targetVersion] = minAppVersion;
writeFileSync('versions.json', JSON.stringify(versions, null, '\t'));
}