forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eslintrc
162 lines (161 loc) · 5.65 KB
/
.eslintrc
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
{
"extends": ["@grafana/eslint-config", "plugin:react/jsx-runtime"],
"root": true,
"plugins": [
"@emotion",
"lodash",
"jest",
"import",
"jsx-a11y",
"@grafana",
"no-barrel-files",
// Included so betterer doesn't fail when processing all files,
// as other parts of the code use testing-library plugin
"testing-library",
],
"settings": {
"import/internal-regex": "^(app/)|(@grafana)",
"import/external-module-folders": ["node_modules", ".yarn"],
},
"rules": {
"@grafana/no-border-radius-literal": "error",
"@grafana/no-unreduced-motion": "error",
"react/prop-types": "off",
// need to ignore emotion's `css` prop, see https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md#rule-options
"react/no-unknown-property": ["error", { "ignore": ["css"] }],
"@emotion/jsx-import": "error",
"lodash/import-scope": [2, "member"],
"jest/no-focused-tests": "error",
"import/order": [
"error",
{
"groups": [["builtin", "external"], "internal", "parent", "sibling", "index"],
"newlines-between": "always",
"alphabetize": { "order": "asc" },
},
],
"no-restricted-imports": [
"error",
{
"paths": [
{
"name": "react-redux",
"importNames": ["useDispatch", "useSelector"],
"message": "Please import from app/types instead.",
},
{
"name": "react-i18next",
"importNames": ["Trans", "t"],
"message": "Please import from app/core/internationalization instead",
},
],
},
],
// Use typescript's no-redeclare for compatibility with overrides
"no-redeclare": "off",
"@typescript-eslint/no-redeclare": ["error"],
},
"overrides": [
{
"files": ["packages/grafana-ui/src/components/uPlot/**/*.{ts,tsx}"],
"rules": {
"react-hooks/rules-of-hooks": "off",
"react-hooks/exhaustive-deps": "off",
},
},
{
"files": ["packages/grafana-ui/src/components/ThemeDemos/**/*.{ts,tsx}"],
"rules": {
"@emotion/jsx-import": "off",
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
},
},
{
"files": ["public/dashboards/scripted*.js"],
"rules": {
"no-redeclare": "error",
"@typescript-eslint/no-redeclare": "off",
},
},
{
"extends": ["plugin:jsx-a11y/recommended"],
"files": ["**/*.tsx"],
"excludedFiles": ["**/*.{spec,test}.tsx"],
"rules": {
// rules marked "off" are those left in the recommended preset we need to fix
// we should remove the corresponding line and fix them one by one
// any marked "error" contain specific overrides we'll need to keep
"jsx-a11y/no-autofocus": [
"error",
{
"ignoreNonDOM": true,
},
],
"jsx-a11y/label-has-associated-control": [
"error",
{
"controlComponents": ["NumberInput"],
"depth": 2,
},
],
},
},
{
"files": [
"public/app/plugins/datasource/azuremonitor/*.{ts,tsx}",
"public/app/plugins/datasource/azuremonitor/**/*.{ts,tsx}",
"public/app/plugins/datasource/cloud-monitoring/*.{ts,tsx}",
"public/app/plugins/datasource/cloud-monitoring/**/*.{ts,tsx}",
"public/app/plugins/datasource/elasticsearch/*.{ts,tsx}",
"public/app/plugins/datasource/elasticsearch/**/*.{ts,tsx}",
"public/app/plugins/datasource/grafana-postgresql-datasource/*.{ts,tsx}",
"public/app/plugins/datasource/grafana-postgresql-datasource/**/*.{ts,tsx}",
"public/app/plugins/datasource/grafana-pyroscope-datasource/*.{ts,tsx}",
"public/app/plugins/datasource/grafana-pyroscope-datasource/**/*.{ts,tsx}",
"public/app/plugins/datasource/grafana-testdata-datasource/*.{ts,tsx}",
"public/app/plugins/datasource/grafana-testdata-datasource/**/*.{ts,tsx}",
"public/app/plugins/datasource/jaeger/*.{ts,tsx}",
"public/app/plugins/datasource/jaeger/**/*.{ts,tsx}",
"public/app/plugins/datasource/loki/*.{ts,tsx}",
"public/app/plugins/datasource/loki/**/*.{ts,tsx}",
"public/app/plugins/datasource/mysql/*.{ts,tsx}",
"public/app/plugins/datasource/mysql/**/*.{ts,tsx}",
"public/app/plugins/datasource/parca/*.{ts,tsx}",
"public/app/plugins/datasource/parca/**/*.{ts,tsx}",
"public/app/plugins/datasource/tempo/*.{ts,tsx}",
"public/app/plugins/datasource/tempo/**/*.{ts,tsx}",
"public/app/plugins/datasource/loki/*.{ts,tsx}",
"public/app/plugins/datasource/loki/**/*.{ts,tsx}",
"public/app/plugins/datasource/elasticsearch/*.{ts,tsx}",
"public/app/plugins/datasource/elasticsearch/**/*.{ts,tsx}",
"public/app/plugins/datasource/cloudwatch/*.{ts,tsx}",
"public/app/plugins/datasource/cloudwatch/**/*.{ts,tsx}",
"public/app/plugins/datasource/zipkin/*.{ts,tsx}",
"public/app/plugins/datasource/zipkin/**/*.{ts,tsx}",
],
"settings": {
"import/resolver": {
"node": {
"extensions": [".ts", ".tsx"],
},
},
},
"rules": {
"import/no-restricted-paths": [
"error",
{
"zones": [
{
"target": "./public/app/plugins",
"from": "./public",
"except": ["./app/plugins"],
"message": "Core plugins are not allowed to depend on Grafana core packages",
},
],
},
],
},
},
],
}