Skip to content

Commit 3967803

Browse files
committed
Adds code style configs
1 parent 3071442 commit 3967803

33 files changed

+2212
-106
lines changed

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
dist
2+
images
23
node_modules
34
out
45
pnpm-lock.yaml
56
LICENSE
7+
ThirdPartyNotices.txt
8+
CLAUDE.md

.vscode/settings.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
// Editor settings
3+
"editor.codeActionsOnSave": {
4+
"source.fixAll.eslint": "explicit"
5+
},
6+
"files.insertFinalNewline": true,
7+
"files.trimTrailingWhitespace": true,
8+
9+
// File associations and excludes
10+
"files.exclude": {
11+
"**/.vscode-test": true,
12+
"**/.vscode-test-web": true
13+
},
14+
"search.exclude": {
15+
"**/node_modules": true,
16+
"**/dist": true,
17+
"**/.vscode-test": true,
18+
"**/.vscode-test-web": true,
19+
"**/*.vsix": true
20+
},
21+
22+
// Extension development specific
23+
"debug.allowBreakpointsEverywhere": true,
24+
25+
// Language specific settings
26+
"[html][javascript][json][jsonc][markdown][scss][svg][typescript][typescriptreact]": {
27+
"editor.defaultFormatter": "esbenp.prettier-vscode"
28+
},
29+
"[markdown]": {
30+
"editor.wordWrap": "on"
31+
},
32+
"typescript.preferences.importModuleSpecifier": "project-relative",
33+
"typescript.preferences.includePackageJsonAutoImports": "on",
34+
"typescript.suggest.autoImports": true,
35+
"typescript.tsdk": "node_modules/typescript/lib",
36+
"typescript.updateImportsOnFileMove.enabled": "always"
37+
}

CLAUDE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ This is a VS Code extension that provides web component information to AI assist
1414
- `pnpm run watch` - Watch mode for development
1515
- `pnpm run clean` - Clean build artifacts
1616

17+
### Code Quality
18+
- `pnpm run lint` - Run ESLint on TypeScript files
19+
- `pnpm run lint:fix` - Run ESLint with auto-fix
20+
- `pnpm run format` - Format code with Prettier
21+
- `pnpm run format:check` - Check code formatting
22+
1723
### Packaging & Publishing
1824
- `pnpm run package` - Create VSIX package
1925
- `pnpm run package-pre` - Create pre-release VSIX package

eslint.config.mjs

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import js from '@eslint/js';
2+
import prettier from 'eslint-config-prettier';
3+
import importPlugin from 'eslint-plugin-import';
4+
import tseslint from 'typescript-eslint';
5+
6+
export default tseslint.config(
7+
// Base JavaScript configuration for all files
8+
js.configs.recommended,
9+
10+
// TypeScript configuration for .ts files only
11+
{
12+
files: ['src/**/*.ts'],
13+
extends: [...tseslint.configs.recommended, ...tseslint.configs.recommendedTypeChecked],
14+
plugins: {
15+
import: importPlugin,
16+
},
17+
languageOptions: {
18+
parserOptions: {
19+
ecmaVersion: 2022,
20+
sourceType: 'module',
21+
project: './tsconfig.node.json',
22+
tsconfigRootDir: import.meta.dirname,
23+
},
24+
},
25+
settings: {
26+
'import/resolver': {
27+
typescript: {
28+
alwaysTryTypes: true,
29+
project: './tsconfig.node.json',
30+
},
31+
},
32+
},
33+
rules: {
34+
'no-debugger': 'off',
35+
// Import ordering and organization rules
36+
'import/order': [
37+
'error',
38+
{
39+
groups: [
40+
'builtin', // Node.js built-in modules
41+
'external', // npm packages
42+
'internal', // Internal modules (configured with path mapping)
43+
'parent', // ../
44+
'sibling', // ./
45+
'index', // ./index
46+
],
47+
'newlines-between': 'never',
48+
alphabetize: {
49+
order: 'asc',
50+
caseInsensitive: true,
51+
},
52+
},
53+
],
54+
'import/first': 'error',
55+
'import/no-duplicates': 'error',
56+
'import/no-unresolved': 'off', // TypeScript handles this
57+
'import/extensions': ['error', 'ignorePackages', { ts: 'never' }],
58+
59+
// TypeScript import rules
60+
'@typescript-eslint/consistent-type-imports': [
61+
'error',
62+
{
63+
prefer: 'type-imports',
64+
disallowTypeAnnotations: false,
65+
fixStyle: 'separate-type-imports',
66+
},
67+
],
68+
'@typescript-eslint/consistent-type-exports': [
69+
'error',
70+
{
71+
fixMixedExportsWithInlineTypeSpecifier: true,
72+
},
73+
],
74+
75+
// Custom rules - balanced approach for development
76+
'@typescript-eslint/await-thenable': 'error',
77+
'@typescript-eslint/no-base-to-string': 'off', // Common pattern in VS Code
78+
'@typescript-eslint/no-duplicate-type-constituents': 'off', // False positives
79+
'@typescript-eslint/no-explicit-any': 'off', // Allowing any for flexibility... for now
80+
'@typescript-eslint/no-floating-promises': 'off', // Too strict for VS Code extension patterns
81+
'@typescript-eslint/no-misused-promises': 'off', // Common in VS Code APIs
82+
'@typescript-eslint/no-redundant-type-constituents': 'off', // False positives
83+
'@typescript-eslint/no-unused-vars': [
84+
'warn',
85+
{
86+
args: 'all',
87+
argsIgnorePattern: '^_',
88+
caughtErrors: 'all',
89+
caughtErrorsIgnorePattern: '^_',
90+
destructuredArrayIgnorePattern: '^_',
91+
varsIgnorePattern: '^_',
92+
ignoreRestSiblings: true,
93+
},
94+
],
95+
'@typescript-eslint/no-unsafe-assignment': 'off', // Too strict for dynamic APIs
96+
'@typescript-eslint/no-unsafe-member-access': 'off', // Too strict for dynamic APIs
97+
'@typescript-eslint/no-unsafe-argument': 'off', // Too strict for dynamic APIs
98+
'@typescript-eslint/no-unsafe-return': 'off', // Too strict for dynamic APIs
99+
'@typescript-eslint/no-use-before-define': ['error', { functions: false, classes: false }],
100+
'@typescript-eslint/prefer-optional-chain': 'warn',
101+
'@typescript-eslint/prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],
102+
'@typescript-eslint/restrict-template-expressions': 'off', // Too strict for logging
103+
'@typescript-eslint/unbound-method': 'off', // Too strict for VS Code APIs
104+
},
105+
},
106+
{
107+
ignores: [
108+
'dist/',
109+
'node_modules/',
110+
'*.js',
111+
'webpack.config.mjs',
112+
'scripts/',
113+
'.vscode-test/',
114+
'.vscode-test-web/',
115+
'LICENSE',
116+
'ThirdPartyNotices.txt',
117+
],
118+
},
119+
prettier,
120+
);

package.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,20 @@
201201
"main": "./dist/extension.js",
202202
"scripts": {
203203
"build": "webpack --mode development",
204-
"clean": "pnpx rimraf dist out .vscode-test .vscode-test-web .eslintcache* tsconfig*.tsbuildinfo",
205204
"bundle": "webpack --mode production",
206205
"bundle:extension": "webpack --mode production --config-name extension:node",
206+
"clean": "pnpx rimraf dist out .vscode-test .vscode-test-web .eslintcache* tsconfig*.tsbuildinfo",
207+
"format": "prettier --write .",
208+
"format:check": "prettier --check .",
207209
"generate:licenses": "node ./scripts/generateLicenses.mjs",
210+
"lint": "eslint .",
211+
"lint:fix": "eslint . --fix",
208212
"package": "vsce package --no-dependencies",
209213
"package-pre": "pnpm run package --pre-release",
210214
"pub": "vsce publish --no-dependencies",
211215
"pub-pre": "vsce publish --no-dependencies --pre-release",
212-
"watch": "webpack --watch --mode development",
213-
"vscode:prepublish": "pnpm run bundle"
216+
"vscode:prepublish": "pnpm run bundle",
217+
"watch": "webpack --watch --mode development"
214218
},
215219
"dependencies": {
216220
"@modelcontextprotocol/sdk": "^1.12.3",
@@ -219,13 +223,22 @@
219223
"zod": "^3.25.32"
220224
},
221225
"devDependencies": {
226+
"@eslint/js": "^9.29.0",
222227
"@types/node": "^22.15.17",
223228
"@types/vscode": "1.99.0",
229+
"@typescript-eslint/eslint-plugin": "^8.34.1",
230+
"@typescript-eslint/parser": "^8.34.1",
224231
"@vscode/vsce": "^3.5.0",
225232
"copy-webpack-plugin": "^13.0.0",
233+
"eslint": "^9.29.0",
234+
"eslint-config-prettier": "^10.1.5",
235+
"eslint-import-resolver-typescript": "^4.4.3",
236+
"eslint-plugin-import": "^2.32.0",
226237
"license-checker-rseidelsohn": "^4.4.2",
238+
"prettier": "^3.5.3",
227239
"ts-loader": "^9.5.2",
228240
"typescript": "^5.8.3",
241+
"typescript-eslint": "^8.34.1",
229242
"webpack": "^5.99.9",
230243
"webpack-cli": "^6.0.1"
231244
},

0 commit comments

Comments
 (0)