diff --git a/README.md b/README.md index f61a7ee0..e29fb0b7 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ For more details on how to extend your configuration from a plugin configuration -| | Name | Description | -| :- | :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| ✅ | `recommended` | This configuration includes rules which I recommend to avoid QUnit runtime errors or incorrect behavior, some of which can be difficult to debug. Some of these rules also encourage best practices that help QUnit work better for you. You can use this configuration by extending from `"plugin:qunit/recommended"` in your configuration file. | +| | Name | Description | +| :- | :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| ✅ | `recommended` | This configuration includes rules which I recommend to avoid QUnit runtime errors or incorrect behavior, some of which can be difficult to debug. Some of these rules also encourage best practices that help QUnit work better for you. For ESLint `.eslintrc.js` legacy config, extend from `"plugin:qunit/recommended"`. For ESLint `eslint.config.js` flat config, load from `require('eslint-plugin-qunit/configs/recommended')`. | diff --git a/index.js b/index.js index 411b8300..0c14ff2b 100644 --- a/index.js +++ b/index.js @@ -8,14 +8,24 @@ "use strict"; const requireIndex = require("requireindex"); +const pkg = require("./package.json"); module.exports = { + meta: { + name: pkg.name, + version: pkg.version + }, + rules: requireIndex(`${__dirname}/lib/rules`), // eslint-disable-next-line sort-keys configs: { recommended: { - description: "This configuration includes rules which I recommend to avoid QUnit runtime errors or incorrect behavior, some of which can be difficult to debug. Some of these rules also encourage best practices that help QUnit work better for you. You can use this configuration by extending from `\"plugin:qunit/recommended\"` in your configuration file.", + description: [ + "This configuration includes rules which I recommend to avoid QUnit runtime errors or incorrect behavior, some of which can be difficult to debug. Some of these rules also encourage best practices that help QUnit work better for you.", + "For ESLint `.eslintrc.js` legacy config, extend from `\"plugin:qunit/recommended\"`.", + "For ESLint `eslint.config.js` flat config, load from `require('eslint-plugin-qunit/configs/recommended')`." + ].join(" "), plugins: ["qunit"], rules: { "qunit/assert-args": "error", diff --git a/lib/configs/recommended.js b/lib/configs/recommended.js new file mode 100644 index 00000000..e5c31c18 --- /dev/null +++ b/lib/configs/recommended.js @@ -0,0 +1,8 @@ +"use strict"; + +const plugin = require("../../index.js"); + +module.exports = { + plugins: { qunit: plugin }, + rules: plugin.configs.recommended.rules +}; diff --git a/package.json b/package.json index 68f03466..af1736b0 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,10 @@ "name": "eslint-plugin-qunit", "version": "8.0.1", "description": "ESLint plugin containing rules useful for QUnit tests.", - "exports": "./index.js", + "exports": { + ".": "./index.js", + "./configs/*": "./lib/configs/*.js" + }, "main": "./index.js", "scripts": { "lint": "npm-run-all --continue-on-error --aggregate-output --parallel lint:*",