租房小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.0 KiB

2 months ago
  1. import fs from 'fs';
  2. import path from 'path';
  3. import test from 'tape';
  4. import index from '..';
  5. const files = { ...{ index } }; // object spread is to test parsing
  6. fs.readdirSync(path.join(__dirname, '../rules')).forEach((name) => {
  7. // eslint-disable-next-line import/no-dynamic-require
  8. files[name] = require(`../rules/${name}`); // eslint-disable-line global-require
  9. });
  10. Object.keys(files).forEach((
  11. name, // trailing function comma is to test parsing
  12. ) => {
  13. const config = files[name];
  14. test(`${name}: does not reference react`, (t) => {
  15. t.plan(2);
  16. // scan plugins for react and fail if it is found
  17. const hasReactPlugin = Object.prototype.hasOwnProperty.call(config, 'plugins')
  18. && config.plugins.indexOf('react') !== -1;
  19. t.notOk(hasReactPlugin, 'there is no react plugin');
  20. // scan rules for react/ and fail if any exist
  21. const reactRuleIds = Object.keys(config.rules)
  22. .filter((ruleId) => ruleId.indexOf('react/') === 0);
  23. t.deepEquals(reactRuleIds, [], 'there are no react/ rules');
  24. });
  25. });