From 80de4f6538cf8f22378b86172af474127f4a1c1b Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Sat, 30 Mar 2019 22:22:54 +0100 Subject: [PATCH] Reverted changes --- .eslintrc | 31 +++++++++++++++++-------------- components/prism-abap.js | 6 +++--- components/prism-aspnet.js | 2 +- components/prism-autoit.js | 24 ++++++++++++------------ components/prism-core.js | 12 ++++++------ components/prism-kotlin.js | 2 +- components/prism-less.js | 2 +- components/prism-parser.js | 2 +- components/prism-parser.min.js | 2 +- components/prism-smarty.js | 4 ++-- components/prism-toml.js | 4 ++-- components/prism-vbnet.js | 2 +- components/prism-xeora.js | 2 +- components/prism-xquery.js | 2 +- prism.js | 12 ++++++------ 15 files changed, 56 insertions(+), 53 deletions(-) diff --git a/.eslintrc b/.eslintrc index 44421d0b5f..a0cec0228a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -12,6 +12,10 @@ }, "root": true, "rules": { + "comma-dangle": [ + "warn", + "only-multiline", + ], // "indent": [ // "error", // "tab", @@ -37,26 +41,19 @@ } ], "no-useless-escape": "off", +// "quotes": [ +// "warn", +// "single", +// { +// "avoidEscape": true, +// } +// ], "semi": [ "error", "always", ], }, "overrides": [ - { - "files": [ - "components/*.js", - ], - "rules": { - "quotes": [ - "warn", - "single", - { - "avoidEscape": true, - } - ], - }, - }, { "files": [ "components/prism-core.js", @@ -90,6 +87,12 @@ "parserOptions": { "ecmaVersion": 2015, }, + "rules": { + "comma-dangle": [ + "error", + "always-multiline", + ], + }, }, { "files": [ diff --git a/components/prism-abap.js b/components/prism-abap.js index 56b2c13076..049dbe7da1 100644 --- a/components/prism-abap.js +++ b/components/prism-abap.js @@ -32,17 +32,17 @@ Prism.languages.abap = { pattern: /(\s)&&?(?=\s)/, lookbehind: true, /* The official editor highlights */ - alias: 'keyword' + alias: "keyword" }, 'token-operator' : [{ /* Special operators used to access structure components, class methods/attributes, etc. */ pattern: /(\w)(?:->?|=>|[~|{}])(?=\w)/, lookbehind: true, - alias: 'punctuation' + alias: "punctuation" }, { /* Special tokens used do delimit string templates */ pattern: /[|{}]/, - alias: 'punctuation' + alias: "punctuation" }], 'punctuation' : /[,.:()]/ }; \ No newline at end of file diff --git a/components/prism-aspnet.js b/components/prism-aspnet.js index 3c7f4a992b..816063494f 100644 --- a/components/prism-aspnet.js +++ b/components/prism-aspnet.js @@ -20,7 +20,7 @@ Prism.languages.aspnet.tag.pattern = /<(?!%)\/?[^\s>\/]+(?:\s+[^\s>\/=]+(?:=(?:( // match directives of attribute value foo="<% Bar %>" Prism.languages.insertBefore('inside', 'punctuation', { 'directive tag': Prism.languages.aspnet['directive tag'] -}, Prism.languages.aspnet.tag.inside['attr-value']); +}, Prism.languages.aspnet.tag.inside["attr-value"]); Prism.languages.insertBefore('aspnet', 'comment', { 'asp comment': /<%--[\s\S]*?--%>/ diff --git a/components/prism-autoit.js b/components/prism-autoit.js index 3f1ae87b37..9f821c7360 100644 --- a/components/prism-autoit.js +++ b/components/prism-autoit.js @@ -1,5 +1,5 @@ Prism.languages.autoit = { - 'comment': [ + "comment": [ /;.*/, { // The multi-line comments delimiters can actually be commented out with ";" @@ -7,28 +7,28 @@ Prism.languages.autoit = { lookbehind: true } ], - 'url': { + "url": { pattern: /(^\s*#include\s+)(?:<[^\r\n>]+>|"[^\r\n"]+")/m, lookbehind: true }, - 'string': { + "string": { pattern: /(["'])(?:\1\1|(?!\1)[^\r\n])*\1/, greedy: true, inside: { - 'variable': /([%$@])\w+\1/ + "variable": /([%$@])\w+\1/ } }, - 'directive': { + "directive": { pattern: /(^\s*)#\w+/m, lookbehind: true, alias: 'keyword' }, - 'function': /\b\w+(?=\()/, + "function": /\b\w+(?=\()/, // Variables and macros - 'variable': /[$@]\w+/, - 'keyword': /\b(?:Case|Const|Continue(?:Case|Loop)|Default|Dim|Do|Else(?:If)?|End(?:Func|If|Select|Switch|With)|Enum|Exit(?:Loop)?|For|Func|Global|If|In|Local|Next|Null|ReDim|Select|Static|Step|Switch|Then|To|Until|Volatile|WEnd|While|With)\b/i, - 'number': /\b(?:0x[\da-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)\b/i, - 'boolean': /\b(?:True|False)\b/i, - 'operator': /<[=>]?|[-+*\/=&>]=?|[?^]|\b(?:And|Or|Not)\b/i, - 'punctuation': /[\[\]().,:]/ + "variable": /[$@]\w+/, + "keyword": /\b(?:Case|Const|Continue(?:Case|Loop)|Default|Dim|Do|Else(?:If)?|End(?:Func|If|Select|Switch|With)|Enum|Exit(?:Loop)?|For|Func|Global|If|In|Local|Next|Null|ReDim|Select|Static|Step|Switch|Then|To|Until|Volatile|WEnd|While|With)\b/i, + "number": /\b(?:0x[\da-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)\b/i, + "boolean": /\b(?:True|False)\b/i, + "operator": /<[=>]?|[-+*\/=&>]=?|[?^]|\b(?:And|Or|Not)\b/i, + "punctuation": /[\[\]().,:]/ }; \ No newline at end of file diff --git a/components/prism-core.js b/components/prism-core.js index 6e87539ff9..37f0f28de0 100644 --- a/components/prism-core.js +++ b/components/prism-core.js @@ -177,7 +177,7 @@ var _ = { selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code' }; - _.hooks.run('before-highlightall', env); + _.hooks.run("before-highlightall", env); var elements = env.elements || container.querySelectorAll(env.selector); @@ -287,7 +287,7 @@ var _ = { } var patterns = grammar[token]; - patterns = (_.util.type(patterns) === 'Array') ? patterns : [patterns]; + patterns = (_.util.type(patterns) === "Array") ? patterns : [patterns]; for (var j = 0; j < patterns.length; ++j) { var pattern = patterns[j], @@ -300,7 +300,7 @@ var _ = { if (greedy && !pattern.pattern.global) { // Without the global flag, lastIndex won't work var flags = pattern.pattern.toString().match(/[imuy]*$/)[0]; - pattern.pattern = RegExp(pattern.pattern.source, flags + 'g'); + pattern.pattern = RegExp(pattern.pattern.source, flags + "g"); } pattern = pattern.pattern || pattern; @@ -454,7 +454,7 @@ function Token(type, content, alias, matchedStr, greedy) { this.content = content; this.alias = alias; // Copy of the full string this token was created from - this.length = (matchedStr || '').length|0; + this.length = (matchedStr || "").length|0; this.greedy = !!greedy; } @@ -517,13 +517,13 @@ if (!_self.document) { } //Get current script and highlight -var script = document.currentScript || [].slice.call(document.getElementsByTagName('script')).pop(); +var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop(); if (script) { _.filename = script.src; if (!_.manual && !script.hasAttribute('data-manual')) { - if(document.readyState !== 'loading') { + if(document.readyState !== "loading") { if (window.requestAnimationFrame) { window.requestAnimationFrame(_.highlightAll); } else { diff --git a/components/prism-kotlin.js b/components/prism-kotlin.js index 73156e665e..08ba269c75 100644 --- a/components/prism-kotlin.js +++ b/components/prism-kotlin.js @@ -16,7 +16,7 @@ 'operator': /\+[+=]?|-[-=>]?|==?=?|!(?:!|==?)?|[\/*%<>]=?|[?:]:?|\.\.|&&|\|\||\b(?:and|inv|or|shl|shr|ushr|xor)\b/ }); - delete Prism.languages.kotlin['class-name']; + delete Prism.languages.kotlin["class-name"]; Prism.languages.insertBefore('kotlin', 'string', { 'raw-string': { diff --git a/components/prism-less.js b/components/prism-less.js index 5d3bb1a982..4762062db8 100644 --- a/components/prism-less.js +++ b/components/prism-less.js @@ -39,7 +39,7 @@ Prism.languages.insertBefore('less', 'property', { { pattern: /@[\w-]+\s*:/, inside: { - 'punctuation': /:/ + "punctuation": /:/ } }, diff --git a/components/prism-parser.js b/components/prism-parser.js index 6237dfaf88..c5cd3451f0 100644 --- a/components/prism-parser.js +++ b/components/prism-parser.js @@ -58,7 +58,7 @@ } }); - Prism.languages.insertBefore('inside', 'punctuation', { + parser = Prism.languages.insertBefore('inside', 'punctuation', { 'expression': parser.expression, 'keyword': parser.keyword, 'variable': parser.variable, diff --git a/components/prism-parser.min.js b/components/prism-parser.min.js index 886546994b..e7b91ccda0 100644 --- a/components/prism-parser.min.js +++ b/components/prism-parser.min.js @@ -1 +1 @@ -!function(e){var n=e.languages.parser=e.languages.extend("markup",{keyword:{pattern:/(^|[^^])(?:\^(?:case|eval|for|if|switch|throw)\b|@(?:BASE|CLASS|GET(?:_DEFAULT)?|OPTIONS|SET_DEFAULT|USE)\b)/,lookbehind:!0},variable:{pattern:/(^|[^^])\B\$(?:\w+|(?=[.{]))(?:(?:\.|::?)\w+)*(?:\.|::?)?/,lookbehind:!0,inside:{punctuation:/\.|:+/}},function:{pattern:/(^|[^^])\B[@^]\w+(?:(?:\.|::?)\w+)*(?:\.|::?)?/,lookbehind:!0,inside:{keyword:{pattern:/(^@)(?:GET_|SET_)/,lookbehind:!0},punctuation:/\.|:+/}},escape:{pattern:/\^(?:[$^;@()\[\]{}"':]|#[a-f\d]*)/i,alias:"builtin"},punctuation:/[\[\](){};]/});n=e.languages.insertBefore("parser","keyword",{"parser-comment":{pattern:/(\s)#.*/,lookbehind:!0,alias:"comment"},expression:{pattern:/(^|[^^])\((?:[^()]|\((?:[^()]|\((?:[^()])*\))*\))*\)/,greedy:!0,lookbehind:!0,inside:{string:{pattern:/(^|[^^])(["'])(?:(?!\2)[^^]|\^[\s\S])*\2/,lookbehind:!0},keyword:n.keyword,variable:n.variable,function:n.function,boolean:/\b(?:true|false)\b/,number:/\b(?:0x[a-f\d]+|\d+\.?\d*(?:e[+-]?\d+)?)\b/i,escape:n.escape,operator:/[~+*\/\\%]|!(?:\|\|?|=)?|&&?|\|\|?|==|<[<=]?|>[>=]?|-[fd]?|\b(?:def|eq|ge|gt|in|is|le|lt|ne)\b/,punctuation:n.punctuation}}}),e.languages.insertBefore("inside","punctuation",{expression:n.expression,keyword:n.keyword,variable:n.variable,function:n.function,escape:n.escape,"parser-punctuation":{pattern:n.punctuation,alias:"punctuation"}},n.tag.inside["attr-value"])}(Prism); \ No newline at end of file +!function(e){var n=e.languages.parser=e.languages.extend("markup",{keyword:{pattern:/(^|[^^])(?:\^(?:case|eval|for|if|switch|throw)\b|@(?:BASE|CLASS|GET(?:_DEFAULT)?|OPTIONS|SET_DEFAULT|USE)\b)/,lookbehind:!0},variable:{pattern:/(^|[^^])\B\$(?:\w+|(?=[.{]))(?:(?:\.|::?)\w+)*(?:\.|::?)?/,lookbehind:!0,inside:{punctuation:/\.|:+/}},function:{pattern:/(^|[^^])\B[@^]\w+(?:(?:\.|::?)\w+)*(?:\.|::?)?/,lookbehind:!0,inside:{keyword:{pattern:/(^@)(?:GET_|SET_)/,lookbehind:!0},punctuation:/\.|:+/}},escape:{pattern:/\^(?:[$^;@()\[\]{}"':]|#[a-f\d]*)/i,alias:"builtin"},punctuation:/[\[\](){};]/});n=e.languages.insertBefore("parser","keyword",{"parser-comment":{pattern:/(\s)#.*/,lookbehind:!0,alias:"comment"},expression:{pattern:/(^|[^^])\((?:[^()]|\((?:[^()]|\((?:[^()])*\))*\))*\)/,greedy:!0,lookbehind:!0,inside:{string:{pattern:/(^|[^^])(["'])(?:(?!\2)[^^]|\^[\s\S])*\2/,lookbehind:!0},keyword:n.keyword,variable:n.variable,function:n.function,boolean:/\b(?:true|false)\b/,number:/\b(?:0x[a-f\d]+|\d+\.?\d*(?:e[+-]?\d+)?)\b/i,escape:n.escape,operator:/[~+*\/\\%]|!(?:\|\|?|=)?|&&?|\|\|?|==|<[<=]?|>[>=]?|-[fd]?|\b(?:def|eq|ge|gt|in|is|le|lt|ne)\b/,punctuation:n.punctuation}}}),n=e.languages.insertBefore("inside","punctuation",{expression:n.expression,keyword:n.keyword,variable:n.variable,function:n.function,escape:n.escape,"parser-punctuation":{pattern:n.punctuation,alias:"punctuation"}},n.tag.inside["attr-value"])}(Prism); \ No newline at end of file diff --git a/components/prism-smarty.js b/components/prism-smarty.js index 4392ab2a10..10be1caa68 100644 --- a/components/prism-smarty.js +++ b/components/prism-smarty.js @@ -37,11 +37,11 @@ // Value is made optional because it may have already been tokenized pattern: /\w+\s*=\s*(?:(?!\d)\w+)?/, inside: { - 'variable': { + "variable": { pattern: /(=\s*)(?!\d)\w+/, lookbehind: true }, - 'operator': /=/ + "operator": /=/ } }, 'punctuation': [ diff --git a/components/prism-toml.js b/components/prism-toml.js index 587cea3340..200fbdd0c3 100644 --- a/components/prism-toml.js +++ b/components/prism-toml.js @@ -9,13 +9,13 @@ greedy: true }, 'table': { - pattern: RegExp('(\\[\\s*)' + key + '(?:\\s*\\.\\s*' + key + ')*(?=\\s*\\])'), + pattern: RegExp("(\\[\\s*)" + key + "(?:\\s*\\.\\s*" + key + ")*(?=\\s*\\])"), lookbehind: true, greedy: true, alias: 'class-name' }, 'key': { - pattern: RegExp('(^\\s*|[{,]\\s*)' + key + '(?:\\s*\\.\\s*' + key + ')*(?=\\s*=)', 'm'), + pattern: RegExp("(^\\s*|[{,]\\s*)" + key + "(?:\\s*\\.\\s*" + key + ")*(?=\\s*=)", "m"), lookbehind: true, greedy: true, alias: 'property' diff --git a/components/prism-vbnet.js b/components/prism-vbnet.js index 53754cb291..25368eb5e1 100644 --- a/components/prism-vbnet.js +++ b/components/prism-vbnet.js @@ -1,4 +1,4 @@ -Prism.languages.vbnet = Prism.languages.extend('basic', { +Prism.languages.vbnet = Prism.languages.extend("basic", { 'keyword': /(?:\b(?:ADDHANDLER|ADDRESSOF|ALIAS|AND|ANDALSO|AS|BEEP|BLOAD|BOOLEAN|BSAVE|BYREF|BYTE|BYVAL|CALL(?: ABSOLUTE)?|CASE|CATCH|CBOOL|CBYTE|CCHAR|CDATE|CDEC|CDBL|CHAIN|CHAR|CHDIR|CINT|CLASS|CLEAR|CLNG|CLOSE|CLS|COBJ|COM|COMMON|CONST|CONTINUE|CSBYTE|CSHORT|CSNG|CSTR|CTYPE|CUINT|CULNG|CUSHORT|DATA|DATE|DECIMAL|DECLARE|DEFAULT|DEF(?: FN| SEG|DBL|INT|LNG|SNG|STR)|DELEGATE|DIM|DIRECTCAST|DO|DOUBLE|ELSE|ELSEIF|END|ENUM|ENVIRON|ERASE|ERROR|EVENT|EXIT|FALSE|FIELD|FILES|FINALLY|FOR(?: EACH)?|FRIEND|FUNCTION|GET|GETTYPE|GETXMLNAMESPACE|GLOBAL|GOSUB|GOTO|HANDLES|IF|IMPLEMENTS|IMPORTS|IN|INHERITS|INPUT|INTEGER|INTERFACE|IOCTL|IS|ISNOT|KEY|KILL|LINE INPUT|LET|LIB|LIKE|LOCATE|LOCK|LONG|LOOP|LSET|ME|MKDIR|MOD|MODULE|MUSTINHERIT|MUSTOVERRIDE|MYBASE|MYCLASS|NAME|NAMESPACE|NARROWING|NEW|NEXT|NOT|NOTHING|NOTINHERITABLE|NOTOVERRIDABLE|OBJECT|OF|OFF|ON(?: COM| ERROR| KEY| TIMER)?|OPERATOR|OPEN|OPTION(?: BASE)?|OPTIONAL|OR|ORELSE|OUT|OVERLOADS|OVERRIDABLE|OVERRIDES|PARAMARRAY|PARTIAL|POKE|PRIVATE|PROPERTY|PROTECTED|PUBLIC|PUT|RAISEEVENT|READ|READONLY|REDIM|REM|REMOVEHANDLER|RESTORE|RESUME|RETURN|RMDIR|RSET|RUN|SBYTE|SELECT(?: CASE)?|SET|SHADOWS|SHARED|SHORT|SINGLE|SHELL|SLEEP|STATIC|STEP|STOP|STRING|STRUCTURE|SUB|SYNCLOCK|SWAP|SYSTEM|THEN|THROW|TIMER|TO|TROFF|TRON|TRUE|TRY|TRYCAST|TYPE|TYPEOF|UINTEGER|ULONG|UNLOCK|UNTIL|USHORT|USING|VIEW PRINT|WAIT|WEND|WHEN|WHILE|WIDENING|WITH|WITHEVENTS|WRITE|WRITEONLY|XOR)|\B(?:#CONST|#ELSE|#ELSEIF|#END|#IF))(?:\$|\b)/i, 'comment': [ { diff --git a/components/prism-xeora.js b/components/prism-xeora.js index f8623fb3f4..fbb7860db6 100644 --- a/components/prism-xeora.js +++ b/components/prism-xeora.js @@ -107,7 +107,7 @@ Prism.languages.insertBefore('inside', 'punctuation', { 'variable': Prism.languages.xeora['function-inline'].inside['variable'] - }, Prism.languages.xeora['function-block']); + }, Prism.languages.xeora["function-block"]); Prism.languages.xeoracube = Prism.languages.xeora; diff --git a/components/prism-xquery.js b/components/prism-xquery.js index 181e37abc8..dbb620c016 100644 --- a/components/prism-xquery.js +++ b/components/prism-xquery.js @@ -4,7 +4,7 @@ 'xquery-comment': { pattern: /\(:[\s\S]*?:\)/, greedy: true, - alias: 'comment' + alias: "comment" }, 'string': { pattern: /(["'])(?:\1\1|(?!\1)[\s\S])*\1/, diff --git a/prism.js b/prism.js index 5248dad2a5..ff0c6e6f75 100644 --- a/prism.js +++ b/prism.js @@ -182,7 +182,7 @@ var _ = { selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code' }; - _.hooks.run('before-highlightall', env); + _.hooks.run("before-highlightall", env); var elements = env.elements || container.querySelectorAll(env.selector); @@ -292,7 +292,7 @@ var _ = { } var patterns = grammar[token]; - patterns = (_.util.type(patterns) === 'Array') ? patterns : [patterns]; + patterns = (_.util.type(patterns) === "Array") ? patterns : [patterns]; for (var j = 0; j < patterns.length; ++j) { var pattern = patterns[j], @@ -305,7 +305,7 @@ var _ = { if (greedy && !pattern.pattern.global) { // Without the global flag, lastIndex won't work var flags = pattern.pattern.toString().match(/[imuy]*$/)[0]; - pattern.pattern = RegExp(pattern.pattern.source, flags + 'g'); + pattern.pattern = RegExp(pattern.pattern.source, flags + "g"); } pattern = pattern.pattern || pattern; @@ -459,7 +459,7 @@ function Token(type, content, alias, matchedStr, greedy) { this.content = content; this.alias = alias; // Copy of the full string this token was created from - this.length = (matchedStr || '').length|0; + this.length = (matchedStr || "").length|0; this.greedy = !!greedy; } @@ -522,13 +522,13 @@ if (!_self.document) { } //Get current script and highlight -var script = document.currentScript || [].slice.call(document.getElementsByTagName('script')).pop(); +var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop(); if (script) { _.filename = script.src; if (!_.manual && !script.hasAttribute('data-manual')) { - if(document.readyState !== 'loading') { + if(document.readyState !== "loading") { if (window.requestAnimationFrame) { window.requestAnimationFrame(_.highlightAll); } else {