test.js 939 B

12345678910111213141516171819202122232425262728293031323334
  1. const testBoilerplate = (name, author, description) => `/* eslint-env jest */
  2. /**
  3. * @fileoverview ${description}
  4. * @author ${author}
  5. */
  6. // -----------------------------------------------------------------------------
  7. // Requirements
  8. // -----------------------------------------------------------------------------
  9. import { RuleTester } from 'eslint';
  10. import parserOptionsMapper from '../../__util__/parserOptionsMapper';
  11. import rule from '../../../src/rules/${name}';
  12. // -----------------------------------------------------------------------------
  13. // Tests
  14. // -----------------------------------------------------------------------------
  15. const ruleTester = new RuleTester();
  16. const expectedError = {
  17. message: '',
  18. type: 'JSXOpeningElement',
  19. };
  20. ruleTester.run('${name}', rule, {
  21. valid: [
  22. { code: '<div />;' },
  23. ].map(parserOptionsMapper),
  24. invalid: [].map(parserOptionsMapper),
  25. });
  26. `;
  27. module.exports = testBoilerplate;