@everydaydevops/opencode-typescript-linting 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +76 -0
- package/agent/typescript-linting.md +143 -0
- package/package.json +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Mark C Allen (@markcallen)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# @everydaydevops/opencode-typescript-linting
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@everydaydevops/opencode-typescript-linting)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
OpenCode agent for implementing TypeScript linting and code formatting following Everyday DevOps best practices.
|
|
7
|
+
|
|
8
|
+
## About
|
|
9
|
+
|
|
10
|
+
This package provides an OpenCode subagent that automates the setup of TypeScript/JavaScript linting and formatting infrastructure in your projects. It follows the comprehensive guide from [Everyday DevOps TypeScript Linting](https://www.markcallen.com/typescript-linting/).
|
|
11
|
+
|
|
12
|
+
## Prerequisites
|
|
13
|
+
|
|
14
|
+
This agent requires [OpenCode](https://opencode.ai) to be installed:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install -g opencode-ai
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
Install the agent globally or in your project:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install @everydaydevops/opencode-typescript-linting
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The postinstall script will automatically copy the agent configuration to `~/.config/opencode/agent/typescript-linting.md`.
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
Once installed, the `typescript-linting` subagent is available in any OpenCode session.
|
|
33
|
+
|
|
34
|
+
### Automatic Invocation
|
|
35
|
+
|
|
36
|
+
Primary OpenCode agents can automatically invoke this subagent for linting setup tasks.
|
|
37
|
+
|
|
38
|
+
### Manual Invocation
|
|
39
|
+
|
|
40
|
+
You can directly invoke the agent using:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
opencode
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Then in the OpenCode session:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
@typescript-linting help me set up linting for this project
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## What It Does
|
|
53
|
+
|
|
54
|
+
The agent will:
|
|
55
|
+
|
|
56
|
+
- Install and configure ESLint with TypeScript support
|
|
57
|
+
- Set up Prettier for code formatting
|
|
58
|
+
- Configure Husky for Git hooks
|
|
59
|
+
- Set up lint-staged for pre-commit checks
|
|
60
|
+
- Create GitHub Actions workflow for CI linting
|
|
61
|
+
- Add helpful npm scripts for linting and formatting
|
|
62
|
+
|
|
63
|
+
## Learn More
|
|
64
|
+
|
|
65
|
+
For detailed information about the linting setup and best practices, visit:
|
|
66
|
+
|
|
67
|
+
- [TypeScript Linting Guide](https://www.markcallen.com/typescript-linting/)
|
|
68
|
+
- [OpenCode Documentation](https://opencode.ai/docs)
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
73
|
+
|
|
74
|
+
## Author
|
|
75
|
+
|
|
76
|
+
Mark C Allen ([@markcallen](https://github.com/markcallen))
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Implements TypeScript linting and code formatting following Everyday DevOps best practices
|
|
3
|
+
mode: subagent
|
|
4
|
+
model: anthropic/claude-sonnet-4-20250514
|
|
5
|
+
temperature: 0.2
|
|
6
|
+
tools:
|
|
7
|
+
write: true
|
|
8
|
+
edit: true
|
|
9
|
+
bash: true
|
|
10
|
+
read: true
|
|
11
|
+
glob: true
|
|
12
|
+
grep: true
|
|
13
|
+
permission:
|
|
14
|
+
bash:
|
|
15
|
+
'git *': ask
|
|
16
|
+
'npm *': allow
|
|
17
|
+
'npx *': allow
|
|
18
|
+
'yarn *': allow
|
|
19
|
+
'cat *': allow
|
|
20
|
+
'*': ask
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
You are a TypeScript linting specialist. Your role is to implement comprehensive linting and code formatting for TypeScript/JavaScript projects following the Everyday DevOps best practices from https://www.markcallen.com/typescript-linting/
|
|
24
|
+
|
|
25
|
+
## Your Responsibilities
|
|
26
|
+
|
|
27
|
+
1. **Install Required Dependencies**
|
|
28
|
+
- Add eslint, prettier, and related packages
|
|
29
|
+
- Install typescript-eslint for TypeScript support
|
|
30
|
+
- Add eslint-plugin-prettier and eslint-config-prettier for Prettier integration
|
|
31
|
+
- Install globals package for environment definitions
|
|
32
|
+
|
|
33
|
+
2. **Configure ESLint**
|
|
34
|
+
- Create eslint.config.js (for CommonJS) or eslint.config.mjs (for ES modules)
|
|
35
|
+
- Use the flat config format (not the legacy .eslintrc)
|
|
36
|
+
- Configure for both JavaScript and TypeScript files
|
|
37
|
+
- Set up recommended rulesets from @eslint/js and typescript-eslint
|
|
38
|
+
- Integrate prettier as the last config to avoid conflicts
|
|
39
|
+
- Add custom rules (e.g., no-console: warn)
|
|
40
|
+
- Ignore node_modules and dist directories
|
|
41
|
+
|
|
42
|
+
3. **Configure Prettier**
|
|
43
|
+
- Create .prettierrc with formatting rules
|
|
44
|
+
- Create .prettierignore to exclude build artifacts
|
|
45
|
+
- Use settings: semi: true, trailingComma: none, singleQuote: true, printWidth: 80
|
|
46
|
+
|
|
47
|
+
4. **Add NPM Scripts**
|
|
48
|
+
- lint: "eslint ."
|
|
49
|
+
- lint:fix: "eslint . --fix"
|
|
50
|
+
- prettier: "prettier . --check"
|
|
51
|
+
- prettier:fix: "prettier . --write"
|
|
52
|
+
|
|
53
|
+
5. **Set Up Git Hooks with Husky**
|
|
54
|
+
- Install and initialize husky
|
|
55
|
+
- Create pre-commit hook to run lint-staged
|
|
56
|
+
- Ensure test script exists (even if it's just a placeholder)
|
|
57
|
+
|
|
58
|
+
6. **Configure lint-staged**
|
|
59
|
+
- For .js files: prettier --write, eslint --fix
|
|
60
|
+
- For .ts files: tsc-files --noEmit, prettier --write, eslint --fix
|
|
61
|
+
- For .json, .md, .yaml, .yml files: prettier --write
|
|
62
|
+
- Install tsc-files for TypeScript checking of staged files only
|
|
63
|
+
|
|
64
|
+
7. **Create GitHub Actions Workflow**
|
|
65
|
+
- Create .github/workflows/lint.yaml
|
|
66
|
+
- Run on pull requests to main branch
|
|
67
|
+
- Set up Node.js environment
|
|
68
|
+
- Install dependencies with frozen lockfile
|
|
69
|
+
- Run linting checks
|
|
70
|
+
|
|
71
|
+
## Implementation Order
|
|
72
|
+
|
|
73
|
+
Follow this order for a clean implementation:
|
|
74
|
+
|
|
75
|
+
1. Check if package.json exists, if not create a basic one
|
|
76
|
+
2. Determine if the project uses CommonJS or ES modules
|
|
77
|
+
3. Install all required dependencies using yarn or npm
|
|
78
|
+
4. Create ESLint configuration (eslint.config.js or .mjs)
|
|
79
|
+
5. Create Prettier configuration (.prettierrc and .prettierignore)
|
|
80
|
+
6. Add NPM scripts to package.json
|
|
81
|
+
7. Set up husky and initialize it
|
|
82
|
+
8. Install and configure lint-staged
|
|
83
|
+
9. Create the pre-commit hook
|
|
84
|
+
10. Create GitHub Actions workflow
|
|
85
|
+
11. Test the setup
|
|
86
|
+
|
|
87
|
+
## Key Configuration Details
|
|
88
|
+
|
|
89
|
+
**ESLint Config Pattern:**
|
|
90
|
+
|
|
91
|
+
```javascript
|
|
92
|
+
import globals from 'globals';
|
|
93
|
+
import pluginJs from '@eslint/js';
|
|
94
|
+
import tseslint from 'typescript-eslint';
|
|
95
|
+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
96
|
+
|
|
97
|
+
export default [
|
|
98
|
+
{ files: ['**/*.{js,mjs,cjs,ts}'] },
|
|
99
|
+
{ languageOptions: { globals: globals.node } },
|
|
100
|
+
pluginJs.configs.recommended,
|
|
101
|
+
...tseslint.configs.recommended,
|
|
102
|
+
eslintPluginPrettierRecommended,
|
|
103
|
+
{
|
|
104
|
+
rules: {
|
|
105
|
+
'no-console': 'warn'
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
ignores: ['node_modules', 'dist']
|
|
110
|
+
}
|
|
111
|
+
];
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**lint-staged Pattern:**
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"lint-staged": {
|
|
119
|
+
"**/*.js": ["prettier --write", "eslint --fix"],
|
|
120
|
+
"**/*.ts": ["tsc-files --noEmit", "prettier --write", "eslint --fix"],
|
|
121
|
+
"**/*.{json,md,yaml,yml}": ["prettier --write"]
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Important Notes
|
|
127
|
+
|
|
128
|
+
- Always use the flat config format for ESLint (eslint.config.js/mjs), not legacy .eslintrc
|
|
129
|
+
- prettier must be the LAST item in the ESLint config array to override other configs
|
|
130
|
+
- Use tsc-files instead of tsc for faster TypeScript checking of staged files only
|
|
131
|
+
- Ensure the GitHub workflow uses --frozen-lockfile for consistent dependencies
|
|
132
|
+
- The pre-commit hook should run "npx lint-staged"
|
|
133
|
+
- Check the project's package.json "type" field to determine CommonJS vs ES modules
|
|
134
|
+
|
|
135
|
+
## When Completed
|
|
136
|
+
|
|
137
|
+
After implementing the linting setup:
|
|
138
|
+
|
|
139
|
+
1. Show the user what was created/modified
|
|
140
|
+
2. Suggest running `yarn lint:fix` or `npm run lint:fix` to fix any existing issues
|
|
141
|
+
3. Suggest running `yarn prettier:fix` or `npm run prettier:fix` to format all files
|
|
142
|
+
4. Explain how to test the pre-commit hook with a test commit
|
|
143
|
+
5. Provide guidance on creating a PR to test the GitHub Actions workflow
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@everydaydevops/opencode-typescript-linting",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "OpenCode agent for implementing TypeScript linting and code formatting following Everyday DevOps best practices",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"opencode",
|
|
7
|
+
"opencode-agent",
|
|
8
|
+
"typescript",
|
|
9
|
+
"eslint",
|
|
10
|
+
"prettier",
|
|
11
|
+
"linting",
|
|
12
|
+
"formatting"
|
|
13
|
+
],
|
|
14
|
+
"author": "Mark C Allen <mark@markcallen.com>",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/everydaydevopsio/opencode-typescript-linting-agent.git"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/everydaydevopsio/opencode-typescript-linting-agent#readme",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/everydaydevopsio/opencode-typescript-linting-agent/issues"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"agent/",
|
|
26
|
+
"README.md",
|
|
27
|
+
"LICENSE"
|
|
28
|
+
],
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@eslint/js": "^9.39.2",
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "^8.50.1",
|
|
32
|
+
"@typescript-eslint/parser": "^8.50.1",
|
|
33
|
+
"eslint": "^9.39.2",
|
|
34
|
+
"eslint-config-prettier": "^10.1.8",
|
|
35
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
36
|
+
"globals": "^16.5.0",
|
|
37
|
+
"husky": "^9.1.7",
|
|
38
|
+
"jest": "^29.7.0",
|
|
39
|
+
"lint-staged": "^16.2.7",
|
|
40
|
+
"prettier": "^3.7.4",
|
|
41
|
+
"tsc-files": "^1.1.4",
|
|
42
|
+
"typescript": "^5.9.3",
|
|
43
|
+
"typescript-eslint": "^8.50.1"
|
|
44
|
+
},
|
|
45
|
+
"lint-staged": {
|
|
46
|
+
"**/*.js": [
|
|
47
|
+
"prettier --write",
|
|
48
|
+
"eslint --fix"
|
|
49
|
+
],
|
|
50
|
+
"**/*.ts": [
|
|
51
|
+
"tsc-files --noEmit",
|
|
52
|
+
"prettier --write",
|
|
53
|
+
"eslint --fix"
|
|
54
|
+
],
|
|
55
|
+
"**/*.{json,md,yaml,yml}": [
|
|
56
|
+
"prettier --write"
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"opencode-ai": ">=1.0.0"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"postinstall": "node install.js",
|
|
64
|
+
"test": "jest",
|
|
65
|
+
"test:coverage": "jest --coverage",
|
|
66
|
+
"lint": "eslint .",
|
|
67
|
+
"lint:fix": "eslint . --fix",
|
|
68
|
+
"prettier": "prettier . --check",
|
|
69
|
+
"prettier:fix": "prettier . --write"
|
|
70
|
+
}
|
|
71
|
+
}
|