Skip to content

Commit

Permalink
added linting
Browse files Browse the repository at this point in the history
  • Loading branch information
introkun committed Feb 15, 2021
1 parent b2af12f commit 4b67b18
Show file tree
Hide file tree
Showing 11 changed files with 2,189 additions and 113 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js}]
charset = utf-8

[*.js]
indent_style = space
indent_size = 2
trim_trailing_whitespace=true
17 changes: 17 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"google"
],
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"rules": {
"require-jsdoc": 0,
"max-len": ["error", 100]
}
}
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run eslint
55 changes: 28 additions & 27 deletions aux/update-latest-db-record.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
import Datastore from 'nedb'
import config from 'config'
import Datastore from 'nedb';
import config from 'config';

const dbPath = config.get('DbPath')
const dbPath = config.get('DbPath');

console.log(`Initialising DB (${dbPath})...`)
let db = new Datastore({filename: dbPath, autoload: true, onload: (error) => {
if (error)
console.log(`Failed to load DB: ${error}`)
}})
console.log(`Initialising DB (${dbPath})...`);
const db = new Datastore({filename: dbPath, autoload: true, onload: (error) => {
if (error) {
console.log(`Failed to load DB: ${error}`);
}
}});

db.findOne({}).sort({ createdAt: -1 }).exec((err, doc) => {
if (err) {
console.log(`Error selecting from DB: ${err}`)
return
}
db.findOne({}).sort({createdAt: -1}).exec((err, doc) => {
if (err) {
console.log(`Error selecting from DB: ${err}`);
return;
}

if (doc) {
const now = new Date()
delete doc._id
doc.createdAt = now.toISOString()
console.log(doc)
if (doc) {
const now = new Date();
delete doc._id;
doc.createdAt = now.toISOString();
console.log(doc);

db.insert(doc, function (err, newItem) {
if (err) {
console.log(`Error inserting into DB: ${err}`)
return
}
console.log(`Successfully inserted into DB`)
})
}
})
db.insert(doc, function(err, newItem) {
if (err) {
console.log(`Error inserting into DB: ${err}`);
return;
}
console.log(`Successfully inserted into DB`);
});
}
});
Loading

0 comments on commit 4b67b18

Please sign in to comment.