Skip to content

Commit 664eec4

Browse files
authored
Merge pull request #7 from docker/cm/eslint-fix
Fix ESLint Violations
2 parents 36bd8fa + 159ebce commit 664eec4

File tree

5 files changed

+42
-2
lines changed

5 files changed

+42
-2
lines changed

prompts/eslint/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ functions:
3535
description: Whether to fix the files
3636
outputLevel:
3737
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.
38+
description: Nullish values return a summary from the linter. `complaint` returns a list of editor complaints. `condensed` returns violations grouped by violation id. `json` returns the raw JSON output from the linter.
3939
files:
4040
type: array
4141
items:

prompts/eslint/scripts/remap_lint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ for index in "${!FILE_PATHS[@]}"; do
2929
if [ $OUTPUT_MODE == "complaints" ]; then
3030
echo "complaints"
3131
# Complaint: {filePath: "path", "start": [line, column], "end": [line, column], "message": "message", "severity": "severity", "ruleId": "ruleId"}
32-
messages=$(echo $messages | jq -r -c '.[]')
32+
messages=$(echo $messages | jq -r -c '.[]' | tr '\n' ' ')
3333
IFS=$'\n' messages=($messages)
3434
for message in "${messages[@]}"; do
3535
# If endLine is null, set it to line
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
You are an AI assistant who specializes in resolving lint violations in projects.

prompts/eslint_fix/020_user_prompt.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
1. Run ESLint summary in the project
2+
2. Evaluate total violations.
3+
<10 violations: Re-run eslint with complaints output.
4+
10+ violations: Re-run eslint with condensed output.
5+
3. Fix the violations.

prompts/eslint_fix/README.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
functions:
3+
- name: eslint
4+
type: prompt
5+
ref: github:docker/labs-ai-tools-for-devs?ref=main&path=prompts/eslint
6+
- name: write_files
7+
description: Write a set of files to my project
8+
parameters:
9+
type: object
10+
properties:
11+
files:
12+
type: array
13+
items:
14+
type: object
15+
properties:
16+
path:
17+
type: string
18+
description: the relative path to the file that the script should run in
19+
script:
20+
type: string
21+
description: The script to run in the files.
22+
container:
23+
image: vonwig/apply_script:latest
24+
- name: read_eslint
25+
description: Loads ESLint violations
26+
parameters:
27+
type: object
28+
properties:
29+
output_level:
30+
type: string
31+
description: "`condensed` or `complaints`"
32+
container:
33+
image: vonwig/read_eslint
34+
---

0 commit comments

Comments
 (0)