Skip to content

Feature/eslint#408

Closed
jason-fox wants to merge 0 commit intotelefonicaid:masterfrom
jason-fox:feature/eslint
Closed

Feature/eslint#408
jason-fox wants to merge 0 commit intotelefonicaid:masterfrom
jason-fox:feature/eslint

Conversation

@jason-fox
Copy link
Copy Markdown
Contributor

Update codebase to use ES6

  • Remove JSHint and jshint overrides
  • Add esLint using standard tamia presets
  • Replace var with let/const
  • Fix or disable eslint errors

.eslintignore Outdated
@@ -0,0 +1,13 @@
# editorconfig.org
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The reference to jshint should be changed in this section https://github.com/telefonicaid/iotagent-ul/blob/master/docs/usermanual.md#coding-guidelines

(Maybe the same in the other associated PRs)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

.editorconfig Outdated
# editorconfig.org
root = true

[*]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we force a default style for files not matching any extension? Not sure if it is a good idea to over-force in this case as the potential files can be quite different.

Could be the [*] section safely removed?

Copy link
Copy Markdown
Contributor Author

@jason-fox jason-fox Jan 8, 2020

Choose a reason for hiding this comment

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

Most of the settings are deliberately general - it would probably make more sense if you tell me which of the setting you don't like and I can remove those.

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

end_of_line = lf and charset = utf-8 and insert_final_newline = true are standard UNIX defaults and would avoid problems like: #305

trim_trailing_whitespace = true along with insert_final_newline = true align with the linter settings - so trim_trailing_whitespace = true could be moved down and duplicated in the json and js settings.

The only controversial one is indent_style = tab - maybe should probably be redefined for Dockerfile only?

There are a couple of *.sh bash scripts in the repo - which are inconsistently spaced - should they be added?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suggested fix: e55fdb6

Copy link
Copy Markdown
Member

@fgalan fgalan Jan 8, 2020

Choose a reason for hiding this comment

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

The only controversial one is indent_style = tab - maybe should probably be redefined for Dockerfile only?

Yes, that's controversial... especially when other file formats in the repo are using indent_style = space :). Is there any syntactical requirement that enforce tabs in Dockefiles? Or it's a matter of taste decide between spaces and tabs?

In the second case, I'd suggest to let Dockerfile out of the scope of this file.

There are a couple of *.sh bash scripts in the repo - which are inconsistently spaced - should they be added?

Style & homogeneity for JavaScript source code is great. Style & homogeneity for JSON files could be also great. However, going to far trying to cover each little file of the repository could be excessive... I'd suggest by the moment leaving out *.sh files.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So something like this: caaffcb

  • Default to Unix line endings and UTF-8
  • agnostic over tabs/spaces.
  • Specific config for JS, md, yaml etc for the things that the linter cares about.

Note that editorConfig is just a suggestion. Husky should run the prettifier to re-enforce code style.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

After the last changes the .eseditorcnofig file looks nice :) Thx!

NTC

numRetried++;
return setTimeout(createConnection, retryTime * 1000);
}
} else {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

CC: @fiqare-secmotic

Curiously this is contrary to one of the rules from fiQare project, see #411 (comment). We enforce one thing (to remove empty else brarnches) and the opposite (to enforce else branch even when empty) at the same time :)

@jason-fox @fiqare-secmotic what do you think?

Copy link
Copy Markdown
Contributor Author

@jason-fox jason-fox Jan 8, 2020

Choose a reason for hiding this comment

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

This is an if...else... construct not an if...else if... construct.

Placing the return within the else clause is therefore totally unnecessary.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi! yes, as @jason-fox says, it is not an if...else if construct

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just to check if I'm understanding it correctly...

The MISRA and CERT rules cited at #411 (comment), prescribe the inclusion of final "else" in "if... else if..." structures but not prescribe the use of "else" in simple "if" structured.

@fiqare-secmotic, could you confirm my understanding is correct?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@fiqare-secmotic, could you confirm my understanding is correct?

Any news?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@fgalan yes, your understanding is correct.

@jason-fox jason-fox closed this Jan 21, 2020
@jason-fox jason-fox mentioned this pull request Jan 21, 2020
@fgalan
Copy link
Copy Markdown
Member

fgalan commented Jan 22, 2020

Should I understand this PR has moved to PR #415 ? Why? (it's fine, just curiosity...)

The question raised at #408 (comment) still having no answer. @fiqare-secmotic could you have a look, please? Thanks!

@fgalan
Copy link
Copy Markdown
Member

fgalan commented Jan 22, 2020

Should I understand this PR has moved to PR #415 ? Why? (it's fine, just curiosity...)

I just see at PR #415

Repeats #408 closed in error

Sorry not checking PR #415 before asking this...

@jason-fox
Copy link
Copy Markdown
Contributor Author

@fgalan - I was just doing some automated scripted housekeeping and instead of updating origin:master to upstream:master, my script accidentally updated origin:feature/eslint to upstream:master which caused the PR to close.

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