Browse Source

HUE-8909 [frontend] Add console.log check to eslint

Johan Ahlen 6 năm trước cách đây
mục cha
commit
ce2a9512aa
28 tập tin đã thay đổi với 88 bổ sung39 xóa
  1. 7 0
      .eslintrc.js
  2. 1 0
      desktop/core/src/desktop/js/apps/notebook/snippet.js
  3. 1 0
      desktop/core/src/desktop/js/apps/notebook2/editorViewModel.js
  4. 1 1
      desktop/core/src/desktop/js/apps/notebook2/snippet.js
  5. 1 0
      desktop/core/src/desktop/js/ko/components/ko.inlineAutocomplete.js
  6. 1 1
      desktop/core/src/desktop/js/ko/components/ko.jobBrowserLinks.js
  7. 1 1
      desktop/core/src/desktop/js/parse/spec/sqlStatementsParserSpec.js
  8. 1 0
      desktop/core/src/desktop/js/parse/sql/generic/spec/sqlParseSupportSpec.js
  9. 8 8
      desktop/core/src/desktop/js/parse/sql/generic/sqlParseSupport.js
  10. 1 0
      desktop/core/src/desktop/js/parse/sql/hive/spec/sqlParseSupportSpec.js
  11. 11 11
      desktop/core/src/desktop/js/parse/sql/hive/sqlParseSupport.js
  12. 1 0
      desktop/core/src/desktop/js/parse/sql/impala/spec/sqlParseSupportSpec.js
  13. 11 11
      desktop/core/src/desktop/js/parse/sql/impala/sqlParseSupport.js
  14. 3 3
      desktop/core/src/desktop/js/parse/sqlParseSupport.js
  15. 2 0
      desktop/core/src/desktop/js/sql/aceLocationHandler.js
  16. 1 0
      desktop/core/src/desktop/js/sql/spec/autocompleteResultsSpec.js
  17. 1 0
      desktop/core/src/desktop/js/sql/spec/sqlAutocompleterSpec_IGNORE.js
  18. 2 2
      desktop/core/src/desktop/js/sql/sqlAutocompleter.js
  19. 0 1
      desktop/core/src/desktop/js/sql/sqlSyntaxWebWorker.js
  20. 1 0
      desktop/core/src/desktop/js/utils/hueDebug.js
  21. 4 0
      tools/jison/generateParsers.js
  22. 4 0
      tools/sql-docs/ditamapParser.js
  23. 4 0
      tools/sql-docs/docExtractor.js
  24. 4 0
      tools/sql-docs/docXmlParser.js
  25. 4 0
      tools/sql-docs/extractorUtils.js
  26. 4 0
      tools/sql-docs/hiveExtractor.js
  27. 4 0
      tools/sql-docs/jsonHandler.js
  28. 4 0
      tools/sql-docs/topicLinker.js

+ 7 - 0
.eslintrc.js

@@ -44,6 +44,13 @@ module.exports = {
   rules: {
     'new-cap': 0,
     'no-console': 0,
+    "no-restricted-syntax": [
+      "error",
+      {
+        "selector": "CallExpression[callee.object.name='console'][callee.property.name!=/^(warn|error|info|trace)$/]",
+        "message": "Unexpected property on console object was called"
+      }
+    ],
     'no-extra-boolean-cast': 0,
     'no-invalid-this': 0,
     'no-lonely-if': 2,

+ 1 - 0
desktop/core/src/desktop/js/apps/notebook/snippet.js

@@ -2641,6 +2641,7 @@ class Snippet {
         },
         data => {
           if (data.status == 0) {
+            // eslint-disable-next-line no-restricted-syntax
             console.log(data.statement_similarity);
           } else {
             $(document).trigger('error', data.message);

+ 1 - 0
desktop/core/src/desktop/js/apps/notebook2/editorViewModel.js

@@ -30,6 +30,7 @@ class EditorViewModel {
   constructor(editorId, notebooks, options, CoordinatorEditorViewModel, RunningCoordinatorModel) {
     const self = this;
 
+    // eslint-disable-next-line no-restricted-syntax
     console.log('Notebook 2 enabled.');
 
     self.editorId = editorId;

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook2/snippet.js

@@ -1575,7 +1575,6 @@ class Snippet {
 
   format() {
     const self = this;
-    console.log(self);
     if (self.isSqlDialect()) {
       apiHelper
         .formatSql({
@@ -1808,6 +1807,7 @@ class Snippet {
       },
       data => {
         if (data.status === 0) {
+          // eslint-disable-next-line no-restricted-syntax
           console.log(data.statement_similarity);
         } else {
           $(document).trigger('error', data.message);

+ 1 - 0
desktop/core/src/desktop/js/ko/components/ko.inlineAutocomplete.js

@@ -288,6 +288,7 @@ class InlineAutocomplete {
     // TODO: Get cursor position and split to before and after
     self.lastParseResult = globalSearchParser.parseGlobalSearch(self.searchInput(), '');
     if (hueDebug && hueDebug.showGlobalSearchParseResults) {
+      // eslint-disable-next-line no-restricted-syntax
       console.log(self.lastParseResult);
     }
     const querySpec = { query: self.searchInput() };

+ 1 - 1
desktop/core/src/desktop/js/ko/components/ko.jobBrowserLinks.js

@@ -117,7 +117,7 @@ class JobBrowserPanel {
           }
         })
         .fail(response => {
-          console.log(response);
+          console.warn(response);
         });
     };
     let lastScheduleBrowserRequest = undefined;

+ 1 - 1
desktop/core/src/desktop/js/parse/spec/sqlStatementsParserSpec.js

@@ -57,7 +57,7 @@ describe('sqlStatementsParser.js', () => {
       expect(result).toEqual(expectedOutput, because);
     } catch (error) {
       console.error(error);
-      console.log(error.message);
+      console.warn(error.message);
 
       fail('Got error');
     }

+ 1 - 0
desktop/core/src/desktop/js/parse/sql/generic/spec/sqlParseSupportSpec.js

@@ -107,6 +107,7 @@ describe('sqlParseSupport.js', () => {
     durations.forEach(duration => {
       sum += duration;
     });
+    // eslint-disable-next-line no-restricted-syntax
     console.log('it took ' + sum / durations.length + ' ms on average.');
     // ~ 0.037 ms on average
     expect(true).toBeTruthy();

+ 8 - 8
desktop/core/src/desktop/js/parse/sql/generic/sqlParseSupport.js

@@ -1914,15 +1914,15 @@ const initSqlParser = function(parser) {
         throw err;
       }
       if (debug) {
-        console.log(err);
-        console.error(err.stack);
+        console.warn(err);
+        console.warn(err.stack);
       }
       result = parser.yy.result;
     }
     if (parser.yy.errors.length > 0) {
       parser.yy.result.errors = parser.yy.errors;
       if (debug) {
-        console.log(parser.yy.errors);
+        console.warn(parser.yy.errors);
       }
     }
     try {
@@ -1932,8 +1932,8 @@ const initSqlParser = function(parser) {
       prioritizeSuggestions();
     } catch (err) {
       if (debug) {
-        console.log(err);
-        console.error(err.stack);
+        console.warn(err);
+        console.warn(err.stack);
       }
     }
 
@@ -2189,9 +2189,9 @@ const initSyntaxParser = function(parser) {
       parser.parse(beforeCursor + afterCursor);
     } catch (err) {
       if (debug) {
-        console.log(err);
-        console.error(err.stack);
-        console.log(parser.yy.error);
+        console.warn(err);
+        console.warn(err.stack);
+        console.warn(parser.yy.error);
       }
     }
 

+ 1 - 0
desktop/core/src/desktop/js/parse/sql/hive/spec/sqlParseSupportSpec.js

@@ -107,6 +107,7 @@ describe('sqlParseSupport.js', () => {
     durations.forEach(duration => {
       sum += duration;
     });
+    // eslint-disable-next-line no-restricted-syntax
     console.log('it took ' + sum / durations.length + ' ms on average.');
     // ~ 0.037 ms on average
     expect(true).toBeTruthy();

+ 11 - 11
desktop/core/src/desktop/js/parse/sql/hive/sqlParseSupport.js

@@ -2056,15 +2056,15 @@ const initSqlParser = function(parser) {
         throw err;
       }
       if (debug) {
-        console.log(err);
-        console.error(err.stack);
+        console.warn(err);
+        console.warn(err.stack);
       }
       result = parser.yy.result;
     }
     if (parser.yy.errors.length > 0) {
       parser.yy.result.errors = parser.yy.errors;
       if (debug) {
-        console.log(parser.yy.errors);
+        console.warn(parser.yy.errors);
       }
     }
     try {
@@ -2074,8 +2074,8 @@ const initSqlParser = function(parser) {
       prioritizeSuggestions();
     } catch (err) {
       if (debug) {
-        console.log(err);
-        console.error(err.stack);
+        console.warn(err);
+        console.warn(err.stack);
       }
     }
 
@@ -2346,9 +2346,9 @@ const initSyntaxParser = function(parser) {
       parser.parse(beforeCursor + afterCursor);
     } catch (err) {
       if (debug) {
-        console.log(err);
-        console.error(err.stack);
-        console.log(parser.yy.error);
+        console.warn(err);
+        console.warn(err.stack);
+        console.warn(parser.yy.error);
       }
     }
 
@@ -2502,9 +2502,9 @@ const initGlobalSearchParser = function(parser) {
       result = parser.parse(beforeCursor + '\u2020' + afterCursor);
     } catch (err) {
       if (debug) {
-        console.log(err);
-        console.error(err.stack);
-        console.log(parser.yy.error);
+        console.warn(err);
+        console.warn(err.stack);
+        console.warn(parser.yy.error);
       }
       return {
         facets: {},

+ 1 - 0
desktop/core/src/desktop/js/parse/sql/impala/spec/sqlParseSupportSpec.js

@@ -107,6 +107,7 @@ describe('sqlParseSupport.js', () => {
     durations.forEach(duration => {
       sum += duration;
     });
+    // eslint-disable-next-line no-restricted-syntax
     console.log('it took ' + sum / durations.length + ' ms on average.');
     // ~ 0.037 ms on average
     expect(true).toBeTruthy();

+ 11 - 11
desktop/core/src/desktop/js/parse/sql/impala/sqlParseSupport.js

@@ -2138,15 +2138,15 @@ const initSqlParser = function(parser) {
         throw err;
       }
       if (debug) {
-        console.log(err);
-        console.error(err.stack);
+        console.warn(err);
+        console.warn(err.stack);
       }
       result = parser.yy.result;
     }
     if (parser.yy.errors.length > 0) {
       parser.yy.result.errors = parser.yy.errors;
       if (debug) {
-        console.log(parser.yy.errors);
+        console.warn(parser.yy.errors);
       }
     }
     try {
@@ -2156,8 +2156,8 @@ const initSqlParser = function(parser) {
       prioritizeSuggestions();
     } catch (err) {
       if (debug) {
-        console.log(err);
-        console.error(err.stack);
+        console.warn(err);
+        console.warn(err.stack);
       }
     }
 
@@ -2428,9 +2428,9 @@ const initSyntaxParser = function(parser) {
       parser.parse(beforeCursor + afterCursor);
     } catch (err) {
       if (debug) {
-        console.log(err);
-        console.error(err.stack);
-        console.log(parser.yy.error);
+        console.warn(err);
+        console.warn(err.stack);
+        console.warn(parser.yy.error);
       }
     }
 
@@ -2584,9 +2584,9 @@ const initGlobalSearchParser = function(parser) {
       result = parser.parse(beforeCursor + '\u2020' + afterCursor);
     } catch (err) {
       if (debug) {
-        console.log(err);
-        console.error(err.stack);
-        console.log(parser.yy.error);
+        console.warn(err);
+        console.warn(err.stack);
+        console.warn(parser.yy.error);
       }
       return {
         facets: {},

+ 3 - 3
desktop/core/src/desktop/js/parse/sqlParseSupport.js

@@ -85,9 +85,9 @@ const initGlobalSearchParser = function(parser) {
       result = parser.parse(beforeCursor + '\u2020' + afterCursor);
     } catch (err) {
       if (debug) {
-        console.log(err);
-        console.error(err.stack);
-        console.log(parser.yy.error);
+        console.warn(err);
+        console.warn(err.stack);
+        console.warn(parser.yy.error);
       }
       return {
         facets: {},

+ 2 - 0
desktop/core/src/desktop/js/sql/aceLocationHandler.js

@@ -591,6 +591,7 @@ class AceLocationHandler {
           lastKnownStatements.editorChangeTime = lastChangeTime;
 
           if (typeof hueDebug !== 'undefined' && hueDebug.logStatementLocations) {
+            // eslint-disable-next-line no-restricted-syntax
             console.log(lastKnownStatements);
           }
         } catch (error) {
@@ -787,6 +788,7 @@ class AceLocationHandler {
           self.snippet.positionStatement().syntaxError = true;
         }
         if (hueDebug && hueDebug.showSyntaxParseResult) {
+          // eslint-disable-next-line no-restricted-syntax
           console.log(e.data.syntaxError);
         }
 

+ 1 - 0
desktop/core/src/desktop/js/sql/spec/autocompleteResultsSpec.js

@@ -327,6 +327,7 @@ describe('AutocompleteResults.js', () => {
         }
         if (subject.loading()) {
           for (let i = 0; i < jasmine.Ajax.requests.count(); i++) {
+            // eslint-disable-next-line no-restricted-syntax
             console.log(jasmine.Ajax.requests.at(i));
           }
           fail('Still loading, missing ajax spec?');

+ 1 - 0
desktop/core/src/desktop/js/sql/spec/sqlAutocompleterSpec_IGNORE.js

@@ -60,6 +60,7 @@ describe('sqlAutocomplete.js', () => {
   afterEach(() => {
     if (subject.suggestions.loading()) {
       for (let i = 0; i < jasmine.Ajax.requests.count(); i++) {
+        // eslint-disable-next-line no-restricted-syntax
         console.log(jasmine.Ajax.requests.at(i));
       }
       fail('Still loading, missing ajax spec?');

+ 2 - 2
desktop/core/src/desktop/js/sql/sqlAutocompleter.js

@@ -80,7 +80,7 @@ class SqlAutocompleter {
               resolve(autocompleteParser.parseSql(beforeCursor, afterCursor));
             })
             .catch(err => {
-              console.log(err);
+              console.warn(err);
               reject(err);
             });
         } else {
@@ -131,10 +131,10 @@ class SqlAutocompleter {
       parseResult = await this.parseActiveStatement();
 
       if (typeof hueDebug !== 'undefined' && hueDebug.showParseResult) {
+        // eslint-disable-next-line no-restricted-syntax
         console.log(parseResult);
       }
     } catch (e) {
-      console.log(e);
       if (typeof console.warn !== 'undefined') {
         console.warn(e);
       }

+ 0 - 1
desktop/core/src/desktop/js/sql/sqlSyntaxWebWorker.js

@@ -47,7 +47,6 @@ const onMessage = msg => {
   throttle = setTimeout(() => {
     sqlParserRepository.getSyntaxParser(msg.data.type).then(parser => {
       const syntaxError = parser.parseSyntax(msg.data.beforeCursor, msg.data.afterCursor);
-      console.log(syntaxError);
 
       if (syntaxError) {
         toAbsoluteLocation(msg.data.statementLocation, syntaxError.loc);

+ 1 - 0
desktop/core/src/desktop/js/utils/hueDebug.js

@@ -29,6 +29,7 @@ const hueDebug = {
     clearInstance('HueDataCatalog_impala_');
     clearInstance('HueDataCatalog_impala_multiTable_');
     Promise.all(promises).then(() => {
+      // eslint-disable-next-line no-restricted-syntax
       console.log('Done! Refresh the browser.');
     });
   }

+ 4 - 0
tools/jison/generateParsers.js

@@ -14,6 +14,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+/* eslint-disable no-restricted-syntax */
+
 const fs = require('fs');
 const exec = require('child_process').exec;
 
@@ -544,3 +546,5 @@ identifySqlParsers().then(() => {
     generateRecursive();
   });
 });
+
+/* eslint-enable no-restricted-syntax */

+ 4 - 0
tools/sql-docs/ditamapParser.js

@@ -14,6 +14,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+/* eslint-disable no-restricted-syntax */
+
 const libxml = require('libxmljs');
 
 const Topic = require('./Topic');
@@ -171,3 +173,5 @@ const extractFromMapNode = (mapNode, ditamapFile, docRootPath, parseResult) => {
 module.exports = {
   parseDitamap: parseDitamap
 };
+
+/* eslint-enable no-restricted-syntax */

+ 4 - 0
tools/sql-docs/docExtractor.js

@@ -14,6 +14,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+/* eslint-disable no-restricted-syntax */
+
 const program = require('commander');
 
 const extractorUtils = require('./extractorUtils');
@@ -81,3 +83,5 @@ Promise.all(ditamapParsePromises).then(parseResults => {
       });
   });
 });
+
+/* eslint-enable no-restricted-syntax */

+ 4 - 0
tools/sql-docs/docXmlParser.js

@@ -14,6 +14,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+/* eslint-disable no-restricted-syntax */
+
 const DocFragment = require('./DocFragment');
 const Topic = require('./Topic');
 const extractorUtils = require('./extractorUtils');
@@ -376,3 +378,5 @@ module.exports = {
   parseTopics: parseTopics,
   isHidden: isHidden
 };
+
+/* eslint-enable no-restricted-syntax */

+ 4 - 0
tools/sql-docs/extractorUtils.js

@@ -14,6 +14,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+/* eslint-disable no-restricted-syntax */
+
 const fs = require('fs');
 
 const LOG_NAME = 'extractorUtils.js';
@@ -178,3 +180,5 @@ module.exports = {
   removeAllAttributes: removeAllAttributes,
   findFragment: findFragment
 };
+
+/* eslint-enable no-restricted-syntax */

+ 4 - 0
tools/sql-docs/hiveExtractor.js

@@ -14,6 +14,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+/* eslint-disable no-restricted-syntax */
+
 const program = require('commander');
 
 const EPub = require('epub');
@@ -208,3 +210,5 @@ epub.on('end', () => {
 });
 
 epub.parse();
+
+/* eslint-enable no-restricted-syntax */

+ 4 - 0
tools/sql-docs/jsonHandler.js

@@ -14,6 +14,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+/* eslint-disable no-restricted-syntax */
+
 const fs = require('fs');
 const mkdirp = require('mkdirp');
 const path = require('path');
@@ -149,3 +151,5 @@ const saveTopics = (topics, outputPath, makoPath, isImpala) => {
 module.exports = {
   saveTopics: saveTopics
 };
+
+/* eslint-enable no-restricted-syntax */

+ 4 - 0
tools/sql-docs/topicLinker.js

@@ -14,6 +14,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+/* eslint-disable no-restricted-syntax */
+
 const extractorUtils = require('./extractorUtils');
 const EXTERNAL_DOC_URL_PREFIX = 'https://www.cloudera.com/documentation/enterprise/latest/';
 
@@ -296,3 +298,5 @@ const linkTopics = (parseResults, cssClassPrefix) => {
 module.exports = {
   linkTopics: linkTopics
 };
+
+/* eslint-enable no-restricted-syntax */