index-test.js 1.1 KB

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