mozilla / eslint-plugin-no-unsanitized

Custom ESLint rule to disallows unsafe innerHTML, outerHTML, insertAdjacentHTML and alike
Mozilla Public License 2.0
228 stars 37 forks source link

No test, no code coverage for TSAsExpression case in `checkCallExpression` #180

Open mozfreddyb opened 3 years ago

mozfreddyb commented 3 years ago

nyc is reporting no code coverage for the lines https://github.com/mozilla/eslint-plugin-no-unsanitized/blob/8dae8ae6db66a3ea91b5d2d9469f8e78666ee2fb/lib/rules/method.js#L129-L130.

Would be nice if someone could think of a a piece of TypeScript code for the method.js tests, that calls a TSAsExpression.

Here are the exact steps:

  1. Clone the repo, install dependencies (I am expecting the person who wants to help to be able to do this on their own)
  2. Write two piece of TypeScript code that calls the result of a TSAsExpression. The first one should pass (along the lines of foo()) - the second one should not (along the lines of document.write(evil)).
  3. Look at the test case objects in tests/method.js, find existing tests that look similar enough and make a copy of those cases and add them to the end of the file
  4. Run the test (npm run test) and ensure that error message in your test case matches the error message that will be thrown. If not, adjust
  5. Submit a Pull Request for review :)