Skip to content

Commit 3b30527

Browse files
committed
feat: migrate to official Obsidian plugin template
- Upgrade to v1.0.0 - Add ESLint with eslint-plugin-obsidianmd - Add proper TypeScript strict mode config - Separate tsconfig for production and test files - Add CI workflow (lint + test + build) - Add release workflow for automatic GitHub releases - Add fundingUrl (ko-fi) - Fix sentence case for UI text
1 parent 9d41073 commit 3b30527

21 files changed

Lines changed: 9295 additions & 5740 deletions

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# top-most EditorConfig file
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
insert_final_newline = true
8+
indent_style = tab
9+
indent_size = 4
10+
tab_width = 4

.github/workflows/ci.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
branches: ["**"]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [20.x, 22.x]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
cache: "npm"
24+
- run: npm ci
25+
- run: npm run lint
26+
- run: npm test
27+
- run: npm run build

.gitignore

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1-
# Dependencies
2-
node_modules/
1+
# vscode
2+
.vscode
33

4-
# Build output (keep main.js for releases)
5-
# main.js
4+
# Intellij
5+
*.iml
6+
.idea
67

7-
# IDE
8-
.idea/
9-
.vscode/
10-
*.swp
11-
*.swo
8+
# npm
9+
node_modules
1210

13-
# OS
11+
# Don't include the compiled main.js file in the repo.
12+
# They should be uploaded to GitHub releases instead.
13+
main.js
14+
15+
# Exclude sourcemaps
16+
*.map
17+
18+
# obsidian
19+
data.json
20+
21+
# Exclude macOS Finder (System Explorer) View States
1422
.DS_Store
15-
Thumbs.db
1623

17-
# Debug
18-
*.log
24+
# Local dev scripts
25+
install.sh
26+
install-all.sh

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tag-version-prefix=""

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2025
3+
Copyright (c) 2025 yhao3
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Import external code files in your Obsidian notes using `@import` syntax (compat
5151

5252
## Installation
5353

54-
### From Community Plugins (Coming Soon)
54+
### From Community Plugins
5555

5656
1. Open Settings → Community plugins
5757
2. Search for "Code Import"

esbuild.config.mjs

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,49 @@
11
import esbuild from "esbuild";
22
import process from "process";
3-
import builtins from "builtin-modules";
3+
import { builtinModules } from 'node:module';
44

5-
const banner = `/*
5+
const banner =
6+
`/*
67
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
78
if you want to view the source, please visit the github repository of this plugin
89
*/
910
`;
1011

11-
const prod = process.argv[2] === "production";
12+
const prod = (process.argv[2] === "production");
1213

1314
const context = await esbuild.context({
14-
banner: {
15-
js: banner,
16-
},
17-
entryPoints: ["src/main.ts"],
18-
bundle: true,
19-
external: [
20-
"obsidian",
21-
"electron",
22-
"@codemirror/autocomplete",
23-
"@codemirror/collab",
24-
"@codemirror/commands",
25-
"@codemirror/language",
26-
"@codemirror/lint",
27-
"@codemirror/search",
28-
"@codemirror/state",
29-
"@codemirror/view",
30-
"@lezer/common",
31-
"@lezer/highlight",
32-
"@lezer/lr",
33-
...builtins,
34-
],
35-
format: "cjs",
36-
target: "es2018",
37-
logLevel: "info",
38-
sourcemap: prod ? false : "inline",
39-
treeShaking: true,
40-
outfile: "main.js",
15+
banner: {
16+
js: banner,
17+
},
18+
entryPoints: ["src/main.ts"],
19+
bundle: true,
20+
external: [
21+
"obsidian",
22+
"electron",
23+
"@codemirror/autocomplete",
24+
"@codemirror/collab",
25+
"@codemirror/commands",
26+
"@codemirror/language",
27+
"@codemirror/lint",
28+
"@codemirror/search",
29+
"@codemirror/state",
30+
"@codemirror/view",
31+
"@lezer/common",
32+
"@lezer/highlight",
33+
"@lezer/lr",
34+
...builtinModules],
35+
format: "cjs",
36+
target: "es2018",
37+
logLevel: "info",
38+
sourcemap: prod ? false : "inline",
39+
treeShaking: true,
40+
outfile: "main.js",
41+
minify: prod,
4142
});
4243

4344
if (prod) {
44-
await context.rebuild();
45-
process.exit(0);
45+
await context.rebuild();
46+
process.exit(0);
4647
} else {
47-
await context.watch();
48+
await context.watch();
4849
}

eslint.config.mts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import tseslint from 'typescript-eslint';
2+
import obsidianmd from "eslint-plugin-obsidianmd";
3+
import globals from "globals";
4+
import { globalIgnores } from "eslint/config";
5+
import jest from "eslint-plugin-jest";
6+
7+
export default tseslint.config(
8+
// Global ignores
9+
globalIgnores([
10+
"node_modules",
11+
"dist",
12+
"main.js",
13+
"*.config.js",
14+
"*.config.mjs",
15+
"version-bump.mjs",
16+
"versions.json",
17+
]),
18+
// Base config for all TS files
19+
{
20+
languageOptions: {
21+
globals: {
22+
...globals.browser,
23+
},
24+
parserOptions: {
25+
projectService: {
26+
allowDefaultProject: [
27+
'eslint.config.mts',
28+
'manifest.json'
29+
]
30+
},
31+
tsconfigRootDir: import.meta.dirname,
32+
extraFileExtensions: ['.json']
33+
},
34+
},
35+
},
36+
// Obsidian plugin rules
37+
...obsidianmd.configs.recommended,
38+
// Test files: use separate tsconfig, Jest plugin
39+
{
40+
files: ["**/*.test.ts"],
41+
languageOptions: {
42+
parserOptions: {
43+
projectService: false,
44+
project: "./tsconfig.test.json",
45+
},
46+
globals: {
47+
...globals.jest,
48+
},
49+
},
50+
plugins: {
51+
jest,
52+
},
53+
rules: {
54+
...jest.configs.recommended.rules,
55+
},
56+
},
57+
);

jest.config.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
module.exports = {
2-
preset: 'ts-jest',
1+
export default {
2+
preset: 'ts-jest/presets/default-esm',
33
testEnvironment: 'node',
4-
roots: ['<rootDir>/src'],
4+
extensionsToTreatAsEsm: ['.ts'],
5+
moduleNameMapper: {
6+
'^(\\.{1,2}/.*)\\.js$': '$1',
7+
},
8+
transform: {
9+
'^.+\\.tsx?$': [
10+
'ts-jest',
11+
{
12+
useESM: true,
13+
},
14+
],
15+
},
516
testMatch: ['**/*.test.ts'],
6-
moduleFileExtensions: ['ts', 'js'],
717
};

0 commit comments

Comments
 (0)