Skip to content

Commit 5d8cb15

Browse files
authored
chore: update dependencies with dedupe and audit fix (#9)
* chore: update dependencies with dedupe and audit fix * test: enhance ExportParser tests to ignore exports in strings and improve parsing logic * docs: update README with known limitations of ExportParser and improve clarity fix: update coverage badge to reflect current coverage percentage chore: reorganize package.json dependencies and scripts for better clarity test: add integration tests for ExportParser to validate export extraction logic refactor: enhance ExportParser to use ts-morph for accurate AST parsing build: update webpack config to handle ts-morph dependencies and ignore warnings * feat(logging): enhance OutputChannelLogger with improved error handling and metadata formatting feat(tests): add comprehensive tests for assertion utilities and error handling fix(utils): improve guards and formatting functions for better type safety and error handling chore(tests): organize test structure and add missing test cases for utility functions refactor(tests): streamline test cases for clarity and maintainability chore: update tsconfig to enable importHelpers for better code optimization * feat(FileSystemService): enhance TypeScript file filtering to exclude test files * feat: add isDirectory method to FileSystemService - Implemented isDirectory method to check if a given path is a directory. - Added corresponding unit tests for isDirectory in file-system.service.test.ts. - Updated file-system.service.ts to include the new method. - Enhanced index.ts to export the FileSystemService. chore: add copyright headers to all files - Added copyright headers to all source and test files for consistency and compliance. refactor: clean up exports in index files - Updated index.ts files in core, parser, and types directories to streamline exports. - Removed unnecessary exports and ensured proper type exports. test: improve test structure and coverage - Enhanced test cases in various test files for better coverage and clarity. - Updated assertions to ensure accuracy in tests across multiple utility functions. - Refactored test descriptions for better readability. fix: update logging exports - Adjusted logging/index.ts to export types and classes correctly. - Ensured consistent export structure across the logging module. style: format code and improve readability - Applied consistent formatting across all files. - Improved code comments and documentation for better understanding. * refactor: improve documentation comments across test files for clarity * fix(format): return an empty string for undefined values in safeStringify * refactor(array): simplify isEmptyArray function logic * refactor(ExportParser): create a new project instance for each parsing operation to prevent memory accumulation
1 parent 2f79893 commit 5d8cb15

57 files changed

Lines changed: 5345 additions & 1332 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ Thank you for your interest in contributing to Barrel Roll! This document provid
1111
cd barrel-roll
1212
```
1313

14-
2. **Install Dependencies**
14+
1. **Install Dependencies**
1515

1616
```bash
1717
npm install
1818
```
1919

20-
3. **Build the Extension**
20+
1. **Build the Extension**
21+
2122
```bash
2223
npm run compile
2324
```
@@ -27,9 +28,9 @@ Thank you for your interest in contributing to Barrel Roll! This document provid
2728
### Running the Extension Locally
2829

2930
1. Open the project in VS Code
30-
2. Press F5 to start debugging
31-
3. A new VS Code window will open with the extension loaded
32-
4. Right-click on any folder in the file explorer to test the "Barrel Roll: Generate/Update index.ts" command
31+
1. Press F5 to start debugging
32+
1. A new VS Code window will open with the extension loaded
33+
1. Right-click on any folder in the file explorer to test the "Barrel Roll: Generate/Update index.ts" command
3334

3435
### Making Changes
3536

@@ -39,24 +40,25 @@ Thank you for your interest in contributing to Barrel Roll! This document provid
3940
git checkout -b feature/your-feature-name
4041
```
4142

42-
2. Make your changes following the code style guidelines
43+
1. Make your changes following the code style guidelines
4344

44-
3. Run linting:
45+
1. Run linting:
4546

4647
```bash
4748
npm run lint
4849
npm run lint:fix # Auto-fix issues
4950
```
5051

51-
4. Run formatting:
52+
1. Run formatting:
5253

5354
```bash
5455
npm run format
5556
```
5657

57-
5. Write tests for your changes (if applicable)
58+
1. Write tests for your changes (if applicable)
59+
60+
1. Run tests:
5861

59-
6. Run tests:
6062
```bash
6163
npm test
6264
```
@@ -108,10 +110,22 @@ feat: add support for default exports
108110
## Pull Request Process
109111

110112
1. Ensure all tests pass
111-
2. Update documentation if needed
112-
3. Update CHANGELOG.md with your changes
113-
4. Submit a pull request with a clear description of the changes
113+
1. Update documentation if needed
114+
1. Update CHANGELOG.md with your changes
115+
1. Submit a pull request with a clear description of the changes
114116

115117
## Questions?
116118

117119
Feel free to open an issue for any questions or concerns.
120+
121+
## Coding conventions: error handling
122+
123+
- Prefer the shared helpers in `src/utils/errors.ts`:
124+
- `getErrorMessage(error)` — safe extraction of an error message
125+
- `formatErrorForLog(error)` — prefer when logging since it preserves stack when available
126+
127+
- To catch and automatically correct ad-hoc checks like `error instanceof Error ? error.message : String(error)` run:
128+
- `npm run lint:fix` (uses ESLint auto-fix where applicable)
129+
- `npm run fix:instanceof-error` (codemod using `jscodeshift` for larger-scale replacements)
130+
131+
If you want to add more auto-fix patterns, please open an issue or PR so we can review and add targeted rules/codemods.

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,16 @@ This architecture ensures:
228228
- **Dependency Inversion**: High-level modules don't depend on low-level details
229229
- **Testability**: Each component can be tested in isolation
230230

231+
## Known Limitations
232+
233+
- **Bundle size**: The extension uses [ts-morph](https://github.com/dsherret/ts-morph) for robust TypeScript AST parsing. This adds approximately 6 MB to the extension bundle. The trade-off is accurate parsing that correctly ignores export-like text inside strings, comments, and regex literals.
234+
235+
- **Re-exports without aliases**: Passthrough re-exports like `export { foo } from './module'` are intentionally skipped because they don't introduce new named exports—they simply forward exports from other modules. Re-exports **with** aliases (e.g., `export { default as MyClass } from './impl'`) are included because they create a new named export.
236+
237+
- **Dynamic exports**: Exports computed at runtime (e.g., `export default someFactory()`) are captured as default exports, but any dynamically generated named exports cannot be statically detected.
238+
239+
- **Non-TypeScript files**: Only `.ts` and `.tsx` files are scanned. JavaScript files, JSON, and other formats are ignored.
240+
231241
## Contributing
232242

233243
Contributions are welcome! Please feel free to submit a Pull Request.
@@ -236,4 +246,8 @@ For developer notes on automation, dependency checks, test conventions, and othe
236246

237247
## License
238248

239-
Apache-2.0
249+
This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.
250+
251+
## Ownership
252+
253+
This repository is maintained by **Rob "Coderrob" Lindley**. For inquiries, please contact via GitHub.

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

eslint.config.mjs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import js from '@eslint/js';
88
import typescriptEslint from '@typescript-eslint/eslint-plugin';
99
import tsParser from '@typescript-eslint/parser';
1010
import _import from 'eslint-plugin-import';
11+
import jsdoc from 'eslint-plugin-jsdoc';
1112
import prettier from 'eslint-plugin-prettier';
1213
import simpleImportSort from 'eslint-plugin-simple-import-sort';
1314
import sonarjs from 'eslint-plugin-sonarjs';
15+
import localPlugin from './scripts/eslint-plugin-local.mjs';
1416
import globals from 'globals';
1517

1618
const __filename = fileURLToPath(import.meta.url);
@@ -64,8 +66,10 @@ export default [
6466
plugins: {
6567
'@typescript-eslint': typescriptEslint,
6668
import: _import,
69+
jsdoc,
6770
'simple-import-sort': simpleImportSort,
6871
sonarjs,
72+
local: localPlugin,
6973
},
7074
settings: {
7175
'import/resolver': {
@@ -98,8 +102,25 @@ export default [
98102
message:
99103
'Avoid using \'typeof import(...)["T"]\' indexed import types; import the type and refer to it directly.',
100104
},
105+
{
106+
selector: "BinaryExpression[operator='instanceof'][right.name='Error']",
107+
message:
108+
"Avoid ad-hoc 'instanceof Error' checks — prefer `getErrorMessage` or `formatErrorForLog` from 'src/utils/errors' for consistent error handling and logging.",
109+
},
110+
{
111+
selector:
112+
"TSTypeReference[typeName.name='ReturnType'] > TSTypeParameterInstantiation > TSIndexedAccessType",
113+
message:
114+
'Avoid ReturnType applied to indexed access types; define a named type/interface instead.',
115+
},
116+
{
117+
selector:
118+
"TSTypeReference[typeName.name='ReturnType'] > TSTypeParameterInstantiation > TSTypeReference[typeName.name='ReturnType']",
119+
message: 'Avoid nested ReturnType chains; define a named type/interface instead.',
120+
},
101121
],
102122
'sonarjs/no-duplicate-string': ['error', { threshold: 3 }],
123+
'local/no-instanceof-error-autofix': 'error',
103124
'sonarjs/no-identical-functions': 'error',
104125
'sonarjs/prefer-immediate-return': 'error',
105126
'sonarjs/pseudo-random': 'warn',
@@ -111,6 +132,27 @@ export default [
111132
'sonarjs/prefer-single-boolean-return': 'error',
112133

113134
// TypeScript ESLint rules
135+
'@typescript-eslint/explicit-function-return-type': [
136+
'error',
137+
{
138+
allowExpressions: false,
139+
allowTypedFunctionExpressions: false,
140+
allowHigherOrderFunctions: false,
141+
allowDirectConstAssertionInArrowFunctions: false,
142+
},
143+
],
144+
'jsdoc/require-jsdoc': [
145+
'error',
146+
{
147+
require: {
148+
FunctionDeclaration: true,
149+
MethodDefinition: true,
150+
ClassDeclaration: false,
151+
ArrowFunctionExpression: false,
152+
FunctionExpression: false,
153+
},
154+
},
155+
],
114156
'no-unused-vars': 'off',
115157
'@typescript-eslint/no-unused-vars': [
116158
'error',
@@ -168,6 +210,23 @@ export default [
168210
},
169211
},
170212

213+
// Allow 'instanceof Error' only within guards helper to implement the guard itself
214+
{
215+
files: ['src/utils/guards.ts'],
216+
rules: {
217+
'no-restricted-syntax': 'off',
218+
},
219+
},
220+
221+
// Source files - relax strict return type rules since methods already have explicit return types
222+
{
223+
files: ['src/**/*.ts'],
224+
rules: {
225+
'@typescript-eslint/explicit-function-return-type': 'off',
226+
'no-restricted-syntax': 'off',
227+
},
228+
},
229+
171230
// Mocha test suite files (VS Code extension integration tests)
172231
{
173232
files: ['**/src/test/suite/**/*.{ts,tsx}'],
@@ -225,4 +284,13 @@ export default [
225284
'unicorn/prefer-top-level-await': 'off',
226285
},
227286
},
287+
288+
// Test files - relax strict rules
289+
{
290+
files: ['**/*.test.ts', '**/*.test.js', '**/test/**'],
291+
rules: {
292+
'@typescript-eslint/explicit-function-return-type': 'off',
293+
'no-restricted-syntax': 'off',
294+
},
295+
},
228296
];

0 commit comments

Comments
 (0)