Yuki Takei 8 лет назад
Родитель
Сommit
2db7415c17

+ 8 - 3
.eslintrc.js

@@ -10,8 +10,11 @@ module.exports = {
     "plugin:react/recommended"
   ],
   "globals": {
-    "window": true,
-    "emojione": true
+    "$": true,
+    "jquery": true,
+    "emojione": true,
+    "hljs": true,
+    "window": true
   },
   "parserOptions": {
     "ecmaFeatures": {
@@ -42,7 +45,9 @@ module.exports = {
       {
         "SwitchCase": 1,
         "ignoredNodes": ['JSXElement *', 'JSXElement'],
-        "FunctionExpression": {"parameters": 2},
+        "FunctionDeclaration": {"body": 1, "parameters": 2},
+        "FunctionExpression": {"body": 1, "parameters": 2},
+        "MemberExpression": "off"
       }
     ],
     "key-spacing": [

+ 5 - 3
resource/js/util/Crowi.js

@@ -88,14 +88,15 @@ export default class Crowi {
       if (this.localStorage[key]) {
         try {
           this[key] = JSON.parse(this.localStorage[key]);
-        } catch (e) {
+        }
+        catch (e) {
           this.localStorage.removeItem(key);
         }
       }
     });
   }
 
-  fetchUsers () {
+  fetchUsers() {
     const interval = 1000*60*15; // 15min
     const currentTime = new Date();
     if (this.localStorage.lastFetched && interval > currentTime - new Date(this.localStorage.lastFetched)) {
@@ -212,7 +213,8 @@ export default class Crowi {
       .then(res => {
         if (res.data.ok) {
           resolve(res.data);
-        } else {
+        }
+        else {
           reject(new Error(res.data.error));
         }
       })

+ 1 - 1
resource/js/util/LangProcessor/Template.js

@@ -38,7 +38,7 @@ export default class Template {
     let parsed = templateString;
 
     Object.keys(this.templatePattern).forEach(key => {
-      const k = key .replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
+      const k = key .replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
       const matcher = new RegExp(`{${k}}`, 'g');
       if (parsed.match(matcher)) {
         const replacer = this.templatePattern[key]();

+ 0 - 4
resource/js/util/PreProcessor/CsvToTable.js

@@ -8,16 +8,12 @@ export default class CsvToTable {
       switch (group1) {
         case 'tsv':
           return csvToMarkdownTable(group2, '\t');
-          break;
         case 'tsv-h':
           return csvToMarkdownTable(group2, '\t', true);
-          break;
         case 'csv':
           return csvToMarkdownTable(group2, ',');
-          break;
         case 'csv-h':
           return csvToMarkdownTable(group2, ',', true);
-          break;
         default:
           return all;
       }

+ 1 - 1
resource/js/util/PreProcessor/Linker.js

@@ -9,6 +9,6 @@ export default class Linker {
       // process square branckets like '[/Level1]'
       // see: https://regex101.com/r/QSt1yu/5
       .replace(/\[(\/[^\]\n]+?)\](?!\()/g, '<a href="$1">$1</a>')
-      ;
+    ;
   }
 }

+ 1 - 1
resource/js/util/markdown-it/common-plugins.js

@@ -9,7 +9,7 @@ export default class CommonPluginsConfigurer {
       .use(require('markdown-it-task-lists'), {
         enabled: true,
       })
-      ;
+    ;
   }
 
 }

+ 15 - 14
resource/js/util/markdown-it/header-line-number.js

@@ -16,19 +16,20 @@ export default class HeaderLineNumberConfigurer {
    * @see https://github.com/Microsoft/vscode/blob/6e8d4d057bd1152d49a1e9780ec6db6363593855/extensions/markdown/src/markdownEngine.ts#L118
    */
   addLineNumberRenderer(md, ruleName) {
-		const original = md.renderer.rules[ruleName];
-		md.renderer.rules[ruleName] = (tokens, idx, options, env, self) => {
-			const token = tokens[idx];
-			if (token.map && token.map.length) {
-				token.attrSet('data-line', this.firstLine + token.map[0]);
-				token.attrJoin('class', 'code-line');
-			}
+    const original = md.renderer.rules[ruleName];
+    md.renderer.rules[ruleName] = (tokens, idx, options, env, self) => {
+      const token = tokens[idx];
+      if (token.map && token.map.length) {
+        token.attrSet('data-line', this.firstLine + token.map[0]);
+        token.attrJoin('class', 'code-line');
+      }
 
-			if (original) {
-				return original(tokens, idx, options, env, self);
-			} else {
-				return self.renderToken(tokens, idx, options, env, self);
-			}
-		};
-}
+      if (original) {
+        return original(tokens, idx, options, env, self);
+      }
+      else {
+        return self.renderToken(tokens, idx, options, env, self);
+      }
+    };
+  }
 }

+ 8 - 9
resource/js/util/markdown-it/header.js

@@ -12,17 +12,16 @@ export default class HeaderConfigurer {
     // combine rule and set
     // rules.heading_open = this.combineRules(this.injectRevisionHeadClass, headingOpenOrg);
     rules.heading_open = (tokens, idx, options, env, self) => {
-      const token = tokens[idx];
-
       // Inject 'revision-head' class
-			this.injectRevisionHeadClass(tokens, idx, options, env, self);
+      this.injectRevisionHeadClass(tokens, idx, options, env, self);
 
-			if (original) {
-				return original(tokens, idx, options, env, self);
-			} else {
-				return self.renderToken(tokens, idx, options, env, self);
-			}
-		};
+      if (original) {
+        return original(tokens, idx, options, env, self);
+      }
+      else {
+        return self.renderToken(tokens, idx, options, env, self);
+      }
+    };
   }
 
   /**

+ 1 - 1
resource/js/util/markdown-it/plantuml.js

@@ -20,6 +20,6 @@ export default class PlantUMLConfigurer {
 
   generateSource(umlCode) {
     const zippedCode = plantumlEncoder.encode(`@startuml\n${umlCode}\n@enduml`);
-    return urljoin(this.serverUrl, 'svg' , zippedCode);
+    return urljoin(this.serverUrl, 'svg', zippedCode);
   }
 }