Преглед изворни кода

Merge pull request #2218 from overleaf/as-eslint-globals

Move around eslint globals

GitOrigin-RevId: 81144a0b763159b9425aff673211c07ec65b3be5
Eric Mc Sween пре 7 година
родитељ
комит
ed7b5a9450

+ 32 - 10
services/web/.eslintrc

@@ -19,15 +19,6 @@
     "browser": true,
     "mocha": true
   },
-  "globals": {
-    "expect": true,
-    "define": true,
-    "$": true,
-    "angular": true,
-    // Injected in layout.pug
-    "user_id": true,
-    "ace": true
-  },
   "settings": {
     // Tell eslint-plugin-react to detect which version of React we are using
     "react": {
@@ -59,7 +50,11 @@
   },
   "overrides": [
     {
+      // Test specific rules
       "files": ["**/test/*/src/**/*.js"],
+      "globals": {
+        "expect": true
+      },
       "rules": {
         // mocha-specific rules
         "mocha/handle-done-callback": "error",
@@ -82,11 +77,38 @@
       }
     },
     {
-      // don't allow console.log in backend code
+      // Frontend test specific rules
+      "files": ["**/test/unit_frontend/{src,es}/**/*.js"],
+      "globals": {
+        "expect": true,
+        "define": true,
+        "$": true
+      }
+    },
+    {
+      // Backend specific rules
       "files": ["**/app/*/src/**/*.js"],
       "rules": {
+        // don't allow console.log in backend code
         "no-console": "error"
       }
+    },
+    {
+      // Frontend specific rules
+      "files": ["**/public/{src,es}/**/*.js"],
+      "globals": {
+        "define": true,
+        "$": true,
+        "angular": true,
+        "_": true,
+        "ace": true,
+        "ga": true,
+        "AlgoliaSearch": true,
+        "sl_console": true,
+        "sl_debugging": true,
+        // Injected in layout.pug
+        "user_id": true
+      }
     }
   ]
 }

+ 1 - 5
services/web/app/src/Features/Project/SafePath.js

@@ -128,8 +128,4 @@ prototype\
   })
 }
 
-if (typeof define !== 'undefined' && define !== null) {
-  define([], load)
-} else {
-  module.exports = load()
-}
+module.exports = load()

+ 1 - 1
services/web/public/src/directives/mathjax.js

@@ -1,4 +1,4 @@
-/* global MathJax, _ */
+/* global MathJax */
 
 define(['base'], function(App) {
   return App.directive('mathjax', function($compile, $parse) {

+ 1 - 1
services/web/public/src/ide/connection/ConnectionManager.js

@@ -8,7 +8,7 @@
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  */
 
-/* global io sl_console sl_debugging */
+/* global io */
 
 define([], function() {
   let ConnectionManager

+ 0 - 1
services/web/public/src/ide/editor/directives/aceEditor.js

@@ -1,4 +1,3 @@
-/* global _ */
 /* eslint-disable
     camelcase,
     max-len

+ 0 - 1
services/web/public/src/ide/editor/directives/aceEditor/auto-complete/AutoCompleteManager.js

@@ -1,4 +1,3 @@
-/* global _ */
 define([
   'ide/editor/directives/aceEditor/auto-complete/CommandManager',
   'ide/editor/directives/aceEditor/auto-complete/EnvironmentManager',

+ 0 - 1
services/web/public/src/ide/files/services/files.js

@@ -1,4 +1,3 @@
-/* global _ */
 define(['base'], App =>
   App.factory('files', function(ide) {
     const Files = {

+ 1 - 1
services/web/public/src/main/new-subscription.js

@@ -3,7 +3,7 @@
     max-len,
     no-return-assign
 */
-/* global recurly,_,define */
+/* global recurly */
 define(['base', 'directives/creditCards'], App =>
   App.controller('NewSubscriptionController', function(
     $scope,

+ 0 - 1
services/web/public/src/main/plans.js

@@ -2,7 +2,6 @@
     camelcase,
     max-len
 */
-/* global define,history */
 define(['base'], function(App) {
   App.factory('MultiCurrencyPricing', function() {
     const currencyCode = window.recomendedCurrency