Skip to content

Commit 2e1d29c

Browse files
author
fuzzc0re
committed
Fixed HMR, lint, tested on macOS
1 parent 8d8f259 commit 2e1d29c

File tree

13 files changed

+2315
-628
lines changed

13 files changed

+2315
-628
lines changed

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Template for apps written with [Electron](https://github.com/electron/electron), [Svelte](https://github.com/sveltejs/svelte) and [Typescript](https://github.com/microsoft/TypeScript).
44

5+
The template does hot module replacement and reloads electron on main process file changes out of the box.
6+
It also follows some good security practices, such as Content-Security-Policy meta tags in html,
7+
context isolation set to true, remote modules set to false etc.
8+
59
## Get started
610

711
To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):
@@ -26,10 +30,9 @@ npm start
2630
```
2731

2832
The start script spins up [Rollup](https://github.com/rollup/rollup)
29-
in watch mode with a [sirv](https://github.com/lukeed/sirv) instance
30-
serving the static files on [localhost:5000](http://localhost:5000) and a
31-
nodemon server on [localhost:5858](http://localhost:5858) with a
32-
typescript compiler.
33+
in watch mode with a [Rollup-Plugin-Serve](https://github.com/thgh/rollup-plugin-serve) instance
34+
serving the frontend static files on [localhost:5000](http://localhost:5000) and a
35+
nodemon server to watch for file changes related to the main electron process.
3336

3437
Electron loads its html content from [localhost:5000](https://github.com/fuzzc0re/electron-svelte-typescript-boilerplate/src/electron/index.ts#L40)
3538
in dev mode and from [build/public/index.html](https://github.com/fuzzc0re/electron-svelte-typescript-boilerplate/src/electron/index.ts#L38)
@@ -61,7 +64,19 @@ In production mode, sourcemaps are [disabled](https://github.com/fuzzc0re/electr
6164

6265
## Contributing
6366

64-
You should run the following command on your contributed code:
67+
In order to lint the code you run:
68+
69+
```bash
70+
npm run lint
71+
```
72+
73+
In order to prettify the code you run:
74+
75+
```bash
76+
npm run format
77+
```
78+
79+
You should run the following command, which runs lint and then format, on your contributed code:
6580

6681
```bash
6782
npm run preversion

eslint.electron.json

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
{
2+
"env": {
3+
"browser": false,
4+
"es6": true,
5+
"node": true
6+
},
7+
"extends": [
8+
"plugin:@typescript-eslint/recommended",
9+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
10+
"prettier",
11+
"prettier/@typescript-eslint"
12+
],
13+
"parser": "@typescript-eslint/parser",
14+
"parserOptions": {
15+
"project": "tsconfig.electron.json",
16+
"sourceType": "module"
17+
},
18+
"plugins": ["eslint-plugin-jsdoc", "eslint-plugin-prefer-arrow", "@typescript-eslint"],
19+
"rules": {
20+
"@typescript-eslint/adjacent-overload-signatures": "error",
21+
"@typescript-eslint/array-type": [
22+
"error",
23+
{
24+
"default": "array"
25+
}
26+
],
27+
"@typescript-eslint/ban-types": [
28+
"error",
29+
{
30+
"types": {
31+
"Object": {
32+
"message": "Avoid using the `Object` type. Did you mean `object`?"
33+
},
34+
"Function": {
35+
"message": "Avoid using the `Function` type. Prefer a specific function type, like `() => void`."
36+
},
37+
"Boolean": {
38+
"message": "Avoid using the `Boolean` type. Did you mean `boolean`?"
39+
},
40+
"Number": {
41+
"message": "Avoid using the `Number` type. Did you mean `number`?"
42+
},
43+
"String": {
44+
"message": "Avoid using the `String` type. Did you mean `string`?"
45+
},
46+
"Symbol": {
47+
"message": "Avoid using the `Symbol` type. Did you mean `symbol`?"
48+
}
49+
}
50+
}
51+
],
52+
"@typescript-eslint/consistent-type-assertions": "error",
53+
"@typescript-eslint/dot-notation": "error",
54+
"@typescript-eslint/indent": "off",
55+
"@typescript-eslint/member-delimiter-style": [
56+
"off",
57+
{
58+
"multiline": {
59+
"delimiter": "none",
60+
"requireLast": true
61+
},
62+
"singleline": {
63+
"delimiter": "semi",
64+
"requireLast": false
65+
}
66+
}
67+
],
68+
"@typescript-eslint/naming-convention": "error",
69+
"@typescript-eslint/no-empty-function": "error",
70+
"@typescript-eslint/no-empty-interface": "error",
71+
"@typescript-eslint/no-explicit-any": "off",
72+
"@typescript-eslint/no-misused-new": "error",
73+
"@typescript-eslint/no-namespace": "error",
74+
"@typescript-eslint/no-parameter-properties": "off",
75+
"@typescript-eslint/no-unused-expressions": "error",
76+
"@typescript-eslint/no-use-before-define": "off",
77+
"@typescript-eslint/no-var-requires": "error",
78+
"@typescript-eslint/prefer-for-of": "error",
79+
"@typescript-eslint/prefer-function-type": "error",
80+
"@typescript-eslint/prefer-namespace-keyword": "error",
81+
"@typescript-eslint/quotes": "off",
82+
"@typescript-eslint/semi": ["off", null],
83+
"@typescript-eslint/triple-slash-reference": [
84+
"error",
85+
{
86+
"path": "always",
87+
"types": "prefer-import",
88+
"lib": "always"
89+
}
90+
],
91+
"@typescript-eslint/type-annotation-spacing": "off",
92+
"@typescript-eslint/unified-signatures": "error",
93+
"arrow-parens": ["off", "always"],
94+
"brace-style": ["off", "off"],
95+
"comma-dangle": "off",
96+
"complexity": "off",
97+
"constructor-super": "error",
98+
"eol-last": "off",
99+
"eqeqeq": ["error", "smart"],
100+
"guard-for-in": "error",
101+
"id-blacklist": [
102+
"error",
103+
"any",
104+
"Number",
105+
"number",
106+
"String",
107+
"string",
108+
"Boolean",
109+
"boolean",
110+
"Undefined",
111+
"undefined"
112+
],
113+
"id-match": "error",
114+
"jsdoc/check-alignment": "error",
115+
"jsdoc/check-indentation": "error",
116+
"jsdoc/newline-after-description": "error",
117+
"linebreak-style": "off",
118+
"max-classes-per-file": ["error", 1],
119+
"max-len": "off",
120+
"new-parens": "off",
121+
"newline-per-chained-call": "off",
122+
"no-bitwise": "error",
123+
"no-caller": "error",
124+
"no-cond-assign": "error",
125+
"no-console": "error",
126+
"no-debugger": "error",
127+
"no-empty": "error",
128+
"no-eval": "error",
129+
"no-extra-semi": "off",
130+
"no-fallthrough": "off",
131+
"no-invalid-this": "off",
132+
"no-irregular-whitespace": "off",
133+
"no-multiple-empty-lines": "off",
134+
"no-new-wrappers": "error",
135+
"no-shadow": [
136+
"error",
137+
{
138+
"hoist": "all"
139+
}
140+
],
141+
"no-throw-literal": "error",
142+
"no-trailing-spaces": "off",
143+
"no-undef-init": "error",
144+
"no-underscore-dangle": "error",
145+
"no-unsafe-finally": "error",
146+
"no-unused-labels": "error",
147+
"no-var": "error",
148+
"object-shorthand": "error",
149+
"one-var": ["error", "never"],
150+
"prefer-arrow/prefer-arrow-functions": "error",
151+
"prefer-const": "error",
152+
"quote-props": "off",
153+
"radix": "error",
154+
"space-before-function-paren": "off",
155+
"space-in-parens": ["off", "never"],
156+
"spaced-comment": [
157+
"error",
158+
"always",
159+
{
160+
"markers": ["/"]
161+
}
162+
],
163+
"use-isnan": "error",
164+
"valid-typeof": "off"
165+
}
166+
}

eslint.svelte.json

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true,
5+
"node": true
6+
},
7+
"extends": [
8+
"plugin:@typescript-eslint/recommended",
9+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
10+
"prettier",
11+
"prettier/@typescript-eslint"
12+
],
13+
"parser": "@typescript-eslint/parser",
14+
"parserOptions": {
15+
"project": "tsconfig.svelte.json",
16+
"ecmaVersion": 2021,
17+
"sourceType": "module"
18+
},
19+
"plugins": ["eslint-plugin-jsdoc", "eslint-plugin-prefer-arrow", "@typescript-eslint"],
20+
"rules": {
21+
"@typescript-eslint/adjacent-overload-signatures": "error",
22+
"@typescript-eslint/array-type": [
23+
"error",
24+
{
25+
"default": "array"
26+
}
27+
],
28+
"@typescript-eslint/ban-types": [
29+
"error",
30+
{
31+
"types": {
32+
"Object": {
33+
"message": "Avoid using the `Object` type. Did you mean `object`?"
34+
},
35+
"Function": {
36+
"message": "Avoid using the `Function` type. Prefer a specific function type, like `() => void`."
37+
},
38+
"Boolean": {
39+
"message": "Avoid using the `Boolean` type. Did you mean `boolean`?"
40+
},
41+
"Number": {
42+
"message": "Avoid using the `Number` type. Did you mean `number`?"
43+
},
44+
"String": {
45+
"message": "Avoid using the `String` type. Did you mean `string`?"
46+
},
47+
"Symbol": {
48+
"message": "Avoid using the `Symbol` type. Did you mean `symbol`?"
49+
}
50+
}
51+
}
52+
],
53+
"@typescript-eslint/consistent-type-assertions": "error",
54+
"@typescript-eslint/dot-notation": "error",
55+
"@typescript-eslint/indent": "off",
56+
"@typescript-eslint/member-delimiter-style": [
57+
"off",
58+
{
59+
"multiline": {
60+
"delimiter": "none",
61+
"requireLast": true
62+
},
63+
"singleline": {
64+
"delimiter": "semi",
65+
"requireLast": false
66+
}
67+
}
68+
],
69+
"@typescript-eslint/naming-convention": "error",
70+
"@typescript-eslint/no-empty-function": "error",
71+
"@typescript-eslint/no-empty-interface": "error",
72+
"@typescript-eslint/no-explicit-any": "off",
73+
"@typescript-eslint/no-misused-new": "error",
74+
"@typescript-eslint/no-namespace": "error",
75+
"@typescript-eslint/no-parameter-properties": "off",
76+
"@typescript-eslint/no-unused-expressions": "error",
77+
"@typescript-eslint/no-use-before-define": "off",
78+
"@typescript-eslint/no-var-requires": "error",
79+
"@typescript-eslint/prefer-for-of": "error",
80+
"@typescript-eslint/prefer-function-type": "error",
81+
"@typescript-eslint/prefer-namespace-keyword": "error",
82+
"@typescript-eslint/quotes": "off",
83+
"@typescript-eslint/semi": ["off", null],
84+
"@typescript-eslint/triple-slash-reference": [
85+
"error",
86+
{
87+
"path": "always",
88+
"types": "prefer-import",
89+
"lib": "always"
90+
}
91+
],
92+
"@typescript-eslint/type-annotation-spacing": "off",
93+
"@typescript-eslint/unified-signatures": "error",
94+
"arrow-parens": ["off", "always"],
95+
"brace-style": ["off", "off"],
96+
"comma-dangle": "off",
97+
"complexity": "off",
98+
"constructor-super": "error",
99+
"eol-last": "off",
100+
"eqeqeq": ["error", "smart"],
101+
"guard-for-in": "error",
102+
"id-blacklist": [
103+
"error",
104+
"any",
105+
"Number",
106+
"number",
107+
"String",
108+
"string",
109+
"Boolean",
110+
"boolean",
111+
"Undefined",
112+
"undefined"
113+
],
114+
"id-match": "error",
115+
"jsdoc/check-alignment": "error",
116+
"jsdoc/check-indentation": "error",
117+
"jsdoc/newline-after-description": "error",
118+
"linebreak-style": "off",
119+
"max-classes-per-file": ["error", 1],
120+
"max-len": "off",
121+
"new-parens": "off",
122+
"newline-per-chained-call": "off",
123+
"no-bitwise": "error",
124+
"no-caller": "error",
125+
"no-cond-assign": "error",
126+
"no-console": "error",
127+
"no-debugger": "error",
128+
"no-empty": "error",
129+
"no-eval": "error",
130+
"no-extra-semi": "off",
131+
"no-fallthrough": "off",
132+
"no-invalid-this": "off",
133+
"no-irregular-whitespace": "off",
134+
"no-multiple-empty-lines": "off",
135+
"no-new-wrappers": "error",
136+
"no-shadow": [
137+
"error",
138+
{
139+
"hoist": "all"
140+
}
141+
],
142+
"no-throw-literal": "error",
143+
"no-trailing-spaces": "off",
144+
"no-undef-init": "error",
145+
"no-underscore-dangle": "error",
146+
"no-unsafe-finally": "error",
147+
"no-unused-labels": "error",
148+
"no-var": "error",
149+
"object-shorthand": "error",
150+
"one-var": ["error", "never"],
151+
"prefer-arrow/prefer-arrow-functions": "error",
152+
"prefer-const": "error",
153+
"quote-props": "off",
154+
"radix": "error",
155+
"space-before-function-paren": "off",
156+
"space-in-parens": ["off", "never"],
157+
"spaced-comment": [
158+
"error",
159+
"always",
160+
{
161+
"markers": ["/"]
162+
}
163+
],
164+
"use-isnan": "error",
165+
"valid-typeof": "off"
166+
}
167+
}

nodemon.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"watch": ["build"],
3+
"exec": "npm run start:electron:run",
4+
"ext": "js, json, ts, proto, css, png, jpeg, jpg, ico"
5+
}

0 commit comments

Comments
 (0)