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: add eslint #154

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Dependabot should update GitHub Action dependencies.
# Please see the documentation for all configuration options:
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
commit-message:
prefix: "chore(ci): "
groups:
github-actions:
patterns:
- "*"
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies
run: npm ci

- name: Run test
run: npm run test
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
test-flows/
.github/
test-flows/
eslint.config.mjs
34 changes: 34 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import globals from 'globals';
import pluginJs from '@eslint/js';
import json from 'eslint-plugin-json';

/**
* @type {import('eslint').Linter.FlatConfig[]}
*/
const config = [
{files: ['**/*.js'], languageOptions: {sourceType: 'commonjs'}},
{languageOptions: {globals: globals.node}},
pluginJs.configs.recommended,
{
files: ['**/*.json'],
...json.configs['recommended']
},
{
rules: {
// Use modern ES2015+
// TODO
// 'no-var': 'warn',
// 'prefer-const': 'warn',
},
},
{
rules: {
// TODO
'no-redeclare': 'off',
'no-prototype-builtins': 'off',
semi: 'off',
},
},
];

export default config;
8 changes: 4 additions & 4 deletions influxdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module.exports = function (RED) {
} else if (typeof value === 'number') {
point.floatField(name, value);
} else if (typeof value === 'string') {
// string values with numbers ending with 'i' are considered integers
// string values with numbers ending with 'i' are considered integers
if (isIntegerString(value)) {
value = parseInt(value.substring(0,value.length-1));
point.intField(name, value);
Expand Down Expand Up @@ -209,7 +209,6 @@ module.exports = function (RED) {
var client = this.influxdbConfig.client;

node.on("input", function (msg, send, done) {
var measurement;
var writeOptions = {};

var measurement = msg.hasOwnProperty('measurement') ? msg.measurement : node.measurement;
Expand Down Expand Up @@ -436,6 +435,7 @@ module.exports = function (RED) {
var query;
var rawOutput;
var queryOptions = {};
var queryPromise;
var precision;
var retentionPolicy;

Expand All @@ -457,9 +457,9 @@ module.exports = function (RED) {
}

if (rawOutput) {
var queryPromise = client.queryRaw(query, queryOptions);
queryPromise = client.queryRaw(query, queryOptions);
} else {
var queryPromise = client.query(query, queryOptions);
queryPromise = client.query(query, queryOptions);
}

queryPromise.then(function (results) {
Expand Down
Loading