Giter Club home page Giter Club logo

Comments (4)

bartlomieju avatar bartlomieju commented on May 10, 2024 1

@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.

lucacasonato avatar lucacasonato commented on May 10, 2024

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.

bartlomieju avatar bartlomieju commented on May 10, 2024

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.

bartlomieju avatar bartlomieju commented on May 10, 2024

Cleanly done by @lucacasonato in #72

from deno_lint.

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.