Skip to content

Commit

Permalink
Lint: add object-shorthand rule (#1927)
Browse files Browse the repository at this point in the history
* Lint: add object-shorthand rule
* Run `eslint --fix` on all files
  • Loading branch information
simison authored Dec 22, 2020
1 parent ac90338 commit 582038a
Show file tree
Hide file tree
Showing 89 changed files with 273 additions and 281 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const rules = {
'no-unused-expressions': 0,
'no-use-before-define': [1, 'nofunc'],
'object-curly-spacing': [2, 'always'],
'object-shorthand': 2,
'one-var': [2, 'never'],
'one-var-declaration-per-line': [2, 'always'],
semi: [2, 'always'],
Expand Down
2 changes: 1 addition & 1 deletion config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const initGlobalConfig = function () {

// Expose configuration utilities
config.utils = {
getGlobbedPaths: getGlobbedPaths,
getGlobbedPaths,
};

return config;
Expand Down
2 changes: 1 addition & 1 deletion config/lib/exponent-notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports.sendToDevice = function sendToDevice(tokens, notification) {
tokens.forEach(function (token) {
if (!token || !Expo.isExpoPushToken(token)) {
log('error', 'Invalid or missing Expo push notification token #mg9hwf', {
token: token,
token,
});
return;
}
Expand Down
2 changes: 1 addition & 1 deletion config/lib/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ module.exports.initMiddleware = function (app) {
// Should be placed before express.static
app.use(
compress({
filter: function (req, res) {
filter(req, res) {
return /json|text|javascript|css|font|svg/.test(
res.getHeader('Content-Type'),
);
Expand Down
10 changes: 5 additions & 5 deletions config/lib/mongoose.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ module.exports.loadModels = function (callback) {
mongoose.model(model).on('index', function (error) {
if (error) {
log('error', 'Calling createIndex failed for Mongoose Schema.', {
error: error,
model: model,
error,
model,
});
} else {
log('info', 'Calling createIndex succeeded for Mongoose Schema.', {
model: model,
model,
});
}
});
Expand Down Expand Up @@ -173,7 +173,7 @@ module.exports.ensureIndexes = function (modelNames) {
if (error) {
log('error', 'Indexing Mongoose Schema failed', {
model: modelName,
error: error,
error,
});
callback(error);
} else {
Expand All @@ -188,7 +188,7 @@ module.exports.ensureIndexes = function (modelNames) {
// One of the iterations produced an error.
// All processing will now stop.
log('error', 'A Schema failed to index.', {
error: error,
error,
});
reject(error);
} else {
Expand Down
6 changes: 3 additions & 3 deletions modules/contacts/client/config/contacts.client.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ function ContactsRoutes($stateProvider) {
ContactByService: 'ContactByService',
UsersMini: 'UsersMini',

existingContact: function (ContactByService, $stateParams) {
existingContact(ContactByService, $stateParams) {
return ContactByService.get({ userId: $stateParams.userId });
},

friend: function (UsersMini, $stateParams) {
friend(UsersMini, $stateParams) {
return UsersMini.get({
userId: $stateParams.userId,
});
Expand All @@ -41,7 +41,7 @@ function ContactsRoutes($stateProvider) {
// A string value resolves to a service
Contact: 'Contact',

contact: function (Contact, $stateParams) {
contact(Contact, $stateParams) {
return Contact.get({ contactId: $stateParams.contactId });
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ function trContactRemoveDirective($uibModal) {
scope: {
contactToRemove: '=trContactRemove',
},
link: function (scope, element) {
link(scope, element) {
function openModal() {
$uibModal.open({
templateUrl,
controllerAs: 'removeContactModal',
controller: 'ContactRemoveController',
scope: scope,
scope,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ describe('ContactRemoveController', function () {
inject(function ($controller) {
Authentication.user = user1;
ContactRemoveController = $controller('ContactRemoveController', {
$scope: $scope,
$uibModalInstance: $uibModalInstance,
messageCenterService: messageCenterService,
$scope,
$uibModalInstance,
messageCenterService,
});
done();
});
Expand Down
4 changes: 2 additions & 2 deletions modules/core/client/components/StepNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ export default function StepNavigation({
* https://reactjs.org/docs/react-api.html#cloneelement
*/
const backProps = { onClick: onBack };
const nextProps = { onClick: onNext, disabled: disabled };
const submitProps = { onClick: onSubmit, disabled: disabled };
const nextProps = { onClick: onNext, disabled };
const submitProps = { onClick: onSubmit, disabled };
const tooltipProps = {
tooltip: disabledReason,
id: 'tooltip-disabled-button',
Expand Down
2 changes: 1 addition & 1 deletion modules/core/client/config/core.client.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function CoreConfig($httpProvider) {
/* @ngInject */
function CoreServiceUnavailable($q, $rootScope) {
return {
responseError: function (rejection) {
responseError(rejection) {
if (rejection.status === 503) {
$rootScope.$broadcast('serviceUnavailable');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function mcMessages($rootScope, messageCenterService) {
return {
restrict: 'EA',
template: templateString,
link: function (scope, element, attrs) {
link(scope, element, attrs) {
// Bind the messages from the service to the root scope.
messageCenterService.flush();
const changeReaction = function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function trBoardsDirective($window) {
scope: {
trBoards: '=',
},
link: function (scope, elem, attrs) {
link(scope, elem, attrs) {
// Don't set background images for mobile screens if defined so via attribute
if (
angular.isDefined(attrs.trBoardsIgnoreSmall) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ angular
return {
restrict: 'A',
replace: true,
templateUrl: function ($element, $attrs) {
templateUrl($element, $attrs) {
return $attrs.templateUrl || 'tr-date-select.html';
},
require: 'ngModel',
Expand All @@ -49,7 +49,7 @@ angular
selectClass: '@trSelectClass',
},

link: function (scope, elem, attrs, ngModel) {
link(scope, elem, attrs, ngModel) {
scope.val = {};

const min = (scope.min = moment(attrs.min || '1900-01-01'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function trEditorDirective($parse) {
scope: {
trEditorOptions: '=',
},
link: function (scope, iElement, iAttrs, ngModel) {
link(scope, iElement, iAttrs, ngModel) {
const angularIElement = angular.element(iElement);

angularIElement.addClass('tr-editor');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function trFlashcardsDirective() {
' <p class="tr-flashcards-title" ng-bind="::flashTitle"></p>' +
' <p class="tr-flashcards-content" ng-bind="::flashContent"></p>' +
'</a>',
link: function (scope) {
link(scope) {
const flashcards = [
{
title: 'Make sure your profile is complete',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function trFocustipDirective($compile) {
scope: {
trFocustip: '=',
},
link: function (scope, element) {
link(scope, element) {
// Compiled template
// after() requires jQuery
const template = $compile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ angular.module('core').directive('trSelectOnClick', trSelectOnClickDirective);
function trSelectOnClickDirective($window) {
return {
restrict: 'A',
link: function (scope, element) {
link(scope, element) {
element.on('click', function () {
if (!$window.getSelection().toString()) {
// Required for mobile Safari
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function trLanguagesDirective() {
$scope.output.forEach(function (key) {
if (angular.isString(key)) {
this.push({
key: key,
key,
name: vm.languages[key],
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function trLocationDirective($compile, $timeout, LocationService) {
trLocationBounds: '=?',
},
replace: false,
link: function (scope, element, attr, ngModel) {
link(scope, element, attr, ngModel) {
// Event handler to stop submitting the surrounding form
element.bind('keydown keypress focus', function ($event) {
scope.trLocationNotfound = false;
Expand Down Expand Up @@ -91,7 +91,7 @@ function trLocationDirective($compile, $timeout, LocationService) {
});
},
controllerAs: 'trLocation',
controller: function ($scope, $timeout) {
controller($scope, $timeout) {
// View Model
const vm = this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ angular.module('core').directive('trPageTitle', trPageTitle);
function trPageTitle($rootScope, $interpolate, $state, $window) {
const directive = {
restrict: 'A',
link: link,
link,
};

return directive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ angular.module('core').directive('trSpinner', trSpinnerDirective);
function trSpinnerDirective() {
return {
restrict: 'E',
link: function (scope, element, attrs) {
link(scope, element, attrs) {
// @link https://haltersweb.github.io/Accessibility/svg.html
function generateSVGMarkup(size, square, stroke) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ angular.module('core').directive('trSwitch', trSwitchDirective);
function trSwitchDirective() {
return {
restrict: 'A',
link: function (scope, elem, attrs) {
link(scope, elem, attrs) {
elem.addClass('tr-switch');

// Small size
Expand Down
2 changes: 1 addition & 1 deletion modules/core/client/directives/tr-time.client.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function trTimeDirective($log, $rootScope, $parse, locker) {
trTimeTooltipPlacement: '@',
trTimeFormat: '=?', // `?` makes it optional
},
link: function (scope, element, attrs) {
link(scope, element, attrs) {
if (!scope.trTime) {
$log.warn('No time passed for tr-time directive.');
return;
Expand Down
2 changes: 1 addition & 1 deletion modules/core/client/services/facebook.client.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function FacebookFactory(
Authentication,
) {
const service = {
init: init,
init,
};

return service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ function firebaseMessaging($window, $q, $timeout, SettingsService) {
const firebaseMessaging = {
name: 'fcm',
shouldInitialize: !!SENDER_ID,
getToken: getToken,
requestPermission: requestPermission,
deleteToken: deleteToken,
onTokenRefresh: onTokenRefresh,
onMessage: onMessage,
removeServiceWorker: removeServiceWorker,
getToken,
requestPermission,
deleteToken,
onTokenRefresh,
onMessage,
removeServiceWorker,
};

function getToken() {
Expand Down
4 changes: 2 additions & 2 deletions modules/core/client/services/languages.client.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ angular.module('core').factory('Languages', LanguagesFactory);
/* @ngInject */
function LanguagesFactory($window) {
const service = {
get: get,
get,
};

return service;
Expand All @@ -15,7 +15,7 @@ function LanguagesFactory($window) {
angular.forEach(
$window.languages,
function (value, key) {
this.push({ key: key, name: value });
this.push({ key, name: value });
},
langsArr,
);
Expand Down
10 changes: 5 additions & 5 deletions modules/core/client/services/location.client.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ function LocationService($log, $http, SettingsFactory) {
};

const service = {
getDefaultLocation: getDefaultLocation,
getBounds: getBounds,
getCenter: getCenter,
shortTitle: shortTitle,
suggestions: suggestions,
getDefaultLocation,
getBounds,
getCenter,
shortTitle,
suggestions,
};

/**
Expand Down
2 changes: 1 addition & 1 deletion modules/core/client/services/maplayers.client.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function MapLayersFactory(SettingsFactory, LocationService) {
const location = LocationService.getDefaultLocation(3);

const service = {
getLayers: getLayers,
getLayers,
};

return service;
Expand Down
6 changes: 3 additions & 3 deletions modules/core/client/services/mapmarkers.client.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ function MapMarkersFactory($window) {
const Leaflet = $window.L;

const service = {
getIconConfig: getIconConfig,
getIcon: getIcon,
getOfferCircle: getOfferCircle,
getIconConfig,
getIcon,
getOfferCircle,
};

return service;
Expand Down
Loading

0 comments on commit 582038a

Please sign in to comment.