Skip to content

Commit 14bdee1

Browse files
committed
Merge branch 'release/4.1.0'
2 parents d7682b8 + 541024a commit 14bdee1

15 files changed

+1338
-1254
lines changed

.eslintignore

-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ dist
33
coverage
44
out
55
public
6-
jest.config.js
7-
webpack.config.js

.eslintrc

-72
This file was deleted.

.eslintrc.cjs

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
const baseConfig = {
2+
env: { node: true },
3+
plugins: ['import'],
4+
parser: '@typescript-eslint/parser',
5+
parserOptions: {
6+
project: ['./tsconfig.eslint.json'],
7+
},
8+
extends: [
9+
'airbnb',
10+
'airbnb/hooks',
11+
'plugin:import/recommended',
12+
],
13+
rules: {
14+
'max-len': [
15+
'warn',
16+
{
17+
code: 80,
18+
tabWidth: 2,
19+
ignoreComments: true,
20+
},
21+
],
22+
'no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
23+
'import/order': [
24+
'error',
25+
{ alphabetize: { order: 'asc' } },
26+
],
27+
},
28+
};
29+
30+
const tsConfig = {
31+
files: ['*.ts', '*.tsx'],
32+
excludedFiles: ['*.spec.ts', '*.spec.tsx', '*.test.ts', '*.test.tsx'],
33+
plugins: [
34+
...baseConfig.plugins,
35+
'@typescript-eslint',
36+
],
37+
extends: [
38+
...baseConfig.extends,
39+
'airbnb-typescript',
40+
'plugin:import/typescript',
41+
'plugin:@typescript-eslint/recommended',
42+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
43+
],
44+
rules: {
45+
...baseConfig.rules,
46+
// disable rules covered by TypesScript compiler
47+
'import/default': 'off',
48+
'import/named': 'off',
49+
'import/namespace': 'off',
50+
'import/no-named-as-default-member': 'off',
51+
// disable rules for better local performance
52+
'import/no-cycle': 'off',
53+
'import/no-deprecated': 'off',
54+
'import/no-named-as-default': 'off',
55+
'import/no-unused-modules': 'off',
56+
},
57+
settings: {
58+
'import/parsers': { '@typescript-eslint/parser': ['.ts', '.tsx'] },
59+
'import/resolver': {
60+
typescript: {
61+
alwaysTryTypes: true,
62+
project: ['./tsconfig.eslint.json'],
63+
},
64+
},
65+
},
66+
};
67+
68+
const jestConfig = {
69+
files: ['*.spec.ts', '*.spec.tsx', '*.test.ts', '*.test.tsx'],
70+
env: { node: true, 'jest/globals': true },
71+
plugins: [
72+
...tsConfig.plugins,
73+
'jest',
74+
],
75+
extends: [
76+
...tsConfig.extends,
77+
'plugin:jest/recommended',
78+
'plugin:jest/style',
79+
],
80+
rules: {
81+
...tsConfig.rules,
82+
'@typescript-eslint/no-non-null-assertion': 'off',
83+
},
84+
settings: tsConfig.settings,
85+
};
86+
87+
const specialConfig = {
88+
files: [
89+
'**/*.config.js',
90+
'**/*.config.cjs',
91+
'**/*.config.*.js',
92+
'**/*.config.*.cjs',
93+
],
94+
rules: {
95+
...baseConfig.rules,
96+
'import/no-extraneous-dependencies': 'off',
97+
},
98+
};
99+
100+
module.exports = {
101+
root: true,
102+
...baseConfig,
103+
overrides: [
104+
tsConfig,
105+
jestConfig,
106+
specialConfig,
107+
],
108+
};

CHANGELOG_V4+.md

+54-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,58 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [v4.1.0] - 2022-08-07
10+
### Added
11+
- `tsconfig.eslint.json` to avoid ESLint complains for file not being included
12+
in project provided.
13+
14+
### Changed
15+
- Migrated from deprecated `.eslintrc` (ESLint config with no file extension) to
16+
`CommonJS` file - `.eslintrc.cjs`, with the following changes on the
17+
configurations:
18+
- Different rules and plugins are now applied based on file types, allowing
19+
JavaScript files to be linted properly and only using plugins & rules needed
20+
on the targeted files.
21+
- Separated config to 4 objects - naming as `baseConfig`, `tsConfig`,
22+
`jestConfig`, and `specialConfig` respectively to maintain the readability
23+
on the pervious `.eslintrc`.
24+
- `eslint-plugin-import` is now properly configured for both JavaScript and
25+
TypeScript files.
26+
- `jest.config.js` & `webpack.config.js` are no longer ignored by ESLint.
27+
- Improved the readability of `webpack.config.js` by migrating to `webpack-merge`
28+
from using `lodash.deepClone()` for merging configuration objects.
29+
- Configured Node to resolve JavaScript files as ES modules (`"type": "module"`
30+
in `package.json`).
31+
- Refactored Jest and Webpack config files as ES modules.
32+
33+
### Fixed
34+
- Module import order warnings in most modules.
35+
- ESLint warnings & errors on `jest.config.js` & `webpack.config.js`.
36+
37+
### Updates on package dependencies
38+
### Added
39+
- `eslint-import-resolver-typescript` *- Enhanced TypeScript support for ESLint
40+
`import` plugin*
41+
- `webpack-merge` *- Replaced the sections using `lodash.deepClone()` in
42+
`webpack.config.js`*
43+
44+
### Updated
45+
- Major version updates:
46+
- `electron` - `19.0.9` -> `20.0.1`
47+
- `tsconfig-paths-webpack-plugin` - `3.5.2` -> `4.0.0`
48+
- Minor & patch version updates:
49+
- `@typescript-eslint/eslint-plugin` & `@typescript-eslint/parser` -
50+
`5.30.7` -> `5.32.0`
51+
- `eslint` - `8.20.0` -> `8.21.0`
52+
- `eslint-plugin-jest` - `26.6.0` -> `26.7.0`
53+
- `electron-builder` - `23.1.0` -> `23.3.3`
54+
- `tsconfig-paths` - `4.0.0` -> `4.1.0`
55+
56+
### Removed
57+
- `eslint-import-resolver-webpack` *- Not being used in any part of the
58+
boilerplate*
59+
- `lodash` *- Replaced by `webpack-merge` for its' usage in `webpack.config.js`*
60+
961
## [v4.0.0] - 2022-07-22
1062
### Added
1163
- Jest as default unit testing framework, with sample test suite for `main`.
@@ -87,5 +139,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
87139
`ts-jest`*
88140
- `spectron` *- Deprecated package; No replacement*
89141

90-
[Unreleased]: https://github.com/Devtography/electron-react-typescript-webpack-boilerplate/compare/v4.0.0...HEAD
142+
[Unreleased]: https://github.com/Devtography/electron-react-typescript-webpack-boilerplate/compare/v4.1.0...HEAD
91143
[v4.0.0]: https://github.com/Devtography/electron-react-typescript-webpack-boilerplate/compare/v3.0.0...v4.0.0
144+
[v4.1.0]: https://github.com/Devtography/electron-react-typescript-webpack-boilerplate/compare/v4.0.0...v4.1.0

README.md

+27-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Electron-React-TypeScript-Webpack-Boilerplate
1+
# Electron-React-TypeScript-Webpack (ERTW) Boilerplate
22
A boilerplate that let you instantly start working on your next [Electron] app
3-
in [TypeScript] with no time wasted messing with the config files.
3+
project in [TypeScript] with no time wasted messing with the config files.
44

55
- Ready to use [Electron] project template with [React], [Webpack] and
66
[TypeScript] seamlessly integrated.
@@ -16,8 +16,8 @@ in [TypeScript] with no time wasted messing with the config files.
1616
doesn't work, please [file an issue].*
1717

1818
### Maintenance schedule
19-
Starting from `v4.0.0`, the project maintenance will become much more regular.
20-
A new release will be published on a monthly basis to keep the package
19+
Starting from [`v4.0.0`], this project is set to receive regular maintenances.
20+
New releases will be published on monthly basis to keep the package
2121
dependencies, package configurations and APIs / syntax up to date.
2222

2323
Maintenance work will begin on 1st of each month, and expect the new version to
@@ -27,9 +27,10 @@ especially on experimental features. If you want any particular feature to be
2727
implemented, please [file an issue], or consider make a [new pull request].
2828

2929
### Development plan
30-
- [ ] Create a `create-react-app`-like package initialiser __!!!__
30+
- [ ] Develop a `create-react-app`-like NPX tool __!!!__
31+
__*([working on it](https://github.com/Devtography/create-ertw-app))*__
3132
- [ ] Integrate another end-to-end testing framework to replace [Spectron]
32-
- [ ] Migrate to Webpack 5 `Asset Modules`
33+
- [ ] Migrate to Webpack 5 `Asset Modules` __*(pending for `v4.2.0`)*__
3334

3435
---
3536

@@ -48,6 +49,11 @@ implemented, please [file an issue], or consider make a [new pull request].
4849
`mocha` as your unit testing framework, please reference to `package.json`
4950
from [`v3.0.0`].
5051

52+
- [ESLint] config file `.eslintrc.cjs` introduced in [`v4.1.0`] is written in
53+
CommonJS syntax on purpose. As of the release of [`v4.1.0`], ESLint has yet
54+
to support ES module for its' config file. __Converting the config file to
55+
ES module will result in ESLint not working.__
56+
5157
---
5258

5359
## Getting started
@@ -123,7 +129,7 @@ To package your Electron app, run `npm run prod` to get your code compiled in
123129
meant to improve performance of reading files if bundler like Webpack is not
124130
being used. The app packaging workflow defined in this boilerplate already
125131
uses Webpack to minify your code in `production` builds, so there shouldn't
126-
be any significant performance different with `asar` archiving disabled.
132+
be any significant performance difference with `asar` archiving disabled.
127133

128134
## Project folders & files
129135
- `dist/` - [Webpack] output location
@@ -210,7 +216,7 @@ To package your Electron app, run `npm run prod` to get your code compiled in
210216
- `main/main.spec.ts` - Sample test file for `src/main/main`
211217
- `tsconfig.json` - TypeScript config file for `tests` module
212218
- `.eslintignore` - [ESLint] ignore file
213-
- `.eslintrc` - [ESLint] config file
219+
- `.eslintrc.cjs` - [ESLint] config file
214220

215221
Configured to use Airbnb's rules with [TypeScript] supported, and rules for
216222
[Jest] applied.
@@ -229,6 +235,7 @@ To package your Electron app, run `npm run prod` to get your code compiled in
229235
build config setup guides.
230236

231237
- `README.md`
238+
- `tsconfig.eslint.json` - [TypeScript] config file consume by [ESLint].
232239
- `tsconfig.json` - [TypeScript] config file
233240

234241
Module path aliases are configured here. [Jest] & [Webpack] will pick up the
@@ -240,13 +247,14 @@ To package your Electron app, run `npm run prod` to get your code compiled in
240247
Includes configurations targetting `electron-main`, `electron-preload`, and
241248
`electron-renderer` respectively.
242249

243-
## Author
244-
[Wing Chau](https://github.com/iamWing) [@Devtography](https://github.com/Devtography)
245-
246250
## Donation
247251
Maintaining this project takes time, lots of cups of coffee, and I do it for
248-
free. Consider buy me coffee via [donations]. 100% of donation will fund my
249-
coffee buying budget for quality coffee beans from great roasters I know 😉 ☕️️
252+
free. Consider buy me some coffee via [GitHub Sponsors] or [PayPal]. 100% of
253+
your donation will fund my coffee buying budget for quality coffee beans from
254+
great roasters I know 😉 ☕️️
255+
256+
## Author
257+
[Wing Chau](https://github.com/iamWing) [@Devtography](https://github.com/Devtography)
250258

251259
## License
252260
Electron React TypeScript Webpack Boilerplate is open source software
@@ -265,11 +273,15 @@ Electron React TypeScript Webpack Boilerplate is open source software
265273
[Playwright]: https://playwright.dev
266274
[WebdriverIO]: https://webdriver.io
267275
[Spectron Deprecation Notice]: https://www.electronjs.org/blog/spectron-deprecation-notice
268-
[`v3.0.0`]: https://github.com/Devtography/electron-react-typescript-webpack-boilerplate/releases/tag/v3.0.0
269276
[`Use this template`]: https://github.com/Devtography/electron-react-typescript-webpack-boilerplate/generate
270277
[`tsconfig-paths`]: https://github.com/dividab/tsconfig-paths
271278
[`tsconfig-paths-webpack-plugin`]: https://github.com/dividab/tsconfig-paths-webpack-plugin
272279
[Electron quick start guide]: https://www.electronjs.org/docs/latest/tutorial/quick-start
273280
[Electron Forge]: https://github.com/electron-userland/electron-forge
274281
[`electron-builder`'s document]: https://www.electron.build
275-
[donations]: https://github.com/sponsors/iamWing
282+
[GitHub Sponsors]: https://github.com/sponsors/iamWing
283+
[PayPal]: https://paypal.me/iamWing0w0
284+
285+
[`v3.0.0`]: https://github.com/Devtography/electron-react-typescript-webpack-boilerplate/releases/tag/v3.0.0
286+
[`v4.0.0`]: https://github.com/Devtography/electron-react-typescript-webpack-boilerplate/releases/tag/v4.0.0
287+
[`v4.1.0`]: https://github.com/Devtography/electron-react-typescript-webpack-boilerplate/releases/tag/v4.1.0

jest.config.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
const { pathsToModuleNameMapper } = require('ts-jest')
2-
const { compilerOptions } = require('./tsconfig.json')
1+
import { createRequire } from 'module';
2+
import { pathsToModuleNameMapper } from 'ts-jest';
33

4-
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
5-
module.exports = config = {
4+
const require = createRequire(import.meta.url);
5+
const { compilerOptions } = require('./tsconfig.json');
6+
7+
export default {
68
testEnvironment: 'node',
79
globals: {
810
'ts-jest': {

0 commit comments

Comments
 (0)