Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-35175][BUILD] Add linter for JavaScript source files. #32274

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
61b4782
Add ESLint support.
sarutak Apr 21, 2021
e2fcd9e
Add a newline at the end of .gitignore.
sarutak Apr 21, 2021
990e538
Modify .rat-exclude.
sarutak Apr 22, 2021
d6eb61a
Add docs/js for a lint target.
sarutak Apr 25, 2021
c1afc31
npm install -> npm ci to avoid package-lock.json being changed.
sarutak May 6, 2021
d858aa8
Upgrade eslint.
sarutak May 6, 2021
e459d90
Add switch-case rule.
sarutak May 6, 2021
1ad98a5
Fix style for webui.js.
sarutak May 6, 2021
feb6d76
Disable indentation rule for member expressions.
sarutak May 6, 2021
0a1a461
Fix style for utils.js.
sarutak May 6, 2021
71ea913
Fix style for timeline-view.js.
sarutak May 6, 2021
5ec9eea
Fix style for table.js.
sarutak May 6, 2021
701514a
Fix style for structured-streaming-page.js.
sarutak May 6, 2021
5b18e69
Fix style for streaming-page.js.
sarutak May 6, 2021
1d209ca
Add ignored argument rule.
sarutak May 6, 2021
4c8cb17
Fix style for stagepage.js.
sarutak May 6, 2021
4884b8e
Fix style for spark-dag-viz.js.
sarutak May 6, 2021
da34039
Fix style for log-view.js.
sarutak May 6, 2021
896b475
Modify indentation in eslint.json.
sarutak May 6, 2021
e8170eb
Fix style for initialize-tooltips.js.
sarutak May 6, 2021
e3847db
Fix style for historypage.js.
sarutak May 6, 2021
b129c4e
Fix style for historypage-common.js.
sarutak May 6, 2021
d174384
Fix style for executorspage.js.
sarutak May 6, 2021
1d67631
Revert "Fix style for stagepage.js."
sarutak May 6, 2021
82a9947
Merge branch 'master' of https://github.com/apache/spark into introdu…
sarutak May 6, 2021
5bda9fc
Fix style for stagepage.js.
sarutak May 6, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -52,6 +52,7 @@ sql/docs
sql/site
lib_managed/
lint-r-report.log
lint-js-report.log
log/
logs/
out/
Expand Down Expand Up @@ -103,3 +104,6 @@ spark-warehouse/

# For SBT
.jvmopts

# For Node.js
node_modules
1 change: 1 addition & 0 deletions dev/.rat-excludes
Expand Up @@ -134,3 +134,4 @@ flights_tiny.txt.1
over1k
over10k
exported_table/*
node_modules
11 changes: 11 additions & 0 deletions dev/eslint.json
@@ -0,0 +1,11 @@
{
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
"rules": {
"indent": ["error", 2]
},
"ignorePatterns": ["*.min.js"]
}
55 changes: 55 additions & 0 deletions dev/lint-js
@@ -0,0 +1,55 @@
#!/usr/bin/env bash

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

set -o pipefail

SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
SPARK_ROOT_DIR="$(dirname $SCRIPT_DIR)"
LINT_JS_REPORT_FILE_NAME="$SPARK_ROOT_DIR/dev/lint-js-report.log"
LINT_TARGET_FILES=(
"$SPARK_ROOT_DIR/core/src/main/resources/org/apache/spark/ui/static/"
"$SPARK_ROOT_DIR/sql/core/src/main/resources/org/apache/spark/sql/execution/ui/static/"
Copy link
Contributor

@echohlne echohlne Apr 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just curious, should the dir: $SPARK_ROOT_DIR/docs/js/" be added to the LINT_TARGET_FILES` ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, it seems that some files should be checked. Thanks.

)

if ! type "npm" > /dev/null; then
echo "ERROR: You should install npm"
exit 1
fi

if ! type "npx" > /dev/null; then
echo "ERROR: You should install npx"
exit 1
fi

cd $SCRIPT_DIR

if ! npm ls eslint > /dev/null; then
npm install eslint
fi

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
echo "lint-js checks passed."
else
echo "lint-js checks failed."
fi

exit "$lint_status"