index-test.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* eslint global-require: 0 */
  2. import fs from 'fs';
  3. import path from 'path';
  4. import test from 'tape';
  5. import plugin from '../src';
  6. const rules = fs.readdirSync(path.resolve(__dirname, '../src/rules/'))
  7. .map((f) => path.basename(f, '.js'));
  8. test('all rule files should be exported by the plugin', (t) => {
  9. rules.forEach((ruleName) => {
  10. t.equal(
  11. plugin.rules[ruleName],
  12. require(path.join('../src/rules', ruleName)), // eslint-disable-line import/no-dynamic-require
  13. `exports ${ruleName}`,
  14. );
  15. });
  16. t.end();
  17. });
  18. test('configurations', (t) => {
  19. t.notEqual(plugin.configs.recommended, undefined, 'exports a \'recommended\' configuration');
  20. t.end();
  21. });
  22. test('schemas', (t) => {
  23. rules.forEach((ruleName) => {
  24. const rule = require(path.join('../src/rules', ruleName)); // eslint-disable-line import/no-dynamic-require
  25. const schema = rule.meta && rule.meta.schema && rule.meta.schema[0];
  26. const { type } = schema;
  27. t.equal(type, 'object', `${ruleName} exports a schema with type object`);
  28. });
  29. t.end();
  30. });