jsx-only.js 605 B

12345678910111213141516171819202122
  1. const testFile = require('../../helpers/testFile');
  2. const runTest = require('../../helpers/runTest');
  3. const cases = {
  4. valid: [
  5. {
  6. code: '<DIV foo="bar" />',
  7. options: [{ mode: 'jsx-only', 'jsx-attributes': { exclude: ['foo'] } }],
  8. },
  9. {
  10. code: `<div>{[].map((a) => { switch (a) { case 'abc': return null; default: return null; } })}</div>`,
  11. options: [{ mode: 'jsx-only' }],
  12. },
  13. ],
  14. invalid: [
  15. {
  16. ...testFile('invalid-jsx-only.jsx'),
  17. options: [{ mode: 'jsx-only' }],
  18. errors: 5,
  19. },
  20. ],
  21. };
  22. runTest('no-literal-string: mode jsx-only', cases);