Comments (4)
@lucacasonato looks good - I suggested skipping line number because in most cases tests can be written on single line:
assert_lint_ok::<RequireYield>("function foo() {}");
assert_lint_ok::<RequireYield>("function* bar() { yield "bar"; }");
// source code, expected diagnostic code, expected column
assert_lint_err::<RequireYield>("function* bar() { return "bar"; }", "requireYield", 10);
Maybe it would make sense to have a helper that asserts there is single diagnostics returned and separate helper that returns array of diagnostics (user gives number of expected diagnostics)?
assert_lint_err_n::<RequireYield>(3, "function* bar() { return "bar"; }");
from deno_lint.
This is what I have right now:
fn ban_ts_ignore() {
let diagnostics = assert_lint_err::<BanTsIgnore>(
r#"
// @ts-ignore
function foo() {
// pass
}
function bar() {
// @ts-ignore
const a = "bar";
}
"#,
);
assert_has_diagnostic(&diagnostics, "banTsIgnore", 2, 0);
assert_has_diagnostic(&diagnostics, "banTsIgnore", 8, 2);
}
Does that seem reasonable? I don't think we should be ignoring line number because it is actually important in many cases. I agree the file name can be ignored. Also should we also check the error message? I personally think the error code is enough.
EDIT: we also need some way to check that there are no diagnostics left over after the asserts. So maybe pop off the diagnostics that we checked from the diagnostics vec and then assert at the end that the vec is empty?
from deno_lint.
One more thought: asserting valid code can probably be done by passing vector of test cases
assert_lint_ok::<RequireYield>(vec![
"function foo() {}",
"function* bar() { yield "bar"; }",
]);
from deno_lint.
Cleanly done by @lucacasonato in #72
from deno_lint.
Related Issues (20)
- Rule semiColons for Deno lint HOT 1
- refactor: `Context` needs to be split up
- The require-await rule does more harm than good HOT 1
- Hint is wrong when use `deno.readAll` HOT 2
- Lint to detect npm dependencies without versions
- `no-console` and `no-window` warn on object property names
- Support multiple line comments for ignore directive explanation
- Website: Going to lint rule `no-console` via diagnostic url displays nothing HOT 2
- Lint rule for non-bare specifier
- Lint rule for usage of `exports` or `module.exports`
- relax the `no-console` rule within the `Deno.test` calls or the whole test file HOT 2
- Tag All Rules
- Interface with no members but with `extend` is not equivalent of the supertype
- no-unused-vars suggests breaking change.
- no-extra-non-null-assertion gives incorrect recommendation
- Class marked as unused when used in a static block
- ban-types gives misleading/wrong suggestion for empty object on generic bounds
- suggestion: `ban-untagged-deprecation`
- lint for unused files, dependencies and exports
- `no-invalid-regexp` does not look inside function calls
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 deno_lint.