Skip to content

Commit

Permalink
feat: support eslint flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
bmish committed Dec 10, 2023
1 parent bc854b0 commit 5b7505a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -15,9 +15,9 @@ For more details on how to extend your configuration from a plugin configuration

<!-- begin auto-generated configs list -->

| | 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')`. |

<!-- end auto-generated configs list -->

Expand Down
12 changes: 11 additions & 1 deletion index.js
Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions 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
};
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -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:*",
Expand Down

0 comments on commit 5b7505a

Please sign in to comment.