diff --git a/README.md b/README.md
index 575a5190..d802ac9b 100644
--- a/README.md
+++ b/README.md
@@ -38,6 +38,7 @@ Here's an example ESLint configuration that:
* Enables the `recommended` configuration
* Enables an optional/non-recommended rule
+### eslintrc
```json
{
"parserOptions": {
@@ -52,6 +53,20 @@ Here's an example ESLint configuration that:
}
```
+### `eslint.config.js`
+```js
+const eslintPluginRecommended = require("eslint-plugin-eslint-plugin/configs/recommended");
+module.exports = [
+ eslintPluginRecommended,
+ {
+ languageOptions: {sourceType: "commonjs"},
+ rules: {
+ "eslint-plugin/require-meta-docs-description": "error",
+ },
+ },
+];
+```
+
## Rules
diff --git a/configs/all.js b/configs/all.js
new file mode 100644
index 00000000..27568984
--- /dev/null
+++ b/configs/all.js
@@ -0,0 +1,13 @@
+/**
+ * @fileoverview the `all` config for `eslint.config.js`
+ * @author 唯然
+ */
+
+'use strict';
+
+const { configs, rules } = require('../lib/index.js');
+
+module.exports = {
+ plugins: { 'eslint-plugin': { rules } },
+ rules: configs.all.rules,
+};
diff --git a/configs/index.js b/configs/index.js
deleted file mode 100644
index 525f8576..00000000
--- a/configs/index.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * @fileoverview the configs for `eslint.config.js`
- * @link https://eslint.org/docs/latest/use/configure/configuration-files-new
- * @author 唯然
- */
-
-'use strict';
-
-const { configs, rules } = require('../lib/index.js');
-const configNames = Object.keys(configs);
-
-configNames.forEach((configName) => {
- // the only difference is the `plugins` property must be an object
- // TODO: we might better copy the config instead of mutating it, in case it's used by somewhere else
- configs[configName].plugins = { 'eslint-plugin': { rules } };
-});
-
-module.exports = configs;
diff --git a/configs/recommended.js b/configs/recommended.js
new file mode 100644
index 00000000..74c7cf23
--- /dev/null
+++ b/configs/recommended.js
@@ -0,0 +1,13 @@
+/**
+ * @fileoverview the `recommended` config for `eslint.config.js`
+ * @author 唯然
+ */
+
+'use strict';
+
+const { configs, rules } = require('../lib/index.js');
+
+module.exports = {
+ plugins: { 'eslint-plugin': { rules } },
+ rules: configs.recommended.rules,
+};
diff --git a/configs/rules-recommended.js b/configs/rules-recommended.js
new file mode 100644
index 00000000..527d4fd0
--- /dev/null
+++ b/configs/rules-recommended.js
@@ -0,0 +1,13 @@
+/**
+ * @fileoverview the `rules-recommended` config for `eslint.config.js`
+ * @author 唯然
+ */
+
+'use strict';
+
+const { configs, rules } = require('../lib/index.js');
+
+module.exports = {
+ plugins: { 'eslint-plugin': { rules } },
+ rules: configs['rules-recommended'].rules,
+};
diff --git a/configs/rules.js b/configs/rules.js
new file mode 100644
index 00000000..fd777c55
--- /dev/null
+++ b/configs/rules.js
@@ -0,0 +1,13 @@
+/**
+ * @fileoverview the `rules` config for `eslint.config.js`
+ * @author 唯然
+ */
+
+'use strict';
+
+const { configs, rules } = require('../lib/index.js');
+
+module.exports = {
+ plugins: { 'eslint-plugin': { rules } },
+ rules: configs.rules.rules,
+};
diff --git a/configs/tests-recommended.js b/configs/tests-recommended.js
new file mode 100644
index 00000000..a872c478
--- /dev/null
+++ b/configs/tests-recommended.js
@@ -0,0 +1,13 @@
+/**
+ * @fileoverview the `tests-recommended` config for `eslint.config.js`
+ * @author 唯然
+ */
+
+'use strict';
+
+const { configs, rules } = require('../lib/index.js');
+
+module.exports = {
+ plugins: { 'eslint-plugin': { rules } },
+ rules: configs['tests-recommended'].rules,
+};
diff --git a/configs/tests.js b/configs/tests.js
new file mode 100644
index 00000000..b0ac3235
--- /dev/null
+++ b/configs/tests.js
@@ -0,0 +1,13 @@
+/**
+ * @fileoverview the `tests` config for `eslint.config.js`
+ * @author 唯然
+ */
+
+'use strict';
+
+const { configs, rules } = require('../lib/index.js');
+
+module.exports = {
+ plugins: { 'eslint-plugin': { rules } },
+ rules: configs.tests.rules,
+};
diff --git a/eslint.config.js b/eslint.config.js
index eeb4ad3c..94bebc30 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -4,7 +4,7 @@ const js = require('@eslint/js');
const { FlatCompat } = require('@eslint/eslintrc');
const globals = require('globals');
const markdown = require('eslint-plugin-markdown');
-const eslintPluginConfig = require('eslint-plugin-eslint-plugin/configs').all;
+const eslintPluginConfig = require('eslint-plugin-eslint-plugin/configs/all');
const compat = new FlatCompat({
baseDirectory: __dirname,
@@ -48,8 +48,9 @@ module.exports = [
{
// Apply eslint-plugin rules to our own rules/tests (but not docs).
files: ['lib/**/*.js', 'tests/**/*.js'],
- ...eslintPluginConfig,
+ plugins: eslintPluginConfig.plugins,
rules: {
+ ...eslintPluginConfig.rules,
'eslint-plugin/report-message-format': ['error', '^[^a-z].*.$'],
'eslint-plugin/require-meta-docs-url': [
'error',
diff --git a/package.json b/package.json
index 86221d9e..6e8df6d4 100644
--- a/package.json
+++ b/package.json
@@ -6,7 +6,7 @@
"main": "./lib/index.js",
"exports": {
".": "./lib/index.js",
- "./configs": "./configs/index.js",
+ "./configs/*": "./configs/*.js",
"./package.json": "./package.json"
},
"license": "MIT",