detect-buffer-noassert.js 662 B

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. const RuleTester = require('eslint').RuleTester;
  3. const tester = new RuleTester();
  4. const ruleName = 'detect-buffer-noassert';
  5. const Rule = require(`../rules/${ruleName}`);
  6. const invalid = 'a.readUInt8(0, true);';
  7. tester.run(ruleName, Rule, {
  8. valid: [{ code: 'a.readUInt8(0);' }],
  9. invalid: [
  10. {
  11. code: invalid,
  12. errors: [{ message: 'Found Buffer.readUInt8 with noAssert flag set true' }]
  13. }
  14. ]
  15. });
  16. tester.run(`${ruleName} (false)`, Rule, {
  17. valid: [{ code: 'a.readUInt8(0, false);' }],
  18. invalid: [
  19. {
  20. code: invalid,
  21. errors: [{ message: 'Found Buffer.readUInt8 with noAssert flag set true' }]
  22. }
  23. ]
  24. });