Skip to content

Commit 5d2822a

Browse files
committed
move startup helpers and constants to separate files
1 parent 6cdf6ed commit 5d2822a

File tree

10 files changed

+540
-477
lines changed

10 files changed

+540
-477
lines changed

.github/renovate.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"config:recommended",
5+
":semanticPrefixChore",
6+
":prHourlyLimitNone",
7+
":prConcurrentLimitNone",
8+
":enableVulnerabilityAlerts",
9+
":dependencyDashboard",
10+
"schedule:weekends"
11+
],
12+
"packageRules": [
13+
{
14+
"matchPackageNames": ["zotero-plugin-toolkit", "zotero-types"],
15+
"automerge": true
16+
}
17+
],
18+
"git-submodules": {
19+
"enabled": true
20+
}
21+
}

.release-it.json

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

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/daeh/zotero-markdb-connect?style=for-the-badge)](https://github.com/daeh/zotero-markdb-connect/releases/latest) [![GitHub all releases](https://img.shields.io/github/downloads/daeh/zotero-markdb-connect/total?style=for-the-badge&color=forestgreen)](https://github.com/daeh/zotero-markdb-connect/releases/latest)
1+
[![GitHub release (with filter)](https://img.shields.io/github/v/release/daeh/zotero-markdb-connect?style=for-the-badge&filter=*v0.1.0*)](https://github.com/daeh/zotero-markdb-connect/releases/tag/v0.1.0-rc.3)
2+
3+
<!-- [![GitHub release (latest by date)](https://img.shields.io/github/v/release/daeh/zotero-markdb-connect?style=for-the-badge)](https://github.com/daeh/zotero-markdb-connect/releases/latest) [![GitHub all releases](https://img.shields.io/github/downloads/daeh/zotero-markdb-connect/total?style=for-the-badge&color=forestgreen)](https://github.com/daeh/zotero-markdb-connect/releases/latest) -->
4+
25

36
# MarkDB-Connect (Zotero Markdown DataBase Connect)
47

8+
[![zotero target version](https://img.shields.io/badge/Zotero-7-green?style=flat-square&logo=zotero&logoColor=CC2936)](https://www.zotero.org) [![Using Zotero Plugin Template](https://img.shields.io/badge/Using-Zotero%20Plugin%20Template-blue?style=flat-square&logo=github)](https://github.com/windingwind/zotero-plugin-template)
9+
510
- **_Scans your Markdown database and adds a colored tag to associated Zotero items._**
611
- **_Jump to Markdown notes from the contextual menu of Zotero items._**
712
- **_Supports various Markdown databases, including [Obsidian](https://obsidian.md), [logseq](https://logseq.com), and [Zettlr](https://www.zettlr.com)_**
@@ -191,4 +196,4 @@ Distributed under the MIT License.
191196

192197
## Author
193198

194-
[![Personal Website](https://img.shields.io/badge/personal%20website-daeh.info-orange?style=for-the-badge)](https://daeh.info) [![Blue Sky](https://img.shields.io/badge/bsky-@dae.bsky.social-skyblue?style=for-the-badge&logo=mastodon)](https://bsky.app/profile/dae.bsky.social) [![Twitter](https://img.shields.io/badge/twitter-@DaeHoulihan-blue?style=for-the-badge&logo=twitter)](https://twitter.com/DaeHoulihan)
199+
[![Personal Website](https://img.shields.io/badge/personal%20website-daeh.info-orange?style=for-the-badge)](https://daeh.info) [![BlueSky](https://img.shields.io/badge/bsky-@dae.bsky.social-skyblue?style=for-the-badge&logo=mastodon)](https://bsky.app/profile/dae.bsky.social) [![Twitter](https://img.shields.io/badge/twitter-@DaeHoulihan-white?style=for-the-badge&logo=twitter)](https://twitter.com/DaeHoulihan)

eslint.config.mjs

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ import globals from 'globals'
1414

1515
const projectDirname = dirname(fileURLToPath(import.meta.url))
1616

17-
const allTsExtensionsArray = ['ts', 'mts', 'cts', 'tsx', 'mtsx']
18-
const allJsExtensionsArray = ['js', 'mjs', 'cjs', 'jsx', 'mjsx']
19-
const allTsExtensions = allTsExtensionsArray.join(',')
20-
const allJsExtensions = allJsExtensionsArray.join(',')
21-
// @ts-expect-error - ignore this local variable
22-
const allExtensions = [...allTsExtensionsArray, ...allJsExtensionsArray].join(',')
23-
2417
const env = (() => {
2518
if (typeof process.env.NODE_ENV === 'undefined') return 'base'
2619
if (process.env.NODE_ENV === 'development') return 'development'
2720
if (process.env.NODE_ENV === 'production') return 'production'
2821
return 'error'
2922
})()
3023

24+
const allTsExtensionsArray = ['ts', 'mts', 'cts', 'tsx', 'mtsx']
25+
const allJsExtensionsArray = ['js', 'mjs', 'cjs', 'jsx', 'mjsx']
26+
const allTsExtensions = allTsExtensionsArray.join(',')
27+
const allJsExtensions = allJsExtensionsArray.join(',')
28+
// @ts-expect-error - ignore this local variable
29+
const allExtensions = [...allTsExtensionsArray, ...allJsExtensionsArray].join(',')
30+
3131
const importRules = {
3232
'import/no-unresolved': 'error',
3333
'sort-imports': [
@@ -76,7 +76,20 @@ const baseRules = {
7676
// '@stylistic/multiline-ternary': ['warn', 'always'],
7777
}
7878

79-
const typescriptRules = {}
79+
const typescriptRules = {
80+
...prettierConfig.rules,
81+
...pluginImportConfig.rules,
82+
...typescriptEslintPlugin.configs.recommended.rules,
83+
...typescriptEslintPlugin.configs['recommended-type-checked'].rules,
84+
//
85+
// ...typescriptEslintPlugin.configs.strict.rules,
86+
// ...typescriptEslintPlugin.configs['strict-type-checked'].rules,
87+
//
88+
...typescriptEslintPlugin.configs['stylistic-type-checked'].rules,
89+
...typescriptStylisticPlugin.configs['disable-legacy'].rules,
90+
...importRules,
91+
...baseRules,
92+
}
8093

8194
const javascriptRules = {}
8295

@@ -114,12 +127,12 @@ const config = [
114127
/* setup parser for all files */
115128
files: [`**/*.{${allTsExtensions}}`],
116129
languageOptions: {
117-
sourceType: 'module',
118130
parser: typescriptEslintParser,
119131
parserOptions: {
120132
ecmaVersion: 'latest', // 2024 sets the ecmaVersion parser option to 15
121133
tsconfigRootDir: resolve(projectDirname),
122134
project: env === 'production' ? './tsconfig.prod.json' : './tsconfig.json',
135+
sourceType: 'module',
123136
},
124137
},
125138
},
@@ -141,21 +154,22 @@ const config = [
141154
'prettier': prettierPlugin,
142155
},
143156
rules: {
144-
...prettierConfig.rules,
145-
...pluginImportConfig.rules,
146-
...typescriptEslintPlugin.configs.recommended.rules,
147-
...typescriptEslintPlugin.configs['recommended-type-checked'].rules,
148-
//
149-
// ...typescriptEslintPlugin.configs.strict.rules,
150-
// ...typescriptEslintPlugin.configs['strict-type-checked'].rules,
151-
//
152-
...typescriptEslintPlugin.configs['stylistic-type-checked'].rules,
153-
...typescriptStylisticPlugin.configs['disable-legacy'].rules,
154-
...importRules,
155-
...baseRules,
156157
...typescriptRules,
157158
},
158159
},
160+
{
161+
/* +strict for typescript files NOT in ./src/ folder */
162+
files: [`**/*.{${allTsExtensions}}`],
163+
ignores: [`src/**/*.{${allTsExtensions}}`, `typing/**/*.d.ts`, `**/*.config.{${allTsExtensions}}`],
164+
plugins: {
165+
'@typescript-eslint': typescriptEslintPlugin,
166+
'@stylistic': defaultStylisticPlugin,
167+
},
168+
rules: {
169+
...typescriptEslintPlugin.configs.strict.rules,
170+
...typescriptEslintPlugin.configs['strict-type-checked'].rules,
171+
},
172+
},
159173
{
160174
/* +lenient for typescript files in ./src/ folder */
161175
files: [`src/**/*.{${allTsExtensions}}`, `typing/**/*.d.ts`],
@@ -174,19 +188,6 @@ const config = [
174188
...typescriptRulesDev,
175189
},
176190
},
177-
{
178-
/* +strict for typescript files NOT in ./src/ folder */
179-
files: [`**/*.{${allTsExtensions}}`],
180-
ignores: [`src/**/*.{${allTsExtensions}}`, `typing/**/*.d.ts`, `**/*.config.{${allTsExtensions}}`],
181-
plugins: {
182-
'@typescript-eslint': typescriptEslintPlugin,
183-
'@stylistic': defaultStylisticPlugin,
184-
},
185-
rules: {
186-
...typescriptEslintPlugin.configs.strict.rules,
187-
...typescriptEslintPlugin.configs['strict-type-checked'].rules,
188-
},
189-
},
190191
{
191192
ignores: ['build', 'scripts', '**/*.js', '**/*.bak'],
192193
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"publish": false
6767
},
6868
"github": {
69-
"release": false,
69+
"release": true,
7070
"assets": [
7171
"build/*.xpi"
7272
]

scripts/zotero-cmd-default.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"usage": "Copy and rename this file to zotero-cmd.json. Edit the cmd.",
33
"killZoteroWindows": "taskkill /f /im zotero.exe",
4-
"killZoteroUnix": "kill -9 $(ps -x | grep zotero)",
4+
"killZoteroUnix": "kill -9 $(ps -x | grep '[z]otero' | awk '{print $1}')", // DAEMOD
55
"exec": {
66
"@comment-zoteroBinPath": "Please input the path of the Zotero binary file in `zoteroBinPath`.",
77
"@comment-zoteroBinPath-tip": "The path delimiter should be escaped as `\\` for win32. The path is `*/Zotero.app/Contents/MacOS/zotero` for MacOS.",

src/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import {
1010
ScanMarkdownFiles,
1111
systemInterface,
1212
UIHelpers,
13-
wrappers,
1413
} from './modules/mdbcScan'
14+
import { wrappers } from './modules/mdbcStartupHelpers'
1515
import { unpatch as $unpatch$ } from './modules/monkey-patch'
1616
import { registerPrefsScripts } from './modules/preferenceScript'
1717
import { getString, initLocale } from './utils/locale'

src/modules/mdbcConstants.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const _paramVals_filefilterstrategy = ['default', 'customfileregexp'] as const
2+
type _param_filefilterstrategy = (typeof _paramVals_filefilterstrategy)[number]
3+
4+
const _paramVals_matchstrategy = ['bbtcitekeyyaml', 'bbtcitekeyregexp', 'zotitemkey'] as const
5+
type _paramTypes_matchstrategy = (typeof _paramVals_matchstrategy)[number]
6+
7+
const _paramVals_mdeditor = ['system', 'obsidian', 'logseq'] as const
8+
type _param_mdeditor = (typeof _paramVals_mdeditor)[number]
9+
10+
const _paramVals_obsidianresolvewithfile = [false, true] as const
11+
type _param_obsidianresolvewithfile = (typeof _paramVals_obsidianresolvewithfile)[number]
12+
const _paramVals_obsidianresolvespec = ['path', 'file'] as const
13+
type _param_obsidianresolvespec = (typeof _paramVals_obsidianresolvespec)[number]
14+
15+
const _paramVals_grouplibraries = ['user', 'group'] as const
16+
type _param_grouplibraries = (typeof _paramVals_grouplibraries)[number]
17+
18+
const _paramVals_removetags = ['keepsynced', 'addonly'] as const
19+
type _param_removetags = (typeof _paramVals_removetags)[number]
20+
21+
const _paramVals_debugmode = ['minimal' as DebugMode, 'maximal' as DebugMode] as const
22+
23+
export const paramVals = {
24+
filefilterstrategy: _paramVals_filefilterstrategy,
25+
matchstrategy: _paramVals_matchstrategy,
26+
mdeditor: _paramVals_mdeditor,
27+
obsidianresolvewithfile: _paramVals_obsidianresolvewithfile,
28+
obsidianresolvespec: _paramVals_obsidianresolvespec,
29+
grouplibraries: _paramVals_grouplibraries,
30+
removetags: _paramVals_removetags,
31+
debugmode: _paramVals_debugmode,
32+
}
33+
34+
export declare interface paramTypes {
35+
filefilterstrategy: _param_filefilterstrategy
36+
matchstrategy: _paramTypes_matchstrategy
37+
mdeditor: _param_mdeditor
38+
obsidianresolvewithfile: _param_obsidianresolvewithfile
39+
obsidianresolvespec: _param_obsidianresolvespec
40+
grouplibraries: _param_grouplibraries
41+
removetags: _param_removetags
42+
}

0 commit comments

Comments
 (0)