From e582cb61d0f51c15a8e5d9e38c82d1c73f2d6edd Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Thu, 16 Jan 2020 18:56:03 -0800 Subject: [PATCH 1/2] Fix: update `require-meta-schema` rule to allow object schemas (in addition to array schemas) (#90) Turns out that eslint supports both array and object schemas. eslint itself has a handful of rules that use objects schemas, although array schemas are much more common. https://eslint.org/docs/developer-guide/working-with-rules#options-schemas --- lib/rules/require-meta-schema.js | 4 ++-- tests/lib/rules/require-meta-schema.js | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/rules/require-meta-schema.js b/lib/rules/require-meta-schema.js index a4d5def9..01510520 100644 --- a/lib/rules/require-meta-schema.js +++ b/lib/rules/require-meta-schema.js @@ -28,7 +28,7 @@ module.exports = { ], messages: { missing: '`meta.schema` is required (use [] if rule has no schema).', - wrongType: '`meta.schema` should be an array (use [] if rule has no schema).', + wrongType: '`meta.schema` should be an array or object (use [] if rule has no schema).', }, }, @@ -56,7 +56,7 @@ module.exports = { return utils.insertProperty(fixer, metaNode, 'schema: []', sourceCode); }, }); - } else if (schemaNode.value.type !== 'ArrayExpression') { + } else if (!['ArrayExpression', 'ObjectExpression'].includes(schemaNode.value.type)) { context.report({ node: schemaNode.value, messageId: 'wrongType' }); } }, diff --git a/tests/lib/rules/require-meta-schema.js b/tests/lib/rules/require-meta-schema.js index 21acd912..db79efba 100644 --- a/tests/lib/rules/require-meta-schema.js +++ b/tests/lib/rules/require-meta-schema.js @@ -26,6 +26,12 @@ ruleTester.run('require-meta-schema', rule, { create(context) {} }; `, + ` + module.exports = { + meta: { schema: { "enum": ["always", "never"] } }, + create(context) {} + }; + `, ], invalid: [ From 66aeb8731285fcc86809790ec7035d97ee75ef7b Mon Sep 17 00:00:00 2001 From: Teddy Katz Date: Thu, 16 Jan 2020 21:56:33 -0500 Subject: [PATCH 2/2] Build: update package.json and changelog for v2.2.1 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae054c59..5e03ddaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v2.2.1 (2020-01-17) + +* Fix: update `require-meta-schema` rule to allow object schemas (in addition to array schemas) ([#90](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/issues/90)) ([e582cb6](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/commit/e582cb61d0f51c15a8e5d9e38c82d1c73f2d6edd)) + ## v2.2.0 (2020-01-08) * Update: Add new rule `require-meta-docs-description` ([#89](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/issues/89)) ([b175b46](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/commit/b175b46732033c99e26e5380d83ea94727c15218)) diff --git a/package.json b/package.json index e568b632..38ba0c15 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-eslint-plugin", - "version": "2.2.0", + "version": "2.2.1", "description": "An ESLint plugin for linting ESLint plugins", "author": "Teddy Katz", "main": "lib/index.js",