Browse Source

chore: enable eslint no-use-before-define

tophf 3 years ago
parent
commit
7d76145936
2 changed files with 8 additions and 2 deletions
  1. 6 0
      .eslintrc.js
  2. 2 2
      src/background/utils/preinject.js

+ 6 - 0
.eslintrc.js

@@ -144,6 +144,12 @@ module.exports = {
     //   js: 'never',
     //   js: 'never',
     //   vue: 'never',
     //   vue: 'never',
     // }],
     // }],
+    'no-use-before-define': ['error', {
+      'functions': false,
+      'classes': true,
+      'variables': true,
+      'allowNamedExports': true,
+    }],
     // copied from airbnb-base, replaced 4 with 8
     // copied from airbnb-base, replaced 4 with 8
     'object-curly-newline': ['error', {
     'object-curly-newline': ['error', {
       ObjectExpression: { minProperties: 8, multiline: true, consistent: true },
       ObjectExpression: { minProperties: 8, multiline: true, consistent: true },

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

@@ -20,8 +20,10 @@ const API_CONFIG = {
   urls: ['*://*/*'], // `*` scheme matches only http and https
   urls: ['*://*/*'], // `*` scheme matches only http and https
   types: ['main_frame', 'sub_frame'],
   types: ['main_frame', 'sub_frame'],
 };
 };
+const INJECT = 'inject';
 const CSAPI_REG = 'csar';
 const CSAPI_REG = 'csar';
 const contentScriptsAPI = browser.contentScripts;
 const contentScriptsAPI = browser.contentScripts;
+const envStartKey = {};
 /** In normal circumstances the data will be removed in ~1sec on use,
 /** In normal circumstances the data will be removed in ~1sec on use,
  * however connecting may take a long time or the tab may be paused in devtools. */
  * however connecting may take a long time or the tab may be paused in devtools. */
 const TIME_KEEP_DATA = 5 * 60e3;
 const TIME_KEEP_DATA = 5 * 60e3;
@@ -38,7 +40,6 @@ const cache = initCache({
     }
     }
   },
   },
 });
 });
-const INJECT = 'inject';
 // KEY_XXX for hooked options
 // KEY_XXX for hooked options
 const KEY_EXPOSE = 'expose';
 const KEY_EXPOSE = 'expose';
 const KEY_DEF_INJECT_INTO = 'defaultInjectInto';
 const KEY_DEF_INJECT_INTO = 'defaultInjectInto';
@@ -52,7 +53,6 @@ const META_KEYS_TO_ENSURE = [
   'runAt',
   'runAt',
   'version',
   'version',
 ];
 ];
-const envStartKey = {};
 const expose = {};
 const expose = {};
 let isApplied;
 let isApplied;
 let injectInto;
 let injectInto;