Skip to content

Add prettier code formatting #753

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

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
879f7c3
Add prettier, husky and lint-staged
jason-fox Jan 28, 2019
7ad34bb
Run `npm run prettier` to format files - whitespace changes only.
jason-fox Jan 28, 2019
913b790
Revert Single quote of string due to apostrophe.
jason-fox Jan 28, 2019
8fa62e8
Add exception for single/double quote to pass linter
jason-fox Jan 28, 2019
feafc92
Simplify update
jason-fox Jan 28, 2019
20bd137
Husky Update
jason-fox Jan 29, 2019
75c0c54
Add prettier to documentation
jason-fox Jan 29, 2019
a4979bd
Amend tab-width to 4
jason-fox Jan 30, 2019
998f379
Re-run prettier across all files.
jason-fox Jan 30, 2019
3536dbf
Replace ^ with ~ in dependencies
jason-fox Jan 30, 2019
73534ef
Create Prettier Config
jason-fox Jan 31, 2019
74d8ed2
Rerun prettier - 120 width
jason-fox Jan 31, 2019
a3b04be
Fix additional linting errors
jason-fox Jan 31, 2019
77b13e3
Re-running prettier with no trailing comma.
jason-fox Feb 1, 2019
716f799
Remove package lock
jason-fox Feb 27, 2019
3167237
Merge branch 'master' into feature/prettier and fix conflicts
jason-fox Apr 2, 2019
99d8f1c
Merge branch 'master' into feature/prettier
jason-fox Apr 23, 2019
9541a14
Merge commit '86cbf1765676686609265940bfde0c0b3db265e5' into feature/…
jason-fox May 17, 2019
6ff33a9
Merge branch 'master' into feature/prettier
jason-fox Jun 3, 2019
9e99d91
Merge branch 'master' into feature/prettier
jason-fox Aug 20, 2019
f899af4
Merge branch 'master' into feature/prettier
jason-fox Sep 19, 2019
70d677f
Merge branch 'master' into feature/prettier
jason-fox Oct 3, 2019
d828e9d
Merge commit '5b0ea795c51cb4f903fcbf1853372488380b7f61' into feature/…
jason-fox Oct 25, 2019
a3c469c
Merge branch 'master' into feature/prettier
jason-fox Nov 23, 2019
ccedbdf
Merge commit 'd47bba79fc5c90c0c0a9d0c88c33c598b8c1ff4c' into feature/…
jason-fox Nov 30, 2019
1fb7ed0
Merge commit 'd9c5ac9af583e7610eaafa5baa0f4abb1aead5c2' into feature/…
jason-fox Dec 4, 2019
ad15943
Merge commit '25b690aa97059ba3e2306f300ca3647486134c18' into feature/…
jason-fox Dec 15, 2019
2335a69
Merge branch 'master' into feature/prettier
jason-fox Feb 11, 2020
d84e426
Merge branch 'master' into feature/prettier
jason-fox Feb 26, 2020
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
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"expr": true,
"unused": "vars",
"esversion": 6,
"laxbreak": true,
"globals": {
"describe":true,
"it": true,
Expand Down
9 changes: 9 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"singleQuote": true,
"parser": "flow",
"printWidth": 120,
"trailingComma": "none",
"tabWidth": 4
}
70 changes: 44 additions & 26 deletions bin/agentConsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,64 +32,66 @@ var readline = require('readline'),
separator = '\n\n\t';

var commands = {
'start': {
start: {
parameters: [],
description: '\tStart the IoT Agent',
handler: startApp
},
'stop': {
stop: {
parameters: [],
description: '\tStop the IoT Agent',
handler: stopApp
},
'register': {
register: {
parameters: ['id', 'type'],
description: '\tRegister a new device in the IoT Agent. The attributes to register will be extracted from the\n' +
description:
'\tRegister a new device in the IoT Agent. The attributes to register will be extracted from the\n' +
'\ttype configuration',
handler: registerDevice
},
'unregister': {
unregister: {
parameters: ['id', 'type'],
description: '\tUnregister the selected device',
handler: unregisterDevice
},
'showConfig': {
showConfig: {
parameters: [],
description: '\tShow the current configuration file',
handler: showConfig
},
'config': {
config: {
parameters: ['newConfig'],
description: '\tChange the configuration file to a new one',
handler: changeConfig
},
'updatevalue': {
updatevalue: {
parameters: ['deviceId', 'deviceType', 'attributes'],
description: '\tUpdate a device value in the Context Broker. The attributes should be triads with the following\n' +
description:
'\tUpdate a device value in the Context Broker. The attributes should be triads with the following\n' +
'\tformat: "name/type/value" sepparated by commas.',
handler: updateDeviceValue
},
'listdevices': {
listdevices: {
parameters: [],
description: '\tList all the devices that have been registered in this IoT Agent session\n',
handler: listDevices
}
};

function handleError(message) {
return function (error) {
return function(error) {
if (error) {
console.log('\n\033[31mERROR:\033[0m %s', error.message);
} else {
console.log(message)
console.log(message);
}

commandUtils.prompt();
};
}

function listDevices() {
iotAgentLib.listDevices(config.service, config.subservice, function (error, devices) {
iotAgentLib.listDevices(config.service, config.subservice, function(error, devices) {
if (error) {
console.log('\n\033[31mERROR:\033[0m %s', error.message);
} else {
Expand All @@ -115,7 +117,6 @@ function extractAttributes(attributeString, callback) {
type: fields[1]
};


if (fields[2]) {
attribute.value = fields[2];
}
Expand All @@ -135,8 +136,12 @@ function changeConfig(command) {
}

function writeHandler(id, type, attributes, callback) {
console.log('\n\nFake WRITE handler for update in entity [%s] with type [%s]\n%s\n',
id, type, JSON.stringify(attributes, null, 4));
console.log(
'\n\nFake WRITE handler for update in entity [%s] with type [%s]\n%s\n',
id,
type,
JSON.stringify(attributes, null, 4)
);

callback(null, {
id: id,
Expand All @@ -146,8 +151,12 @@ function writeHandler(id, type, attributes, callback) {
}

function readHandler(id, type, attributes, callback) {
console.log('\n\nFake READ handler for update in entity [%s] with type [%s]\n%s\n'
, id, type, JSON.stringify(attributes, null, 4));
console.log(
'\n\nFake READ handler for update in entity [%s] with type [%s]\n%s\n',
id,
type,
JSON.stringify(attributes, null, 4)
);

var sensorData = {
id: id,
Expand Down Expand Up @@ -181,7 +190,7 @@ function exitAgent(command) {
}

function registerDevice(command) {
var device = {
var device = {
id: command[0],
type: command[1]
};
Expand All @@ -199,14 +208,23 @@ function updateDeviceValue(command) {
iotAgentLib.getDevice(command[0], function(error, device) {
if (device) {
extractAttributes(command[2], function(error, attributes) {
iotAgentLib.update(device.name, device.type, '', attributes, device,
handleError('Device value updated'));
iotAgentLib.update(
device.name,
device.type,
'',
attributes,
device,
handleError('Device value updated')
);
});
} else {
async.waterfall([
async.apply(extractAttributes, command[2]),
async.apply(iotAgentLib.update, command[0], command[1], '')
], handleError('Device value updated'));
async.waterfall(
[
async.apply(extractAttributes, command[2]),
async.apply(iotAgentLib.update, command[0], command[1], '')
],
handleError('Device value updated')
);
}
});
}
Expand All @@ -223,7 +241,7 @@ function queryHandler(id, type, attributes, callback) {
}

function updateHandler(id, type, attributes, callback) {
console.log("Update message received for device with id [%s] and type [%s]", id, type);
console.log('Update message received for device with id [%s] and type [%s]', id, type);

callback(null, {
type: type,
Expand Down
2 changes: 1 addition & 1 deletion bin/iotAgentTester.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ var commandLine = require('../lib/command/commandLine'),

commandLine.init(configCb, configIot);

clUtils.initialize(commandLine.commands, 'IoT Agent tester> ');
clUtils.initialize(commandLine.commands, 'IoT Agent tester> ');
3 changes: 1 addition & 2 deletions config-blank.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ var config = {
deviceRegistry: {
type: 'memory'
},
types: {
},
types: {},
service: 'tester',
subservice: '/test',
providerUrl: 'http://192.168.56.1:4041',
Expand Down
2 changes: 1 addition & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var config = {
type: 'memory'
},
types: {
'Light': {
Light: {
url: '/',
apikey: '',
type: 'Light',
Expand Down
20 changes: 10 additions & 10 deletions ghpages/javascripts/scale.fix.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
var metas = document.getElementsByTagName('meta');
var i;
if (navigator.userAgent.match(/iPhone/i)) {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
for (i = 0; i < metas.length; i++) {
if (metas[i].name == 'viewport') {
metas[i].content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0';
}
}
}
document.addEventListener("gesturestart", gestureStart, false);
document.addEventListener('gesturestart', gestureStart, false);
}
function gestureStart() {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6";
for (i = 0; i < metas.length; i++) {
if (metas[i].name == 'viewport') {
metas[i].content = 'width=device-width, minimum-scale=0.25, maximum-scale=1.6';
}
}
}
}
}
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./lib/fiware-iotagent-lib');
module.exports = require('./lib/fiware-iotagent-lib');
Loading