Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: typescript everything #2406

Merged
merged 22 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 54 additions & 58 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,61 @@
module.exports = {
"extends": [
"eslint:recommended",
"plugin:node/recommended",
"plugin:mocha/recommended",
"plugin:@typescript-eslint/recommended",
],
"parser": "@typescript-eslint/parser",
"plugins": [
"prettier",
"node",
"mocha",
"@typescript-eslint",
],
"env": {
"node": true,
"mocha": true,
"es6": true
extends: ['eslint:recommended', 'plugin:node/recommended', 'plugin:mocha/recommended', 'plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
plugins: ['prettier', 'node', 'mocha', '@typescript-eslint'],
env: {
node: true,
mocha: true,
es6: true,
},
"parserOptions": {
"ecmaVersion": 12,
parserOptions: {
ecmaVersion: 12,
},
"globals": {
"assert": false,
"makeTestFeature": false,
"shouldReject": false
globals: {
assert: false,
makeTestFeature: false,
shouldReject: false,
},
"rules": {
"no-extra-semi": "off",
"no-process-exit": "off",
"no-var": "error",
"node/no-extraneous-require": "off",
"node/no-missing-import": "off",
"node/no-missing-require": "off",
"node/no-unpublished-import": "off",
"node/no-unpublished-require": "off",
"node/no-unsupported-features/es-builtins": "error",
"node/no-unsupported-features/es-syntax": "off",
"node/no-unsupported-features/node-builtins": "error",
"node/shebang": "off",
"object-shorthand": "error",
"prefer-arrow-callback": "error",
"prefer-const": "error",
"prefer-template": "error",
"prettier/prettier": [
"error",
rules: {
'no-extra-semi': 'off', //prettier does this
'@typescript-eslint/no-extra-semi': 'off', //prettier does this
'no-process-exit': 'off',
'no-var': 'error',
'node/no-extraneous-import': [
'error',
{
"singleQuote": true,
"trailingComma": "es5",
"semi": false,
"printWidth": 150,
"arrowParens": "avoid"
}
allowModules: ['sinon', 'chai'], //this gets pulled from monorepo root where the tests are run
},
],
"mocha/no-exclusive-tests": "error",
"mocha/no-hooks-for-single-case": "off",
"mocha/no-mocha-arrows": "off",
"mocha/no-pending-tests": "error",
"mocha/no-setup-in-describe": "off",
"strict": ["error", "never"],
"valid-jsdoc": "off",
"@typescript-eslint/no-var-requires": "off", // until we get all js ported over
"@typescript-eslint/no-empty-function": "off",
}
'node/no-missing-import': 'off',
'node/no-missing-require': 'off',
'node/no-unpublished-import': 'off',
'node/no-unpublished-require': 'off',
'node/no-unsupported-features/es-builtins': 'error',
'node/no-unsupported-features/es-syntax': 'off',
'node/no-unsupported-features/node-builtins': 'error',
'node/shebang': 'off',
'object-shorthand': 'error',
'prefer-arrow-callback': 'error',
'prefer-const': 'error',
'prefer-template': 'error',
'prettier/prettier': [
'error',
{
singleQuote: true,
trailingComma: 'es5',
semi: false,
printWidth: 150,
arrowParens: 'avoid',
},
],
'mocha/no-exclusive-tests': 'error',
'mocha/no-hooks-for-single-case': 'off',
'mocha/no-mocha-arrows': 'off',
'mocha/no-pending-tests': 'error',
'mocha/no-setup-in-describe': 'off',
strict: ['error', 'never'],
'valid-jsdoc': 'off',
'@typescript-eslint/no-var-requires': 'off', // until we get all js ported over
'@typescript-eslint/no-empty-function': 'off',
},
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ lerna-debug.log
node_modules
npm-debug.log
/packages/**/dist
tsconfig-build.tsbuildinfo
tsconfig.tsbuildinfo
5 changes: 2 additions & 3 deletions .mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
module.exports = {
bail: true,
require: [
'esbuild-register',
'./test/initializers'
'esbuild-register'
],
'spec': ['packages/**/*.test.js'],
'spec': ['packages/**/*.test.ts'],
}
20 changes: 20 additions & 0 deletions UPGRADE_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
Upgading from 9x to 10x
-------------

- Typscript types are now available for all packages
- Serialport no longer supports Node 10
- SerialPort stream (from npm `serialport` and `@serialport/stream`) now take an options object with a required `path` and `baudRate`. They no longer default to a `baudRate` of 9600 as that's slow and usually not what's needed.
- All packages now have named exports. They export their types and all relevant classes.
- The package `serialport` no longer exports `serialport/test` but instead who classes `{ SerialPort, SerialPortMock }` where the mock is pre-configured with a mock binding.
- Bindings have moved from `@serialport/bindings` to `@serialport/bindings-cpp` they are shipped with `prebuildify` and no longer require a post install download.
- `@serialport/bindings-cpp` leverages N-API and shouldn't need to be upgraded for every node release or rebuild for electron
- Bindings in general now have a new interface with the `@serialport/bindings-interface` type package that replaces `@serialport/bindings-abstract`
- `SerialPortStream` from `@serialport/stream` no longer has a `list()` method as that was a direct call to the bindings.
- `SerialPort` class from the `serialport` package no longer has a static `Bindings` property as it provides the OS specific bindings from `@serialport/bindings-cpp` if you need control of the bindings use `SerialPortStream`.
- `SerialPortStream` methods (and by extension `SerialPort` methods) no longer throw when called with invalid input, their callbacks or the error event will convey input errors. This is because the binding layer now handles input validation as it's different on each platform.
- `SerialPort` is now delivering a few more parsers

TODO
- stop bits are incorrect


Upgrading from 8.x to 9.x
-------------
- Serialport no longer supports Node 8
Expand Down
6 changes: 3 additions & 3 deletions bin/find-arduino.js → bin/find-arduino.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env node
#!/usr/bin/env node -r esbuild-register

// outputs the path to an Arduino to stdout or an error to stderror

const SerialPort = require('../packages/serialport')
SerialPort.list().then(ports => {
import { autoDetect } from '@serialport/bindings-cpp'
autoDetect().list().then(ports => {
const port = ports.find(port => /arduino/i.test(port.manufacturer))
if (!port) {
console.error('Arduino Not found')
Expand Down
40 changes: 0 additions & 40 deletions bin/write-a-lot.js

This file was deleted.

120 changes: 120 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading