Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jslint shows errors in pdf.js #3567

Closed
rahmanih opened this issue Aug 13, 2013 · 2 comments
Closed

jslint shows errors in pdf.js #3567

rahmanih opened this issue Aug 13, 2013 · 2 comments

Comments

@rahmanih
Copy link

this is a followup of the Issue #3500.

the pdf.js is not JSlint freindly it generates the following errors:

rahmanih@kentoon:~/git_repos/pdf.js$ jslint --color build/generic/web/*.js

build/generic/web/compatibility.js
#1 'PDFJS' was used before it was defined.
if (typeof PDFJS === 'undefined') { // Line 23, Pos 12
#2 Expected '(' at column 5, not column 3.
(typeof window !== 'undefined' ? window : this).PDFJS = {}; // Line 24, Pos 3
#3 'window' was used before it was defined.
(typeof window !== 'undefined' ? window : this).PDFJS = {}; // Line 24, Pos 11
#4 Cannot read property 'arity' of undefined
// Line 24, Pos 49

build/generic/web/debugger.js
#1 Expected 'var' at column 9, not column 3.
var fonts; // Line 22, Pos 3
#2 Expected 'var' at column 9, not column 3.
var panelWidth = 300; // Line 23, Pos 3
#3 Combine this with the previous 'var' statement.
var panelWidth = 300; // Line 23, Pos 7
#4 Expected 'var' at column 9, not column 3.
var active = false; // Line 24, Pos 3
#5 Combine this with the previous 'var' statement.
var active = false; // Line 24, Pos 7
#6 Expected 'var' at column 9, not column 3.
var fontAttribute = 'data-font-name'; // Line 25, Pos 3
#7 Combine this with the previous 'var' statement.
var fontAttribute = 'data-font-name'; // Line 25, Pos 7
#8 Expected 'function' at column 9, not column 3.
function removeSelection() { // Line 26, Pos 3
#9 Expected 'var' at column 13, not column 5.
var divs = document.querySelectorAll('div[' + fontAttribute + ']'); // Line 27, Pos 5
#10 'document' was used before it was defined.

var divs = document.querySelectorAll('div[' + fontAttribute + ']'); // Line 27, Pos 16

#11 Expected 'for' at column 13, not column 5.

for (var i = 0, ii = divs.length; i < ii; ++i) { // Line 28, Pos 5

#12 Move 'var' declarations to the top of the function.

for (var i = 0, ii = divs.length; i < ii; ++i) { // Line 28, Pos 10

#13 Stopping. (5% scanned).

 // Line 28, Pos 10

build/generic/web/l10n.js
#1 'document' was used before it was defined.
document.webL10n = (function(window, document, undefined) { // Line 31, Pos 1
#2 Expected exactly one space between 'function' and '('.
document.webL10n = (function(window, document, undefined) { // Line 31, Pos 29
#3 Expected 'var' at column 5, not column 3.
var gL10nData = {}; // Line 32, Pos 3
#4 Expected 'var' at column 5, not column 3.
var gTextData = ''; // Line 33, Pos 3
#5 Combine this with the previous 'var' statement.
var gTextData = ''; // Line 33, Pos 7
#6 Expected 'var' at column 5, not column 3.
var gTextProp = 'textContent'; // Line 34, Pos 3
#7 Combine this with the previous 'var' statement.
var gTextProp = 'textContent'; // Line 34, Pos 7
#8 Expected 'var' at column 5, not column 3.
var gLanguage = ''; // Line 35, Pos 3
#9 Combine this with the previous 'var' statement.
var gLanguage = ''; // Line 35, Pos 7
#10 Expected 'var' at column 5, not column 3.

var gMacros = {}; // Line 36, Pos 3

#11 Combine this with the previous 'var' statement.

var gMacros = {}; // Line 36, Pos 7

#12 Expected 'var' at column 5, not column 3.

var gReadyState = 'loading'; // Line 37, Pos 3

#13 Combine this with the previous 'var' statement.

var gReadyState = 'loading'; // Line 37, Pos 7

#14 Expected 'var' at column 5, not column 3.

var gAsyncResourceLoading = true; // Line 40, Pos 3

#15 Combine this with the previous 'var' statement.

var gAsyncResourceLoading = true; // Line 40, Pos 7

#16 Expected 'function' at column 5, not column 3.

function consoleWarn(message) { // Line 43, Pos 3

#17 Expected 'console' at column 9, not column 5.

console.log('[l10n] ' + message); // Line 44, Pos 5

#18 Expected '}' at column 5, not column 3.

}; // Line 45, Pos 3

#19 Missing space between '}' and ';'.

}; // Line 45, Pos 4

#20 Unexpected ';'.

}; // Line 45, Pos 4

#21 Expected 'function' at column 5, not column 3.

function getL10nResourceLinks() { // Line 54, Pos 3

#22 Expected 'return' at column 9, not column 5.

return document.querySelectorAll('link[type="application/l10n"]'); // Line 55, Pos 5

#23 Expected '}' at column 5, not column 3.

} // Line 56, Pos 3

#24 Expected 'function' at column 5, not column 3.

function getTranslatableChildren(element) { // Line 58, Pos 3

#25 Expected 'return' at column 9, not column 5.

return element ? element.querySelectorAll('*[data-l10n-id]') : []; // Line 59, Pos 5

#26 Expected '}' at column 5, not column 3.

} // Line 60, Pos 3

#27 Expected 'function' at column 5, not column 3.

function getL10nAttributes(element) { // Line 62, Pos 3

#28 Expected 'if' at column 9, not column 5.

if (!element) // Line 63, Pos 5

#29 Expected exactly one space between ')' and 'return'.

return {}; // Line 64, Pos 7

#30 Expected '{' and instead saw 'return'.

return {}; // Line 64, Pos 7

#31 Expected 'return' at column 9, not column 7.

return {}; // Line 64, Pos 7

#32 Expected 'var' at column 9, not column 5.

var l10nId = element.getAttribute('data-l10n-id'); // Line 66, Pos 5

#33 Expected 'var' at column 9, not column 5.

var l10nArgs = element.getAttribute('data-l10n-args'); // Line 67, Pos 5

#34 Combine this with the previous 'var' statement.

var l10nArgs = element.getAttribute('data-l10n-args'); // Line 67, Pos 9

#35 Expected 'var' at column 9, not column 5.

var args = {}; // Line 68, Pos 5

#36 Combine this with the previous 'var' statement.

var args = {}; // Line 68, Pos 9

#37 Expected 'if' at column 9, not column 5.

if (l10nArgs) { // Line 69, Pos 5

#38 Expected 'try' at column 13, not column 7.

try { // Line 70, Pos 7

#39 Expected 'args' at column 17, not column 9.

args = JSON.parse(l10nArgs); // Line 71, Pos 9

#40 Expected '}' at column 13, not column 7.

} catch (e) { // Line 72, Pos 7

#41 Expected 'consoleWarn' at column 17, not column 9.

consoleWarn('could not parse arguments for #' + l10nId); // Line 73, Pos 9

#42 Expected '}' at column 13, not column 7.

} // Line 74, Pos 7

#43 Expected '}' at column 9, not column 5.

} // Line 75, Pos 5

#44 Expected 'return' at column 9, not column 5.

return { id: l10nId, args: args }; // Line 76, Pos 5

#45 Expected '}' at column 5, not column 3.

} // Line 77, Pos 3

#46 Expected 'function' at column 5, not column 3.

function fireL10nReadyEvent(lang) { // Line 79, Pos 3

#47 Expected 'var' at column 9, not column 5.

var evtObject = document.createEvent('Event'); // Line 80, Pos 5

#48 Expected 'evtObject' at column 9, not column 5.

evtObject.initEvent('localized', false, false); // Line 81, Pos 5

#49 Expected 'evtObject' at column 9, not column 5.

evtObject.language = lang; // Line 82, Pos 5

#50 Expected 'window' at column 9, not column 5.

window.dispatchEvent(evtObject); // Line 83, Pos 5

#51 Too many errors. (8% scanned).

 // Line 83, Pos 5

build/generic/web/viewer.js
#1 Expected 'INITIAL' at column 9, not column 3.
INITIAL: 0, // Line 38, Pos 3
#2 Expected 'RUNNING' at column 9, not column 3.
RUNNING: 1, // Line 39, Pos 3
#3 Expected 'PAUSED' at column 9, not column 3.
PAUSED: 2, // Line 40, Pos 3
#4 Expected 'FINISHED' at column 9, not column 3.
FINISHED: 3 // Line 41, Pos 3
#5 Expected '}' at column 5, not column 1.
}; // Line 42, Pos 1
#6 Expected 'FIND_FOUND' at column 9, not column 3.
FIND_FOUND: 0, // Line 44, Pos 3
#7 Expected 'FIND_NOTFOUND' at column 9, not column 3.
FIND_NOTFOUND: 1, // Line 45, Pos 3
#8 Expected 'FIND_WRAPPED' at column 9, not column 3.
FIND_WRAPPED: 2, // Line 46, Pos 3
#9 Expected 'FIND_PENDING' at column 9, not column 3.
FIND_PENDING: 3 // Line 47, Pos 3
#10 Expected '}' at column 5, not column 1.

}; // Line 48, Pos 1

#11 'PDFJS' was used before it was defined.

PDFJS.imageResourcesPath = './images/'; // Line 50, Pos 1

#12 Expected 'PDFJS' at column 1, not column 3.

PDFJS.workerSrc = '../build/pdf.js'; // Line 51, Pos 3

#13 'document' was used before it was defined.

var mozL10n = document.mozL10n || document.webL10n; // Line 53, Pos 15

#14 Expected 'var' at column 9, not column 3.

var prefixes = ['ms', 'Moz', 'Webkit', 'O']; // Line 63, Pos 3

#15 Expected 'var' at column 9, not column 3.

var _cache = { }; // Line 64, Pos 3

#16 Unexpected dangling '_' in '_cache'.

var _cache = { }; // Line 64, Pos 7

#17 Combine this with the previous 'var' statement.

var _cache = { }; // Line 64, Pos 7

#18 Expected 'function' at column 9, not column 3.

function CustomStyle() { // Line 66, Pos 3

#19 Expected '}' at column 9, not column 3.

} // Line 67, Pos 3

#20 Expected 'CustomStyle' at column 9, not column 3.

CustomStyle.getProp = function get(propName, element) { // Line 69, Pos 3

#21 Expected 'if' at column 13, not column 5.

if (arguments.length == 1 && typeof _cache[propName] == 'string') { // Line 71, Pos 5

#22 Expected '===' and instead saw '=='.

if (arguments.length == 1 && typeof _cache[propName] == 'string') { // Line 71, Pos 26

#23 Unexpected dangling '_' in '_cache'.

if (arguments.length == 1 && typeof _cache[propName] == 'string') { // Line 71, Pos 41

#24 Expected '===' and instead saw '=='.

if (arguments.length == 1 && typeof _cache[propName] == 'string') { // Line 71, Pos 58

#25 Expected 'return' at column 17, not column 7.

return _cache[propName]; // Line 72, Pos 7

#26 Unexpected dangling '_' in '_cache'.

return _cache[propName]; // Line 72, Pos 14

#27 Expected '}' at column 13, not column 5.

} // Line 73, Pos 5

#28 Expected 'element' at column 13, not column 5.

element = element || document.documentElement; // Line 75, Pos 5

#29 Expected 'var' at column 13, not column 5.

var style = element.style, prefixed, uPropName; // Line 76, Pos 5

#30 Expected 'if' at column 13, not column 5.

if (typeof style[propName] == 'string') { // Line 79, Pos 5

#31 Expected '===' and instead saw '=='.

if (typeof style[propName] == 'string') { // Line 79, Pos 32

#32 Expected 'return' at column 17, not column 7.

return (_cache[propName] = propName); // Line 80, Pos 7

#33 Unexpected dangling '_' in '_cache'.

return (_cache[propName] = propName); // Line 80, Pos 15

#34 Expected '}' at column 13, not column 5.

} // Line 81, Pos 5

#35 Expected 'uPropName' at column 13, not column 5.

uPropName = propName.charAt(0).toUpperCase() + propName.slice(1); // Line 84, Pos 5

#36 Expected 'for' at column 13, not column 5.

for (var i = 0, l = prefixes.length; i < l; i++) { // Line 87, Pos 5

#37 Move 'var' declarations to the top of the function.

for (var i = 0, l = prefixes.length; i < l; i++) { // Line 87, Pos 10

#38 Stopping. (2% scanned).

 // Line 87, Pos 10

is there any way to fix those issues?

thanks and regards
Haithem

@Snuffleupagus
Copy link
Collaborator

PDF.js uses JSHint as a lint tool, hence that is the only one that is supported out of the box.
If you want to use another lint tool, you need to configure it yourself to make it work properly. For JSHint, the configuration options are specified in: https://github.com/mozilla/pdf.js/blob/master/.jshintrc.

I believe that this question is unfortunately out of scope in the PDF.js project.

@rahmanih
Copy link
Author

thanks for the answer and sorry for any disturbance I caused.

closing this bug.

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

No branches or pull requests

2 participants