-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy patheslint.config.mjs
More file actions
119 lines (104 loc) · 5.38 KB
/
Copy patheslint.config.mjs
File metadata and controls
119 lines (104 loc) · 5.38 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
import pluginJs from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import sonarjs from 'eslint-plugin-sonarjs';
import unicorn from 'eslint-plugin-unicorn';
import globals from 'globals';
import tseslint from 'typescript-eslint';
export default [
// ── Ignore patterns ────────────────────────────────────────────
{ ignores: ['dist/', 'node_modules/', 'coverage/', 'examples/'] },
// ── File patterns ──────────────────────────────────────────────
{ files: ['**/*.{js,mjs,cjs,ts}'] },
// ── Language globals ───────────────────────────────────────────
{ languageOptions: { globals: { ...globals.node } } },
// ── Base ESLint + TypeScript ───────────────────────────────────
pluginJs.configs.recommended,
...tseslint.configs.recommended,
eslintConfigPrettier,
// ── SonarJS ────────────────────────────────────────────────────
sonarjs.configs.recommended,
// ── Core rules ─────────────────────────────────────────────────
{
plugins: {
'simple-import-sort': simpleImportSort,
},
rules: {
// No raw console in library source — use logixia's own log system
'no-console': 'warn',
// ── TypeScript ─────────────────────────────────────────────
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
'@typescript-eslint/consistent-type-imports': ['warn', { prefer: 'type-imports' }],
// Non-null assertions are intentional in library code — used after
// Map.get(), optional checks, and other guarded patterns.
'@typescript-eslint/no-non-null-assertion': 'off',
// ── Import ordering ────────────────────────────────────────
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
// ── SonarJS ────────────────────────────────────────────────
// Threshold raised to match the real complexity of core transport/
// search utility functions (highest observed: transport.manager = 49).
'sonarjs/cognitive-complexity': ['warn', 55],
'sonarjs/todo-tag': 'off',
// With `exactOptionalPropertyTypes: true` (tsconfig.json), `?: T` and
// `?: T | undefined` are NOT equivalent — the latter permits explicitly
// assigning `undefined`, which callers throughout this codebase rely on.
// This rule is purely syntactic and doesn't account for that tsconfig flag.
'sonarjs/no-redundant-optional': 'off',
},
},
// ── Unicorn ────────────────────────────────────────────────────
{
plugins: { unicorn },
rules: {
'unicorn/prefer-node-protocol': 'error',
'unicorn/prefer-module': 'off', // Uses CommonJS
'unicorn/no-array-for-each': 'error',
'unicorn/prefer-number-properties': 'error',
'unicorn/no-instanceof-array': 'error',
'unicorn/prefer-optional-catch-binding': 'error',
'unicorn/no-useless-undefined': 'error',
'unicorn/prefer-string-slice': 'error',
'unicorn/throw-new-error': 'error',
'unicorn/no-new-array': 'error',
'unicorn/error-message': 'error',
'unicorn/consistent-destructuring': 'warn',
},
},
// ── Test file overrides ────────────────────────────────────────
{
files: ['test/**/*.ts', '**/*.test.ts', '**/*.spec.ts'],
rules: {
'no-console': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'sonarjs/no-duplicate-string': 'off',
'sonarjs/no-hardcoded-credentials': 'off',
'unicorn/prefer-node-protocol': 'off',
},
},
// ── CLI commands: console.* is intentional for user output ─────
{
files: ['src/cli/**/*.ts'],
rules: { 'no-console': 'off' },
},
// ── Console transport: wraps console.* by design ───────────────
{
files: ['src/transports/console.transport.ts'],
rules: { 'no-console': 'off' },
},
// ── Internal log: IS the console wrapper ──────────────────────
{
files: ['src/utils/internal-log.ts'],
rules: { 'no-console': 'off' },
},
// ── Logger core: fallback console output when no transports ───
{
files: ['src/core/logitron-logger.ts'],
rules: { 'no-console': 'off' },
},
];