Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-setup-in-describe function expression false positives #274

Closed
rhansen opened this issue Nov 14, 2020 · 1 comment · Fixed by #293
Closed

no-setup-in-describe function expression false positives #274

rhansen opened this issue Nov 14, 2020 · 1 comment · Fixed by #293

Comments

@rhansen
Copy link

rhansen commented Nov 14, 2020

no-setup-in-describe thinks that the bodies of function expressions are executed as part of the describe block:

describe('description', function () {
  const x = {};

  const foo = function () {
    // mocha/no-setup-in-describe: Unexpected member expression in describe block. Member
    // expressions may call functions via getters
    x.a = 'foo';
  };

  function bar() {
    x.a = 'bar'; // OK
  }

  const baz = () => {
    x.a = 'baz'; // OK
  };

  it('example', async function () {
    foo();
    bar();
    baz();
  });
});

Versions:

  • eslint-plugin-mocha 8.0.0
  • eslint 7.13.0
  • mocha 8.2.1
  • node 14.14.0
rhansen added a commit to ether/ep_comments_page that referenced this issue Nov 17, 2020
rhansen added a commit to ether/ep_comments_page that referenced this issue Nov 17, 2020
rhansen added a commit to ether/ep_comments_page that referenced this issue Nov 19, 2020
JohnMcLear pushed a commit to ether/ep_comments_page that referenced this issue Nov 19, 2020
* Configure ESLint

* Run `eslint --fix .`

* Fix comments

`eslint --fix .` added a space after the second asterisk because it
interprets `/***/` as a JSDoc comment.

* Combine two string literals into one

For some reason `eslint --fix .` didn't do this. I don't know why.

* Delete unnecessary `else`

* Fix comment indentation

* Switch single and double quotes in HTML string

* Use `this` instead of `self` where possible

* Enable strict mode everywhere

* Delete unused imports

* Delete most unused variables

There are still some variables that can't be removed without
technically changing behavior. Those will be fixed in a future commit.

* Delete redundant variable redeclarations

* Delete commented-out code

* Delete dead code

Regarding the conditions: One of them is always false and the other is
always true.

* Use `const` and `let` instead of `var`

* Rename `ep_comments` class to `EpComments`

* Simplify handling of "Show Comments" toggle

This also eliminates a bunch of ESLint errors.

* Use camel case for variable names

* Remove redundant ESLint global declarations

* Reduce global namespace pollution

This silences some ESLint errors.

* Use jQuery to build HTML

This also silences an ESLint error.

* Fix various minor ESLint errors:

  * Convert to arrow functions.
  * Use strict equality except for null checks.
  * Irregular whitespace fix.
  * Keep lines under 100 columns long.
  * Use camel case for variable names.
  * Put `else if` on same line as preceding `}`.

* Don't iterate over inherited properties

This fixes ESLint errors.

* Simplify comment counting

This also eliminates ESLint unused variable errors (the loop
variables).

* Rewrite `getSelectedText` for readability, robustness

* Delete redundant jQuery imports

jQuery is already available as a global var.

* Avoid mutating passed-in list

This also fixes an ESLint error.

* Capitalize PreCommentMarker class name

* Add missing variable declaration

* tests: Fix exception error message (copy+paste bug)

This also fixes an ESLint error.

* tests: Delete unnecessary wrapper objects

* tests: Switch some function expressions to arrow functions

This is a workaround for
lo1tuma/eslint-plugin-mocha#274
@mikeshawdev
Copy link

We've been seeing this on some of our projects as well. Any updates on a potential fix at all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants