Skip to content

Commit

Permalink
feat: add linter and typecheck
Browse files Browse the repository at this point in the history
  • Loading branch information
jellydn committed Oct 15, 2023
1 parent 966a9db commit 8e86d34
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ["productsway/typescript"],
};
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/sweep-template.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Sweep Issue
title: 'Sweep: '
title: "Sweep: "
description: For small bugs, features, refactors, and tests to be handled by Sweep, an AI-powered junior developer.
labels: sweep
body:
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Linter & Typecheck
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
typecheck:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v4
- id: setup-bun
name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- id: install-bun
name: Bun Install
run: |
bun install
- id: Typecheck
name: Checking Typescript Error
run: |
bun run typecheck
linter:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v4
- id: setup-bun
name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- id: install-bun
name: Bun Install
run: |
bun install
- id: linter
name: Linter check
run: |
bun run lint
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,4 @@ dist
# Finder (MacOS) folder config
.DS_Store

tsconfig.tsbuildinfo
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion cli/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
"addWords": true
}
],
"dictionaries": [
"cspell-tool"
],
"ignorePaths": [
"node_modules",
"/cspell-tool.txt"
]
}
"dictionaries": ["cspell-tool"],
"ignorePaths": ["node_modules", "/cspell-tool.txt"]
}
6 changes: 4 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ writeFile("./cspell.json", JSON.stringify(cSpellContent, null, 2));

// TODO: Support other file types
// Run cspell on Markdown files to get unknown words
const cmd = `${isInstalled ? "" : "npx "
}cspell --words-only --unique --no-progress --show-context "**/**/*.md" "**/**/*.ts" "**/**/*.json"`;
const cmd = `${
isInstalled ? "" : "npx "
}cspell --words-only --unique --no-progress --show-context "**/**/*.md" "**/**/*.ts" "**/**/*.json"`;
const unknownWords = await new Promise<string[]>((resolve) => {
exec(cmd, (error: any, stdout: string) => {
if (error) {
console.error(`Error running cspell: ${error}`);
}

const words = stdout ? stdout.split("\n").filter((word: any) => word) : [];
resolve(words);
});
Expand Down
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,22 @@
"scripts": {
"build": "bun build index.ts --outdir ./cli --target node --format esm --minify --external zx",
"clean": "rm -rf cli && echo 'Done.'",
"lint": "eslint --ext .ts .",
"typecheck": "tsc --noEmit",
"format": "prettier --write .",
"dev": "bun run --watch index.ts"
},
"dependencies": {
"zx": "7.2.3"
},
"devDependencies": {
"@skypack/package-check": "0.2.2",
"bun-types": "latest"
"@typescript-eslint/eslint-plugin": "^6",
"@typescript-eslint/parser": "^6",
"bun-types": "latest",
"eslint": "^8",
"eslint-config-productsway": "1.3.0",
"prettier": "^3"
},
"peerDependencies": {
"typescript": "^5.0.0"
Expand Down
16 changes: 8 additions & 8 deletions sweep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

# This setting contains a list of rules that Sweep will check for. If any of these rules are broken in a new commit, Sweep will create an pull request to fix the broken rule.
rules:
- "All docstrings and comments should be up to date."
- "Code should be properly formatted and indented."
- "Variable and function names should be descriptive and follow a consistent naming convention."
- "There should be no unused imports or variables."
- "Code should be free of unnecessary comments and commented-out code."
- "There should be no hard-coded values or magic numbers in the code."
- "All docstrings and comments should be up to date."
- "Code should be properly formatted and indented."
- "Variable and function names should be descriptive and follow a consistent naming convention."
- "There should be no unused imports or variables."
- "Code should be free of unnecessary comments and commented-out code."
- "There should be no hard-coded values or magic numbers in the code."

# This is the branch that Sweep will develop from and make pull requests to. Most people use 'main' or 'master' but some users also use 'dev' or 'staging'.
branch: 'main'
branch: "main"

# By default Sweep will read the logs and outputs from your existing Github Actions. To disable this, set this to false.
gha_enabled: True
Expand All @@ -21,7 +21,7 @@ gha_enabled: True
# Example:
#
# description: sweepai/sweep is a python project. The main api endpoints are in sweepai/api.py. Write code that adheres to PEP8.
description: ''
description: ""

# This sets whether to create pull requests as drafts. If this is set to True, then all pull requests will be created as drafts and GitHub Actions will not be triggered.
draft: False
Expand Down

0 comments on commit 8e86d34

Please sign in to comment.