Moved most of the functions that contained "window.doSomething" that were located at:
- app/assets/javascripts/application.js
To the following file:
- app/assets/javascripts/lib/utils/common_utils.js
The functions listed here:
- window.ajaxGet
- window.split
- window.extractLast
- window.rstrip
- window.disableButtonIfEmptyField
- window.disableButtonIfAnyEmptyField
- window.sanitize
- window.unbindEvents
- window.shiftWindow
Now will be accessible from the "gl.utils" namespace
Add ESLint
## What does this MR do?
- create `package.json`
- add ESLint dependencies to `package.json`
- add JavaScript linting to CI
- add Rake task `lint:javascript`as alias for `eslint` (which itself is an alias for `npm run eslint`)
## Are there points in the code the reviewer needs to double check?
Probably not.
## Why was this MR needed?
My hovercraft was full of eels.
## What are the relevant issue numbers?
- https://gitlab.com/gitlab-org/gitlab-ce/issues/13224#note_12537431
- https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5006#note_13255658
See merge request !5445
CoffeeScript generated JavaScript contains some unreadable
expressions. This refactoring addresses complex uses of
the exestential operator that produced unreadable Javascript.
* resetTooltip totally destroyed and regenerated the
tooltip while fixTitle simply replaces the text in
the existing element.
* resetTooltip also called an asyncronous function
with no suitable callback resulting in a messy
setTimout workaround. fixTitle is syncronous.
* Only the first 10 names are displayed
* Further users are indicated by "and X more."
* String "and X more" is appended to the array THEN join is called
* An oxford comma seperates the last name from "and X more"
* In coffeescript "me" is now always prepended
* Tests included