should-validate-template.js 829 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. const testFile = require('../../helpers/testFile');
  2. const runTest = require('../../helpers/runTest');
  3. const options = [{ mode: 'all', 'should-validate-template': true }];
  4. const cases = {
  5. valid: [
  6. {
  7. code: `import(\`hello\`);
  8. var a = \`12345\`
  9. var a = \`\`
  10. `,
  11. options,
  12. },
  13. {
  14. code: 'var a = `hello ${abc} world`',
  15. options: [
  16. {
  17. mode: 'jsx-only',
  18. 'should-validate-template': true,
  19. },
  20. ],
  21. },
  22. ],
  23. invalid: [
  24. { code: 'var a = `hello ${abc} world`', options, errors: 1 },
  25. {
  26. code: 'var a = "hello world"; <>`abcd`</>',
  27. options: [
  28. {
  29. mode: 'jsx-only',
  30. 'should-validate-template': true,
  31. },
  32. ],
  33. errors: 1,
  34. },
  35. ],
  36. };
  37. runTest('no-literal-string: should-validate-template', cases);