mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
94c8178442
With ESLint flat config, we don't need a hack with `node_modules` anymore to load ESLint plugins. This commit moves the node-core plugin out of `tools/node_modules` and creates a new `tools/eslint` directory to store ESLint tools. PR-URL: https://github.com/nodejs/node/pull/53393 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
25 lines
519 B
JavaScript
25 lines
519 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;
|
|
},
|
|
};
|