Skip to content

Commit

Permalink
add changelog and migration guide
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Jan 5, 2024
1 parent ac55ff6 commit 9c9ff1d
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
## __WORK IN PROGRESS__
(at the beginning of a new line )
-->
## __WORK IN PROGRESS__
* (AlCalzone) Change supported Node.js versions to 18 / 20 (#1082) · [Migration guide](docs/updates/20240105_min_node18.md)
* (AlCalzone) Simplify maintenance of ESLint config by using the `"latest"` parser version (#1082) · [Migration guide](docs/updates/20240105_ecmaversion_latest.md)

## 2.5.0 (2023-07-06)
* (mcm1957) Add `admin/words.js` to `.eslintignore` · [Migration guide](docs/updates/20230507_eslintignore_words_js.md)
* (mcm1957) Change supported Node.js versions to 16 / 18 / 20 (#1032) · [Migration guide](docs/updates/20230507_update_node_versions.md)
Expand Down
22 changes: 22 additions & 0 deletions docs/updates/20240105_ecmaversion_latest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Simplify maintenance of ESLint config by using the `"latest"` parser version

Previously, ESLint required the developer to specify which ECMAScript version to use for parsing. When using newer JavaScript features, this setting had to be changed for ESLint to work.
It is now possible to set the field to `"latest"`, which will make further changes unnecessary.

To do this, edit the ESLint config as follows (2022 can be a diffent number currently):

**If you have a file `.eslintrc.json`:**

```diff
"parserOptions": {
- "ecmaVersion": 2022,
+ "ecmaVersion": "latest",
```

**If you have a file `.eslintrc.js`:**

```diff
parserOptions: {
- ecmaVersion: 2022,
+ ecmaVersion: "latest",
```
91 changes: 91 additions & 0 deletions docs/updates/20240105_min_node18.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Update package configuration to reflect minimum Node.js version required

As Node.js 16 is EOL and Node.js 20 is already available, new adapters should support either Node.js 18 or 20 as the minimum version. There are a few changes necessary in `package.json` to reflect this when upgrading an existing adapter.

The `engines` field must specify the minimum version:

```diff
"engines": {
- "node": ">= 16"
+ "node": ">= 18"
},
```

```diff
"engines": {
- "node": ">= 16"
+ "node": ">= 20"
},
```

In addition, the testing workflow also needs to be updated. To do this, edit `.github/workflows/test-and-release.yml` as follows:

```diff
steps:
- uses: ioBroker/testing-action-check@v1
with:
- node-version: '16.x'
+ node-version: '18.x'
# Uncomment the following line if your adapter cannot be installed using 'npm ci'
# install-command: 'npm install'
lint: true
...
runs-on: ${{ matrix.os }}
strategy:
matrix:
- node-version: [16.x, 18.x, 20.x]
+ node-version: [18.x, 20.x]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
...
# steps:
# - uses: ioBroker/testing-action-deploy@v1
# with:
-# node-version: '16.x'
+# node-version: '18.x'
# # Uncomment the following line if your adapter cannot be installed using 'npm ci'
# # install-command: 'npm install'
# npm-token: ${{ secrets.NPM_TOKEN }}
```

---

When using TypeScript or when type-checking is enabled, the type definitions and `tsconfig.json` need to be updated aswell.
First, update TypeScript itself:

```bash
npm i -D "typescript@~5.3.3"
```

To update the Node.js type definitions, run **one** of the following commands depending on the desired Node.js version:

```bash
npm i -D @types/node@18
npm i -D @types/node@20
```

Next, uninstall the old tsconfig base:

```bash
npm uninstall -D @tsconfig/node16
```

(or an even older version if you still use that).

Then, run **one** of the following commands depending on the desired Node.js version:

```bash
npm i -D @tsconfig/node18
npm i -D @tsconfig/node20
```

Last, reference this new base in your `tsconfig.json` by replacing `node16` with the version you just installed the tsconfig for, e.g. `node18` for Node.js 18:

```diff
{
- "extends": "@tsconfig/node16/tsconfig.json",
+ "extends": "@tsconfig/node18/tsconfig.json",
// ...
}
```

0 comments on commit 9c9ff1d

Please sign in to comment.