Skip to content

Commit 0b5de0e

Browse files
committed
Fix broken eslint version and stuck in loop issues
1 parent ae24728 commit 0b5de0e

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

prompts/eslint/Dockerfile

+13-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,19 @@ RUN apk add --no-cache bash jq
55

66
ENTRYPOINT ["/lint.sh"]
77

8-
# Install eslint versions 6-9
9-
RUN npm install -g eslint@6 eslint@7 eslint@8 eslint@9 typescript typescript-eslint
8+
# Install node modules to /eslint
9+
WORKDIR /eslint7
10+
RUN npm install --save eslint@7 typescript
11+
12+
WORKDIR /eslint8
13+
RUN npm install --save eslint@8 typescript typescript-eslint
14+
15+
WORKDIR /eslint9
16+
RUN npm install --save eslint@9 typescript typescript-eslint@8.0.0-alpha.50
17+
18+
19+
20+
WORKDIR /
1021

1122
COPY scripts/lint.sh /lint.sh
1223
COPY scripts/remap_lint.sh /remap_lint.sh

prompts/eslint/scripts/lint.sh

+16-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,23 @@ ESLINT_ARGS=$(echo $ARGS | jq -r '.args')
1111

1212
ESLINT_VERSION=$(echo $ARGS | jq -r '.version')
1313

14+
ESLINT_DIR="/eslint$ESLINT_VERSION"
15+
16+
TEMP_DIR="/eslint-temp"
17+
mkdir -p $TEMP_DIR
18+
19+
cp -r $PROJECT_DIR/. $TEMP_DIR
20+
cp -r $ESLINT_DIR/. $TEMP_DIR
21+
22+
cd $TEMP_DIR
23+
1424
# How verbose to output the linting results
1525
OUTPUT_LEVEL=$(echo $ARGS | jq -r '.outputLevel')
1626

17-
echo "Linting: eslint@$ESLINT_VERSION $ESLINT_ARGS"
27+
ARGS="eslint@$ESLINT_VERSION --format json $ESLINT_ARGS"
28+
29+
echo "Running npx with args: $ARGS"
30+
31+
ESLINT_JSON=$(npx --no-install $ARGS )
1832

19-
ESLINT_JSON=$(npx --no-install "eslint@$ESLINT_VERSION" --format json "$ESLINT_ARGS" | /remap_lint.sh "$OUTPUT_LEVEL")
33+
echo $ESLINT_JSON | /remap_lint.sh "$OUTPUT_LEVEL"

prompts/eslint/scripts/remap_lint.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ ALL_MESSAGES=$(echo $INPUT | jq -r -c '.[].messages')
1818
# convert to array
1919
IFS=$'\n' FILE_PATHS=($FILE_PATHS)
2020
IFS=$'\n' ALL_MESSAGES=($ALL_MESSAGES)
21+
echo "Peparing output"
22+
AFFECTED_FILE_COUNT=$(echo $INPUT | jq -r 'length')
2123
# Iterate over file paths
2224
for index in "${!FILE_PATHS[@]}"; do
2325
file_path=${FILE_PATHS[$index]}
2426
# Get the messages for the file path
2527
messages=${ALL_MESSAGES[$index]}
2628

2729
if [ $OUTPUT_MODE == "complaints" ]; then
28-
30+
echo "complaints"
2931
# Complaint: {filePath: "path", "start": [line, column], "end": [line, column], "message": "message", "severity": "severity", "ruleId": "ruleId"}
3032
messages=$(echo $messages | jq -r -c '.[]')
3133
IFS=$'\n' messages=($messages)
@@ -40,6 +42,7 @@ for index in "${!FILE_PATHS[@]}"; do
4042
echo $COMPLAINT
4143
done
4244
elif [ $OUTPUT_MODE == "condensed" ]; then
45+
echo "condensed"
4346
# Remove duplicates
4447
messages=$(echo $messages | jq -r -c 'unique_by(.ruleId)')
4548
messages=$(echo $messages | jq -r -c '.[]')
@@ -58,6 +61,7 @@ for index in "${!FILE_PATHS[@]}"; do
5861
done
5962
elif [ $OUTPUT_MODE == "json" ]; then
6063
OUTPUT=$(echo $INPUT)
64+
break
6165
else
6266
# Summary
6367
AFFECTED_FILE_COUNT=$(echo $INPUT | jq -r 'length')
@@ -68,6 +72,7 @@ for index in "${!FILE_PATHS[@]}"; do
6872
else
6973
OUTPUT="No violations found."
7074
fi
75+
break
7176
fi
7277
done
7378

0 commit comments

Comments
 (0)