Skip to content

Commit

Permalink
fix: Apply ESLint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ExE-Boss committed Mar 7, 2019
1 parent 4bc2ba6 commit 085b6c5
Show file tree
Hide file tree
Showing 23 changed files with 98 additions and 99 deletions.
10 changes: 5 additions & 5 deletions components/prism-abap.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/prism-cil.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ Prism.languages.cil = {
'number': /\b-?(?:0x[0-9a-fA-F]+|[0-9]+)(?:\.[0-9a-fA-F]+)?\b/i,

'punctuation': /[{}[\];(),:=]|IL_[0-9A-Za-z]+/
}
};
8 changes: 4 additions & 4 deletions components/prism-coffeescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

// Ignore comments starting with { to privilege string interpolation highlighting
var comment = /#(?!\{).+/,
interpolation = {
pattern: /#\{[^}]+\}/,
alias: 'variable'
};
interpolation = {
pattern: /#\{[^}]+\}/,
alias: 'variable'
};

Prism.languages.coffeescript = Prism.languages.extend('javascript', {
'comment': comment,
Expand Down
28 changes: 14 additions & 14 deletions components/prism-core.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global WorkerGlobalScope */
var _self = (typeof window !== 'undefined')
? window // if in browser
: (
(typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
: ((typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
? self // if in worker
: {} // if in node js
);
Expand Down Expand Up @@ -152,7 +152,7 @@ var _ = {
callback.call(o, i, o[i], type || i);

var property = o[i],
propertyType = _.util.type(property);
propertyType = _.util.type(property);

if (propertyType === 'Object' && !visited[objId(property)]) {
visited[objId(property)] = true;
Expand Down Expand Up @@ -182,7 +182,7 @@ var _ = {

var elements = env.elements || container.querySelectorAll(env.selector);

for (var i=0, element; element = elements[i++];) {
for (var i=0, element; (element = elements[i++]);) {
_.highlightElement(element, async === true, env.callback);
}
},
Expand Down Expand Up @@ -231,7 +231,7 @@ var _ = {
_.hooks.run('after-highlight', env);
_.hooks.run('complete', env);
callback && callback.call(env.element);
}
};

_.hooks.run('before-sanity-check', env);

Expand Down Expand Up @@ -328,9 +328,9 @@ var _ = {
}

var from = match.index + (lookbehind ? match[1].length : 0),
to = match.index + match[0].length,
k = i,
p = pos;
to = match.index + match[0].length,
k = i,
p = pos;

for (var len = strarr.length; k < len && (p < to || (!strarr[k].type && !strarr[k - 1].greedy)); ++k) {
p += strarr[k].length;
Expand Down Expand Up @@ -370,10 +370,10 @@ var _ = {
}

var from = match.index + lookbehindLength,
match = match[0].slice(lookbehindLength),
to = from + match.length,
before = str.slice(0, from),
after = str.slice(to);
match = match[0].slice(lookbehindLength),
to = from + match.length,
before = str.slice(0, from),
after = str.slice(to);

var args = [i, delNum];

Expand Down Expand Up @@ -439,7 +439,7 @@ var _ = {
return;
}

for (var i=0, callback; callback = callbacks[i++];) {
for (var i=0, callback; (callback = callbacks[i++]);) {
callback(env);
}
}
Expand Down Expand Up @@ -549,5 +549,5 @@ if (typeof module !== 'undefined' && module.exports) {

// hack for components to work correctly in node.js
if (typeof global !== 'undefined') {
global.Prism = Prism;
global['Prism'] = Prism;
}
2 changes: 1 addition & 1 deletion components/prism-haml.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
},
rest: Prism.languages[filter.language]
}
}
};
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/prism-javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Prism.languages.javascript = Prism.languages.extend('clike', {
'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/
});

Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/
Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/;

Prism.languages.insertBefore('javascript', 'keyword', {
'regex': {
Expand Down
2 changes: 1 addition & 1 deletion components/prism-json5.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function (Prism) {

var string = /("|')(?:\\(?:\r\n?|\n|.)|(?!\1)[^\\\r\n])*\1/
var string = /("|')(?:\\(?:\r\n?|\n|.)|(?!\1)[^\\\r\n])*\1/;

Prism.languages.json5 = Prism.languages.extend('json', {
'property': [
Expand Down
2 changes: 1 addition & 1 deletion components/prism-jsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var walkTokens = function (tokens) {
openedTags[openedTags.length - 1].openedBraces--;

} else {
notTagNorBrace = true
notTagNorBrace = true;
}
}
if (notTagNorBrace || typeof token === 'string') {
Expand Down
12 changes: 6 additions & 6 deletions components/prism-latex.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(function(Prism) {
var funcPattern = /\\(?:[^a-z()[\]]|[a-z*]+)/i,
insideEqu = {
'equation-command': {
pattern: funcPattern,
alias: 'regex'
}
};
insideEqu = {
'equation-command': {
pattern: funcPattern,
alias: 'regex'
}
};

Prism.languages.latex = {
'comment': /%.*/m,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-pug.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
},
rest: Prism.languages[filter.language]
}
}
};
}
}

Expand Down
6 changes: 3 additions & 3 deletions components/prism-regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
pattern: /\\[\\(){}[\]^$+*?|.]/,
alias: 'escape'
};
var escape = /\\(?:x[\da-fA-F]{2}|u[\da-fA-F]{4}|u\{[\da-fA-F]+\}|c[a-zA-Z]|0[0-7]{0,2}|[123][0-7]{2}|.)/
var charClass = /\\[wsd]|\.|\\p{[^{}]+}/i
var escape = /\\(?:x[\da-fA-F]{2}|u[\da-fA-F]{4}|u\{[\da-fA-F]+\}|c[a-zA-Z]|0[0-7]{0,2}|[123][0-7]{2}|.)/;
var charClass = /\\[wsd]|\.|\\p{[^{}]+}/i;

var rangeChar = '(?:[^\\\\-]|' + escape.source + ')';
var range = RegExp(rangeChar + '-' + rangeChar);
Expand Down Expand Up @@ -94,4 +94,4 @@
}
});

}(Prism))
}(Prism));
2 changes: 1 addition & 1 deletion components/prism-xquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
openedTags[openedTags.length - 1].openedBraces--;

} else if (token.type !== 'comment') {
notTagNorBrace = true
notTagNorBrace = true;
}
}
if (notTagNorBrace || typeof token === 'string') {
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
var getLanguagePath = function (lang) {
return config.languages_path +
'prism-' + lang
+ (config.use_minified ? '.min' : '') + '.js'
+ (config.use_minified ? '.min' : '') + '.js';
};

/**
Expand Down
2 changes: 1 addition & 1 deletion plugins/custom-class/prism-custom-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Prism.plugins.customClass = {
prefix: function prefix(string) {
options.prefixString = string;
}
}
};

Prism.hooks.add('wrap', function (env) {
if (!options.classMap && !options.prefixString) {
Expand Down
4 changes: 2 additions & 2 deletions plugins/jsonp-highlight/prism-jsonp-highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
*/
function getAdapter(adapter) {
if (typeof adapter === "function") {
for (var i = 0, item; item = adapters[i++];) {
for (var i = 0, item; (item = adapters[i++]);) {
if (item.adapter.valueOf() === adapter.valueOf()) {
return item.adapter;
}
}
}
else if (typeof adapter === "string") {
for (var i = 0, item; item = adapters[i++];) {
for (var i = 0, item; (item = adapters[i++]);) {
if (item.name === adapter) {
return item.adapter;
}
Expand Down
26 changes: 13 additions & 13 deletions plugins/line-highlight/prism-line-highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function $$(expr, con) {
}

function hasClass(element, className) {
className = " " + className + " ";
return (" " + element.className + " ").replace(/[\n\t]/g, " ").indexOf(className) > -1
className = " " + className + " ";
return (" " + element.className + " ").replace(/[\n\t]/g, " ").indexOf(className) > -1;
}

// Some browsers round the line-height, others don't.
Expand All @@ -32,24 +32,24 @@ var isLineHeightRounded = (function() {
document.body.removeChild(d);
}
return res;
}
};
}());

function highlightLines(pre, lines, classes) {
lines = typeof lines === 'string' ? lines : pre.getAttribute('data-line');

var ranges = lines.replace(/\s+/g, '').split(','),
offset = +pre.getAttribute('data-line-offset') || 0;
offset = +pre.getAttribute('data-line-offset') || 0;

var parseMethod = isLineHeightRounded() ? parseInt : parseFloat;
var lineHeight = parseMethod(getComputedStyle(pre).lineHeight);
var hasLineNumbers = hasClass(pre, 'line-numbers');

for (var i=0, currentRange; currentRange = ranges[i++];) {
for (var i=0, currentRange; (currentRange = ranges[i++]);) {
var range = currentRange.split('-');

var start = +range[0],
end = +range[1] || start;
end = +range[1] || start;

var line = pre.querySelector('.line-highlight[data-range="' + currentRange + '"]') || document.createElement('div');

Expand All @@ -61,11 +61,11 @@ function highlightLines(pre, lines, classes) {
if(hasLineNumbers && Prism.plugins.lineNumbers) {
var startNode = Prism.plugins.lineNumbers.getLine(pre, start);
var endNode = Prism.plugins.lineNumbers.getLine(pre, end);

if (startNode) {
line.style.top = startNode.offsetTop + 'px';
}

if (endNode) {
line.style.height = (endNode.offsetTop - startNode.offsetTop) + endNode.offsetHeight + 'px';
}
Expand All @@ -75,7 +75,7 @@ function highlightLines(pre, lines, classes) {
if(end > start) {
line.setAttribute('data-end', end);
}

line.style.top = (start - offset - 1) * lineHeight + 'px';

line.textContent = new Array(end - start + 2).join(' \n');
Expand Down Expand Up @@ -106,7 +106,7 @@ function applyHash() {
}

var id = hash.slice(0, hash.lastIndexOf('.')),
pre = document.getElementById(id);
pre = document.getElementById(id);

if (!pre) {
return;
Expand All @@ -130,9 +130,9 @@ Prism.hooks.add('before-sanity-check', function(env) {
if (!pre || !lines || !/pre/i.test(pre.nodeName)) {
return;
}

/*
* Cleanup for other plugins (e.g. autoloader).
* Cleanup for other plugins (e.g. autoloader).
*
* Sometimes <code> blocks are highlighted multiple times. It is necessary
* to cleanup any left-over tags, because the whitespace inside of the <div>
Expand Down
10 changes: 5 additions & 5 deletions plugins/normalize-whitespace/prism-normalize-whitespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var assign = Object.assign || function (obj1, obj2) {
obj1[name] = obj2[name];
}
return obj1;
}
};

function NormalizeWhitespace(defaults) {
this.defaults = assign({}, defaults);
Expand Down Expand Up @@ -94,7 +94,7 @@ NormalizeWhitespace.prototype = {
continue;

var line = lines[i].split(/(\s+)/g),
len = 0;
len = 0;

for (var j = 0; j < line.length; ++j) {
var tl = tabLen(line[j]);
Expand Down Expand Up @@ -154,9 +154,9 @@ Prism.hooks.add('before-sanity-check', function (env) {
return;

var children = pre.childNodes,
before = '',
after = '',
codeFound = false;
before = '',
after = '',
codeFound = false;

// Move surrounding whitespace from the <pre> tag into the <code> tag
for (var i = 0; i < children.length; ++i) {
Expand Down
4 changes: 2 additions & 2 deletions plugins/previewers/prism-previewers.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@
var previewers = token.getAttribute('data-previewers');
return (previewers || '').split(/\s+/).indexOf(this._type) === -1;
}
} while(token = token.parentNode);
} while((token = token.parentNode));
return false;
};

Expand All @@ -570,7 +570,7 @@
if (tokenRegexp.test(token.className) && this._clsRegexp.test(token.className)) {
break;
}
} while(token = token.parentNode);
} while((token = token.parentNode));

if (token && token !== this._token) {
this._token = token;
Expand Down
Loading

0 comments on commit 085b6c5

Please sign in to comment.