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.

`prefer-arrow-callback` with `mocha/no-mocha-arrows`

See original GitHub issue

Tell us about your environment I am running tests in mocha that i want to eslint out!

  • ESLint Version: ^4.6.1
  • Node Version: v8.1.3
  • npm Version: 5.4.1

What parser (default, Babel-ESLint, etc.) are you using? default

Please show your full configuration:

Configuration
module.exports = {
  extends: [
    'airbnb',
    'prettier',
  ],
  plugins: [
    'prettier',
    'mocha',
  ],
  globals: {
    chai: true,
    logger: true,
  },
  env: {
    node: true,
    mocha: true,
    browser: false,
  },
  rules: {
    'no-console': 'error',
    'prefer-arrow-callback': 2,
    'mocha/no-mocha-arrows': 'error',
    'prettier/prettier': ['error', {
      singleQuote: true,
      bracketSpacing: false,
      trailingComma: 'all',
    }],
  },
}

What did you do? Please include the actual source code causing the issue.

describe("my suite", function() {
});

What did you expect to happen? The above line should not error out the linter. Since i am using mocha, and mocha prefers anonymous function, not an arrow function.

Currently it errors out because of this rule:

rules: {
    'prefer-arrow-callback': 2,
  ...

I am expecting the arrow functions to be preferred everywhere except inside a case function or a suite function.

The prefer arrow-callback errors out, but it shouldn’t, probably it needs a special configuration.

What actually happened? Please include the actual, raw output from ESLint.

$ x:xx  error    Unexpected function expression     prefer-arrow-callback

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
paulmelnikowcommented, Sep 24, 2017

Opened lo1tuma/eslint-plugin-mocha#141.

0reactions
Bamiehcommented, Sep 23, 2017

@paulmelnikow no i did not

Read more comments on GitHub >

github_iconTop Results From Across the Web

`prefer-arrow-callback` with `mocha/no-mocha-arrows`
Since i am using mocha, and mocha prefers anonymous function, not an arrow function. Currently it errors out because of this rule: rules:...
Read more >
What does `this` point at in the following js arrow functions in ...
One thing this object allows you to do, for instance, is change Mocha's configuration. Like changing the timeout of asynchronous function with ...
Read more >
eslint-plugin-mocha - UNPKG
The CDN for eslint-plugin-mocha. ... 22, * Improve no-mocha-arrows performance ... 48, * Fix prefer-arrow-callback to not fail when using import.meta ...
Read more >
arrow-mocha - npm Package Health Analysis | Snyk
Security Policy: No. We found a way for you to contribute to the project! Looks like arrow-mocha is missing a security policy.
Read more >
https://raw.githubusercontent.com/button/eslint-co...
2.0.1 February 24, 2017 - Fix plugins * 2.0.0 February 15, 2017 - Add eslint-plugin-mocha and mocha/no-mocha-arrows rule - Disable prefer-arrow-callback ...
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