Skip to content

Commit

Permalink
feat: improve prompt adding test fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
exKAZUu committed Aug 17, 2023
1 parent 36878d9 commit c39f35e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,21 @@ const argv = await yargs(process.argv.slice(2))

const prompt = PromptTemplate.fromTemplate<{ code: string }>(
`
Act as a linter for source code, judge whether each function in the given code follow these guidelines or not.
If the function does not follow the guidelines, suggest a new function name which follows the guidelines.
Act as a linter for source code, judge whether each function in the given code follow the guidelines or not.
If the function does not follow the guidelines, explain the reason and suggest a new function name which follows the guidelines (G1-G5).
- Function names should be in camelCase.
- Function names should be informative.
- Function names should be easy to understand.
- Function names should explain what they do with domain-specific vocabulary.
- Function should consist of semantically related statements.
- Function should abstract away implementation details which is not important to understand the code block containing the function call.
- Function should make code readers easy to understand code with function calls in comparison to code with inlined function.
# Code
{code}
# Output format
{{
[functionName]: {{
isFollowed: boolean,
suggestedName?: string,
}}
}}
[ {{ name: string, isFollowed: boolean, reason?: string, suggested?: string }} ]
`.trim()
);

Expand Down
7 changes: 7 additions & 0 deletions test-fixtures/helloWorld.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function foo() {
console.log('Hello world!');
}

function printHelloWorld() {
console.log('Hello world!');
}

0 comments on commit c39f35e

Please sign in to comment.