0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/tools/node_modules/eslint-plugin-node-core/index.js
Gus Caplan 6934792eb3 lint: move eslint to new plugin system
PR-URL: https://github.com/nodejs/node/pull/18566
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2018-02-20 13:13:22 -06:00

25 lines
516 B
JavaScript

'use strict';
const fs = require('fs');
const path = require('path');
let cache;
module.exports = {
get rules() {
const RULES_DIR = module.exports.RULES_DIR;
if (!RULES_DIR)
return {};
if (!cache) {
cache = {};
const files = fs.readdirSync(RULES_DIR)
.filter(filename => filename.endsWith('.js'))
for (const file of files) {
const name = file.slice(0, -3);
cache[name] = require(path.resolve(RULES_DIR, file));
}
}
return cache;
},
};