spark-test commented on code in PR #60449:
URL: https://github.com/apache/spark/pull/60449#discussion_r4584175656


##########
dev/sparktestsupport/modules.py:
##########
@@ -1938,6 +1934,27 @@ def __hash__(self):
     shell_script_test_goals=[ShellScriptTestGoal("dev/test-dependencies.sh")],
 )
 
+lint_js = Module(
+    name="lint-js",
+    dependencies=[],
+    source_file_regexes=[
+        # Keep in sync with LINT_TARGET_FILES in dev/lint-js. In the future we 
should expand
+        # dev/lint-js to lint all JavaScript in the repo, at which point these 
can become one rule
+        # for all `.js`.
+        r"core/src/main/resources/org/apache/spark/ui/static/.*\.js$",
+        
r"sql/core/src/main/resources/org/apache/spark/sql/execution/ui/static/.*\.js$",
+        r"docs/js/.*\.js$",
+        r"dev/lint-js$",
+        r"dev/eslint\.js$",

Review Comment:
   **Nit (P3):** This pattern treats `dev/eslint.js` as ESLint's configuration, 
but `dev/lint-js` runs `npx eslint -c dev/eslint.js` without `--no-eslintrc`. 
By this review's reading of ESLint's source at the versions 
`dev/package-lock.json` pins (eslint 7.32.0 with `@eslint/eslintrc` 0.4.3), 
`-c` only adds a layer on top: ESLint still merges the first `.eslintrc.*` 
file, or `package.json` with an `eslintConfig` field, that it finds in the 
linted file's directory and in every directory above it, and only 
`--no-eslintrc` turns that lookup off. So when ESLint lints `ui-test/tests/`, 
it reads `ui-test/package.json`, which stays ignored here.
   
   By this review's reading of the module rules, several of those places select 
neither `lint-js` nor root: `ui-test/package.json` and the other direct 
children of `ui-test/` select no module, an `.eslintrc.json` in `docs/` or 
`docs/js/` selects only `docs`, and one in `sql/core/` or beside the SQL UI's 
static scripts selects only `sql`. So a PR whose only change adds an 
`eslintConfig` field to `ui-test/package.json`, or a `docs/.eslintrc.json`, 
that turns on a rule the linted files break would get "There are no modules to 
test" at the JS linter step and pass. The next PR that selects `lint-js` or 
root, as any `core/` change does, would then fail ESLint on files it did not 
touch. No tracked file holds such configuration today, and the repository keeps 
its ESLint settings in `dev/eslint.js`, so this needs an unusual future change.
   
   To fix it, add `--no-eslintrc` to the `npx eslint` call in `dev/lint-js`, 
next to `-c`. ESLint then reads only `dev/eslint.js`, which this module already 
claims, and `ui-test/package.json` can stay ignored.
   
   **Verification:**
   - **Regression:** With a temporary .eslintrc.json under docs/ that sets 
max-len to 10 characters, ./dev/lint-js passes, where on the current head the 
same file makes it report max-len errors in docs/js/ and fail.
   - **Behavior:** With a temporary eslintConfig field in ui-test/package.json 
that sets max-len to 10 characters, ./dev/lint-js passes, where on the current 
head it reports max-len errors in ui-test/tests/ and fails.



##########
.github/workflows/build_and_test.yml:
##########
@@ -954,7 +954,10 @@ jobs:
       run: |
         PYTHON_EXECUTABLE=python3.12 ./dev/lint-python
     - name: JS linter
-      run: ./dev/lint-js
+      env:
+        SKIP_SCALA_BUILD: true
+        SKIP_MIMA: true
+      run: ./dev/run-tests --modules lint-js

Review Comment:
   Makes sense. The rename blind spot is in the change detection that every 
module-gated job and `is-changed.py` share, so fixing it there in a separate PR 
is reasonable.
   
   <!-- SPARK_DEV_REVIEW_REPLY 
{"feedback_id":"inline:4579775592","thread_id":"inline:4579775592","verdict_sha256":"c7e882cbd4df896aa244723810d45744c47b6cee751be9a203de3b690e6b06ed"}
 -->



##########
dev/sparktestsupport/tests/test_utils.py:
##########
@@ -37,6 +37,52 @@ def test_github_files_only_count_in_github_actions(self):
                     
determine_modules_for_files([".github/workflows/build_main.yml"]), expected
                 )
 
+    def test_lint_js_inputs_select_lint_js(self):

Review Comment:
   Sounds good to cover this wiring for every module-gated job in a follow-up. 
When you do, please include the `LINT_TARGET_FILES` check as well: `lint-js` is 
the one module whose patterns must stay in sync with a list in a script, so 
tests of the shared wiring would not cover it.
   
   <!-- SPARK_DEV_REVIEW_REPLY 
{"feedback_id":"inline:4579775594","thread_id":"inline:4579775594","verdict_sha256":"c7e882cbd4df896aa244723810d45744c47b6cee751be9a203de3b690e6b06ed"}
 -->



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to