-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy patheslint.config.js
More file actions
141 lines (130 loc) · 4.25 KB
/
Copy patheslint.config.js
File metadata and controls
141 lines (130 loc) · 4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import eslint from '@eslint/js';
import globals from 'globals';
import sonarjs from 'eslint-plugin-sonarjs';
import tseslint from 'typescript-eslint';
export default tseslint.config(
eslint.configs.recommended,
sonarjs.configs.recommended,
...tseslint.configs.recommended,
{
rules: {
// Style/micro-optimisation rules — too noisy, not real smells
'sonarjs/prefer-immediate-return': 'off',
'sonarjs/no-collapsible-if': 'off',
'sonarjs/prefer-single-boolean-return': 'off',
'sonarjs/no-redundant-boolean': 'off',
'sonarjs/no-negated-condition': 'off',
// CLI tool intentionally runs OS commands — not a security smell here
'sonarjs/no-os-command-from-path': 'off',
'sonarjs/os-command': 'off',
// Math.random() is used for persona humanization, not crypto
'sonarjs/pseudo-random': 'off',
// void fn() is a valid fire-and-forget pattern in async Slack handlers
'sonarjs/void-use': 'off',
// Intentional app setup — not actionable smells
'sonarjs/cors': 'off',
'sonarjs/hashing': 'off',
'sonarjs/publicly-writable-directories': 'off',
// Too common and not a meaningful smell in template-heavy code
'sonarjs/no-nested-template-literals': 'off',
// Pedantic style preference
'sonarjs/no-small-switch': 'off',
// Duplicate string: only flag egregious repetition (≥5 occurrences)
'sonarjs/no-duplicate-string': ['warn', { threshold: 5 }],
// Complexity: warn at 20 (default 15 is too aggressive)
'sonarjs/cognitive-complexity': ['warn', 20],
},
},
{
languageOptions: {
globals: {
...globals.node,
},
},
rules: {
// Flexible defaults — avoid noisy rules
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': [
'warn',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' },
],
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'interface',
format: ['PascalCase'],
prefix: ['I'],
},
{
selector: 'memberLike',
modifiers: ['private'],
format: null,
leadingUnderscore: 'forbid',
},
],
'no-console': 'off',
'no-useless-escape': 'warn',
'no-useless-assignment': 'warn',
'prefer-const': 'warn',
'preserve-caught-error': 'off',
'sort-imports': ['error', { ignoreDeclarationSort: true }],
// SRP: flag god files (warn only — don't break CI on existing code)
'max-lines': ['warn', { max: 500, skipBlankLines: true, skipComments: true }],
'no-restricted-imports': [
'warn',
{
paths: [
{
name: 'reflect-metadata',
message:
'Only import reflect-metadata in entrypoints (cli.ts, di/container.ts) or test files.',
},
],
patterns: [
{
regex: '^\\.\\./\\.\\.[\\/]',
message: 'Avoid deep relative imports (../../). Use @/* path aliases instead.',
},
{
regex: '^@night-watch/core/.+',
message:
"Import from '@night-watch/core' barrel instead of deep paths (e.g. import { X } from '@night-watch/core').",
},
],
},
],
},
},
// Allow reflect-metadata in entrypoints and test files
{
files: ['**/cli.ts', '**/di/container.ts', '**/__tests__/**'],
rules: {
'no-restricted-imports': [
'warn',
{
patterns: [
{
regex: '^\\.\\./\\.\\.[\\/]',
message: 'Avoid deep relative imports (../../). Use @/* path aliases instead.',
},
],
},
],
},
},
{
ignores: [
'**/dist/**',
'**/node_modules/**',
'scripts/',
'templates/',
'**/*.test.ts',
'**/__tests__/**',
// Compiled TypeScript output files that live alongside source in src/
'packages/**/src/**/*.js',
'packages/**/src/**/*.d.ts',
],
},
);