Add linting support

This commit is contained in:
Michael Woods 2021-06-10 23:44:31 -04:00
parent 53d1654387
commit ec1cacd253
7 changed files with 6322 additions and 242 deletions

6
.babelrc Normal file
View File

@ -0,0 +1,6 @@
{
"presets": ["@babel/env"],
"plugins": [
"@babel/plugin-syntax-class-properties"
]
}

16
.eslintrc.yml Normal file
View File

@ -0,0 +1,16 @@
env:
node: true
browser: false
commonjs: true
es6: true
mocha: true
extends:
- eslint:recommended
parser: "@babel/eslint-parser"
parserOptions:
babelOptions:
configFile: './.babelrc'
ecmaVersion: 2018
plugins:
- "@babel"
rules: {}

View File

@ -39,6 +39,7 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm run lint
- run: npm test
- name: Set up QEMU

6529
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,7 @@
"main": "src/index.js",
"scripts": {
"coverage": "nyc npm test",
"lint": "npx eslint src test",
"start": "node src/index.js",
"test": "mocha"
},
@ -36,6 +37,14 @@
"winston": "^3.3.3"
},
"devDependencies": {
"@babel/eslint-parser": "^7.14.5",
"@babel/eslint-plugin": "^7.14.5",
"@babel/plugin-syntax-class-properties": "^7.12.13",
"@babel/preset-env": "^7.14.5",
"eslint": "^7.28.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"mocha": "^9.0.0",
"nyc": "^15.1.0"
}

View File

@ -5,7 +5,7 @@ const _ = require('lodash');
const Vehicle = require('./vehicle');
const {Diagnostic} = require('./diagnostic');
const MQTT = require('./mqtt');
const Commands = require('./commands');
const {Commands} = require('./commands');
const logger = require('./logger');

View File

@ -129,6 +129,7 @@ class MQTT {
break;
default:
// coerce to number if possible, API uses strings :eyeroll:
// eslint-disable-next-line no-case-declarations
const num = _.toNumber(e.value);
value = _.isNaN(num) ? e.value : num;
break;