Repository: lo1tuma/eslint-plugin-mocha (ts)

Issue:
Error with import.meta.url
Eslint is throwing the following error on `import.meta.url` when the eslint-plugin-mocha plugin is loaded:

```
$ $(npm bin)/eslint minimal.js

Oops! Something went wrong! :(

ESLint: 7.6.0

TypeError: Cannot set property 'meta' of undefined
Occurred while linting /project/minimal.js:2
    at MetaProperty (/project/node_modules/eslint-plugin-mocha/lib/rules/prefer-arrow-callback.js:234:27)
    at /project/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/project/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/project/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/project/node_modules/eslint/lib/linter/node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (/project/node_modules/eslint/lib/linter/node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (/project/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:673:23)
    at (/project/node_modules/eslint/lib/linter/linter.js:949:32
    at Array.forEach (<anonymous>)
```

I am using nodejs v14.7.0 on MacOS, eslint 7.6 and eslint-plugin-mocha 8.0, I have `"type": "module"` specified in my package.json

This is my .eslintrc.cjs, removing `plugins: ['mocha']` and `'plugin:mocha/recommended'` from `extends` causes eslint to parse the file correctly.

```javascript
module.exports = {
	env: {
		es2020: true,
		node: true,
	},
	parserOptions: {
		ecmaVersion: 2020,
	},
	plugins: ['mocha'],
	extends: ['airbnb-base', 'plugin:mocha/recommended'],
	rules: {
		'mocha/prefer-arrow-callback': ['error'],
		'mocha/no-setup-in-describe': 'off',
		'import/extensions': ['error', 'always'],
		'implicit-arrow-linebreak': 'off',
		'arrow-parens': ['error', 'as-needed'],
		'no-confusing-arrow': 'off',
		'no-tabs': 'off',
		indent: ['error', 'tab'],
	},
	overrides: [
		{
			files: ['*.test.js'],
			rules: {
				'func-names': 'off',
				'prefer-arrow-callback': 'off',
				'no-unused-expressions': 'off',
			},
		},
	],
};
```

Minimal javascript file to reproduce the error:

```javascript
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const pkg = require('./package.json');
console.log(pkg.name);
```

Pull request description:
Fix prefer-arrow-callback to not fail when using import.meta
Fixes #265 

Patch:
diff --git a/lib/rules/prefer-arrow-callback.js b/lib/rules/prefer-arrow-callback.js
index 2493018..81ed8f1 100644
--- a/lib/rules/prefer-arrow-callback.js
+++ b/lib/rules/prefer-arrow-callback.js
@@ -27,6 +27,17 @@ function isFunctionName(variable) {
     return variable && variable.defs[0].type === 'FunctionName';
 }
 
+/**
+ * Checks whether or not a given MetaProperty node equals to a given value.
+ * @param {ASTNode} node - A MetaProperty node to check.
+ * @param {string} metaName - The name of `MetaProperty.meta`.
+ * @param {string} propertyName - The name of `MetaProperty.property`.
+ * @returns {boolean} `true` if the node is the specific value.
+ */
+function checkMetaProperty(node, metaName, propertyName) {
+    return node.meta.name === metaName && node.property.name === propertyName;
+}
+
 /**
  * Gets the variable object of `arguments` which is defined implicitly.
  * @param {eslint-scope.Scope} scope - A scope to get.
@@ -228,10 +239,12 @@ module.exports = {
                 }
             },
 
-            MetaProperty() {
+            MetaProperty(node) {
                 const info = stack[stack.length - 1];
 
-                info.meta = true;
+                if (info && checkMetaProperty(node, 'new', 'target')) {
+                    info.meta = true;
+                }
             },
 
             // To skip nested scopes.


Test patch:
diff --git a/test/rules/prefer-arrow-callback.js b/test/rules/prefer-arrow-callback.js
index f18ffba..5e615ca 100644
--- a/test/rules/prefer-arrow-callback.js
+++ b/test/rules/prefer-arrow-callback.js
@@ -43,6 +43,13 @@ ruleTester.run('prefer-arrow-callback', rules['prefer-arrow-callback'], {
         'foo(function bar() { new.target; });',
         'foo(function bar() { new.target; }.bind(this));',
         'foo(function bar() { this; }.bind(this, somethingElse));',
+        {
+            code: 'import.meta.url',
+            parserOptions: {
+                ecmaVersion: 2020,
+                sourceType: 'module'
+            }
+        },
         // mocha-specific valid test cases
         'before(function bar() {});',
         'after(function bar() {});',