Skip to content

Commit 510ae37

Browse files
authored
Merge pull request #831 from jason-fox/feature/eslint
Feature/eslint
2 parents 4d34a07 + ea6d399 commit 510ae37

File tree

154 files changed

+18746
-17123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+18746
-17123
lines changed

.editorconfig

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# editorconfig.org
2+
root = true
3+
4+
# Unix-style newlines with a newline ending every file
5+
[*]
6+
end_of_line = lf
7+
charset = utf-8
8+
insert_final_newline = true
9+
10+
[*.{json,yml,md,babelrc,eslintrc,remarkrc}]
11+
indent_style = space
12+
indent_size = 2
13+
trim_trailing_whitespace = true
14+
15+
[*.{js}]
16+
indent_style = space
17+
indent_size = 4
18+
trim_trailing_whitespace = true

.eslintrc.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "tamia",
3+
"parserOptions": {
4+
"sourceType": "module"
5+
},
6+
"plugins": ["prettier"],
7+
"rules": {
8+
"prettier/prettier": "error",
9+
"no-shadow": 0,
10+
"valid-jsdoc": 0
11+
}
12+
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
.project
1414
.metadata
1515
npm-debug.log
16+
.eslintcache
1617

.jshintrc

-31
This file was deleted.

.prettierrc.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"arrowParens": "always",
3+
"bracketSpacing": true,
4+
"singleQuote": true,
5+
"parser": "flow",
6+
"printWidth": 120,
7+
"trailingComma": "none",
8+
"tabWidth": 4
9+
}

CHANGES_NEXT_RELEASE

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Update codebase to use ES6
2+
- Remove JSHint and jshint overrides
3+
- Add esLint using standard tamia presets
4+
- Replace var with let/const
5+
- Fix or disable eslint errors
6+
Add prettier code formatting
7+
Add husky and lint-staged

README.md

+58-83
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,19 @@
99
[![Coverage Status](https://coveralls.io/repos/github/telefonicaid/iotagent-node-lib/badge.svg?branch=master)](https://coveralls.io/github/telefonicaid/iotagent-node-lib?branch=master)
1010
![Status](https://nexus.lab.fiware.org/static/badges/statuses/iot-node-lib.svg)
1111

12-
This project aims to provide a Node.js module to enable IoT Agent developers to
13-
build custom agents for their devices that can easily connect to NGSI Context
14-
Brokers (such as [Orion](https://github.com/telefonicaid/fiware-orion)).
15-
16-
An IoT Agent is a component that lets groups of devices send their data to and
17-
be managed from a FIWARE NGSI Context Broker using their own native protocols.
18-
IoT Agents should also be able to deal with security aspects of the FIWARE
19-
platform (authentication and authorization of the channel) and provide other
20-
common services to the device programmer.
21-
22-
This project is part of [FIWARE](https://www.fiware.org/). For more information
23-
check the FIWARE Catalogue entry for the
12+
This project aims to provide a Node.js module to enable IoT Agent developers to build custom agents for their devices
13+
that can easily connect to NGSI Context Brokers (such as [Orion](https://github.com/telefonicaid/fiware-orion)).
14+
15+
An IoT Agent is a component that lets groups of devices send their data to and be managed from a FIWARE NGSI Context
16+
Broker using their own native protocols. IoT Agents should also be able to deal with security aspects of the FIWARE
17+
platform (authentication and authorization of the channel) and provide other common services to the device programmer.
18+
19+
This project is part of [FIWARE](https://www.fiware.org/). For more information check the FIWARE Catalogue entry for the
2420
[IoT Agents](https://github.com/Fiware/catalogue/tree/master/iot-agents).
2521

2622
| :books: [Documentation](https://iotagent-node-lib.rtfd.io) | :mortar_board: [Academy](https://fiware-academy.readthedocs.io/en/latest/iot-agents/idas) | :dart: [Roadmap](https://github.com/telefonicaid/iotagent-node-lib/blob/master/docs/roadmap.md) |
27-
|---|---|---|
23+
| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
24+
2825

2926
## Index
3027

@@ -59,7 +56,6 @@ functionality provided by the IoT Agent node lin (e.g. for contecting to a conex
5956
its device communications using a common vocabulary regardless of the payload, syntax or transport protocol used by the
6057
device itself.
6158

62-
6359
## Install
6460

6561
The **IoT Agent node library** is not a standalone product and should be added as a dependency to `package.json` of the
@@ -78,43 +74,39 @@ In order to use the library within your own IoT Agent, you must first you requir
7874
const iotagentLib = require("iotagent-node-lib");
7975
```
8076

81-
Information about how to configure the Library can be found at the corresponding
82-
section of the
77+
Information about how to configure the Library can be found at the corresponding section of the
8378
[Installation & Administration Guide](doc/installationguide.md).
8479

8580
## Usage
8681

87-
This library has no packaging or build processes. The [Getting Started](doc/getting-started.md) is a good place to start.
88-
Usage of the library is explained in the [User & Programmers Manual](doc/usermanual.md).
82+
This library has no packaging or build processes. The [Getting Started](doc/getting-started.md) is a good place to
83+
start. Usage of the library is explained in the [User & Programmers Manual](doc/usermanual.md).
8984

90-
- Details of the architecture of an IoT Agent be found [here](doc/architecture.md).
91-
- Further Advanced topics can be found [here](doc/advanced-topics.md).
92-
- The following features are listed as [deprecated](doc/deprecated.md).
85+
- Details of the architecture of an IoT Agent be found [here](doc/architecture.md).
86+
- Further Advanced topics can be found [here](doc/advanced-topics.md).
87+
- The following features are listed as [deprecated](doc/deprecated.md).
9388

9489
## API
9590

9691
The **IoT Agent node library** offers a simple REST API which provides common functionality to access, provision and
97-
decommission devices.
98-
[API](doc/api.md).
92+
decommission devices. [API](doc/api.md).
9993

10094
## Testing
10195

102-
10396
Contributions to development can be found [here](doc/development.md) - additional contributions are welcome.
10497

10598
### Agent Console
10699

107-
A command-line client to experiment with the library is packed with it. The
108-
command-line client can be started using the following command:
100+
A command-line client to experiment with the library is packed with it. The command-line client can be started using the
101+
following command:
109102

110103
```console
111104
bin/agentConsole.js
112105
```
113106

114-
The client offers an API similar to the one offered by the library: it can start
115-
and stop an IoT agent, register and unregister devices, send measures mimicking
116-
the device and receive updates of the device data. Take into account that, by
117-
default, the console uses the same `config.js` file than the IoT Agent.
107+
The client offers an API similar to the one offered by the library: it can start and stop an IoT agent, register and
108+
unregister devices, send measures mimicking the device and receive updates of the device data. Take into account that,
109+
by default, the console uses the same `config.js` file than the IoT Agent.
118110

119111
The command-line client creates a console that offers the following options:
120112

@@ -172,24 +164,20 @@ listdevices
172164

173165
#### Command-line testing
174166

175-
The library also offers a Context Broker and IoT Agent client that can be used
176-
to:
167+
The library also offers a Context Broker and IoT Agent client that can be used to:
177168

178-
- Simulate operations to the Context Broker used by the IoT Agent, triggering
179-
Context Provider forwardings for lazy attributes and checking the
180-
appropriate values for active ones.
181-
- Simulate operations to the Device Provisioning API and Configuration API of
182-
the IoT Agent.
169+
- Simulate operations to the Context Broker used by the IoT Agent, triggering Context Provider forwardings for lazy
170+
attributes and checking the appropriate values for active ones.
171+
- Simulate operations to the Device Provisioning API and Configuration API of the IoT Agent.
183172

184-
The tester can be started with the following command, from the root folder of
185-
the project:
173+
The tester can be started with the following command, from the root folder of the project:
186174

187175
```console
188176
bin/iotAgentTester.js
189177
```
190178

191-
From the command-line, the `help` command can be used to show a description of
192-
the currently supported features. These are the following:
179+
From the command-line, the `help` command can be used to show a description of the currently supported features. These
180+
are the following:
193181

194182
```text
195183
stressInit
@@ -304,30 +292,26 @@ migrate <targetDb> <service> <subservice>
304292
subservices, use the "*" value.
305293
```
306294

307-
The agent session stores transient configuration data about the target Context
308-
Broker and the target IoT Agent. This configuration is independent, and can be
309-
checked with the `showConfigCb` and `showConfigIot` commands, respectively.
310-
Their values can be changed with the `configCb` and `configIot` commands
311-
respectively. The new configurations will be deleted upon startup.
295+
The agent session stores transient configuration data about the target Context Broker and the target IoT Agent. This
296+
configuration is independent, and can be checked with the `showConfigCb` and `showConfigIot` commands, respectively.
297+
Their values can be changed with the `configCb` and `configIot` commands respectively. The new configurations will be
298+
deleted upon startup.
312299

313300
#### Creating specialized testers
314301

315302
The command-line testing tools make use of the
316-
[command-node Node.js library](https://github.com/telefonicaid/command-shell-lib)
317-
for command-line utils. In order to help creating testing tools for IoTAgents of
318-
specific protocols, all the commands of the library tester are offered as a
319-
array that can be directly imported into other Command-Line tools, using the
320-
following steps:
303+
[command-node Node.js library](https://github.com/telefonicaid/command-shell-lib) for command-line utils. In order to
304+
help creating testing tools for IoTAgents of specific protocols, all the commands of the library tester are offered as a
305+
array that can be directly imported into other Command-Line tools, using the following steps:
321306

322-
- Require the `iotagent-node-lib` command-line module in your command-line
323-
tool:
307+
- Require the `iotagent-node-lib` command-line module in your command-line tool:
324308

325309
```javascript
326-
var iotaCommands = require('iotagent-node-lib').commandLine;
310+
var iotaCommands = require("iotagent-node-lib").commandLine;
327311
```
328312

329-
- Initialize the command-line utils (the initialization function takes two
330-
arguments, that will be explained in detail below:
313+
- Initialize the command-line utils (the initialization function takes two arguments, that will be explained in detail
314+
below:
331315

332316
```javascript
333317
iotaCommands.init(configCb, configIot);
@@ -342,56 +326,47 @@ commands = commands.concat(commands, iotaCommands.commands);
342326
- Execute the command-line interpreter as usual:
343327

344328
```javascript
345-
clUtils.initialize(commandLine.commands, 'IoT Agent tester> ');
329+
clUtils.initialize(commandLine.commands, "IoT Agent tester> ");
346330
```
347331

348-
The command-line module makes use of two configuration objects. Both can be
349-
shown and edited in the command-line using the provided commands, but a default
350-
value must be present.
332+
The command-line module makes use of two configuration objects. Both can be shown and edited in the command-line using
333+
the provided commands, but a default value must be present.
351334

352-
The Context Broker configuration object holds all the information about the
353-
Context Broker where the IoT Agent to be tested is connected. It MUST contain
354-
the following attributes:
335+
The Context Broker configuration object holds all the information about the Context Broker where the IoT Agent to be
336+
tested is connected. It MUST contain the following attributes:
355337

356338
- **host**: host where the Context Broker instance is located.
357339
- **port**: port where the Context Broker instance is listening.
358340
- **service**: service that will be used in all the NGSI operations.
359341
- **subservice**: service that will be used in all the NGSI operations.
360342

361-
The IoT Agent configuration object holds information about the IoT Agent that is
362-
being tested. It MUST contain the following attributes:
343+
The IoT Agent configuration object holds information about the IoT Agent that is being tested. It MUST contain the
344+
following attributes:
363345

364346
- **host**: host where the IoT Agent instance is located.
365347
- **port**: port where the IoT Agent instance is listening.
366-
- **service**: service that will be used to group devices and device
367-
information.
368-
- **subservice**: subservice that will be used to group devices and device
369-
information.
348+
- **service**: service that will be used to group devices and device information.
349+
- **subservice**: subservice that will be used to group devices and device information.
370350

371351
---
372352

373353
## Licence
374354

375-
The IoT Agent Node Library is licensed under [Affero General Public License (GPL)
376-
version 3](./LICENSE).
355+
The IoT Agent Node Library is licensed under [Affero General Public License (GPL) version 3](./LICENSE).
377356

378357
© 2019 Telefonica Investigación y Desarrollo, S.A.U
379358

380-
381-
382359
### Are there any legal issues with AGPL 3.0? Is it safe for me to use?
383360

384-
There is absolutely no problem in using a product licensed under AGPL 3.0. Issues with GPL
385-
(or AGPL) licenses are mostly related with the fact that different people assign different
386-
interpretations on the meaning of the term “derivate work” used in these licenses. Due to this,
387-
some people believe that there is a risk in just _using_ software under GPL or AGPL licenses
388-
(even without _modifying_ it).
361+
There is absolutely no problem in using a product licensed under AGPL 3.0. Issues with GPL (or AGPL) licenses are mostly
362+
related with the fact that different people assign different interpretations on the meaning of the term “derivate work”
363+
used in these licenses. Due to this, some people believe that there is a risk in just _using_ software under GPL or AGPL
364+
licenses (even without _modifying_ it).
389365

390366
For the avoidance of doubt, the owners of this software licensed under an AGPL-3.0 license
391367
wish to make a clarifying public statement as follows:
392368

393-
> Please note that software derived as a result of modifying the source code of this
394-
> software in order to fix a bug or incorporate enhancements is considered a derivative
395-
> work of the product. Software that merely uses or aggregates (i.e. links to) an otherwise
396-
> unmodified version of existing software is not considered a derivative work, and therefore
397-
> it does not need to be released as under the same license, or even released as open source.
369+
> Please note that software derived as a result of modifying the source code of this software in order to fix a bug or
370+
> incorporate enhancements is considered a derivative work of the product. Software that merely uses or aggregates (i.e.
371+
> links to) an otherwise unmodified version of existing software is not considered a derivative work, and therefore it
372+
> does not need to be released as under the same license, or even released as open source.

0 commit comments

Comments
 (0)