question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mocha arrow-function and unnamed function errors.

See original GitHub issue

Hello community I am receiving errors whenever I am using using describe(function(){}) in my code. How can I get rid of these errors? Here is my .eslintrc.yml.

extends: airbnb-base
plugins:
  - standard
  - promise
env:
    node: true
    mocha: true
rules:
    indent: ["error", 2]
    semi: ["error", "always", {omitLastInOneLineBlock: true}]
    no-eval: ["error"]
    no-trailing-spaces: ["error"]
    one-var-declaration-per-line: ["error", "initializations"]
    no-irregular-whitespace: ["error"]
    no-var: ["error"]
    no-empty: ["error"]
    linebreak-style: ["error", "unix"]
    eol-last: ["error", "always"]
    no-console: ["warn", {"allow": ["warn", "error", "info"]}]
    no-use-before-define: ["error", { "functions": false }]
    no-unused-vars: ["error", {"argsIgnorePattern":"^next"}]

Tried to add mocha-plugin like so:

plugins:
- mocha
rules:
mocha/no-arrow-function: "error"

but it still gives me errors.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12

github_iconTop GitHub Comments

4reactions
atif089commented, Jan 30, 2019

For anyone stumbling here in 2019, I followed ljharb’s advice and added the following .eslintrc config in my test directory

{
  "rules": {
    "prefer-arrow-callback": "off",
    "func-names": "off"
  }
}
1reaction
FieryCodcommented, Apr 21, 2017

As i said even if I name a function I am still receiving error with prefer-arrow-callback

Read more comments on GitHub >

github_iconTop Results From Across the Web

What does `this` point at in the following js arrow functions in ...
log are arrow functions and as I've said above, if you use an arrow function then you cannot access the object that Mocha...
Read more >
Two situations where to avoid Arrow Functions
Passing arrow functions (aka “lambdas”) to Mocha is discouraged. Lambdas lexically bind this and cannot access the Mocha context. Let's give it ...
Read more >
Tests, closures and arrow functions - Gleb Bahmutov
Imagine a Mocha test file like this spec.js12345describe('my tests', ... What happens when you use arrow function as a test callback?
Read more >
Mocha - the fun, simple, flexible JavaScript test framework
Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun. Mocha tests run ......
Read more >
Synchronous code, arrow functions and hooks - mocha
You can invoke any hook with an optional description, this makes it easier to pinpoint errors in your tests. If you give a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found