Skip to content

Commit 35b2a9e

Browse files
authored
Update plugin template (#21)
* Improved templates and CI/CD * Update CONTRIBUTING.md * Improved Linting * Fix missing typing
1 parent 913b47a commit 35b2a9e

File tree

16 files changed

+1213
-683
lines changed

16 files changed

+1213
-683
lines changed

.eslintrc

Lines changed: 152 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,155 @@
11
{
2-
"root": true,
3-
"parser": "@typescript-eslint/parser",
4-
"env": {
5-
"node": true
6-
},
7-
"plugins": [
8-
"@typescript-eslint",
9-
"@stylistic/eslint-plugin"
10-
],
11-
"extends": [
12-
"eslint:recommended",
13-
"plugin:@typescript-eslint/eslint-recommended",
14-
"plugin:@typescript-eslint/recommended"
15-
],
16-
"parserOptions": {
17-
"sourceType": "module"
18-
},
19-
"rules": {
20-
"@stylistic/indent": [
21-
"error",
22-
"tab"
23-
],
24-
"@stylistic/indent-binary-ops": [
25-
"error",
26-
"tab"
27-
],
28-
"@stylistic/quotes": [
29-
"error",
30-
"single"
31-
],
32-
"@stylistic/semi": [
33-
"error",
34-
"always"
35-
],
36-
"@stylistic/brace-style": [
37-
"error",
38-
"stroustrup",
39-
{
40-
"allowSingleLine": true
41-
}
42-
],
43-
"@stylistic/comma-dangle": [
44-
"error",
45-
"always-multiline"
46-
],
47-
"@stylistic/dot-location": [
48-
"error",
49-
"property"
50-
],
51-
"@stylistic/function-call-argument-newline": [
52-
"error",
53-
"consistent"
54-
],
55-
"@stylistic/function-call-spacing": "error",
56-
"@stylistic/implicit-arrow-linebreak": "error",
57-
"@stylistic/key-spacing": "error",
58-
"@stylistic/lines-around-comment": "error",
59-
"@stylistic/new-parens": "error",
60-
"@stylistic/no-confusing-arrow": "error",
61-
"@stylistic/no-extra-semi": "error",
62-
"@stylistic/no-floating-decimal": "error",
63-
"@stylistic/no-mixed-operators": "error",
64-
"@stylistic/no-mixed-spaces-and-tabs": "error",
65-
"@stylistic/no-multi-spaces": "error",
66-
"@stylistic/no-multiple-empty-lines": [
67-
"error",
68-
{
69-
"max": 1,
70-
"maxEOF": 0,
71-
"maxBOF": 0
72-
}
73-
],
74-
"@stylistic/no-trailing-spaces": [
75-
"error",
76-
{
77-
"skipBlankLines": true
78-
}
79-
],
80-
"@stylistic/nonblock-statement-body-position": "error",
81-
"@stylistic/operator-linebreak": [
82-
"error",
83-
"after"
84-
],
85-
"@stylistic/padded-blocks": [
86-
"error",
87-
"never"
88-
],
89-
"@stylistic/padding-line-between-statements": "error",
90-
"@stylistic/rest-spread-spacing": "error",
91-
"@stylistic/semi-spacing": "error",
92-
"@stylistic/semi-style": "error",
93-
"@stylistic/space-before-blocks": "error",
94-
"@stylistic/space-before-function-paren": [
95-
"error",
96-
{
97-
"anonymous": "always",
98-
"named": "never",
99-
"asyncArrow": "always"
100-
}
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"env": {
5+
"node": true
6+
},
7+
"plugins": [
8+
"@typescript-eslint",
9+
"@stylistic/eslint-plugin"
10110
],
102-
"@stylistic/arrow-spacing": "error",
103-
"@stylistic/space-in-parens": "error",
104-
"@stylistic/space-infix-ops": "error",
105-
"@stylistic/space-unary-ops": "error",
106-
"@stylistic/spaced-comment": [
107-
"error",
108-
"always"
109-
],
110-
"@stylistic/switch-colon-spacing": "error",
111-
"@stylistic/template-curly-spacing": "error",
112-
"@stylistic/type-generic-spacing": "error",
113-
"@stylistic/type-named-tuple-spacing": "error"
114-
}
11+
"extends": [
12+
"eslint:recommended",
13+
"plugin:@typescript-eslint/eslint-recommended",
14+
"plugin:@typescript-eslint/recommended"
15+
],
16+
"parserOptions": {
17+
"sourceType": "module"
18+
},
19+
"rules": {
20+
"@stylistic/indent": [
21+
"error",
22+
"tab"
23+
],
24+
"@stylistic/indent-binary-ops": [
25+
"error",
26+
"tab"
27+
],
28+
"@stylistic/quotes": [
29+
"error",
30+
"single"
31+
],
32+
"@stylistic/semi": [
33+
"error",
34+
"always"
35+
],
36+
"@stylistic/brace-style": [
37+
"error",
38+
"stroustrup",
39+
{
40+
"allowSingleLine": true
41+
}
42+
],
43+
"@stylistic/comma-dangle": [
44+
"error",
45+
"always-multiline"
46+
],
47+
"comma-spacing": [
48+
"error",
49+
{
50+
"before": false,
51+
"after": true
52+
}
53+
],
54+
"@stylistic/dot-location": [
55+
"error",
56+
"property"
57+
],
58+
"@stylistic/function-call-argument-newline": [
59+
"error",
60+
"consistent"
61+
],
62+
"@stylistic/function-call-spacing": "error",
63+
"@stylistic/implicit-arrow-linebreak": "error",
64+
"@stylistic/key-spacing": "error",
65+
"@stylistic/lines-around-comment": [
66+
"error",
67+
{
68+
"beforeBlockComment": true,
69+
"afterBlockComment": false,
70+
"beforeLineComment": true,
71+
"afterLineComment": false,
72+
"allowBlockStart": true,
73+
"allowBlockEnd": false,
74+
"allowClassStart": true,
75+
"allowClassEnd": false,
76+
"allowObjectStart": true,
77+
"allowObjectEnd": false,
78+
"allowArrayStart": true,
79+
"allowArrayEnd": false,
80+
"ignorePattern": "TODO|HACK|BUG|TEST",
81+
"applyDefaultIgnorePatterns": false
82+
}
83+
],
84+
"@stylistic/new-parens": "error",
85+
"@stylistic/no-confusing-arrow": "error",
86+
"@stylistic/no-extra-semi": "error",
87+
"@stylistic/no-floating-decimal": "error",
88+
"@stylistic/no-mixed-operators": "error",
89+
"@stylistic/no-mixed-spaces-and-tabs": "error",
90+
"@stylistic/no-multi-spaces": "error",
91+
"@stylistic/no-multiple-empty-lines": [
92+
"error",
93+
{
94+
"max": 1,
95+
"maxEOF": 0,
96+
"maxBOF": 0
97+
}
98+
],
99+
"@stylistic/no-trailing-spaces": [
100+
"error",
101+
{
102+
"skipBlankLines": false,
103+
"ignoreComments": false
104+
}
105+
],
106+
"@stylistic/nonblock-statement-body-position": "error",
107+
"@stylistic/operator-linebreak": [
108+
"error",
109+
"after"
110+
],
111+
"@stylistic/padded-blocks": [
112+
"error",
113+
"never"
114+
],
115+
"@stylistic/padding-line-between-statements": "error",
116+
"@stylistic/rest-spread-spacing": "error",
117+
"@stylistic/semi-spacing": "error",
118+
"@stylistic/semi-style": "error",
119+
"@stylistic/space-before-blocks": "error",
120+
"@stylistic/space-before-function-paren": [
121+
"error",
122+
{
123+
"anonymous": "always",
124+
"named": "never",
125+
"asyncArrow": "always"
126+
}
127+
],
128+
"@stylistic/arrow-spacing": "error",
129+
"@stylistic/space-in-parens": "error",
130+
"@stylistic/space-infix-ops": "error",
131+
"@stylistic/space-unary-ops": "error",
132+
"@stylistic/spaced-comment": [
133+
"error",
134+
"always"
135+
],
136+
"@stylistic/switch-colon-spacing": "error",
137+
"@stylistic/template-curly-spacing": "error",
138+
"@stylistic/type-generic-spacing": "error",
139+
"@stylistic/type-named-tuple-spacing": "error",
140+
"no-fallthrough": [
141+
"error",
142+
{
143+
"allowEmptyCase": true
144+
}
145+
],
146+
"line-comment-position": [
147+
"error",
148+
{
149+
"position": "above",
150+
"ignorePattern": "TODO|HACK|BUG|TEST",
151+
"applyDefaultIgnorePatterns": false
152+
}
153+
]
154+
}
115155
}

.eslintrc.dev

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": [
3+
"./.eslintrc"
4+
],
5+
"rules": {
6+
"no-console": "off",
7+
}
8+
}

.eslintrc.release

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"extends": [
3+
"./.eslintrc"
4+
],
5+
"rules": {
6+
"no-console": [
7+
"error",
8+
{
9+
"allow": [
10+
"warn",
11+
"error",
12+
"debug"
13+
]
14+
}
15+
],
16+
"multiline-comment-style": [
17+
"error",
18+
"starred-block"
19+
]
20+
}
21+
}

.github/CONTRIBUTING.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
Thank you for taking the time to contribute to this plugin!
2+
3+
This guide will walk you through the contribution workflow - from [reporting issues](#reporting-issues) and [making changes](#making-changes), to [submitting a pull request](#pull-requests) and [testing the plugin](#testing-the-plugin).
4+
5+
# Getting started
6+
## Reporting Issues
7+
### 1. Check for existing issues
8+
If you encounter a problem, first <a href="../../../issues">search the issue tracker</a> to see if it has already been reported.
9+
- If an there is an existing issue and you can provide additional information add a comment with your information.
10+
- If you just want to indicate that you are experiencing the same issue, add a :+1: reaction to the issue.
11+
### 2. Create a new Issue
12+
If not related issue exists, open a new one using the appropriate <a href="../../../issues/new/choose">issue form</a>.
13+
14+
## Working on an Issue
15+
#### 1. Browse <a href="../../../issues">existing issues</a> to find something you'd like to work on.
16+
#### 2. Comment on the issue to let others know you're working on it.
17+
#### 3. Follow the [making changes](#making-changes) guide below.
18+
#### 4. When ready, submit a [pull request](#pull-request).
19+
20+
## Making Changes
21+
### What you need:
22+
- [**Git**](https://git-scm.com/) on your local machine.
23+
- [**Node.js**](https://nodejs.org/en) at least version `18.x`.
24+
- Code editor, such as [Visual Studio Code](https://code.visualstudio.com/)
25+
### Start working:
26+
#### 1. Fork the repository.
27+
#### 2. Create a new vault
28+
Just for testing the plugin so you **can't** exedentially destroy your real vault
29+
#### 3. Clone repository to your local machine.
30+
```shell
31+
cd path/to/vault
32+
mkdir .obsidian/plugins
33+
cd .obsidian/plugins
34+
git clone <your-fork-url> <plugin-id>
35+
```
36+
#### 4. Install dependencies
37+
```shell
38+
cd <plugin-id>
39+
npm install
40+
```
41+
#### 5. Create a working branch
42+
```shell
43+
git checkout -b <working-branch>
44+
```
45+
#### 6. Compile the source code
46+
The following command keeps running in the terminal and rebuilds the plugin when you modify the source code.
47+
```shell
48+
npm run dev
49+
```
50+
#### 7. Enable the plugin in Obsidian settings
51+
> [!TIP]
52+
> Install the [Hot-Reload](https://github.com/pjeby/hot-reload) plugin to automatically reload the plugin while developing.
53+
54+
## Committing Your Changes
55+
#### 1. Check the formatting of your code
56+
Before committing the following command will fix most of the formatting issues according to our ESLint configuration.
57+
```shell
58+
npm run lint-fix
59+
```
60+
If you see the following output without any errors the formatting matches the the requirements if any errors remain, fix them manually before proceeding.
61+
```output
62+
> eslint . --fix --config .eslintrc.release
63+
```
64+
#### 2. Create commit
65+
Than commit your changes with a clear, descriptive commit message.
66+
67+
## Pull Requests
68+
#### 1. Run tests before submitting
69+
```shell
70+
npm run test
71+
```
72+
- Ensure all tests pass.
73+
- If new tests are needed, add them or note what should be tested in your PR.
74+
#### 2. Push your Branch to your fork
75+
#### 3. Open a Pull Request using the provided template
76+
#### 4. Reference any related issues
77+
78+
## Testing the Plugin
79+
*Not a developer* but still want to help? You can help with testing:
80+
- Test the latest <a href="../../../releases">release</a> for problems
81+
- Test <a href="../../../releases">pre-releases</a>
82+
### How to test
83+
#### 1. Do **not** test in your actual vault - create new vault just for testing
84+
#### 2. Install the version you want to test in the vault
85+
#### 3. If you found a bug or unexpected behavior
86+
- Checkout [reporting issues](#reporting-issues)
87+
- Make sure you know how to reproduce the bug
88+
- Mention the version you have tested
89+
- Provide screenshots/videos or your testfiles to make it easier to reproduce

0 commit comments

Comments
 (0)