File tree Expand file tree Collapse file tree 5 files changed +47
-40
lines changed
Expand file tree Collapse file tree 5 files changed +47
-40
lines changed Original file line number Diff line number Diff line change @@ -9,5 +9,7 @@ ENTRYPOINT ["/lint.sh"]
99RUN npm install -g eslint@6 eslint@7 eslint@8 eslint@9 typescript typescript-eslint
1010
1111COPY scripts/lint.sh /lint.sh
12+ COPY scripts/remap_lint.sh /remap_lint.sh
1213
13- RUN chmod +x /lint.sh
14+ RUN chmod +x /lint.sh
15+ RUN chmod +x /remap_lint.sh
Original file line number Diff line number Diff line change @@ -32,8 +32,7 @@ if [ $TYPESCRIPT == 'false' ]; then
3232 LINT_ARGS=" --fix $FILES "
3333 fi
3434 # Pass files array as args to standard
35- standard $LINT_ARGS
36- exit $?
35+ standard $LINT_ARGS | standard-json | /remap_lint.sh
3736fi
3837
3938echo " Running ts-standard..."
@@ -71,7 +70,7 @@ for TS_ROOT in $TS_ROOTS; do
7170 LINT_ARGS=" $TS_FILES_IN_ROOT "
7271 fi
7372
74- TS_OUTPUT+=$( ts-standard $LINT_ARGS )
73+ TS_OUTPUT+=$( ts-standard $LINT_ARGS | standard-json | /remap_lint.sh )
7574 # If ts-standard failed and EXIT_CODE is 0, set EXIT_CODE
7675 if [ $? -ne 0 ] && [ $EXIT_CODE -eq 0 ]; then
7776 EXIT_CODE=$?
Original file line number Diff line number Diff line change @@ -15,38 +15,4 @@ echo "Linting: eslint@$ESLINT_VERSION $ESLINT_ARGS"
1515
1616ESLINT_JSON=$( npx --no-install " eslint@$ESLINT_VERSION " --format json " $ESLINT_ARGS " )
1717
18- VIOLATIONS_BY_ID=" {}"
19-
20- FILE_PATHS=$( echo $ESLINT_JSON | jq -r ' .[].filePath' )
21- ALL_MESSAGES=$( echo $ESLINT_JSON | jq -r -c ' .[].messages' )
22-
23- # convert to array
24- IFS=$' \n ' FILE_PATHS=($FILE_PATHS )
25- IFS=$' \n ' ALL_MESSAGES=($ALL_MESSAGES )
26- # Iterate over file paths
27- for index in " ${! FILE_PATHS[@]} " ; do
28- file_path=${FILE_PATHS[$index]}
29- # Get the messages for the file path
30- messages=${ALL_MESSAGES[$index]}
31- # Remove duplicates
32- messages=$( echo $messages | jq -r -c ' unique_by(.ruleId)' )
33- messages=$( echo $messages | jq -r -c ' .[]' )
34- IFS=$' \n ' messages=($messages )
35-
36- # Iterate over messages
37- for message in " ${messages[@]} " ; do
38- # Get the message id
39- ID=$( echo $message | jq -r ' .ruleId' )
40-
41- # If the violations_by_id[id] is null, set it to empty array
42- if [[ $( echo $VIOLATIONS_BY_ID | jq -r " has(\" $ID \" )" ) == ' false' ]]; then
43- VIOLATIONS_BY_ID=$( echo $VIOLATIONS_BY_ID | jq --arg id " $ID " ' .[$id] = []' )
44- fi
45- # Add the fileid to the violations object key
46- VIOLATIONS_BY_ID=$( echo $VIOLATIONS_BY_ID | jq --arg id " $ID " --arg file_path " $file_path " ' .[$id] += [$file_path]' )
47- done
48- done
49-
50- echo $VIOLATIONS_BY_ID
51-
52- exit 0
18+ echo $ESLINT_JSON | /remap_lint.sh
Original file line number Diff line number Diff line change 1+ # Get piped stdin as input
2+ INPUT=$( cat)
3+
4+ VIOLATIONS_BY_ID=" {}"
5+
6+ FILE_PATHS=$( echo $INPUT | jq -r ' .[].filePath' )
7+ ALL_MESSAGES=$( echo $INPUT | jq -r -c ' .[].messages' )
8+
9+ # convert to array
10+ IFS=$' \n ' FILE_PATHS=($FILE_PATHS )
11+ IFS=$' \n ' ALL_MESSAGES=($ALL_MESSAGES )
12+ # Iterate over file paths
13+ for index in " ${! FILE_PATHS[@]} " ; do
14+ file_path=${FILE_PATHS[$index]}
15+ # Get the messages for the file path
16+ messages=${ALL_MESSAGES[$index]}
17+ # Remove duplicates
18+ messages=$( echo $messages | jq -r -c ' unique_by(.ruleId)' )
19+ messages=$( echo $messages | jq -r -c ' .[]' )
20+ IFS=$' \n ' messages=($messages )
21+
22+ # Iterate over messages
23+ for message in " ${messages[@]} " ; do
24+ # Get the message id
25+ ID=$( echo $message | jq -r ' .ruleId' )
26+
27+ # If the violations_by_id[id] is null, set it to empty array
28+ if [[ $( echo $VIOLATIONS_BY_ID | jq -r " has(\" $ID \" )" ) == ' false' ]]; then
29+ VIOLATIONS_BY_ID=$( echo $VIOLATIONS_BY_ID | jq --arg id " $ID " ' .[$id] = []' )
30+ fi
31+ # Add the fileid to the violations object key
32+ VIOLATIONS_BY_ID=$( echo $VIOLATIONS_BY_ID | jq --arg id " $ID " --arg file_path " $file_path " ' .[$id] += [$file_path]' )
33+ done
34+ done
35+
36+ echo $VIOLATIONS_BY_ID
37+
38+ exit 0
Original file line number Diff line number Diff line change @@ -6,9 +6,11 @@ RUN apk add --no-cache bash fd jq
66ENTRYPOINT ["/lint-standardjs.sh" ]
77
88# Install standard and ts-standard
9- RUN npm install -g standard ts-standard
9+ RUN npm install -g standard ts-standard standard-json
1010
1111COPY scripts/lint-standardjs.sh /lint-standardjs.sh
12+ COPY scripts/remap_lint.sh /remap_lint.sh
1213
1314RUN chmod +x /lint-standardjs.sh
15+ RUN chmod +x /remap_lint.sh
1416
You can’t perform that action at this time.
0 commit comments