Comments (7)
#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.
@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.
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.
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.
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.
I don't see how this discussion is relevant to this issue. Use Gitter or open a new issue ;)
from eslint-plugin-ava.
Aww - sorry for that: #164
from eslint-plugin-ava.
Related Issues (20)
- no-ignored-test-files caches results too aggressively. HOT 1
- Edge-case crashes & false-positives in no-statement-after-end with unreachable statements
- no-identical-title crashes if title is missing HOT 4
- `use-test`: Allow import statements without default specifier HOT 1
- Ensure AVA is specified as a dev dependency HOT 1
- `no-identical-title` crash HOT 2
- Support test.macro()
- No checks with typed context HOT 2
- Allow concatenation when ensuring assertion message is a string HOT 1
- Fix integration tests
- Support ESLint 8.x HOT 1
- Prefer `t.true(x)` over `t.is(x, true)` HOT 1
- Enable `eslint-plugin/prefer-placeholders` rule
- cannot destructure property 'type' or 'node' as it is undefined HOT 2
- Some rules do not fail gracefully: ava/prefer-t-regex HOT 1
- `prefer-t-regex` fails with `t.is()` with a single argument
- `ava/use-test` allow inline type imports
- `no-import-test-files` is slow
- `ava/use-test` does not allow `anyTest` in `.cts` and `.mts` files
- TypeError: Cannot destructure property 'type' of 'node' as it is undefined.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eslint-plugin-ava.