Git Product home page Git Product logo

Comments (7)

jamestalmage avatar jamestalmage commented on June 2, 2024

#86 will help with this.

If someone is putting a non-string inline, it's usually an expression, like prefix + ' some title', which you can be confident always evaluates to a string without evaluating what prefix is.

That's not to say we couldn't also pursue the more complex evaluation, though I'm not sure you would need to bother with CodePath analysis. Just iterating every assignment for a particular scope should get you there. It's really unlikely that you will see prefix = "foo" and prefix = 3 in the same scope. If it does comes to that, I say just give up and accept that it's probably a string by the time it reaches the assertion call instead of using CodePath analysis. CodePath analysis is hard enough to use when you're looking for something really specific (like t.end). Tracking types through the code-path would be hard, and would provide really minimal improvements over other methods.

from eslint-plugin-ava.

sindresorhus avatar sindresorhus commented on June 2, 2024

@jamestalmage Good points. I agree.

In addition, one mistake I've done multiple times is the order of arguments in t.regex(). I've sometimes put the regex first and not last. Would be nice if the editor warned me about that.

from eslint-plugin-ava.

florianb avatar florianb commented on June 2, 2024

I currently face the use case where i want to test for an explicit call of one callback like this:

test.cb('test callbacks', () => {
  run({
    a: () => t.end(true),
    b: () => t.end(false)
  });
});

The linter of course fails, isn't this a intended use case of t.end?

Is this issue still active and what approach should be taken to fix it? ☕️

from eslint-plugin-ava.

jfmengels avatar jfmengels commented on June 2, 2024

t.end() does not take arguments. If with t.end(false) you meant to fail the test, I'd suggest using t.fail() or throwing something instead.

This issue is still active, nobody started working on it. If you feel like working on it, please do :)
I think that a good first step for this rule would be to ignore arguments that are too complex to identify their type (Identifiers, function calls, expressions, etc...) and only report things whose type you know for sure (functions, strings, regexes, numbers, etc.)

from eslint-plugin-ava.

florianb avatar florianb commented on June 2, 2024

Interesting, thanks @jfmengels. I didn't get t.fail() work within a test.cb():

$ xo && ava

  test.js:17:1
  ✖  17:1  Callback test was not ended. Make sure to explicitly end the test with t.end().  ava/test-ended

I guess i will take an approach to improve this rule. :)

from eslint-plugin-ava.

sindresorhus avatar sindresorhus commented on June 2, 2024

I don't see how this discussion is relevant to this issue. Use Gitter or open a new issue ;)

from eslint-plugin-ava.

florianb avatar florianb commented on June 2, 2024

Aww - sorry for that: #164

from eslint-plugin-ava.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.