Skip to content

Commit 06f321b

Browse files
authored
feat: update plugin template to use defineConfig (#205)
* refactor: update plugin template to use `defineConfig` * wip: update `eslint.config.mjs` * wip * wip * wip * wip * wip * wip
1 parent 0ff5d1f commit 06f321b

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

plugin/templates/_README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,26 @@ npm install eslint-plugin-<%= pluginId %> --save-dev
2121
In your [configuration file](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-file), import the plugin `eslint-plugin-<%= pluginId %>` and add `<%= pluginId %>` to the `plugins` key:
2222

2323
```js
24+
import { defineConfig } from "eslint/config";
2425
import <%= pluginId %> from "eslint-plugin-<%= pluginId %>";
2526

26-
export default [
27+
export default defineConfig([
2728
{
2829
plugins: {
2930
<%= pluginId %>
3031
}
3132
}
32-
];
33+
]);
3334
```
3435

3536
<% if (hasRules) { %>
3637
Then configure the rules you want to use under the `rules` key.
3738

3839
```js
40+
import { defineConfig } from "eslint/config";
3941
import <%= pluginId %> from "eslint-plugin-<%= pluginId %>";
4042

41-
export default [
43+
export default defineConfig([
4244
{
4345
plugins: {
4446
<%= pluginId %>
@@ -47,7 +49,7 @@ export default [
4749
"<%= pluginId %>/rule-name": "warn"
4850
}
4951
}
50-
];
52+
]);
5153
```
5254

5355
<% } %>

plugin/templates/_eslint.config.mjs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
1+
import { defineConfig } from "eslint/config";
12
import pluginJs from "@eslint/js";
23
import pluginNode from "eslint-plugin-n";
34
import eslintPlugin from "eslint-plugin-eslint-plugin";
45

5-
export default [
6-
pluginJs.configs.recommended,
7-
...pluginNode.configs["flat/mixed-esm-and-cjs"],
8-
eslintPlugin.configs["flat/recommended"]
9-
];
6+
export default defineConfig([
7+
{
8+
name: "eslint/js",
9+
plugins: {
10+
js: pluginJs,
11+
},
12+
extends: ["js/recommended"],
13+
},
14+
{
15+
name: "eslint/node",
16+
plugins: {
17+
n: pluginNode,
18+
},
19+
extends: ["n/mixed-esm-and-cjs"],
20+
},
21+
{
22+
name: "eslint/eslint-plugin",
23+
plugins: {
24+
"eslint-plugin": eslintPlugin,
25+
},
26+
extends: ["eslint-plugin/recommended"],
27+
}
28+
]);

0 commit comments

Comments
 (0)