forked from grafana/plugin-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
90 lines (88 loc) · 2.47 KB
/
eslint.config.js
File metadata and controls
90 lines (88 loc) · 2.47 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
// @ts-check
const grafanaConfig = require('@grafana/eslint-config/flat');
const mdxParser = require('eslint-mdx');
const mdxPlugin = require('eslint-plugin-mdx');
// If you edit this config consider running `npx -y @eslint/config-inspector@latest` first.
/**
* @type {Array<import('eslint').Linter.Config>}
*/
module.exports = [
{
name: 'plugin-tools/ignores',
ignores: [
'.github',
'.nx/**',
'**/.*', // dotfiles aren't ignored by default in FlatConfig,
'packages/**/dist/**',
'packages/create-plugin/templates/**',
'docusaurus/website/.docusaurus',
'docusaurus/website/build',
],
},
// Focus the source code configs on source code so mdx codeblocks don't inherit all the eslint config
// which would make it very difficult to write "incomplete" snippets of code in the docs.
...grafanaConfig.map((config) => ({
...config,
files: ['**/*.{ts,tsx,js,jsx}'],
ignores: ['docusaurus/docs/**'],
})),
{
name: 'plugin-e2e/overrides',
rules: {
'react/prop-types': 'off',
'react-hooks/rules-of-hooks': 'off',
},
},
{
name: 'create-plugin/overrides',
files: ['packages/create-plugin/src/migrations/scripts/**/*.ts'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['fs', 'fs:promises', 'node:fs', 'node:fs/promises'],
message: 'Use the Context passed to the migration script.',
},
],
},
],
},
},
{
...mdxPlugin.flat,
...mdxPlugin.flatCodeBlocks,
name: 'website/mdx',
files: ['docusaurus/docs/**/*.{md,mdx}'],
languageOptions: {
parser: mdxParser,
parserOptions: {
extensions: ['.md', '.mdx'],
markdownExtensions: ['.md', '.mdx'],
},
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
},
processor: mdxPlugin.createRemarkProcessor({
lintCodeBlocks: true,
}),
rules: {
...mdxPlugin.flat.rules,
...mdxPlugin.flatCodeBlocks.rules,
},
},
{
name: 'plugin-tools/typescript-overrides',
files: ['packages/plugin-docs-cli/src/validation/types.ts'],
rules: {
'no-redeclare': 'off',
// ts compiler handles redeclaration; using the same name for a const object and its derived type (e.g. `const Foo = {...} as const; type Foo = ...`) is valid ts but trips eslint
},
},
];