Skip to content
Draft
62 changes: 61 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import zeroTolerance from '@coderrob/eslint-plugin-zero-tolerance';
import _import from 'eslint-plugin-import';
import jsdoc from 'eslint-plugin-jsdoc';
import prettier from 'eslint-plugin-prettier';
Expand Down Expand Up @@ -69,6 +70,7 @@ export default [
jsdoc,
'simple-import-sort': simpleImportSort,
sonarjs,
'zero-tolerance': zeroTolerance,
local: localPlugin,
},
settings: {
Expand Down Expand Up @@ -176,6 +178,9 @@ export default [
'no-shadow': 'off',
'space-in-parens': ['error', 'never'],
'spaced-comment': ['error', 'always'],

// Zero-tolerance rules
...zeroTolerance.configs.recommended.rules,
},
},

Expand All @@ -202,17 +207,72 @@ export default [
'sonarjs/publicly-writable-directories': 'off',
'simple-import-sort/imports': 'off',
'simple-import-sort/exports': 'off',
// Zero-tolerance rules relaxed for test callbacks and test data
'zero-tolerance/max-function-lines': 'off', // describe/it callbacks are inherently long
'zero-tolerance/no-magic-numbers': 'off', // test data values are inline by design
'zero-tolerance/no-magic-strings': 'off', // test data strings are inline by design
'zero-tolerance/no-type-assertion': 'off', // test mocks need type assertions for VS Code types
'zero-tolerance/require-jsdoc-functions': 'off', // test callbacks don't need JSDoc
'zero-tolerance/no-array-mutation': 'off', // test setup legitimately mutates arrays
'zero-tolerance/no-object-mutation': 'off', // test setup legitimately mutates objects
'zero-tolerance/no-date-now': 'off', // test fixtures legitimately use Date
'zero-tolerance/prefer-readonly-parameters': 'off', // test callbacks and mock fns use mutable sigs
},
},

// Test infrastructure files (helpers, runners, shared types)
{
files: ['**/src/test/*.ts'],
rules: {
'zero-tolerance/max-function-lines': 'off',
'zero-tolerance/no-magic-numbers': 'off',
'zero-tolerance/no-magic-strings': 'off',
'zero-tolerance/no-type-assertion': 'off',
'zero-tolerance/require-jsdoc-functions': 'off',
'zero-tolerance/require-interface-prefix': 'off', // test helper interfaces don't need I prefix
'zero-tolerance/no-re-export': 'off', // test helpers may re-export types for convenience
'zero-tolerance/no-banned-types': 'off', // test helpers may use indexed access types
},
},

// Allow 'instanceof Error' only within guards helper to implement the guard itself
{
files: ['src/utils/guards.ts'],
files: ['src/utils/guards.ts', 'src/utils/assert.ts'],
rules: {
'no-restricted-syntax': 'off',
},
},

// Inherently stateful implementations that legitimately mutate internal state
{
files: [
'src/utils/semaphore.ts', // Semaphore requires mutable permit/queue state
'src/core/barrel/content-sanitizer.ts', // Multiline state machine requires mutable buffer
'src/extension.ts', // VS Code subscriptions.push() and queue class are externally constrained
'src/logging/output-channel.logger.ts', // Logger bindings and timestamp are implementation details
],
rules: {
'zero-tolerance/no-array-mutation': 'off',
'zero-tolerance/no-object-mutation': 'off',
'zero-tolerance/no-date-now': 'off',
'zero-tolerance/no-await-in-loop': 'off', // BarrelCommandQueue.processQueue is intentionally sequential
},
},

// Files where prefer-readonly-parameters cannot be correctly applied
{
files: [
'src/utils/assert.ts', // generic T params - Readonly<T> breaks null/undefined inference
'src/core/barrel/barrel-content.builder.ts', // optional class-instance DI constructor params
'src/core/barrel/barrel-file.generator.ts', // optional class-instance DI constructor params
'src/core/barrel/content-sanitizer.ts', // mutable state machine IMultilineState param
'src/core/parser/export.parser.ts', // ts-morph Statement nodes - Readonly<Statement> != Statement
],
rules: {
'zero-tolerance/prefer-readonly-parameters': 'off',
},
},

// Source files - relax strict return type rules since methods already have explicit return types
{
files: ['src/**/*.ts'],
Expand Down
217 changes: 214 additions & 3 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
},
"description": "A Visual Studio Code extension to automatically export types, functions, constants, and classes through barrel files",
"devDependencies": {
"@coderrob/eslint-plugin-zero-tolerance": "^1.2.2",
"@types/glob": "^8.1.0",
"@types/node": "^22.x",
"@types/vscode": "^1.80.0",
Expand Down
Loading
Loading