This is an automated email from the ASF dual-hosted git repository.

yao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new e818e9cefa0 [SPARK-45202][BUILD] Fix lint-js tool and js format
e818e9cefa0 is described below

commit e818e9cefa012037a38a99819498f331697d3a50
Author: Kent Yao <y...@apache.org>
AuthorDate: Tue Sep 19 11:05:41 2023 +0800

    [SPARK-45202][BUILD] Fix lint-js tool and js format
    
    ### What changes were proposed in this pull request?
    
    This PR fixes lint-js tool, which covers only js files in the core module, 
and also fixes the js format of the rest modules.
    
    ```
    dev/lint-js
    
    
/Users/kentyao/spark/sql/core/src/main/resources/org/apache/spark/sql/execution/ui/static/spark-sql-viz.js
       29:10  error  'renderPlanViz' is defined but never used                  
                    no-unused-vars
       31:18  error  'd3' is not defined                                        
                    no-undef
       35:11  error  'graphlibDot' is not defined                               
                    no-undef
       37:22  error  'dagreD3' is not defined                                   
                    no-undef
       46:27  error  '$' is not defined                                         
                    no-undef
       59:38  error  'd3' is not defined                                        
                    no-undef
       66:21  error  'd3' is not defined                                        
                    no-undef
       67:3   error  'd3' is not defined                                        
                    no-undef
       68:20  error  'd' is defined but never used. Allowed unused args must 
match /^_ignored_.*/u  no-unused-vars
       69:21  error  'd3' is not defined                                        
                    no-undef
       70:7   error  '$' is not defined                                         
                    no-undef
      104:55  error  'i' is defined but never used. Allowed unused args must 
match /^_ignored_.*/u  no-unused-vars
      108:1   error  Expected indentation of 10 spaces but found 12             
                    indent
      109:1   error  Expected indentation of 10 spaces but found 12             
                    indent
      115:1   error  Expected indentation of 4 spaces but found 6               
                    indent
      116:1   error  Expected indentation of 6 spaces but found 8               
                    indent
      116:16  error  'd3' is not defined                                        
                    no-undef
      117:1   error  Expected indentation of 4 spaces but found 6               
                    indent
      118:1   error  Expected indentation of 2 spaces but found 4               
                    indent
      129:13  error  'd3' is not defined                                        
                    no-undef
      130:34  error  'd3' is not defined                                        
                    no-undef
      133:13  error  'd3' is not defined                                        
                    no-undef
      134:34  error  'd3' is not defined                                        
                    no-undef
      137:13  error  'd3' is not defined                                        
                    no-undef
      138:15  error  'd3' is not defined                                        
                    no-undef
      142:13  error  'd3' is not defined                                        
                    no-undef
      143:15  error  'd3' is not defined                                        
                    no-undef
      180:11  error  'd3' is not defined                                        
                    no-undef
      196:3   error  '$' is not defined                                         
                    no-undef
      198:26  error  '$' is not defined                                         
                    no-undef
      199:1   error  Expected indentation of 6 spaces but found 8               
                    indent
      200:1   error  Expected indentation of 8 spaces but found 10              
                    indent
      201:1   error  Expected indentation of 8 spaces but found 10              
                    indent
      201:28  error  'd3' is not defined                                        
                    no-undef
      201:41  error  '$' is not defined                                         
                    no-undef
      202:1   error  Expected indentation of 8 spaces but found 10              
                    indent
      203:1   error  Expected indentation of 8 spaces but found 10              
                    indent
      204:1   error  Expected indentation of 8 spaces but found 10              
                    indent
      204:11  error  '$' is not defined                                         
                    no-undef
      205:1   error  Expected indentation of 6 spaces but found 8               
                    indent
      206:1   error  Expected indentation of 8 spaces but found 10              
                    indent
      207:1   error  Expected indentation of 6 spaces but found 8               
                    indent
      208:1   error  Expected indentation of 4 spaces but found 2               
                    indent
      210:22  error  '$' is not defined                                         
                    no-undef
      212:1   error  Expected indentation of 4 spaces but found 6               
                    indent
      212:40  error  '$' is not defined                                         
                    no-undef
      223:27  error  '$' is not defined                                         
                    no-undef
    
    ✖ 47 problems (47 errors, 0 warnings)
      17 errors and 0 warnings potentially fixable with the `--fix` option.
    
    /Users/kentyao/spark/docs/js/api-docs.js
      20:1   error  '$' is not defined                                          
                       no-undef
      21:21  error  '$' is not defined                                          
                       no-undef
      29:14  error  '$' is not defined                                          
                       no-undef
      32:22  error  'index' is defined but never used. Allowed unused args must 
match /^_ignored_.*/u  no-unused-vars
      33:19  error  '$' is not defined                                          
                       no-undef
      35:5   error  '$' is not defined                                          
                       no-undef
      45:1   error  '$' is not defined                                          
                       no-undef
      50:5   error  'MathJax' is not defined                                    
                       no-undef
    
    /Users/kentyao/spark/docs/js/api-javadocs.js
      20:1   error  '$' is not defined                                          
                       no-undef
      27:14  error  '$' is not defined                                          
                       no-undef
      30:22  error  'index' is defined but never used. Allowed unused args must 
match /^_ignored_.*/u  no-unused-vars
      31:19  error  '$' is not defined                                          
                       no-undef
      33:5   error  '$' is not defined                                          
                       no-undef
      37:22  error  'index' is defined but never used. Allowed unused args must 
match /^_ignored_.*/u  no-unused-vars
      38:9   error  '$' is not defined                                          
                       no-undef
      39:7   error  '$' is not defined                                          
                       no-undef
      40:16  error  '$' is not defined                                          
                       no-undef
      44:30  error  '$' is not defined                                          
                       no-undef
      54:16  error  '$' is not defined                                          
                       no-undef
      55:7   error  '$' is not defined                                          
                       no-undef
      57:7   error  '$' is not defined                                          
                       no-undef
    
    /Users/kentyao/spark/docs/js/main.js
       28:3   error  '$' is not defined                no-undef
       29:5   error  '$' is not defined                no-undef
       32:18  error  '$' is not defined                no-undef
       33:5   error  '$' is not defined                no-undef
       36:23  error  '$' is not defined                no-undef
       40:7   error  '$' is not defined                no-undef
       41:7   error  '$' is not defined                no-undef
       43:18  error  '$' is not defined                no-undef
       44:19  error  '$' is not defined                no-undef
       45:20  error  '$' is not defined                no-undef
       50:7   error  '$' is not defined                no-undef
       54:13  error  'buttonLabel' is already defined  no-redeclare
       56:13  error  'buttonLabel' is already defined  no-redeclare
       63:9   error  '$' is not defined                no-undef
       75:3   error  '$' is not defined                no-undef
       79:24  error  '$' is not defined                no-undef
       79:47  error  '$' is not defined                no-undef
       80:5   error  '$' is not defined                no-undef
       80:13  error  '$' is not defined                no-undef
       81:5   error  '$' is not defined                no-undef
       81:27  error  '$' is not defined                no-undef
       89:31  error  '$' is not defined                no-undef
       90:18  error  '$' is not defined                no-undef
       91:5   error  '$' is not defined                no-undef
       95:1   error  '$' is not defined                no-undef
       99:3   error  'anchors' is not defined          no-undef
      102:3   error  'anchors' is not defined          no-undef
      104:3   error  '$' is not defined                no-undef
      110:3   error  '$' is not defined                no-undef
      115:21  error  '$' is not defined                no-undef
      116:27  error  '$' is not defined                no-undef
      117:25  error  '$' is not defined                no-undef
      119:3   error  '$' is not defined                no-undef
      123:25  error  '$' is not defined                no-undef
      129:25  error  '$' is not defined                no-undef
    
    ✖ 56 problems (56 errors, 0 warnings)
    ```
    
    ### Why are the changes needed?
    
    bugfix and format fix
    
    ### Does this PR introduce _any_ user-facing change?
    
    no
    
    ### How was this patch tested?
    
    dev/lint-js in CI
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    no
    
    Closes #42982 from yaooqinn/SPARK-45202.
    
    Authored-by: Kent Yao <y...@apache.org>
    Signed-off-by: Kent Yao <y...@apache.org>
---
 dev/lint-js                                        |  2 +-
 docs/js/api-docs.js                                |  4 ++-
 docs/js/api-javadocs.js                            |  6 ++--
 docs/js/main.js                                    | 10 ++++--
 .../spark/sql/execution/ui/static/spark-sql-viz.js | 36 +++++++++++++---------
 5 files changed, 36 insertions(+), 22 deletions(-)

diff --git a/dev/lint-js b/dev/lint-js
index ce06e282192..146ed2bcc5c 100755
--- a/dev/lint-js
+++ b/dev/lint-js
@@ -44,7 +44,7 @@ if ! npm ls eslint > /dev/null; then
   npm ci eslint
 fi
 
-npx eslint -c "$SPARK_ROOT_DIR/dev/eslint.json" $LINT_TARGET_FILES | tee 
"$LINT_JS_REPORT_FILE_NAME"
+npx eslint -c "$SPARK_ROOT_DIR/dev/eslint.json" ${LINT_TARGET_FILES[@]} | tee 
"$LINT_JS_REPORT_FILE_NAME"
 lint_status=$?
 
 if [ "$lint_status" = "0" ] ; then
diff --git a/docs/js/api-docs.js b/docs/js/api-docs.js
index 287fce61540..aeed01a966b 100644
--- a/docs/js/api-docs.js
+++ b/docs/js/api-docs.js
@@ -17,6 +17,8 @@
 
 /* Dynamically injected post-processing code for the API docs */
 
+/* global $, MathJax */
+
 $(document).ready(function() {
   var annotations = 
$("dt:contains('Annotations')").next("dd").children("span.name");
   addBadges(annotations, "AlphaComponent", ":: AlphaComponent ::", '<span 
class="alphaComponent badge">Alpha Component</span>');
@@ -29,7 +31,7 @@ function addBadges(allAnnotations, name, tag, html) {
   var tags = $(".cmt:contains(" + tag + ")")
 
   // Remove identifier tags from comments
-  tags.each(function(index) {
+  tags.each(function(_ignored_index) {
     var oldHTML = $(this).html();
     var newHTML = oldHTML.replace(tag, "");
     $(this).html(newHTML);
diff --git a/docs/js/api-javadocs.js b/docs/js/api-javadocs.js
index ead13d6e5fa..ff7ad8b3a1d 100644
--- a/docs/js/api-javadocs.js
+++ b/docs/js/api-javadocs.js
@@ -17,6 +17,8 @@
 
 /* Dynamically injected post-processing code for the API docs */
 
+/* global $ */
+
 $(document).ready(function() {
   addBadges(":: AlphaComponent ::", '<span class="alphaComponent badge">Alpha 
Component</span>');
   addBadges(":: DeveloperApi ::", '<span class="developer badge">Developer 
API</span>');
@@ -27,14 +29,14 @@ function addBadges(tag, html) {
   var tags = $(".block:contains(" + tag + ")")
 
   // Remove identifier tags
-  tags.each(function(index) {
+  tags.each(function(_ignored_index) {
     var oldHTML = $(this).html();
     var newHTML = oldHTML.replace(tag, "");
     $(this).html(newHTML);
   });
 
   // Add html badge tags
-  tags.each(function(index) {
+  tags.each(function(_ignored_index) {
     if ($(this).parent().is('td.colLast')) {
       $(this).parent().prepend(html);
     } else if ($(this).parent('li.blockList')
diff --git a/docs/js/main.js b/docs/js/main.js
index 97434146556..1c601f5210a 100755
--- a/docs/js/main.js
+++ b/docs/js/main.js
@@ -15,9 +15,12 @@
  * limitations under the License.
  */
 
+/* global $, anchors */
+
 /* Custom JavaScript code in the MarkDown docs */
 
 // Enable language-specific code tabs
+
 function codeTabs() {
   var counter = 0;
   var langImages = {
@@ -48,12 +51,13 @@ function codeTabs() {
       var capitalizedLang = lang.substr(0, 1).toUpperCase() + lang.substr(1);
       var id = "tab_" + lang + "_" + counter;
       $(this).attr("id", id);
+      var buttonLabel = "";
       if (image != null && langImages[lang]) {
-        var buttonLabel = "<img src='" +langImages[lang] + "' alt='" + 
capitalizedLang + "' />";
+        buttonLabel = "<img src='" +langImages[lang] + "' alt='" + 
capitalizedLang + "' />";
       } else if (notabs == null) {
-        var buttonLabel = "<b>" + capitalizedLang + "</b>";
+        buttonLabel = "<b>" + capitalizedLang + "</b>";
       } else {
-        var buttonLabel = ""
+        buttonLabel = ""
       }
 
       // Add the link to the tab
diff --git 
a/sql/core/src/main/resources/org/apache/spark/sql/execution/ui/static/spark-sql-viz.js
 
b/sql/core/src/main/resources/org/apache/spark/sql/execution/ui/static/spark-sql-viz.js
index 1847fd5f3ef..a47a588f8c4 100644
--- 
a/sql/core/src/main/resources/org/apache/spark/sql/execution/ui/static/spark-sql-viz.js
+++ 
b/sql/core/src/main/resources/org/apache/spark/sql/execution/ui/static/spark-sql-viz.js
@@ -15,15 +15,20 @@
  * limitations under the License.
  */
 
+/* global $, d3, dagreD3, graphlibDot */
+
 var PlanVizConstants = {
   svgMarginX: 16,
   svgMarginY: 16
 };
 
+/* eslint-disable no-unused-vars */
 function shouldRenderPlanViz() {
   return planVizContainer().selectAll("svg").empty();
 }
+/* eslint-enable no-unused-vars */
 
+/* eslint-disable no-unused-vars */
 function renderPlanViz() {
   var svg = planVizContainer().append("svg");
   var metadata = d3.select("#plan-viz-metadata");
@@ -49,6 +54,7 @@ function renderPlanViz() {
   resizeSvg(svg);
   postprocessForAdditionalMetrics();
 }
+/* eslint-enable no-unused-vars */
 
 /* -------------------- *
  * | Helper functions | *
@@ -63,7 +69,7 @@ function planVizContainer() { return 
d3.select("#plan-viz-graph"); }
 function setupTooltipForSparkPlanNode(nodeId) {
   var nodeTooltip = d3.select("#plan-meta-data-" + nodeId).text();
   d3.select("svg g .node_" + nodeId)
-    .each(function(d) {
+    .each(function(_ignored_d) {
       var domNode = d3.select(this).node();
       $(domNode).tooltip({
         title: nodeTooltip, trigger: "hover focus", container: "body", 
placement: "top"
@@ -99,12 +105,12 @@ function preprocessGraphLayout(g) {
       splitter = "<br>";
     }
 
-    node.label.split(splitter).forEach(function(text, i) {
+    node.label.split(splitter).forEach(function(text, _ignored_i) {
       var newTexts = text.match(stageAndTaskMetricsPattern);
       if (newTexts) {
         node.label = node.label.replace(
-            newTexts[0],
-            newTexts[1] + firstSeparator + newTexts[2] + secondSeparator + 
newTexts[3]);
+          newTexts[0],
+          newTexts[1] + firstSeparator + newTexts[2] + secondSeparator + 
newTexts[3]);
       }
     });
   }
@@ -193,20 +199,20 @@ function postprocessForAdditionalMetrics() {
   $("g.cluster text tspan")
     .each(function() {
       var originalText = $(this).text();
-        if (originalText.indexOf(labelSeparator) > 0) {
-          var newTexts = originalText.split(labelSeparator);
-          var thisD3Node = d3.selectAll($(this));
-          thisD3Node.text(newTexts[0]);
-          thisD3Node.append("tspan").attr("class", 
"stageId-and-taskId-metrics").text(newTexts[1]);
-          $(this).append(newTexts[2]);
-        } else {
-          return originalText;
-        }
-  });
+      if (originalText.indexOf(labelSeparator) > 0) {
+        var newTexts = originalText.split(labelSeparator);
+        var thisD3Node = d3.selectAll($(this));
+        thisD3Node.text(newTexts[0]);
+        thisD3Node.append("tspan").attr("class", 
"stageId-and-taskId-metrics").text(newTexts[1]);
+        $(this).append(newTexts[2]);
+      } else {
+        return originalText;
+      }
+    });
 
   var checkboxNode = $("#stageId-and-taskId-checkbox");
   checkboxNode.click(function() {
-      onClickAdditionalMetricsCheckbox($(this));
+    onClickAdditionalMetricsCheckbox($(this));
   });
   var isChecked = window.localStorage.getItem("stageId-and-taskId-checked") 
=== "true";
   checkboxNode.prop("checked", isChecked);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to