-
Notifications
You must be signed in to change notification settings - Fork 578
Expand file tree
/
Copy patheslint.config.sonar.mjs
More file actions
84 lines (81 loc) · 2.45 KB
/
Copy patheslint.config.sonar.mjs
File metadata and controls
84 lines (81 loc) · 2.45 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
// Sonar-only ESLint config: runs eslint-plugin-sonarjs in isolation so
// contributors can preview the kinds of findings SonarCloud will flag without
// the noise of the full lint config. Mirrors the test/script overrides from
// eslint.config.mjs so the output matches what `npm run lint` produces for
// sonarjs rules.
//
// Plugins from the main config are registered (with no rules enabled) so that
// inline `eslint-disable-next-line` directives targeting those rules don't
// produce "rule not found" errors.
import tsParser from '@typescript-eslint/parser'
import tsPlugin from '@typescript-eslint/eslint-plugin'
import nodePlugin from 'eslint-plugin-node'
import securityPlugin from 'eslint-plugin-security'
import unicornPlugin from 'eslint-plugin-unicorn'
import sonarjsPlugin from 'eslint-plugin-sonarjs'
const sharedPlugins = {
'@typescript-eslint': tsPlugin,
node: nodePlugin,
security: securityPlugin,
unicorn: unicornPlugin,
}
export default [
sonarjsPlugin.configs.recommended,
{
ignores: [
'dist/**',
'build/**',
'coverage/**',
'node_modules/**',
'**/*{.,-}min.js',
'*.d.ts',
'.tsbuild/**',
'tsconfig.tsbuildinfo',
],
},
{
linterOptions: {
reportUnusedDisableDirectives: 'off',
},
plugins: sharedPlugins,
},
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: tsParser,
ecmaVersion: 2024,
sourceType: 'module',
parserOptions: {
// Several sonarjs rules (e.g. void-use) need TS type info to
// distinguish intentional patterns from real bugs.
project: ['./tsconfig.eslint.json'],
tsconfigRootDir: new URL('.', import.meta.url).pathname,
},
},
rules: {
'sonarjs/cognitive-complexity': 'warn',
'sonarjs/function-return-type': 'warn',
},
},
{
files: ['**/*.test.ts', '**/*.spec.ts', 'tests/**/*.ts'],
rules: {
'sonarjs/no-hardcoded-passwords': 'off',
'sonarjs/no-hardcoded-ip': 'off',
'sonarjs/no-os-command-from-path': 'off',
'sonarjs/no-clear-text-protocols': 'off',
'sonarjs/assertions-in-tests': 'off',
'sonarjs/constructor-for-side-effects': 'off',
'sonarjs/os-command': 'off',
'sonarjs/publicly-writable-directories': 'off',
'sonarjs/prefer-regexp-exec': 'warn',
'sonarjs/slow-regex': 'warn',
},
},
{
files: ['scripts/**/*.{ts,js}'],
rules: {
'sonarjs/no-os-command-from-path': 'off',
},
},
]