mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #2937 from overleaf/as-remove-global-lodash
Replace global Lodash with explicit imports in frontend GitOrigin-RevId: b092647039975ac594b69ce1fa145fd03552cc60
This commit is contained in:
parent
5636386c54
commit
0d2a768e1e
42 changed files with 87 additions and 42 deletions
|
@ -22,7 +22,6 @@ import './modules/recursionHelper'
|
|||
import './modules/errorCatcher'
|
||||
import './modules/localStorage'
|
||||
import './modules/sessionStorage'
|
||||
import './utils/underscore'
|
||||
// Configure dynamically loaded assets (via webpack) to be downloaded from CDN
|
||||
// See: https://webpack.js.org/guides/public-path/#on-the-fly
|
||||
// eslint-disable-next-line no-undef
|
||||
|
@ -34,7 +33,6 @@ const App = angular
|
|||
'autocomplete',
|
||||
'RecursionHelper',
|
||||
'ng-context-menu',
|
||||
'underscore',
|
||||
'ngSanitize',
|
||||
'ipCookie',
|
||||
'ErrorCatcher',
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import _ from 'lodash'
|
||||
import App from '../base'
|
||||
App.directive('bookmarkableTabset', ($location, _) => ({
|
||||
App.directive('bookmarkableTabset', $location => ({
|
||||
restrict: 'A',
|
||||
require: 'tabset',
|
||||
link(scope, el, attrs, tabset) {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* global PassField */
|
||||
|
||||
/* eslint-disable
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
max-len,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* global MathJax */
|
||||
|
||||
import App from '../base'
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
max-len
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
import CommandManager from './CommandManager'
|
||||
import EnvironmentManager from './EnvironmentManager'
|
||||
import PackageManager from './PackageManager'
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
max-len,
|
||||
no-return-assign,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
max-len,
|
||||
*/
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
import _ from 'ace/ace'
|
||||
import 'ace/ace'
|
||||
import ColorManager from '../../../../colors/ColorManager'
|
||||
let HighlightsManager
|
||||
const { Range } = ace.require('ace/range')
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
max-len,
|
||||
no-cond-assign,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
max-len,
|
||||
no-return-assign,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
import App from '../../../base'
|
||||
|
||||
export default App.factory('files', function(ide) {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
max-len,
|
||||
*/
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
max-len,
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
import App from '../../../base'
|
||||
const historyEntriesListController = function($scope, $element, $attrs, _) {
|
||||
const historyEntriesListController = function($scope, $element, $attrs) {
|
||||
const ctrl = this
|
||||
ctrl.$entryListViewportEl = null
|
||||
ctrl.isDragging = false
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
max-len,
|
||||
*/
|
||||
|
@ -12,7 +13,7 @@
|
|||
import App from '../../../base'
|
||||
import ColorManager from '../../colors/ColorManager'
|
||||
import displayNameForUser from '../util/displayNameForUser'
|
||||
const historyEntryController = function($scope, $element, $attrs, _) {
|
||||
const historyEntryController = function($scope, $element, $attrs) {
|
||||
const ctrl = this
|
||||
// This method (and maybe the one below) will be removed soon. User details data will be
|
||||
// injected into the history API responses, so we won't need to fetch user data from other
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
|
@ -8,7 +9,7 @@
|
|||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
import App from '../../../base'
|
||||
const historyFileTreeController = function($scope, $element, $attrs, _) {
|
||||
const historyFileTreeController = function($scope, $element, $attrs) {
|
||||
const ctrl = this
|
||||
ctrl.handleEntityClick = file => ctrl.onSelectedFileChange({ file })
|
||||
ctrl._fileTree = []
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
import App from '../../../base'
|
||||
const historyLabelController = function($scope, $element, $attrs, $filter, _) {
|
||||
const historyLabelController = function($scope, $element, $attrs, $filter) {
|
||||
const ctrl = this
|
||||
ctrl.$onInit = () => {
|
||||
if (ctrl.showTooltip == null) {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
max-len,
|
||||
*/
|
||||
|
@ -12,7 +13,7 @@
|
|||
import App from '../../../base'
|
||||
import ColorManager from '../../colors/ColorManager'
|
||||
import displayNameForUser from '../util/displayNameForUser'
|
||||
const historyLabelsListController = function($scope, $element, $attrs, _) {
|
||||
const historyLabelsListController = function($scope, $element, $attrs) {
|
||||
const ctrl = this
|
||||
ctrl.isDragging = false
|
||||
ctrl.versionsWithLabels = []
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
max-len,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
no-return-assign,
|
||||
*/
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
handle-callback-err,
|
||||
max-len,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
max-len,
|
||||
no-return-assign,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
max-len,
|
||||
no-return-assign,
|
||||
|
@ -13,7 +14,7 @@
|
|||
*/
|
||||
import App from '../../../base'
|
||||
|
||||
export default App.directive('resolvedCommentsDropdown', _ => ({
|
||||
export default App.directive('resolvedCommentsDropdown', () => ({
|
||||
restrict: 'E',
|
||||
templateUrl: 'resolvedCommentsDropdownTemplate',
|
||||
scope: {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
max-len,
|
||||
|
@ -17,8 +18,7 @@ export default App.controller('SettingsController', function(
|
|||
$scope,
|
||||
ExposedSettings,
|
||||
settings,
|
||||
ide,
|
||||
_
|
||||
ide
|
||||
) {
|
||||
const validRootDocExtensions = ExposedSettings.validRootDocExtensions
|
||||
const validRootDocRegExp = new RegExp(
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
import App from '../../../base'
|
||||
App.controller('ShareProjectModalController', function(
|
||||
$scope,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
max-len,
|
||||
no-return-assign,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
max-len,
|
||||
no-return-assign,
|
||||
|
@ -10,8 +11,7 @@ export default App.controller('UserAffiliationsController', function(
|
|||
$scope,
|
||||
UserAffiliationsDataService,
|
||||
$q,
|
||||
$window,
|
||||
_
|
||||
$window
|
||||
) {
|
||||
$scope.userEmails = []
|
||||
$scope.linkedInstitutionIds = []
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
import App from '../../../base'
|
||||
const countriesList = [
|
||||
{ code: 'af', name: 'Afghanistan' },
|
||||
|
@ -405,7 +406,7 @@ for (let domain of commonDomains) {
|
|||
}
|
||||
}
|
||||
|
||||
App.factory('UserAffiliationsDataService', function($http, $q, _) {
|
||||
App.factory('UserAffiliationsDataService', function($http, $q) {
|
||||
const getCountries = () => $q.resolve(countriesList)
|
||||
|
||||
const getDefaultRoleHints = () => $q.resolve(defaultRoleHints)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
|
@ -16,12 +17,7 @@
|
|||
import App from '../base'
|
||||
import '../directives/mathjax'
|
||||
import '../services/algolia-search'
|
||||
App.controller('SearchWikiController', function(
|
||||
$scope,
|
||||
algoliaSearch,
|
||||
_,
|
||||
$modal
|
||||
) {
|
||||
App.controller('SearchWikiController', function($scope, algoliaSearch, $modal) {
|
||||
$scope.hits = []
|
||||
$scope.hits_total = 0
|
||||
$scope.config_hits_per_page = 20
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
max-len,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
import App from '../../base'
|
||||
import './services/project-list'
|
||||
App.controller('ProjectPageController', function(
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
max-len,
|
||||
no-return-assign,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* global recurly */
|
||||
|
||||
/* eslint-disable
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
max-len,
|
||||
no-return-assign,
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
/* eslint-disable
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
import '../libraries'
|
||||
export default angular.module('underscore', []).factory('_', () => window._)
|
40
services/web/transform-lodash-global.sh
Executable file
40
services/web/transform-lodash-global.sh
Executable file
|
@ -0,0 +1,40 @@
|
|||
npx jscodeshift \
|
||||
-t https://gist.githack.com/40thieves/0b495af3fb0ad5fe08915ce5159a2b7b/raw/9c583c0a5b0cbd83a66538a07591b41332efda6a/transform-lodash.js \
|
||||
--ignore-pattern frontend/js/vendor \
|
||||
--noSemi=true \
|
||||
frontend/js
|
||||
|
||||
npx jscodeshift \
|
||||
-t https://gist.githack.com/40thieves/0b495af3fb0ad5fe08915ce5159a2b7b/raw/9c583c0a5b0cbd83a66538a07591b41332efda6a/transform-lodash.js \
|
||||
--noSemi=true \
|
||||
test/frontend
|
||||
|
||||
for MODULE in admin-panel cms dropbox git-bridge github-sync launchpad metrics open-in-overleaf overleaf-integration portals references-search support templates tpr-webmodule two-factor-authentication v2-templates
|
||||
do
|
||||
npx jscodeshift \
|
||||
-t https://gist.githack.com/40thieves/0b495af3fb0ad5fe08915ce5159a2b7b/raw/9c583c0a5b0cbd83a66538a07591b41332efda6a/transform-lodash.js \
|
||||
--noSemi=true \
|
||||
modules/$MODULE/frontend/js
|
||||
done
|
||||
|
||||
npx jscodeshift \
|
||||
-t https://gist.githack.com/40thieves/0b495af3fb0ad5fe08915ce5159a2b7b/raw/9c583c0a5b0cbd83a66538a07591b41332efda6a/transform-lodash.js \
|
||||
--noSemi=true \
|
||||
modules/rich-text/frontend/js
|
||||
|
||||
npx jscodeshift \
|
||||
-t https://gist.githack.com/40thieves/0b495af3fb0ad5fe08915ce5159a2b7b/raw/9c583c0a5b0cbd83a66538a07591b41332efda6a/transform-lodash.js \
|
||||
--noSemi=true \
|
||||
modules/rich-text/test/frontend
|
||||
|
||||
npx jscodeshift \
|
||||
-t https://gist.githack.com/40thieves/0b495af3fb0ad5fe08915ce5159a2b7b/raw/9c583c0a5b0cbd83a66538a07591b41332efda6a/transform-lodash.js \
|
||||
--noSemi=true \
|
||||
modules/publish-modal/frontend/js
|
||||
|
||||
npx jscodeshift \
|
||||
-t https://gist.githack.com/40thieves/0b495af3fb0ad5fe08915ce5159a2b7b/raw/9c583c0a5b0cbd83a66538a07591b41332efda6a/transform-lodash.js \
|
||||
--noSemi=true \
|
||||
modules/publish-modal/test/frontend
|
||||
|
||||
make format_fix
|
|
@ -181,16 +181,6 @@ module.exports = {
|
|||
options: 'angular'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
// Expose lodash global variable
|
||||
test: require.resolve('lodash'),
|
||||
use: [
|
||||
{
|
||||
loader: 'expose-loader',
|
||||
options: '_'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue