Skip to content

Commit

Permalink
docs: auto-generate configs list with eslint-doc-generator
Browse files Browse the repository at this point in the history
  • Loading branch information
bmish committed Dec 9, 2023
1 parent 8bd6c7e commit 2b6b7b8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .eslint-doc-generatorrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"use strict"

/** @type {import('eslint-doc-generator').GenerateOptions} */
const config = {
urlConfigs: "https://github.com/eslint-community/eslint-plugin-n#-configs",
configEmoji: [
Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,19 @@ For [Shareable Configs](https://eslint.org/docs/latest/developer-guide/shareable

## 🔧 Configs

This plugin provides three configs:

| Name | Description |
| :-- | :-- |
| `plugin:n/recommended` | Considers both CommonJS and ES Modules. If [`"type":"module"` field](https://medium.com/@nodejs/announcing-a-new-experimental-modules-1be8d2d6c2ff#b023) existed in package.json then it considers files as ES Modules. Otherwise it considers files as CommonJS. In addition, it considers `*.mjs` files as ES Modules and `*.cjs` files as CommonJS. |
| `plugin:n/recommended-module` | Considers all files as ES Modules. |
| `plugin:n/recommended-script` | Considers all files as CommonJS. |
<!-- begin auto-generated configs list -->

| | Name | Description |
| :- | :------------------------ | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 🟠 | `flat/mixed-esm-and-cjs` | |
| ☑️ | `flat/recommended` | |
| 🟢 | `flat/recommended-module` | |
|| `flat/recommended-script` | |
| ☑️ | `recommended` | Considers both CommonJS and ES Modules. If [`"type":"module"` field](https://medium.com/@nodejs/announcing-a-new-experimental-modules-1be8d2d6c2ff#b023) existed in package.json then it considers files as ES Modules. Otherwise it considers files as CommonJS. In addition, it considers `*.mjs` files as ES Modules and `*.cjs` files as CommonJS. |
| 🟢 | `recommended-module` | Considers all files as ES Modules. |
|| `recommended-script` | Considers all files as CommonJS. |

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

These preset configs:

Expand Down
1 change: 1 addition & 0 deletions lib/configs/recommended-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { commonGlobals, commonRules } = require("./_commons")

// eslintrc config: https://eslint.org/docs/latest/use/configure/configuration-files
module.exports.eslintrc = {
description: "Considers all files as ES Modules.",
globals: {
...commonGlobals,
__dirname: "off",
Expand Down
1 change: 1 addition & 0 deletions lib/configs/recommended-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { commonGlobals, commonRules } = require("./_commons")

// eslintrc config: https://eslint.org/docs/latest/use/configure/configuration-files
module.exports.eslintrc = {
description: "Considers all files as CommonJS.",
globals: {
...commonGlobals,
__dirname: "readonly",
Expand Down
2 changes: 2 additions & 0 deletions lib/configs/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const recommendedConfig = isModule ? moduleConfig : scriptConfig

module.exports.eslintrc = {
...recommendedConfig.eslintrc,
description:
'Considers both CommonJS and ES Modules. If [`"type":"module"` field](https://medium.com/@nodejs/announcing-a-new-experimental-modules-1be8d2d6c2ff#b023) existed in package.json then it considers files as ES Modules. Otherwise it considers files as CommonJS. In addition, it considers `*.mjs` files as ES Modules and `*.cjs` files as CommonJS.',
overrides: [
{ files: ["*.cjs", ".*.cjs"], ...scriptConfig.eslintrc },
{ files: ["*.mjs", ".*.mjs"], ...moduleConfig.eslintrc },
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"esbuild": "^0.18.7",
"eslint": "^8.43.0",
"eslint-config-prettier": "^8.8.0",
"eslint-doc-generator": "^1.4.3",
"eslint-doc-generator": "^1.6.1",
"eslint-plugin-eslint-plugin": "^5.1.0",
"eslint-plugin-n": "file:.",
"fast-glob": "^3.2.12",
Expand Down

0 comments on commit 2b6b7b8

Please sign in to comment.