Repository: not-an-aardvark/eslint-plugin-eslint-plugin (js)

Issue:
Cannot read property 'type' of undefined
I have an "extension rule" which spreads the base rule to modify the error message.

## Rule source

```js
'use strict';

const baseRule = require('eslint/lib/rules/no-console');

module.exports = {
  ...baseRule,
  meta: {
    ...baseRule.meta,
    messages: {
      unexpected: `My extended error message`,
    },
  },
};
```

## Expected

Linter runs fine

## Actual

```
TypeError: Error while loading rule 'eslint-plugin/require-meta-fixable': Cannot read property 'type' of undefined
      Occurred while linting <my rule>.js
          at Object.getKeyName (<snip>/node_modules/eslint-plugin-eslint-plugin/lib/utils.js:187:44)
          at node.right.properties.reduce (<snip>/node_modules/eslint-plugin-eslint-plugin/lib/utils.js:114:47)
          at Array.reduce (<anonymous>)
          at ast.body.filter.map.filter.filter.reduce (<snip>/node_modules/eslint-plugin-eslint-plugin/lib/utils.js:113:42)
          at Array.reduce (<anonymous>)
          at Object.getRuleInfo (<snip>/eslint-plugin-eslint-plugin/lib/utils.js:97:8)
```

The problem is here; the function assumes the property is a `Property`, but in this case it is a `SpreadElement`.

https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/68059b1ed2cb2710a4d6c4aa1d05afad8de565f0/lib/utils.js#L187

Pull request:
Fix: handle spreads in rule meta objects
Fixes #99 

Patch:
diff --git a/lib/utils.js b/lib/utils.js
index 0fd86bd..40d38b8 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -184,6 +184,10 @@ module.exports = {
   * @returns {string|null} The key name, or `null` if the name cannot be determined statically.
   */
   getKeyName (property) {
+    if (!property.key) {
+      // likely a SpreadElement or another non-standard node
+      return null;
+    }
     if (!property.computed && property.key.type === 'Identifier') {
       return property.key.name;
     }


Test patch:
diff --git a/tests/lib/rules/require-meta-fixable.js b/tests/lib/rules/require-meta-fixable.js
index 5916515..875e701 100644
--- a/tests/lib/rules/require-meta-fixable.js
+++ b/tests/lib/rules/require-meta-fixable.js
@@ -105,6 +105,19 @@ ruleTester.run('require-meta-fixable', rule, {
         create(context) { context.report(node, message, data, fix); }
       };
     `,
+    {
+      code: `
+        const meta = {};
+        module.exports = {
+          ...meta,
+          meta: {},
+          create(context) { context.report(node, message, data, fix); }
+        };
+      `,
+      parserOptions: {
+        ecmaVersion: 9,
+      },
+    },
   ],
 
   invalid: [
diff --git a/tests/lib/utils.js b/tests/lib/utils.js
index fbe78bf..c92d9f8 100644
--- a/tests/lib/utils.js
+++ b/tests/lib/utils.js
@@ -183,6 +183,17 @@ describe('utils', () => {
         assert.strictEqual(utils.getKeyName(ast.body[0].expression.properties[0]), CASES[objectSource]);
       });
     });
+
+    const CASES_ES9 = {
+      '({ ...foo })': null,
+    };
+    Object.keys(CASES_ES9).forEach(objectSource => {
+      it(objectSource, () => {
+        const ast = espree.parse(objectSource, { ecmaVersion: 9 });
+
+        assert.strictEqual(utils.getKeyName(ast.body[0].expression.properties[0]), CASES_ES9[objectSource]);
+      });
+    });
   });
 
   describe('getTestInfo', () => {