Skip to content

Commit 7fd9bb3

Browse files
author
Colin McNeil
committed
Implement output level
1 parent 8dac30e commit 7fd9bb3

File tree

3 files changed

+59
-5
lines changed

3 files changed

+59
-5
lines changed

prompts/eslint/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ functions:
1313
version:
1414
type: number
1515
description: The ESLint version, 7-9 supported. Use 8 if unsure.
16+
outputLevel:
17+
type: number
18+
description: Accepts [0,1,2]. 0 to only output number of violations, 1 is condensed json grouped by violation id, 2 is full lint json grouped by file.
1619
required:
1720
- args
1821
- version
22+
- outputLevel
1923
container:
2024
image: vonwig/eslint:latest
2125
- name: run-standardjs
@@ -29,6 +33,9 @@ functions:
2933
fix:
3034
type: boolean
3135
description: Whether to fix the files
36+
outputLevel:
37+
type: number
38+
description: Accepts [0,1,2]. 0 to only output number of violations, 1 is condensed json grouped by violation id, 2 is full lint json grouped by file.
3239
files:
3340
type: array
3441
items:
@@ -37,6 +44,7 @@ functions:
3744
required:
3845
- typescript
3946
- fix
47+
- outputLevel
4048
container:
4149
image: vonwig/standardjs:latest
4250
- name: git-branch

prompts/eslint/scripts/lint-standardjs.sh

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/bash
22

3-
shopt -s globstar
4-
53
PROJECT_DIR="/project"
64

75
# First arg
@@ -13,6 +11,9 @@ TYPESCRIPT=$(echo $ARGS | jq -r '.typescript')
1311
# Get boolean value of fix
1412
FIX=$(echo $ARGS | jq -r '.fix')
1513

14+
# How verbose to output the linting results
15+
OUTPUT_LEVEL=$(echo $ARGS | jq -r '.outputLevel')
16+
1617
# If files key is not present, just use glob
1718

1819
if [ $(echo $ARGS | jq -r '.files') == 'null' ]; then
@@ -32,7 +33,21 @@ if [ $TYPESCRIPT == 'false' ]; then
3233
LINT_ARGS="--fix $FILES"
3334
fi
3435
# Pass files array as args to standard
35-
standard $LINT_ARGS | standard-json | /remap_lint.sh
36+
OUTPUT=$(standard $LINT_ARGS | standard-json)
37+
38+
if [ $OUTPUT_LEVEL == "0" ]; then
39+
echo "Linting with StandardJS complete."
40+
fi
41+
42+
if [ $OUTPUT_LEVEL == "1" ]; then
43+
echo "Linting with StandardJS complete. Outputting condensed JSON."
44+
echo $OUTPUT | /remap_lint.sh
45+
fi
46+
47+
if [ $OUTPUT_LEVEL == "2" ]; then
48+
echo "Linting with StandardJS complete. Outputting JSON."
49+
echo $OUTPUT
50+
fi
3651
fi
3752

3853
echo "Running ts-standard..."
@@ -70,14 +85,29 @@ for TS_ROOT in $TS_ROOTS; do
7085
LINT_ARGS="$TS_FILES_IN_ROOT"
7186
fi
7287

73-
TS_OUTPUT+=$(ts-standard $LINT_ARGS | standard-json | /remap_lint.sh)
88+
TS_OUTPUT+=$(ts-standard $LINT_ARGS | standard-json)
7489
# If ts-standard failed and EXIT_CODE is 0, set EXIT_CODE
7590
if [ $? -ne 0 ] && [ $EXIT_CODE -eq 0 ]; then
7691
EXIT_CODE=$?
7792
fi
7893
cd $PROJECT_DIR
7994
done
8095

96+
97+
if [ $OUTPUT_LEVEL == "0" ]; then
98+
echo "Linting with StandardJS (TS) complete."
99+
fi
100+
101+
if [ $OUTPUT_LEVEL == "1" ]; then
102+
echo "Linting with StandardJS (TS) complete. Outputting condensed JSON."
103+
echo $TS_OUTPUT | /remap_lint.sh
104+
fi
105+
106+
if [ $OUTPUT_LEVEL == "2" ]; then
107+
echo "Linting with StandardJS (TS) complete. Outputting JSON."
108+
echo $TS_OUTPUT
109+
fi
110+
81111
echo $TS_OUTPUT
82112

83113
exit $EXIT_CODE

prompts/eslint/scripts/lint.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,24 @@ ESLINT_ARGS=$(echo $ARGS | jq -r '.args')
1111

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

14+
# How verbose to output the linting results
15+
OUTPUT_LEVEL=$(echo $ARGS | jq -r '.outputLevel')
16+
1417
echo "Linting: eslint@$ESLINT_VERSION $ESLINT_ARGS"
1518

1619
ESLINT_JSON=$(npx --no-install "eslint@$ESLINT_VERSION" --format json "$ESLINT_ARGS")
1720

18-
echo $ESLINT_JSON | /remap_lint.sh
21+
22+
if [ $OUTPUT_LEVEL == "0" ]; then
23+
echo "Linting with ESLint v$ESLINT_VERSION complete."
24+
fi
25+
26+
if [ $OUTPUT_LEVEL == "1" ]; then
27+
echo "Linting with ESLint v$ESLINT_VERSION complete. Outputting condensed JSON."
28+
echo $ESLINT_JSON | /remap_lint.sh
29+
fi
30+
31+
if [ $OUTPUT_LEVEL == "2" ]; then
32+
echo "Linting with ESLint v$ESLINT_VERSION complete. Outputting JSON."
33+
echo $ESLINT_JSON
34+
fi

0 commit comments

Comments
 (0)