@@ -127,16 +127,21 @@ if [ -n "$RESOLVE_PLUGINS_DIR" ]; then
127127 # Ensure ESLint resolves plugins from the selected toolchain.
128128 CMD+=(--resolve-plugins-relative-to " $RESOLVE_PLUGINS_DIR " )
129129fi
130+ FIXED_CONFIG=" "
131+ if [ -f " ${PROJECT_ROOT} /.eslintrc.passing.json" ]; then
132+ FIXED_CONFIG=" ${PROJECT_ROOT} /.eslintrc.passing.json"
133+ elif [ -f " ${PROJECT_ROOT} /.eslintrc.json" ]; then
134+ FIXED_CONFIG=" ${PROJECT_ROOT} /.eslintrc.json"
135+ fi
130136if [ " $has_config " = false ] && [ " $ESLINT_CONFIG_MODE " != " nearest" ]; then
131- # Fixed mode: force the passing config for Drupal.org GitLab CI template defaults when requested.
132- if [ -f " ${PROJECT_ROOT} /.eslintrc.passing.json" ]; then
133- CMD+=(--config=" ${PROJECT_ROOT} /.eslintrc.passing.json" )
134- else
135- CMD+=(--config=" ${DOCROOT_PATH} /core/.eslintrc.passing.json" )
136- echo " Warning: using core ESLint config (${DOCROOT} /core/.eslintrc.passing.json); project config not found." >&2
137+ # Fixed mode: prefer project passing config, then project base config.
138+ if [ -z " $FIXED_CONFIG " ]; then
139+ echo " ESLint config file is missing. Create .eslintrc.passing.json (or .eslintrc.json) in the project root, or pass --config." >&2
140+ exit 2
137141 fi
142+ CMD+=(--config=" $FIXED_CONFIG " )
138143fi
139- CMD+=(--ext .js,.yml --ignore-pattern " **/node_modules/** " )
144+ CMD+=(--ext .js,.yml)
140145CMD+=(" ${DEFAULT_ARGS[@]} " )
141146
142147find_nearest_config () {
@@ -146,7 +151,7 @@ find_nearest_config() {
146151 while true ; do
147152 # Walk up the directory tree to find the closest ESLint config.
148153 for candidate in .eslintrc.passing.json .eslintrc .eslintrc.json .eslintrc.yaml .eslintrc.yml .eslintrc.js .eslintrc.cjs; do
149- if [ " $dir " = " web " ] || [ " $dir " = " ./web " ]; then
154+ if [ " $dir " = " $DOCROOT " ] || [ " $dir " = " ./$DOCROOT " ]; then
150155 # Skip docroot configs so nearest-mode prefers theme/module configs or root passing config.
151156 continue
152157 fi
272277
273278FILES=()
274279if [ " $explicit_paths " = false ]; then
275- DEFAULT_FILES=()
276- for candidate in " ${DOCROOT} /modules/custom" " ${DOCROOT} /themes/custom" " ${DOCROOT} /profiles/custom" ; do
277- if [ -d " $candidate " ]; then
278- while IFS= read -r file_path; do
279- DEFAULT_FILES+=(" $file_path " )
280- done < <( find " $candidate " -path ' */node_modules/*' -prune -o -type f \( -name ' *.js' -o -name ' *.yml' \) -print)
281- fi
282- done
283- if [ " ${# DEFAULT_FILES[@]} " -eq 0 ]; then
284- echo " No custom JS/YML files found under modules/custom, themes/custom, or profiles/custom. Nothing to lint." >&2
280+ if [ ! -d " $DOCROOT " ]; then
281+ echo " Configured docroot '$DOCROOT ' does not exist. Nothing to lint." >&2
285282 exit 2
286283 fi
287- FILES=(" ${DEFAULT_FILES[@]} " )
284+ FILES=(" $DOCROOT " )
288285else
289286 FILES=(" ${FINAL_ARGS[@]} " )
290287fi
291288
292289DEFAULT_CONFIG=" "
293- if [ -f " ${PROJECT_ROOT} /.eslintrc.passing.json" ]; then
294- DEFAULT_CONFIG=" ${PROJECT_ROOT} /.eslintrc.passing.json"
295- elif [ -f " ${DOCROOT_PATH} /core/.eslintrc.passing.json" ]; then
296- DEFAULT_CONFIG=" ${DOCROOT_PATH} /core/.eslintrc.passing.json"
297- fi
290+ DEFAULT_CONFIG=" $FIXED_CONFIG "
298291
299292if [ " $ESLINT_CONFIG_MODE " = " nearest" ]; then
293+ if [ " $explicit_paths " = false ]; then
294+ " ${CMD[@]} " " ${FLAGS_ARGS[@]} " " ${FILES[@]} "
295+ exit $?
296+ fi
297+
300298 # Group files by nearest config to avoid plugin conflicts across modules/themes.
301299 declare -A ESLINT_GROUPS
302300 for file_path in " ${FILES[@]} " ; do
@@ -329,7 +327,7 @@ if [ "$ESLINT_CONFIG_MODE" = "nearest" ]; then
329327 if [ -n " $plugins_dir " ]; then
330328 group_cmd+=(--resolve-plugins-relative-to " $plugins_dir " )
331329 fi
332- group_cmd+=(--ext .js,.yml --ignore-pattern " **/node_modules/** " )
330+ group_cmd+=(--ext .js,.yml)
333331 group_cmd+=(" ${DEFAULT_ARGS[@]} " )
334332 " ${group_cmd[@]} " " ${FLAGS_ARGS[@]} " " ${filtered_files[@]} "
335333 status=$?
0 commit comments