Gerald 8 年之前
父節點
當前提交
d7b64fd355

+ 1 - 0
.eslintrc.js

@@ -45,6 +45,7 @@ module.exports = {
     'no-bitwise': ['error', {int32Hint: true}],
     'no-underscore-dangle': ['off'],
     'arrow-parens': 0,
+    'indent': ['error', 2, { MemberExpression: 0 }],
   },
   globals: {
     browser: true,

+ 7 - 7
package.json

@@ -17,27 +17,27 @@
   "description": "Violentmonkey",
   "devDependencies": {
     "babel-core": "^6.25.0",
-    "babel-eslint": "^7.2.2",
-    "babel-loader": "^7.0.0",
+    "babel-eslint": "^7.2.3",
+    "babel-loader": "^7.1.0",
     "babel-plugin-transform-export-extensions": "^6.22.0",
     "babel-plugin-transform-runtime": "^6.23.0",
     "babel-preset-env": "^1.5.2",
     "babili-webpack-plugin": "^0.1.1",
     "css-loader": "^0.28.4",
     "del": "^3.0.0",
-    "eslint": "^3.19.0",
+    "eslint": "^4.0.0",
     "eslint-config-airbnb-base": "^11.2.0",
     "eslint-friendly-formatter": "^3.0.0",
     "eslint-import-resolver-webpack": "^0.8.1",
-    "eslint-loader": "^1.7.1",
-    "eslint-plugin-html": "^2.0.3",
+    "eslint-loader": "^1.8.0",
+    "eslint-plugin-html": "^3.0.0",
     "eslint-plugin-import": "^2.3.0",
     "extract-text-webpack-plugin": "^2.1.2",
     "friendly-errors-webpack-plugin": "^1.6.1",
     "gulp": "^3.9.1",
     "gulp-filter": "^5.0.0",
     "gulp-svg-sprite": "^1.3.7",
-    "gulp-uglify": "^2.0.0",
+    "gulp-uglify": "^3.0.0",
     "gulp-util": "^3.0.7",
     "html-webpack-plugin": "^2.28.0",
     "husky": "^0.13.4",
@@ -50,7 +50,7 @@
     "vue-loader": "^12.2.1",
     "vue-style-loader": "^3.0.1",
     "vue-template-compiler": "^2.3.4",
-    "webpack": "^2.6.1",
+    "webpack": "^3.0.0",
     "webpack-bundle-size-analyzer": "^2.7.0",
     "wrapper-webpack-plugin": "^0.1.11"
   },

+ 3 - 3
src/background/app.js

@@ -77,9 +77,9 @@ const commands = {
         browser.tabs.sendMessage(src.tab.id, { cmd: 'GetBadge' });
       }
     });
-    return data.isApplied
-    ? vmdb.getScriptsByURL(url).then(res => Object.assign(data, res))
-    : data;
+    return data.isApplied ? (
+      vmdb.getScriptsByURL(url).then(res => Object.assign(data, res))
+    ) : data;
   },
   UpdateScriptInfo(data) {
     return vmdb.updateScriptInfo(data.id, data, {

+ 2 - 2
src/background/sync/base.js

@@ -145,7 +145,7 @@ export const BaseService = serviceFactory({
     this.authState = serviceState([
       'idle',
       'initializing',
-      'authorizing',  // in case some services require asynchronous requests to get access_tokens
+      'authorizing', // in case some services require asynchronous requests to get access_tokens
       'authorized',
       'unauthorized',
       'error',
@@ -166,7 +166,7 @@ export const BaseService = serviceFactory({
     });
   },
   log(...args) {
-    console.log(...args);  // eslint-disable-line no-console
+    console.log(...args); // eslint-disable-line no-console
   },
   syncFactory() {
     let promise;

+ 11 - 11
src/background/utils/db.js

@@ -144,17 +144,17 @@ export function getScriptsByURL(url) {
     };
     const require = {};
     const cache = {};
-    return (testBlacklist(url)
-    ? Promise.resolve([])
-    : getScriptsByIndex('position', null, tx, script => {
-      if (!testScript(url, script)) return;
-      data.uris.push(script.uri);
-      script.meta.require.forEach(key => { require[key] = 1; });
-      Object.keys(script.meta.resources).forEach(key => {
-        cache[script.meta.resources[key]] = 1;
-      });
-      return script;
-    }))
+    return (testBlacklist(url) ? Promise.resolve([]) : (
+      getScriptsByIndex('position', null, tx, script => {
+        if (!testScript(url, script)) return;
+        data.uris.push(script.uri);
+        script.meta.require.forEach(key => { require[key] = 1; });
+        Object.keys(script.meta.resources).forEach(key => {
+          cache[script.meta.resources[key]] = 1;
+        });
+        return script;
+      })
+    ))
     .then(scripts => {
       data.scripts = scripts.filter(Boolean);
       data.require = Object.keys(require);

+ 1 - 1
src/background/utils/options.js

@@ -1,5 +1,5 @@
 import { initHooks, debounce, normalizeKeys, object } from 'src/common';
-import storage from 'localStorage';   // eslint-disable-line import/no-extraneous-dependencies
+import storage from 'localStorage'; // eslint-disable-line import/no-extraneous-dependencies
 
 const defaults = {
   isApplied: true,

+ 1 - 1
src/background/utils/requests.js

@@ -286,7 +286,7 @@ browser.webRequest.onBeforeRequest.addListener(req => {
         }
       });
       // { cancel: true } will redirect to a blocked view
-      return { redirectUrl: 'javascript:history.back()' };  // eslint-disable-line no-script-url
+      return { redirectUrl: 'javascript:history.back()' }; // eslint-disable-line no-script-url
     }
   }
 }, {

+ 1 - 1
src/background/utils/script.js

@@ -5,7 +5,7 @@ const metaEnd = '==/UserScript==';
 
 export function isUserScript(text) {
   if (/^\s*</.test(text)) return false; // HTML
-  if (text.indexOf(metaStart) < 0) return false;  // Lack of meta block
+  if (text.indexOf(metaStart) < 0) return false; // Lack of meta block
   return true;
 }
 

+ 2 - 2
src/background/utils/tester.js

@@ -67,9 +67,9 @@ function str2RE(str) {
 
 function autoReg(str) {
   if (str.length > 1 && str[0] === '/' && str[str.length - 1] === '/') {
-    return RegExp(str.slice(1, -1));  // Regular-expression
+    return RegExp(str.slice(1, -1)); // Regular-expression
   }
-  return str2RE(str);              // String with wildcards
+  return str2RE(str); // String with wildcards
 }
 
 function matchScheme(rule, data) {

+ 6 - 7
src/injected/web/index.js

@@ -87,11 +87,10 @@ function onLoadScripts(data) {
     forEach(data.scripts, script => {
       values[script.uri] = data.values[script.uri] || {};
       if (script && script.enabled) {
-        const list = listMap[
-          // XXX: use camelCase since v2.6.3
-          script.custom.runAt || script.custom['run-at'] ||
-          script.meta.runAt || script.meta['run-at']
-        ] || end;
+        // XXX: use camelCase since v2.6.3
+        const runAt = script.custom.runAt || script.custom['run-at']
+          || script.meta.runAt || script.meta['run-at'];
+        const list = listMap[runAt] || end;
         list.push(script);
       }
     });
@@ -177,7 +176,7 @@ function wrapGM(script, cache) {
               url: resources[name],
             })),
             runAt: script.meta.runAt || '',
-            unwrap: false,  // deprecated, always `false`
+            unwrap: false, // deprecated, always `false`
             version: script.meta.version || '',
           },
         };
@@ -376,7 +375,7 @@ function getWrapper() {
     'find',
     'focus',
     'getComputedStyle',
-    'getDefaultComputedStyle',  // Non-standard, Firefox only, used by jQuery
+    'getDefaultComputedStyle', // Non-standard, Firefox only, used by jQuery
     'getSelection',
     'matchMedia',
     'moveBy',

+ 7 - 7
src/options/views/script-item.vue

@@ -42,13 +42,13 @@ function loadImage(url) {
   if (!promise) {
     const cache = store.cache[url];
     promise = cache
-    ? Promise.resolve(cache)
-    : new Promise((resolve, reject) => {
-      const img = new Image();
-      img.onload = () => resolve(url);
-      img.onerror = () => reject(url);
-      img.src = url;
-    });
+      ? Promise.resolve(cache)
+      : new Promise((resolve, reject) => {
+        const img = new Image();
+        img.onload = () => resolve(url);
+        img.onerror = () => reject(url);
+        img.src = url;
+      });
     images[url] = promise;
   }
   return promise;