From b80f5619201447c3df92480ecf797d9fc104959f Mon Sep 17 00:00:00 2001 From: Robat Williams Date: Fri, 14 Jan 2022 17:46:00 +0000 Subject: [PATCH] use plugin for object.fromentries. Fixes #40 --- .../lib/features/es-versions.md | 2 +- .../eslint-plugin-ecmascript-compat/lib/features/es2019.js | 5 +---- .../lib/features/es2019.spec.js | 4 +--- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/eslint-plugin-ecmascript-compat/lib/features/es-versions.md b/packages/eslint-plugin-ecmascript-compat/lib/features/es-versions.md index b9d2978..991891b 100644 --- a/packages/eslint-plugin-ecmascript-compat/lib/features/es-versions.md +++ b/packages/eslint-plugin-ecmascript-compat/lib/features/es-versions.md @@ -27,7 +27,7 @@ Static detectability of recently-added features | ------------------------------------- | ---------------------------- | ------------ | | `Array.prototype.{flat, flatMap}` | 😐 no-restricted-syntax | 69 | | JSON superset | es/no-json-superset | 66 | -| `Object.fromEntries` | no-restricted-properties | 73 | +| `Object.fromEntries` | es/no-object-fromentries | 73 | | Optional `catch` binding | es/no-optional-catch-binding | 66 | | Revised `Function.prototype.toString` | ❌ | | Stable `Array.prototype.sort` | ❌ | diff --git a/packages/eslint-plugin-ecmascript-compat/lib/features/es2019.js b/packages/eslint-plugin-ecmascript-compat/lib/features/es2019.js index a4d74cf..2e3e108 100644 --- a/packages/eslint-plugin-ecmascript-compat/lib/features/es2019.js +++ b/packages/eslint-plugin-ecmascript-compat/lib/features/es2019.js @@ -24,10 +24,7 @@ module.exports = [ compatFeatures: [compatData.javascript.builtins.JSON.json_superset], }, { - ruleConfig: { - definition: coreRules.get('no-restricted-properties'), - options: [{ object: 'Object', property: 'fromEntries', message: '(ES2019)' }], - }, + ruleConfig: { definition: esPlugin.rules['no-object-fromentries'] }, compatFeatures: [compatData.javascript.builtins.Object.fromEntries], }, { diff --git a/packages/eslint-plugin-ecmascript-compat/lib/features/es2019.spec.js b/packages/eslint-plugin-ecmascript-compat/lib/features/es2019.spec.js index 51f28e5..cd5444e 100644 --- a/packages/eslint-plugin-ecmascript-compat/lib/features/es2019.spec.js +++ b/packages/eslint-plugin-ecmascript-compat/lib/features/es2019.spec.js @@ -35,9 +35,7 @@ ruleTester.run('compat', require('../rule'), { }, { code: 'Object.fromEntries();', - errors: [ - { message: "'Object.fromEntries' is restricted from being used. (ES2019)" }, - ], + errors: [{ message: "ES2019 'Object.fromEntries' method is forbidden." }], }, { code: 'try {} catch {}',