|
1 | | -'use strict'; |
| 1 | +import { readdirSync } from 'fs'; |
| 2 | +import { basename, join } from 'path'; |
| 3 | +import * as snapshotProcessor from './processors/snapshot-processor'; |
2 | 4 |
|
3 | | -const fs = require('fs'); |
4 | | -const path = require('path'); |
| 5 | +// copied from https://github.com/babel/babel/blob/d8da63c929f2d28c401571e2a43166678c555bc4/packages/babel-helpers/src/helpers.js#L602-L606 |
| 6 | +/* istanbul ignore next */ |
| 7 | +function interopRequireDefault(obj) { |
| 8 | + return obj && obj.__esModule ? obj : { default: obj }; |
| 9 | +} |
5 | 10 |
|
6 | | -const rules = fs |
7 | | - .readdirSync(path.join(__dirname, 'rules')) |
| 11 | +function importDefault(moduleName) { |
| 12 | + return interopRequireDefault(require(moduleName)).default; |
| 13 | +} |
| 14 | + |
| 15 | +const rules = readdirSync(join(__dirname, 'rules')) |
8 | 16 | .filter(rule => rule !== '__tests__' && rule !== 'util.js') |
9 | | - .map(rule => path.basename(rule, '.js')) |
| 17 | + .map(rule => basename(rule, '.js')) |
10 | 18 | .reduce( |
11 | | - (acc, curr) => Object.assign(acc, { [curr]: require(`./rules/${curr}`) }), |
| 19 | + (acc, curr) => |
| 20 | + Object.assign(acc, { [curr]: importDefault(`./rules/${curr}`) }), |
12 | 21 | {}, |
13 | 22 | ); |
14 | 23 | let allRules = {}; |
15 | 24 | Object.keys(rules).forEach(function(key) { |
16 | 25 | allRules[`jest/${key}`] = 'error'; |
17 | 26 | }); |
18 | 27 |
|
19 | | -const snapshotProcessor = require('./processors/snapshot-processor'); |
20 | | - |
| 28 | +// eslint-disable-next-line import/no-commonjs |
21 | 29 | module.exports = { |
22 | 30 | configs: { |
23 | 31 | all: { |
|
0 commit comments