Skip to content

Feature/eslint #831

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

Merged
merged 37 commits into from
Nov 18, 2020
Merged

Feature/eslint #831

merged 37 commits into from
Nov 18, 2020

Conversation

jason-fox
Copy link
Contributor

  • Replace jshint with eslint
  • Add prettier code formatting
  • Add husky and lint-staged

Incorporates and supercedes #753

Related: #830

@jason-fox
Copy link
Contributor Author

@fgalan @AlvaroVega -

Is there anything now blocking this PR from being reviewed and merged?

@fgalan
Copy link
Member

fgalan commented Oct 6, 2020

@fgalan @AlvaroVega -

Is there anything now blocking this PR from being reviewed and merged?

As far as I understand by #830 (comment), this PR is waiting for others to be merged first (#849 and maybe #854)

@jason-fox
Copy link
Contributor Author

@fgalan - Given the lack of movement on #849, I guess it would make more sense to move this up the queue. #854 is dependent on #849 so would come after the others.

So I'd suggest processing in the following order - #831 , #849 then #854

It's just that there isn't much of a queue at the moment (since the last period of activity has cleared a of of small PRs) so it would make sense to use this opportunity to get the broad ES6 change in whilst the "lull" occurs.

@fgalan
Copy link
Member

fgalan commented Oct 7, 2020

@fgalan - Given the lack of movement on #849, I guess it would make more sense to move this up the queue. #854 is dependent on #849 so would come after the others.

So I'd suggest processing in the following order - #831 , #849 then #854

It's just that there isn't much of a queue at the moment (since the last period of activity has cleared a of of small PRs) so it would make sense to use this opportunity to get the broad ES6 change in whilst the "lull" occurs.

I have updated the table at #830 (comment) based on your feedback. In addition, I have asked other PRs authors about what they think about merging #831 before theirs.

If they agree (or if they don't answer in a reasonable time, assuming in that case they are missing in action :) I think we can finally progress and eventually merge PR #831

@jason-fox
Copy link
Contributor Author

If they agree (or if they don't answer in a reasonable time, assuming in that case they are missing in action :) I think we can finally progress and eventually merge PR #831

@fgalan @AlvaroVega - Any chance this will be actioned before its upcoming first birthday? 🍰

@@ -38,7 +37,7 @@ function raise(alarmName, description) {
if (!alarmRepository[alarmName]) {
alarmRepository[alarmName] = {
name: alarmName,
description: description
description
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are your sure about this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EsLint and Prettier are. This is standard syntax for ES6.

config.getCommandRegistry().removeFromDate(
Date.now() - config.getConfig().pollingExpiration,
function(error, results) {
config
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this way is more easy to read....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated change - take it up with the guys at Prettier. 😄 This syntax has already been applied across the IoT Agents themselves the only hold out is the IoT-Node-lib so this is the one that isn't standardized.

@jason-fox
Copy link
Contributor Author

@fgalan @AlvaroVega -

With the OPC-UA template change #920 , it looks like there are no objections left in the table here.
Is there anything now blocking this PR from being reviewed and merged so that #830 can finally be closed.

@fgalan
Copy link
Member

fgalan commented Nov 10, 2020

@fgalan @AlvaroVega -

With the OPC-UA template change #920 , it looks like there are no objections left in the table here.

I have reviewed and the only pending item is #601, but given the author seems to be MIA (Missing In Action :) as he doesn't answer to the question about adapting his PR after merging the lint changes, I think we can skip it and GO.

Is there anything now blocking this PR from being reviewed and merged so that #830 can finally be closed.

We are near to close a new version of the iotagent-node-lib (along with some other agents). We will wait until that release (we hope that some days or a week maybe) before merging the eslint contribution (in fact, the eslint contribution could be the first PR to be merged in the new version development cycle).

@fgalan
Copy link
Member

fgalan commented Nov 16, 2020

We are near to close a new version of the iotagent-node-lib (along with some other agents). We will wait until that release (we hope that some days or a week maybe) before merging the eslint contribution (in fact, the eslint contribution could be the first PR to be merged in the new version development cycle).

2.14.0 has been already released (https://github.com/telefonicaid/iotagent-node-lib/releases/tag/2.14.0)

Thus, this PR would be ready to be merged, once the conflict with master gets solved.

# Conflicts:
#	CHANGES_NEXT_RELEASE
#	lib/services/northBound/deviceProvisioningServer.js
lib/errors.js Outdated
Comment on lines 9 to 10
* or (at your option) any later version.
* or {
constructor(at your option) any later version.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed ae4416e

"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error",
"no-shadow": 0,
Copy link
Member

@fgalan fgalan Nov 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparing with the .eslintrc.json file in IOTA-JSON .eslintrc.json repo, this setting has been added here.

Which effect does it have in the eslint rules?

Copy link
Contributor Author

@jason-fox jason-fox Nov 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same reasoning it was added here - the latest version of eslint complains about Telefonica style callbacks in the code (it wants the callback variable name to be unique) hence the shadowed variable name rule must be dropped. This is only due to the updates to a more modern Eslint

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification.

So, I understand that "no-shadow": 0 is the desired setting and the repos not using it (if any) should be fixed. Out of the scope of this PR, of course.

NTC

Comment on lines +37 to +38
"prettier": "prettier --config .prettierrc.json --write '**/**/**/**/*.js' '**/**/**/*.js' '**/**/*.js' '**/*.js' '*.js'",
"prettier:text": "prettier 'README.md' 'doc/*.md' 'doc/**/*.md' --no-config --tab-width 4 --print-width 120 --write --prose-wrap always",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the new targets (prettier and prettier:text) included in the corresponding .md describing the different targets? Maybe yes, but it's a bit hard to find it in so large PR :) Could you help providing a pointer, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed ea6d399

Copy link
Member

@fgalan fgalan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

It has been hard, but in the end, the PR is fine and we have found a good lull moment for it. Thanks for all your contributions!

@fgalan fgalan merged commit 510ae37 into telefonicaid:master Nov 18, 2020
@jason-fox
Copy link
Contributor Author

@jason-fox jason-fox deleted the feature/eslint branch November 20, 2020 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants