-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy patheslint.config.mjs
More file actions
148 lines (136 loc) · 3.66 KB
/
eslint.config.mjs
File metadata and controls
148 lines (136 loc) · 3.66 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
142
143
144
145
146
147
148
import { FlatCompat } from '@eslint/eslintrc';
import { defineConfig } from 'eslint/config';
import importPlugin from 'eslint-plugin-import';
import jsxa11y from 'eslint-plugin-jsx-a11y';
import sortPlugin from 'eslint-plugin-sort';
// eslint-disable-next-line import/no-unresolved -- package.json exports field not recognized by import plugin
import grafanaI18nPlugin from '@grafana/i18n/eslint-plugin';
import baseConfig from './.config/eslint.config.mjs';
const compat = new FlatCompat();
export default defineConfig([
{
ignores: [
'**/CHANGELOG.md',
'**/README.md',
'**/dist/',
'**/node_modules/',
'**/package.json',
'./.gitignore',
'**/.config/',
'**/.eslintignore',
'**/.prettierignore',
'**/.husky/',
'**/project-words.txt',
'**/yarn.lock',
'**/tsconfig-for-bundle-types.json',
'**/playwright-report/',
'**/*.md',
'**/*.yaml',
'**/*.json',
'**/*.svg',
'**/*.river',
'**/*.sh',
'**/*.log',
'**/npm-debug.log*',
'**/yarn-debug.log*',
'**/yarn-error.log*',
'**/.pnpm-debug.log*',
'**/.yarn/',
'**/.yarnrc.yml',
'**/pids',
'**/*.pid',
'**/*.seed',
'**/*.pid.lock',
'**/lib-cov',
'**/coverage',
'**/artifacts/',
'**/work/',
'**/ci/',
'**/.idea',
'**/.eslintcache',
'**/.DS_Store',
'test-results/',
'playwright-report/',
'blob-report/',
'playwright/.cache/',
'playwright/.auth/',
'generator/vendor/',
'generator/generator',
'**/.env',
],
},
...baseConfig,
...compat.extends(
'plugin:jsx-a11y/strict',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript'
),
{
plugins: {
'jsx-a11y': jsxa11y,
sort: sortPlugin,
import: importPlugin,
},
rules: {
'no-restricted-globals': ['error', 'location'],
'no-cond-assign': ['error', 'except-parens'],
'import/no-duplicates': 'error',
'import/no-unresolved': 'off',
'sort/imports': [
'error',
{
groups: [
{ type: 'side-effect', order: 20 },
{ regex: '^@grafana', order: 30 },
{ regex: '^react$', order: 10 },
{ type: 'dependency', order: 15 },
{ regex: '^.+\\.s?css$', order: 50 },
{ type: 'other', order: 40 },
],
separator: '\n',
},
],
'sort/object-properties': 'off',
'sort/type-properties': 'error',
'sort/string-unions': 'error',
'sort/exports': 'off',
},
},
{
files: ['src/**/*.test.{ts,tsx}'],
rules: {
'no-restricted-globals': 'off',
'react/jsx-key': ['warn', { checkFragmentShorthand: true }],
},
},
// Grafana Scenes useStyles2 hook throws a warning in scene classes
// Wherever possible pull the scene component out into a function to avoid this warning
{
files: ['src/Components/**/*.tsx'],
rules: {
'react-hooks/rules-of-hooks': 'off',
'react-hooks/set-state-in-effect': 'off',
'react-hooks/immutability': 'off',
'react-hooks/refs': 'off',
},
},
{
name: 'logs-drilldown/i18n',
files: ['src/**/*.{ts,tsx}'],
ignores: ['**/*.test.{ts,tsx}', '**/__tests__/**', '**/test/**', '**/mocks/**'],
plugins: {
'@grafana/i18n': grafanaI18nPlugin,
},
rules: {
'@grafana/i18n/no-untranslated-strings': [
'error',
{
basePaths: ['src'],
calleesToIgnore: ['^css$', 'use[A-Z].*', '^get.*Styles$'],
},
],
'@grafana/i18n/no-translation-top-level': 'error',
},
},
]);