diff --git a/docs/README.md b/docs/README.md
index f6f182cf..c58d003e 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -56,23 +56,29 @@ For example, to enable only Rest/Spread Properties in ES2018, as similar to lega
This plugin provides the following configs.
+
+
| Config ID | Description |
|:----------|:------------|
-| `plugin:es/restrict-to-es2019` | disallow new stuff that ES2019 doesn't include.
-| `plugin:es/restrict-to-es2018` | disallow new stuff that ES2018 doesn't include.
-| `plugin:es/restrict-to-es2017` | disallow new stuff that ES2017 doesn't include.
-| `plugin:es/restrict-to-es2016` | disallow new stuff that ES2016 doesn't include.
-| `plugin:es/restrict-to-es2015` | disallow new stuff that ES2015 doesn't include.
-| `plugin:es/restrict-to-es5` | disallow new stuff that ES5 doesn't include.
-| `plugin:es/restrict-to-es3` | disallow new stuff that ES3 doesn't include.
-| `plugin:es/no-new-in-es2020` | disallow the new stuff in ES2020.
-| `plugin:es/no-new-in-es2019` | disallow the new stuff in ES2019.
-| `plugin:es/no-new-in-es2018` | disallow the new stuff in ES2018.
-| `plugin:es/no-new-in-es2017` | disallow the new stuff in ES2017.
-| `plugin:es/no-new-in-es2016` | disallow the new stuff in ES2016.
-| `plugin:es/no-new-in-es2015` | disallow the new stuff in ES2015.
-| `plugin:es/no-new-in-es5` | disallow the new stuff in ES5.
-| `plugin:es/no-new-in-esnext` | disallow the new stuff to be planned for the next yearly ECMAScript snapshot.
⚠️ This config will be changed in the minor versions of this plugin.
+| `plugin:es/restrict-to-es2020` | disallow new stuff that ES2020 doesn't include. |
+| `plugin:es/restrict-to-es2019` | disallow new stuff that ES2019 doesn't include. |
+| `plugin:es/restrict-to-es2018` | disallow new stuff that ES2018 doesn't include. |
+| `plugin:es/restrict-to-es2017` | disallow new stuff that ES2017 doesn't include. |
+| `plugin:es/restrict-to-es2016` | disallow new stuff that ES2016 doesn't include. |
+| `plugin:es/restrict-to-es2015` | disallow new stuff that ES2015 doesn't include. |
+| `plugin:es/restrict-to-es5` | disallow new stuff that ES5 doesn't include. |
+| `plugin:es/restrict-to-es3` | disallow new stuff that ES3 doesn't include. |
+| `plugin:es/no-new-in-es2021` | disallow the new stuff in ES2021. |
+| `plugin:es/no-new-in-es2020` | disallow the new stuff in ES2020. |
+| `plugin:es/no-new-in-es2019` | disallow the new stuff in ES2019. |
+| `plugin:es/no-new-in-es2018` | disallow the new stuff in ES2018. |
+| `plugin:es/no-new-in-es2017` | disallow the new stuff in ES2017. |
+| `plugin:es/no-new-in-es2016` | disallow the new stuff in ES2016. |
+| `plugin:es/no-new-in-es2015` | disallow the new stuff in ES2015. |
+| `plugin:es/no-new-in-es5` | disallow the new stuff in ES5. |
+| `plugin:es/no-new-in-esnext` | disallow the new stuff to be planned for the next yearly ECMAScript snapshot.
⚠️ This config will be changed in the minor versions of this plugin. |
+
+
For example:
diff --git a/docs/rules/README.md b/docs/rules/README.md
index 67aa97f0..e3c9baee 100644
--- a/docs/rules/README.md
+++ b/docs/rules/README.md
@@ -4,10 +4,16 @@ This plugin provides the following rules.
- 🔧 mark means that the `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by the rule.
-## ES2021
+## ES2022
There is a config that enables the rules in this category: `plugin:es/no-new-in-esnext`
+⚠️ No rules yet. It will be added in the future.
+
+## ES2021
+
+There are multiple configs that enable all rules in this category: `plugin:es/no-new-in-es2021`, `plugin:es/restrict-to-es3`, `plugin:es/restrict-to-es5`, `plugin:es/restrict-to-es2015`, `plugin:es/restrict-to-es2016`, `plugin:es/restrict-to-es2017`, `plugin:es/restrict-to-es2018`, `plugin:es/restrict-to-es2019`, and `plugin:es/restrict-to-es2020`
+
| Rule ID | Description | |
|:--------|:------------|:--:|
| [es/no-logical-assignment-operators](./no-logical-assignment-operators.md) | disallow logical assignment operators. | 🔧 |
@@ -18,7 +24,7 @@ There is a config that enables the rules in this category: `plugin:es/no-new-in-
## ES2020
-There are multiple configs that enable all rules in this category: `plugin:es/no-new-in-es2020`, `plugin:es/restrict-to-es3`, `plugin:es/restrict-to-es5`, `plugin:es/restrict-to-es2015`, `plugin:es/restrict-to-es2016`, `plugin:es/restrict-to-es2017`, `plugin:es/restrict-to-es2018`, and `plugin:es/restrict-to-es2019`
+There are multiple configs that enable all rules in this category: `plugin:es/no-new-in-es2020`, `plugin:es/restrict-to-es3`, `plugin:es/restrict-to-es5`, `plugin:es/restrict-to-es2015`, `plugin:es/restrict-to-es2016`, `plugin:es/restrict-to-es2017`, `plugin:es/restrict-to-es2018`, `plugin:es/restrict-to-es2019`, and `plugin:es/restrict-to-es2020`
| Rule ID | Description | |
|:--------|:------------|:--:|
@@ -34,7 +40,7 @@ There are multiple configs that enable all rules in this category: `plugin:es/no
## ES2019
-There are multiple configs that enable all rules in this category: `plugin:es/no-new-in-es2019`, `plugin:es/restrict-to-es3`, `plugin:es/restrict-to-es5`, `plugin:es/restrict-to-es2015`, `plugin:es/restrict-to-es2016`, `plugin:es/restrict-to-es2017`, and `plugin:es/restrict-to-es2018`
+There are multiple configs that enable all rules in this category: `plugin:es/no-new-in-es2019`, `plugin:es/restrict-to-es3`, `plugin:es/restrict-to-es5`, `plugin:es/restrict-to-es2015`, `plugin:es/restrict-to-es2016`, `plugin:es/restrict-to-es2017`, `plugin:es/restrict-to-es2018`, and `plugin:es/restrict-to-es2019`
| Rule ID | Description | |
|:--------|:------------|:--:|
@@ -48,7 +54,7 @@ There are multiple configs that enable all rules in this category: `plugin:es/no
## ES2018
-There are multiple configs that enable all rules in this category: `plugin:es/no-new-in-es2018`, `plugin:es/restrict-to-es3`, `plugin:es/restrict-to-es5`, `plugin:es/restrict-to-es2015`, `plugin:es/restrict-to-es2016`, and `plugin:es/restrict-to-es2017`
+There are multiple configs that enable all rules in this category: `plugin:es/no-new-in-es2018`, `plugin:es/restrict-to-es3`, `plugin:es/restrict-to-es5`, `plugin:es/restrict-to-es2015`, `plugin:es/restrict-to-es2016`, `plugin:es/restrict-to-es2017`, and `plugin:es/restrict-to-es2018`
| Rule ID | Description | |
|:--------|:------------|:--:|
@@ -63,7 +69,7 @@ There are multiple configs that enable all rules in this category: `plugin:es/no
## ES2017
-There are multiple configs that enable all rules in this category: `plugin:es/no-new-in-es2017`, `plugin:es/restrict-to-es3`, `plugin:es/restrict-to-es5`, `plugin:es/restrict-to-es2015`, and `plugin:es/restrict-to-es2016`
+There are multiple configs that enable all rules in this category: `plugin:es/no-new-in-es2017`, `plugin:es/restrict-to-es3`, `plugin:es/restrict-to-es5`, `plugin:es/restrict-to-es2015`, `plugin:es/restrict-to-es2016`, and `plugin:es/restrict-to-es2017`
| Rule ID | Description | |
|:--------|:------------|:--:|
@@ -78,7 +84,7 @@ There are multiple configs that enable all rules in this category: `plugin:es/no
## ES2016
-There are multiple configs that enable all rules in this category: `plugin:es/no-new-in-es2016`, `plugin:es/restrict-to-es3`, `plugin:es/restrict-to-es5`, and `plugin:es/restrict-to-es2015`
+There are multiple configs that enable all rules in this category: `plugin:es/no-new-in-es2016`, `plugin:es/restrict-to-es3`, `plugin:es/restrict-to-es5`, `plugin:es/restrict-to-es2015`, and `plugin:es/restrict-to-es2016`
| Rule ID | Description | |
|:--------|:------------|:--:|
@@ -87,7 +93,7 @@ There are multiple configs that enable all rules in this category: `plugin:es/no
## ES2015
-There are multiple configs that enable all rules in this category: `plugin:es/no-new-in-es2015`, `plugin:es/restrict-to-es3`, and `plugin:es/restrict-to-es5`
+There are multiple configs that enable all rules in this category: `plugin:es/no-new-in-es2015`, `plugin:es/restrict-to-es3`, `plugin:es/restrict-to-es5`, and `plugin:es/restrict-to-es2015`
| Rule ID | Description | |
|:--------|:------------|:--:|
@@ -173,7 +179,7 @@ There are multiple configs that enable all rules in this category: `plugin:es/no
## ES5
-There are multiple configs that enable all rules in this category: `plugin:es/no-new-in-es5` and `plugin:es/restrict-to-es3`
+There are multiple configs that enable all rules in this category: `plugin:es/no-new-in-es5`, `plugin:es/restrict-to-es3`, and `plugin:es/restrict-to-es5`
| Rule ID | Description | |
|:--------|:------------|:--:|
diff --git a/docs/rules/no-logical-assignment-operators.md b/docs/rules/no-logical-assignment-operators.md
index 329a4290..b7bfdbcc 100644
--- a/docs/rules/no-logical-assignment-operators.md
+++ b/docs/rules/no-logical-assignment-operators.md
@@ -1,7 +1,7 @@
# es/no-logical-assignment-operators
> disallow logical assignment operators
-- ✅ The following configurations enable this rule: `plugin:es/no-new-in-esnext`
+- ✅ The following configurations enable this rule: `plugin:es/no-new-in-es2021`, `plugin:es/restrict-to-es3`, `plugin:es/restrict-to-es5`, `plugin:es/restrict-to-es2015`, `plugin:es/restrict-to-es2016`, `plugin:es/restrict-to-es2017`, `plugin:es/restrict-to-es2018`, `plugin:es/restrict-to-es2019`, and `plugin:es/restrict-to-es2020`
- 🔧 The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
This rule reports ES2021 [logical assignment operators](https://github.com/tc39/proposal-logical-assignment) as errors.
diff --git a/docs/rules/no-numeric-separators.md b/docs/rules/no-numeric-separators.md
index 0f26f227..28184981 100644
--- a/docs/rules/no-numeric-separators.md
+++ b/docs/rules/no-numeric-separators.md
@@ -1,7 +1,7 @@
# es/no-numeric-separators
> disallow numeric separators
-- ✅ The following configurations enable this rule: `plugin:es/no-new-in-esnext`
+- ✅ The following configurations enable this rule: `plugin:es/no-new-in-es2021`, `plugin:es/restrict-to-es3`, `plugin:es/restrict-to-es5`, `plugin:es/restrict-to-es2015`, `plugin:es/restrict-to-es2016`, `plugin:es/restrict-to-es2017`, `plugin:es/restrict-to-es2018`, `plugin:es/restrict-to-es2019`, and `plugin:es/restrict-to-es2020`
- 🔧 The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
This rule reports ES2021 [numeric separators](https://github.com/tc39/proposal-numeric-separator) as errors.
diff --git a/docs/rules/no-promise-any.md b/docs/rules/no-promise-any.md
index 4c31b540..5dbe2dfb 100644
--- a/docs/rules/no-promise-any.md
+++ b/docs/rules/no-promise-any.md
@@ -1,7 +1,7 @@
# es/no-promise-any
> disallow `Promise.any` function and `AggregateError` class
-- ✅ The following configurations enable this rule: `plugin:es/no-new-in-esnext`
+- ✅ The following configurations enable this rule: `plugin:es/no-new-in-es2021`, `plugin:es/restrict-to-es3`, `plugin:es/restrict-to-es5`, `plugin:es/restrict-to-es2015`, `plugin:es/restrict-to-es2016`, `plugin:es/restrict-to-es2017`, `plugin:es/restrict-to-es2018`, `plugin:es/restrict-to-es2019`, and `plugin:es/restrict-to-es2020`
This rule reports ES2021 [`Promise.any`](https://github.com/tc39/proposal-promise-any) as errors.
This proposal includes the following two:
diff --git a/docs/rules/no-string-prototype-replaceall.md b/docs/rules/no-string-prototype-replaceall.md
index 3ad31597..3aa2ce8a 100644
--- a/docs/rules/no-string-prototype-replaceall.md
+++ b/docs/rules/no-string-prototype-replaceall.md
@@ -1,7 +1,7 @@
# es/no-string-prototype-replaceall
> disallow the `String.prototype.replaceAll` method
-- ✅ The following configurations enable this rule: `plugin:es/no-new-in-esnext`
+- ✅ The following configurations enable this rule: `plugin:es/no-new-in-es2021`, `plugin:es/restrict-to-es3`, `plugin:es/restrict-to-es5`, `plugin:es/restrict-to-es2015`, `plugin:es/restrict-to-es2016`, `plugin:es/restrict-to-es2017`, `plugin:es/restrict-to-es2018`, `plugin:es/restrict-to-es2019`, and `plugin:es/restrict-to-es2020`
This rule reports ES2021 [`String.prototype.replaceAll` method](https://github.com/tc39/proposal-string-replaceall) as errors.
diff --git a/docs/rules/no-weakrefs.md b/docs/rules/no-weakrefs.md
index 4f489c0c..d1ab340a 100644
--- a/docs/rules/no-weakrefs.md
+++ b/docs/rules/no-weakrefs.md
@@ -1,7 +1,7 @@
# es/no-weakrefs
> disallow the `WeakRef` and `FinalizationRegistry` class
-- ✅ The following configurations enable this rule: `plugin:es/no-new-in-esnext`
+- ✅ The following configurations enable this rule: `plugin:es/no-new-in-es2021`, `plugin:es/restrict-to-es3`, `plugin:es/restrict-to-es5`, `plugin:es/restrict-to-es2015`, `plugin:es/restrict-to-es2016`, `plugin:es/restrict-to-es2017`, `plugin:es/restrict-to-es2018`, `plugin:es/restrict-to-es2019`, and `plugin:es/restrict-to-es2020`
This rule reports ES2021 [WeakRefs](https://github.com/tc39/proposal-weakrefs) as errors.
This proposal includes the following two:
diff --git a/lib/configs/no-new-in-es2021.js b/lib/configs/no-new-in-es2021.js
new file mode 100644
index 00000000..72940222
--- /dev/null
+++ b/lib/configs/no-new-in-es2021.js
@@ -0,0 +1,16 @@
+/**
+ * DON'T EDIT THIS FILE.
+ * This file was generated by "scripts/update-lib-configs.js" script.
+ */
+"use strict"
+
+module.exports = {
+ plugins: ["es"],
+ rules: {
+ "es/no-logical-assignment-operators": "error",
+ "es/no-numeric-separators": "error",
+ "es/no-promise-any": "error",
+ "es/no-string-prototype-replaceall": "error",
+ "es/no-weakrefs": "error",
+ },
+}
diff --git a/lib/configs/no-new-in-esnext.js b/lib/configs/no-new-in-esnext.js
index 72940222..5e9c6283 100644
--- a/lib/configs/no-new-in-esnext.js
+++ b/lib/configs/no-new-in-esnext.js
@@ -4,13 +4,4 @@
*/
"use strict"
-module.exports = {
- plugins: ["es"],
- rules: {
- "es/no-logical-assignment-operators": "error",
- "es/no-numeric-separators": "error",
- "es/no-promise-any": "error",
- "es/no-string-prototype-replaceall": "error",
- "es/no-weakrefs": "error",
- },
-}
+module.exports = { plugins: ["es"], rules: {} }
diff --git a/lib/configs/restrict-to-es2015.js b/lib/configs/restrict-to-es2015.js
index 12b19705..52adb10c 100644
--- a/lib/configs/restrict-to-es2015.js
+++ b/lib/configs/restrict-to-es2015.js
@@ -6,6 +6,7 @@
module.exports = {
extends: [
+ require.resolve("./no-new-in-es2021"),
require.resolve("./no-new-in-es2020"),
require.resolve("./no-new-in-es2019"),
require.resolve("./no-new-in-es2018"),
diff --git a/lib/configs/restrict-to-es2016.js b/lib/configs/restrict-to-es2016.js
index aa828bdd..129bb594 100644
--- a/lib/configs/restrict-to-es2016.js
+++ b/lib/configs/restrict-to-es2016.js
@@ -6,6 +6,7 @@
module.exports = {
extends: [
+ require.resolve("./no-new-in-es2021"),
require.resolve("./no-new-in-es2020"),
require.resolve("./no-new-in-es2019"),
require.resolve("./no-new-in-es2018"),
diff --git a/lib/configs/restrict-to-es2017.js b/lib/configs/restrict-to-es2017.js
index 3e29f99e..6cdeb394 100644
--- a/lib/configs/restrict-to-es2017.js
+++ b/lib/configs/restrict-to-es2017.js
@@ -6,6 +6,7 @@
module.exports = {
extends: [
+ require.resolve("./no-new-in-es2021"),
require.resolve("./no-new-in-es2020"),
require.resolve("./no-new-in-es2019"),
require.resolve("./no-new-in-es2018"),
diff --git a/lib/configs/restrict-to-es2018.js b/lib/configs/restrict-to-es2018.js
index f51fc05b..17723748 100644
--- a/lib/configs/restrict-to-es2018.js
+++ b/lib/configs/restrict-to-es2018.js
@@ -6,6 +6,7 @@
module.exports = {
extends: [
+ require.resolve("./no-new-in-es2021"),
require.resolve("./no-new-in-es2020"),
require.resolve("./no-new-in-es2019"),
],
diff --git a/lib/configs/restrict-to-es2019.js b/lib/configs/restrict-to-es2019.js
index 06fa15a3..f7c906d2 100644
--- a/lib/configs/restrict-to-es2019.js
+++ b/lib/configs/restrict-to-es2019.js
@@ -4,4 +4,9 @@
*/
"use strict"
-module.exports = { extends: [require.resolve("./no-new-in-es2020")] }
+module.exports = {
+ extends: [
+ require.resolve("./no-new-in-es2021"),
+ require.resolve("./no-new-in-es2020"),
+ ],
+}
diff --git a/lib/configs/restrict-to-es2020.js b/lib/configs/restrict-to-es2020.js
new file mode 100644
index 00000000..cbbdf726
--- /dev/null
+++ b/lib/configs/restrict-to-es2020.js
@@ -0,0 +1,7 @@
+/**
+ * DON'T EDIT THIS FILE.
+ * This file was generated by "scripts/update-lib-configs.js" script.
+ */
+"use strict"
+
+module.exports = { extends: [require.resolve("./no-new-in-es2021")] }
diff --git a/lib/configs/restrict-to-es3.js b/lib/configs/restrict-to-es3.js
index 30d836c0..9bc81bb2 100644
--- a/lib/configs/restrict-to-es3.js
+++ b/lib/configs/restrict-to-es3.js
@@ -6,6 +6,7 @@
module.exports = {
extends: [
+ require.resolve("./no-new-in-es2021"),
require.resolve("./no-new-in-es2020"),
require.resolve("./no-new-in-es2019"),
require.resolve("./no-new-in-es2018"),
diff --git a/lib/configs/restrict-to-es5.js b/lib/configs/restrict-to-es5.js
index 59f372ff..bc312226 100644
--- a/lib/configs/restrict-to-es5.js
+++ b/lib/configs/restrict-to-es5.js
@@ -6,6 +6,7 @@
module.exports = {
extends: [
+ require.resolve("./no-new-in-es2021"),
require.resolve("./no-new-in-es2020"),
require.resolve("./no-new-in-es2019"),
require.resolve("./no-new-in-es2018"),
diff --git a/lib/index.js b/lib/index.js
index 5091fc9e..4c7e65e9 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -15,6 +15,7 @@ module.exports = {
"no-new-in-es2018": require("./configs/no-new-in-es2018"),
"no-new-in-es2019": require("./configs/no-new-in-es2019"),
"no-new-in-es2020": require("./configs/no-new-in-es2020"),
+ "no-new-in-es2021": require("./configs/no-new-in-es2021"),
"no-new-in-esnext": require("./configs/no-new-in-esnext"),
"restrict-to-es3": require("./configs/restrict-to-es3"),
"restrict-to-es5": require("./configs/restrict-to-es5"),
@@ -23,6 +24,7 @@ module.exports = {
"restrict-to-es2017": require("./configs/restrict-to-es2017"),
"restrict-to-es2018": require("./configs/restrict-to-es2018"),
"restrict-to-es2019": require("./configs/restrict-to-es2019"),
+ "restrict-to-es2020": require("./configs/restrict-to-es2020"),
get "no-5"() {
printWarningOfDeprecatedConfig("no-5")
return this["no-new-in-es5"]
diff --git a/scripts/rules.js b/scripts/rules.js
index f0da2f11..90518ea9 100644
--- a/scripts/rules.js
+++ b/scripts/rules.js
@@ -26,7 +26,7 @@ const libRoot = path.resolve(__dirname, "../lib/rules")
*/
/** @type {Record} */
-const categories = [12, 11, 10, 9, 8, 7, 6, 5].reduce(
+const categories = [13, 12, 11, 10, 9, 8, 7, 6, 5].reduce(
(map, revision, _, [latest]) => {
const year = revision <= 5 ? 5 : 2009 + revision
const id = `ES${year}`
diff --git a/scripts/update-docs-readme.js b/scripts/update-docs-readme.js
index cade9347..fe5f7202 100644
--- a/scripts/update-docs-readme.js
+++ b/scripts/update-docs-readme.js
@@ -14,20 +14,26 @@ const configRoot = path.resolve(__dirname, "../lib/configs/")
const configs = fs.readdirSync(configRoot).map(filename => {
const id = `plugin:es/${path.basename(filename, ".js")}`
const configFile = path.join(configRoot, filename)
+ const categoryId = extractCategoryId(configFile)
const categoryIds = [
- extractCategoryId(configFile),
+ categoryId,
...(require(configFile).extends || []).map(extractCategoryId),
].filter(Boolean)
- return { id, categoryIds }
+ return {
+ id,
+ categoryIds,
+ kind: filename.startsWith("no-new-in-") ? "not-new-in" : "restrict-to",
+ es: categoryId.slice(2),
+ }
})
-// Convert categories to README sections
+// Convert categories to rules/README sections
const ruleSectionContent = Object.keys(categories)
.map(toSection)
.join("\n")
-// Write README.md
+// Write rules/README.md
fs.writeFileSync(
"docs/rules/README.md",
`# Available Rules
@@ -40,11 +46,32 @@ ${ruleSectionContent}
`,
)
+// Convert categories to README presets table
+const presetsTableContent = `| Config ID | Description |
+|:----------|:------------|
+${configs
+ .sort(compareConfigId)
+ .map(toPresetConfigTableRow)
+ .join("\n")}`
+
+// Write README.md
+fs.writeFileSync(
+ "docs/README.md",
+ fs.readFileSync("docs/README.md", "utf-8").replace(
+ /[\s\S]*?/u,
+ `
+
+${presetsTableContent}
+
+`,
+ ),
+)
+
//------------------------------------------------------------------------------
function extractCategoryId(filePath) {
const basename = path.basename(filePath, ".js")
- const match = /no-new-in-(es\d+)/u.exec(basename)
+ const match = /(?:no-new-in-|restrict-to-)(es(?:\d+|next))/u.exec(basename)
return match ? match[1].toUpperCase() : undefined
}
@@ -76,6 +103,9 @@ ${toTable(categories[categoryId])}
* @param {import("./rules").Category} category The category information to convert.
*/
function toTable({ rules }) {
+ if (rules.length === 0) {
+ return "⚠️ No rules yet. It will be added in the future."
+ }
return `| Rule ID | Description | |
|:--------|:------------|:--:|
${rules.map(toTableRow).join("\n")}`
@@ -110,3 +140,40 @@ function formatList(xs) {
}
}
}
+
+function compareConfigId(a, b) {
+ if (a.kind !== b.kind) {
+ if (a.kind === "restrict-to") {
+ return -1
+ }
+ return 1
+ }
+ if (a.es === b.es) {
+ return 0
+ }
+ if (a.es === "NEXT") {
+ return 1
+ }
+ if (b.es === "NEXT") {
+ return -1
+ }
+ return Number(b.es) - Number(a.es)
+}
+
+/**
+ * Create markdown table row for a config.
+ * @param {string} config The config to convert.
+ */
+function toPresetConfigTableRow(config) {
+ let description = undefined
+ if (config.kind === "restrict-to") {
+ description = `disallow new stuff that ES${config.es} doesn't include.`
+ } else if (config.es === "NEXT") {
+ description =
+ "disallow the new stuff to be planned for the next yearly ECMAScript snapshot.
⚠️ This config will be changed in the minor versions of this plugin."
+ } else {
+ description = `disallow the new stuff in ES${config.es}.`
+ }
+
+ return `| \`${config.id}\` | ${description} |`
+}