Skip to content

Commit

Permalink
Merge pull request mozilla#8353 from Snuffleupagus/eslint_object-shor…
Browse files Browse the repository at this point in the history
…thand

Enable the `object-shorthand` ESLint rule
  • Loading branch information
timvandermeij authored Apr 30, 2017
2 parents 207a773 + 73e94b8 commit d920710
Show file tree
Hide file tree
Showing 21 changed files with 99 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
"no-useless-computed-key": "error",
"no-useless-constructor": "error",
"no-useless-rename": "error",
"object-shorthand": ["off", "always", {
"object-shorthand": ["error", "always", {
"avoidQuotes": true,
}],
"rest-spread-spacing": ["error", "never"],
Expand Down
4 changes: 4 additions & 0 deletions extensions/chromium/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
"parserOptions": {
"sourceType": "script"
},

"rules": {
"object-shorthand": "off",
},
}
4 changes: 4 additions & 0 deletions external/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
"node": true,
"shelljs": true,
},

"rules": {
"object-shorthand": "off",
},
}
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* limitations under the License.
*/
/* eslint-env node */
/* eslint-disable object-shorthand */
/* globals target */

'use strict';
Expand Down
1 change: 1 addition & 0 deletions test/chromium/test-telemetry.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable object-shorthand */

'use strict';

Expand Down
1 change: 1 addition & 0 deletions test/downloadutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable object-shorthand */

'use strict';

Expand Down
36 changes: 18 additions & 18 deletions test/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ var LinkServiceMock = (function LinkServiceMockClosure() {

set page(value) {},

navigateTo: function (dest) {},
navigateTo(dest) {},

getDestinationHash: function (dest) {
getDestinationHash(dest) {
return '#';
},

getAnchorUrl: function (hash) {
getAnchorUrl(hash) {
return '#';
},

setHash: function (hash) {},
setHash(hash) {},

executeNamedAction: function (action) {},
executeNamedAction(action) {},

onFileAttachmentAnnotation: function (params) {},
onFileAttachmentAnnotation(params) {},

cachePageRef: function (pageNum, pageRef) {},
cachePageRef(pageNum, pageRef) {},
};

return LinkServiceMock;
Expand Down Expand Up @@ -101,10 +101,10 @@ var rasterizeTextLayer = (function rasterizeTextLayerClosure() {

// Rendering text layer as HTML.
var task = PDFJS.renderTextLayer({
textContent: textContent,
textContent,
container: div,
viewport: viewport,
enhanceTextSelection: enhanceTextSelection,
viewport,
enhanceTextSelection,
});
Promise.all([stylePromise, task.promise]).then(function (results) {
task.expandTextDivs(true);
Expand Down Expand Up @@ -200,11 +200,11 @@ var rasterizeAnnotationLayer = (function rasterizeAnnotationLayerClosure() {
var annotation_viewport = viewport.clone({ dontFlip: true });
var parameters = {
viewport: annotation_viewport,
div: div,
annotations: annotations,
page: page,
div,
annotations,
page,
linkService: new LinkServiceMock(),
renderInteractiveForms: renderInteractiveForms,
renderInteractiveForms,
};
PDFJS.AnnotationLayer.render(parameters);

Expand Down Expand Up @@ -527,7 +527,7 @@ var Driver = (function DriverClosure() { // eslint-disable-line no-unused-vars

var renderContext = {
canvasContext: ctx,
viewport: viewport,
viewport,
renderInteractiveForms: renderForms,
};
var completeRender = (function(error) {
Expand Down Expand Up @@ -605,7 +605,7 @@ var Driver = (function DriverClosure() { // eslint-disable-line no-unused-vars
_info: function Driver_info(message) {
this._send('/info', JSON.stringify({
browser: this.browser,
message: message
message,
}));
},

Expand Down Expand Up @@ -641,11 +641,11 @@ var Driver = (function DriverClosure() { // eslint-disable-line no-unused-vars
numPages: task.pdfDoc ?
(task.lastPage || task.pdfDoc.numPages) : 0,
lastPageNum: this._getLastPageNumber(task),
failure: failure,
failure,
file: task.file,
round: task.round,
page: task.pageNum,
snapshot: snapshot,
snapshot,
stats: task.stats.times
});
this._send('/submit_task_results', result, callback);
Expand Down
20 changes: 10 additions & 10 deletions test/font/jasmine-boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function initializePDFJS(callback) {

// Runner Parameters
var queryString = new jasmine.QueryString({
getWindowLocation: function() {
getWindowLocation() {
return window.location;
}
});
Expand All @@ -93,27 +93,27 @@ function initializePDFJS(callback) {

// Reporters
var htmlReporter = new jasmine.HtmlReporter({
env: env,
onRaiseExceptionsClick: function() {
env,
onRaiseExceptionsClick() {
queryString.navigateWithNewParam('catch', !env.catchingExceptions());
},
onThrowExpectationsClick: function() {
onThrowExpectationsClick() {
queryString.navigateWithNewParam('throwFailures',
!env.throwingExpectationFailures());
},
onRandomClick: function() {
onRandomClick() {
queryString.navigateWithNewParam('random', !env.randomTests());
},
addToExistingQueryString: function(key, value) {
addToExistingQueryString(key, value) {
return queryString.fullStringWithNewParam(key, value);
},
getContainer: function() {
getContainer() {
return document.body;
},
createElement: function() {
createElement() {
return document.createElement.apply(document, arguments);
},
createTextNode: function() {
createTextNode() {
return document.createTextNode.apply(document, arguments);
},
timer: new jasmine.Timer()
Expand All @@ -130,7 +130,7 @@ function initializePDFJS(callback) {
// Filter which specs will be run by matching the start of the full name
// against the `spec` query param.
var specFilter = new jasmine.HtmlSpecFilter({
filterString: function() {
filterString() {
return queryString.getParam('spec');
}
});
Expand Down
1 change: 1 addition & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable object-shorthand */

'use strict';

Expand Down
26 changes: 13 additions & 13 deletions test/unit/annotation_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ describe('annotation', function() {
}
}
XRefMock.prototype = {
fetch: function (ref) {
fetch(ref) {
return this.map[ref.toString()];
},
fetchIfRef: function (obj) {
fetchIfRef(obj) {
if (!isRef(obj)) {
return obj;
}
Expand All @@ -56,7 +56,7 @@ describe('annotation', function() {
obj: params.startObjId || 0,
};
return {
createObjId: function () {
createObjId() {
return uniquePrefix + (++idCounters.obj);
},
};
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('annotation', function() {
});

it('should set and get flags', function() {
var annotation = new Annotation({ dict: dict, ref: ref });
var annotation = new Annotation({ dict, ref, });
annotation.setFlags(13);

expect(annotation.hasFlag(AnnotationFlag.INVISIBLE)).toEqual(true);
Expand All @@ -163,63 +163,63 @@ describe('annotation', function() {
});

it('should be viewable and not printable by default', function() {
var annotation = new Annotation({ dict: dict, ref: ref });
var annotation = new Annotation({ dict, ref, });

expect(annotation.viewable).toEqual(true);
expect(annotation.printable).toEqual(false);
});

it('should set and get a valid rectangle', function() {
var annotation = new Annotation({ dict: dict, ref: ref });
var annotation = new Annotation({ dict, ref, });
annotation.setRectangle([117, 694, 164.298, 720]);

expect(annotation.rectangle).toEqual([117, 694, 164.298, 720]);
});

it('should not set and get an invalid rectangle', function() {
var annotation = new Annotation({ dict: dict, ref: ref });
var annotation = new Annotation({ dict, ref, });
annotation.setRectangle([117, 694, 164.298]);

expect(annotation.rectangle).toEqual([0, 0, 0, 0]);
});

it('should reject a color if it is not an array', function() {
var annotation = new Annotation({ dict: dict, ref: ref });
var annotation = new Annotation({ dict, ref, });
annotation.setColor('red');

expect(annotation.color).toEqual(new Uint8Array([0, 0, 0]));
});

it('should set and get a transparent color', function() {
var annotation = new Annotation({ dict: dict, ref: ref });
var annotation = new Annotation({ dict, ref, });
annotation.setColor([]);

expect(annotation.color).toEqual(null);
});

it('should set and get a grayscale color', function() {
var annotation = new Annotation({ dict: dict, ref: ref });
var annotation = new Annotation({ dict, ref, });
annotation.setColor([0.4]);

expect(annotation.color).toEqual(new Uint8Array([102, 102, 102]));
});

it('should set and get an RGB color', function() {
var annotation = new Annotation({ dict: dict, ref: ref });
var annotation = new Annotation({ dict, ref, });
annotation.setColor([0, 0, 1]);

expect(annotation.color).toEqual(new Uint8Array([0, 0, 255]));
});

it('should set and get a CMYK color', function() {
var annotation = new Annotation({ dict: dict, ref: ref });
var annotation = new Annotation({ dict, ref, });
annotation.setColor([0.1, 0.92, 0.84, 0.02]);

expect(annotation.color).toEqual(new Uint8Array([233, 59, 47]));
});

it('should not set and get an invalid color', function() {
var annotation = new Annotation({ dict: dict, ref: ref });
var annotation = new Annotation({ dict, ref, });
annotation.setColor([0.4, 0.6]);

expect(annotation.color).toEqual(new Uint8Array([0, 0, 0]));
Expand Down
18 changes: 9 additions & 9 deletions test/unit/api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ describe('api', function() {
var url = new URL('../pdfs/pr6531_2.pdf', window.location).href;

var passwordNeededLoadingTask = PDFJS.getDocument({
url: url, password: '',
url, password: '',
});
var result1 = passwordNeededLoadingTask.promise.then(function () {
done.fail('shall fail with no password');
Expand All @@ -228,7 +228,7 @@ describe('api', function() {
});

var passwordIncorrectLoadingTask = PDFJS.getDocument({
url: url, password: 'qwerty',
url, password: 'qwerty',
});
var result2 = passwordIncorrectLoadingTask.promise.then(function () {
done.fail('shall fail with wrong password');
Expand All @@ -240,7 +240,7 @@ describe('api', function() {
});

var passwordAcceptedLoadingTask = PDFJS.getDocument({
url: url, password: 'asdfasdf',
url, password: 'asdfasdf',
});

var result3 = passwordAcceptedLoadingTask.promise.then(function (data) {
Expand All @@ -259,7 +259,7 @@ describe('api', function() {
var url = new URL('../pdfs/issue3371.pdf', window.location).href;
var passwordNeededLoadingTask = PDFJS.getDocument(url);
var passwordIncorrectLoadingTask = PDFJS.getDocument({
url: url, password: 'qwerty',
url, password: 'qwerty',
});

passwordNeededLoadingTask.onPassword = function (callback, reason) {
Expand Down Expand Up @@ -342,7 +342,7 @@ describe('api', function() {
});
it('worker created and can be used in getDocument', function (done) {
var worker = new PDFJS.PDFWorker('test1');
var loadingTask = PDFJS.getDocument({url: basicApiUrl, worker: worker});
var loadingTask = PDFJS.getDocument({ url: basicApiUrl, worker, });
loadingTask.promise.then(function () {
var docWorker = loadingTask._worker;
expect(!!docWorker).toEqual(false);
Expand Down Expand Up @@ -893,7 +893,7 @@ describe('api', function() {
});

var docBaseUrlLoadingTask = PDFJS.getDocument({
url: url,
url,
docBaseUrl: 'http://www.example.com/test/pdfs/qwerty.pdf',
});
var docBaseUrlPromise = docBaseUrlLoadingTask.promise.then(
Expand All @@ -904,7 +904,7 @@ describe('api', function() {
});

var invalidDocBaseUrlLoadingTask = PDFJS.getDocument({
url: url,
url,
docBaseUrl: 'qwerty.pdf',
});
var invalidDocBaseUrlPromise = invalidDocBaseUrlLoadingTask.promise.then(
Expand Down Expand Up @@ -1001,7 +1001,7 @@ describe('api', function() {

var renderTask = page.render({
canvasContext: canvasAndCtx.context,
viewport: viewport,
viewport,
});
renderTask.cancel();

Expand Down Expand Up @@ -1041,7 +1041,7 @@ describe('api', function() {
viewport.height);
return page.render({
canvasContext: canvasAndCtx.context,
viewport: viewport,
viewport,
}).then(function() {
var data = canvasAndCtx.canvas.toDataURL();
CanvasFactory.destroy(canvasAndCtx);
Expand Down
Loading

0 comments on commit d920710

Please sign in to comment.