Skip to content

Commit

Permalink
chore!: convert project to typescript (#1641)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Jul 21, 2023
1 parent f4f0550 commit df7881f
Show file tree
Hide file tree
Showing 73 changed files with 3,366 additions and 2,063 deletions.
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
/examples/
/doc/
/dist/
/test/typescript/
/build/

*.js
24 changes: 21 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint/eslint-plugin'],
env: {
browser: true,
commonjs: true,
es2021: true,
node: true,
mocha: true,
},
extends: ['airbnb-base', 'plugin:prettier/recommended'],
extends: [
'airbnb-base',
'airbnb-typescript/base',
'plugin:prettier/recommended',
'plugin:@typescript-eslint/recommended'
],
parserOptions: {
ecmaVersion: 'latest',
project: 'tsconfig.json',
sourceType: 'module',
tsconfigRootDir: __dirname
},
rules: {
'global-require': 'off',
Expand All @@ -29,5 +38,14 @@ module.exports = {
'no-continue': 'off',
'prefer-destructuring': 'off',
'no-use-before-define': 'off',
},
// Typescript rules
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/no-use-before-define': 'off',
}
}
8 changes: 1 addition & 7 deletions .github/workflows/mqttjs-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,12 @@ jobs:
CI: true
DEBUG: "${{ runner.debug == '1' && 'mqttjs:*' || '' }}"

- name: Test Typescript
run: npm run test:typescript
env:
CI: true
DEBUG: "${{ runner.debug == '1' && 'mqttjs:*' || '' }}"

- name: Test Browser
if: matrix.node-version == '20.x'
# only run on latest node version, no reason to run on all
timeout-minutes: 2
run: |
npm run browser-build
npm run build:browser
npm run unit-test:browser

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ test/typescript/*.map
.vscode/
.npmrc

/build/

10 changes: 10 additions & 0 deletions .mocharc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// --check-leaks
// --timeout 10000
// --exit

module.exports = {
checkLeaks: true,
exit: true,
timeout: 10000,
};

8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ There is work being done on the next generation of MQTT.js (vNext). We invite th

## Important notes for existing users

**v5.0.0** (**BETA** 06/2023) removes support for all end of life node versions (v12 and v14), and now supports node v18 and v20.
**v5.0.0** (**BETA** 06/2023)

- Removes support for all end of life node versions (v12 and v14), and now supports node v18 and v20.
- Completely rewritten in Typescript 🚀.
- When creating `MqttClient` instance `new` is now required

**v4.0.0** (Released 04/2020) removes support for all end of life node versions, and now supports node v12 and v14. It also adds improvements to
debug logging, along with some feature additions.
Expand Down Expand Up @@ -389,7 +393,7 @@ The arguments are:
- `customHandleAcks`: MQTT 5 feature of custom handling puback and pubrec packets. Its callback:

```js
customHandleAcks: function(topic, message, packet, done) {/*some logic wit colling done(error, reasonCode)*/}
customHandleAcks: function(topic, message, packet, done) {/*some logic with calling done(error, reasonCode)*/}
```

- `autoUseTopicAlias`: enabling automatic Topic Alias using functionality
Expand Down
159 changes: 0 additions & 159 deletions bin/pub.js

This file was deleted.

Loading

0 comments on commit df7881f

Please sign in to comment.