Closed jason-fox closed 3 years ago
I'd like to swap out JSHint for EsLint on the long runner: https://github.com/telefonicaid/iotagent-node-lib/pull/753 as well [sigh] since it should make the maintenance of the ongoing merge conflicts easier. If this proposal is accepted I may combine prettier and eslint into a single PR (and remove all jshint work arounds.
Related PRs:
Still Open:
Thank you very much for creating the issue and the explanations above. We are still discussing the issue internally and I hope we can provide feedback on it soon. Sorry for the delay.
On the meanwhile, looking to the proposed PRs, I have a couple of doubts, pls:
To quote Wikipedia:
eslint is a static code analysis tool for identifying problematic patterns found in JavaScript code. Rules in ESLint are configurable, and customized rules can be defined and loaded
Tâmia provides a set of such rules
const
, not var
.===
and !==
over ==
and !=
.This is very similar to the commonly used airbnb code rules, with one important addition/omission/change. - Tâmia does not provide any code style rules, hence it is very easy to complement this base set of linter rules with another for code styling.
As you know, I've been pushing Prettier - and they also supply a eslint config eslint-plugin-prettier - using this enforces the prettier formatting, and removes the need for any overrides where jshint formatting rules were conflicting with prettier.
The .eslintignore
and .eslintrc
files are described in the config documentation
Please find some feedback:
async await
I’d suggest not to include that changes in the existing PRs. Different to the changes already included (var to let/conts, etc.), which seems to be pretty straightforward (to be confirmed upon pull request review), the changes from callbacks to promises is more profound. We need to evaluate the pros/cons. It would be great to create a small PR (just one file, the one which best could show the supposed advantages with regards a code cleanness) to do that evaluation. That small PR could be done now (in parallel to the existing big ones) or in a next round of PRs in a later time.I have created my own branch of #800 - expression-lib-alternative and merged my eslint branch into it:
npm run lint
prettifies the code as shown: b59d0c2Total time to fix - 8 minutes - I don't think this is much of a blocker.
Replacing jshint with eslint is a simple mechanical process which could be easily added into IOTA Manager - the only problem is waiting and merging in other PRs whilst still at the back of the queue takes time. If I could see movement elsewhere I could easily apply the same process to another repo.
I fully agree removing callbacks and using promises is an aspiration and not intended to be part of this PR and should be separated from this discussion.
This is the state of the lull across the IoT Agents
Name | Open PRs | Comments |
---|---|---|
iotagent-json | 3 | One from April, A documentation one and a new change |
iotagent-ul | 3 | Two PRs are 11 months old - are they active? One from this month. |
sigfox-iotagent | 1 | A documentation change from March - is it active? |
lightweightm2m-iotagent | 1 | One 18 months old - is it active? |
Name | Open PRs | Comments |
---|---|---|
iotagent-node-lib | 10 | Includes several documentation changes, a Docker change and the obsolete prettier PR |
iotagent-manager | 1 | One outstanding PR |
Which of these PRs are still active?
Tab indentation.
As far as I remember we use plain spaces to indent in our code, not tabs. Can configuration be adjusted to align with our current indentation style?
In fact, maybe already works that way... I see in the proposed PRs configuration like:
indent_style = tab
...
indent_size = 4
What does exactly mean?
(I have tried to find indent_style and indent_size in the link you provide https://eslint.org/docs/user-guide/configuring but I didn't find them...)
My mistake - that should be the editorconfig - an attempt to maintain consistent coding styles across various IDEs.
The JavaScript editorconfig
should indeed match the 4 space guideline (and align with prettierrc.json
)
[*.{js}]
indent_style = space
indent_size = 4
Given that #800 has now been merged, I thought it would be an opportune moment to ask whether these PRs could be processed. I have updated the PRs again to ensure no conflicts.
This is the state of the lull across the IoT Agents
Name | Done | Open PRs | Comments |
---|---|---|---|
iotagent-json | ✅ | 3 | A documentation one and "ignore measure" - updated and currently ready for review. |
sigfox-iotagent | ✅ | 1 | A non-conflicting documentation change from March - is it active? |
lightweightm2m-iotagent | ✅ | 1 | One 2 years-old - is it active? |
iotagent-manager | ✅ | 1 | One outstanding PR - 8 months old |
For these repos I see no conflicting commits in the last 6 months and no progress on the outstanding PRs - are they active? How is the queue being dealt with?
Name | Done | Open PRs | Comments |
---|---|---|---|
iotagent-node-lib | :x: | 10 | Includes several documentation changes, a Docker change and the obsolete prettier PR |
iotagent-ul | ✅ | 8 | Two PRs are 11 months old - are they active? One from this month. |
These two are more problematic, and I can see you will want to process #849 before accepting #831. Question should #753 be withdrawn? The eslint PR supersedes it.
On the UL IoT Agent all the outstanding PRs https://github.com/telefonicaid/iotagent-ul/pull/411 and https://github.com/telefonicaid/iotagent-ul/pull/412 appear to be waiting for some equivalent works - is this scheduled? The other two are approved or equivalents to approved work elsewhere - https://github.com/telefonicaid/iotagent-ul/pull/429 https://github.com/telefonicaid/iotagent-ul/pull/430
Basically just asking if it is worth continuing maintaining these PRs.
I'm still thinking the work is valuable. Let's start the merge by the "simplest" repositories which I think are Sigfox and L2M2M.
The PR in LWM2M has been just merged. The PR in Sigfox has been commented with a couple of things I have spotted in a last review on it.
Current status: eslint PRs on IOTA-Sigfox, IOTA-LWM2M and IOTAManager (and STH, as bonus track ;) has been already merged. Next ones are IOTA-UL and IOTA-JSON.
There is an outstanding ongoing work on leading slashes mqtt topics authored by @jmezzera. The piece of work corresponding to IOTA-JSON is pending, but given that the "parallel" work in IOTA-UL is finished (PR https://github.com/telefonicaid/iotagent-ul/pull/429) I understand it would be provided soon. @jmezzera could you provide some update on this, please? Thanks!
I was just working on this aspect this morning, planning to have it done by the end of the day.
@jmezzera work on MQTT improvements has been just merged in IOTA-UL and IOTA-JSON (thanks!). Thus, I think once the eslint PRs on these repos gets updates with master and conflict solved, they would be ready for final review and merge.
Conflicts have been resolved. PRs have been updated.
As far as I understand, all the PRs related with eslint have been already merged in every repository so we are almost done :) However, there is still one pending, in this repository itself, for the iotagent-node-lib: PR https://github.com/telefonicaid/iotagent-node-lib/pull/831.
The summary of "parallel" PRs that may conflict are the following ones:
PR number | Author | Does the author agree on merging PR #831 before his PR? |
---|---|---|
#601 | @m4n3dw0lf | ? (author asked) |
#674 | @gabrieledeluca | Closed (overpassed by PR #920) |
#688 | @fgalan | Yes |
#753 | @jason-fox | Withdrawn |
#780 | @Jagatjot | Closed (ported to #922) |
#920 | @jason-fox | Merged |
#922 | @fgalan | Yes |
#793 | @Cerfoglg | Yes |
#849 (and dependant #854) | (*) | Yes |
Notes:
master
- usually just whitespace or documentation. It would be simple to merge at the moment. #849 already uses es6 for the code in relevant directories. The however the branch is currently several PRs behind master
.geojson
=> ngsi-ld
and then ngsi-ld
=> master
ngsi-ld
=> master
and then geojson
=> master
master
code which adds unnecessary changes over the currently ngsi-ld
refactored (and already ES6-ified) files. This means a subsequent master
=> ngsi-ld
merge to resolve conflicts would include a lot more unnecessary stuff - it will be very tricky to remove conflicts since each file will need analysis especially as I haven't looked at the code in either of these PRS in over six months.Much easier to merge the ngsi-ld
=> master
stuff first and then merge eslint
=> master
after. Eslint is already up to date with master
so it will be a matter of accept theirs, much easier not to miss something.
In contrast none of the other PRs are large enough to cause too many problems ( 9, 3, 1 and 10 files respectively)
Thanks for the feedback! I have edited the table above accordingly.
I have fixed the merge conflicts for the NGSI-LD PR:
This makes the merge of ngsi-ld + eslint a simple matter of accept mine as an experiment have created a new branch for this see here: https://github.com/jason-fox/iotagent-node-lib/tree/feature/eslint_and_ngsi-ld
I would still prefer that the NGSI-LD is actioned first as I don't want to be maintaining three branches (eslint
, ngsi-ld
, eslint+ngsi-ld
) whilst waiting for merge to master
PR #831 finally merged.
After merging, let's see tonight if the newly generated IOTAs containers with the new version of the library work in the CI e2s tests. If no problem is found (we don't expect any), the issue will be closed.
After merging, let's see tonight if the newly generated IOTAs containers with the new version of the library work in the CI e2s tests. If no problem is found (we don't expect any), the issue will be closed.
CI e2e went fine last night. So I think nothing is pending and this issue can be closed.
LoRaWAN and OPC-UA already use ES6 and are linted using ESLint. The telefonica IoT Agents code base is older and continues to use jshint
I see several advantages of swapping out the older linter and replacing it with the ES6 compliant one:
const
andlet
is supposedly more performant - well they would say that wouldn't theyThe existing minimum node engine is Node 8. Node 8 is reaching EoF and is already compliant with
const
andlet
anyway . I can't see why there would there be any problem is upgrading the IoT Agents to use the newer syntax? It's just a start - ideally someone can delete the existing async library callbacks and replace them with proper native ES2015+ Promises and useasync await
- it would make the code a lot easier to follow. I'm not sure if the iot-node-lib eventually needs to offer promise endpoints itself or just useutils.promisify()
but that is an issue for another day. This would just be a start.As a broad mechanical automated change, it would make sense to try push this through whilst there is a lull to avoid merge conflicts with other ongoing PRs.