Skip to content

Commit 243cfdc

Browse files
authored
Merge pull request #48 from grafana/jh/fix-flat-config
fix composable flat configs
2 parents 16c74ab + 009722b commit 243cfdc

File tree

3 files changed

+36
-39
lines changed

3 files changed

+36
-39
lines changed

README.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,6 @@ npx install-peerdeps --dev @grafana/eslint-config
3030

3131
If using a different package manager, run `npm info "@grafana/eslint-config@latest" peerDependencies` to list the peer dependencies and versions. Then run `yarn add --dev <dependency1>@<version> <dependency2>@<version> <dependency3>@<version>` for the listed peer dependencies.
3232

33-
## Configuration (legacy: .eslintrc\*)
34-
35-
Extend our configuration to get reasonable defaults:
36-
37-
```json
38-
{
39-
"extends": ["@grafana/eslint-config"]
40-
}
41-
```
42-
43-
It will automatically handle `*.(js|ts|tsx)` files.
44-
4533
## Configuration (new: eslint.config.js)
4634

4735
From v8.21.0, Eslint introduced a new flat config system where `eslint.config.js` replaces `.eslintrc*` as the default config file name. Eslint@8.x supports both systems, while Eslint@9.x only supports the new flat config.
@@ -63,9 +51,8 @@ const grafanaConfig = require("@grafana/eslint-config/flat");
6351
* @type {Array<import('eslint').Linter.Config>}
6452
*/
6553
module.exports = [
66-
{
67-
grafanaConfig,
68-
},
54+
...grafanaConfig,
55+
/* rest of your config */
6956
];
7057
```
7158

@@ -83,7 +70,7 @@ module.exports = [
8370
{
8471
ignores: [".github", ".yarn", "**/build/", "**/compiled/", "**/dist/"],
8572
},
86-
grafanaConfig,
73+
...grafanaConfig,
8774
{
8875
name: "myproject/defaults",
8976
files: ["**/*.{ts,tsx,js,jsx}"],
@@ -93,3 +80,15 @@ module.exports = [
9380
},
9481
];
9582
```
83+
84+
## Configuration (legacy: .eslintrc\*)
85+
86+
Extend our configuration to get reasonable defaults:
87+
88+
```json
89+
{
90+
"extends": ["@grafana/eslint-config"]
91+
}
92+
```
93+
94+
It will automatically handle `*.(js|ts|tsx)` files.

flat.js

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,24 @@ const stylisticTs = require("@stylistic/eslint-plugin-ts");
88

99
const baseConfig = require("./base");
1010

11-
/**
12-
* @type {Array<import('eslint').Linter.Config>}
13-
*/
14-
module.exports = {
15-
name: "@grafana/eslint-config/flat",
16-
...reactHooksPlugin.configs.recommended,
17-
...reactPlugin.configs.flat.recommended,
18-
...prettierConfig,
19-
settings: baseConfig.settings,
20-
plugins: {
21-
jsdoc,
22-
"@typescript-eslint": tsPlugin,
23-
"react-hooks": reactHooksPlugin,
24-
"@stylistic/ts": stylisticTs,
11+
module.exports = [
12+
reactHooksPlugin.configs["recommended-latest"],
13+
reactPlugin.configs.flat.recommended,
14+
prettierConfig,
15+
{
16+
name: "@grafana/eslint-config/flat",
17+
settings: baseConfig.settings,
18+
plugins: {
19+
jsdoc,
20+
"@typescript-eslint": tsPlugin,
21+
"@stylistic/ts": stylisticTs,
22+
},
23+
languageOptions: {
24+
parser: typescriptParser,
25+
ecmaVersion: baseConfig.ecmaVersion,
26+
sourceType: baseConfig.sourceType,
27+
parserOptions: baseConfig.parserOptions,
28+
},
29+
rules: baseConfig.rules,
2530
},
26-
languageOptions: {
27-
parser: typescriptParser,
28-
ecmaVersion: baseConfig.ecmaVersion,
29-
sourceType: baseConfig.sourceType,
30-
parserOptions: baseConfig.parserOptions,
31-
},
32-
rules: baseConfig.rules,
33-
};
31+
];

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"license": "Apache-2.0",
44
"name": "@grafana/eslint-config",
55
"main": "index.js",
6-
"version": "8.0.0",
6+
"version": "8.1.0",
77
"description": "Grafana's ESLint config",
88
"keywords": [
99
"grafana",

0 commit comments

Comments
 (0)