mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 13:09:21 +01:00
tools: move ESLint tools to tools/eslint
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>
This commit is contained in:
parent
3a7d8c8e9f
commit
94c8178442
1
Makefile
1
Makefile
@ -1188,6 +1188,7 @@ $(TARBALL): release-only doc-only
|
||||
$(RM) -r $(TARNAME)/doc/images # too big
|
||||
$(RM) -r $(TARNAME)/test*.tap
|
||||
$(RM) -r $(TARNAME)/tools/cpplint.py
|
||||
$(RM) -r $(TARNAME)/tools/eslint
|
||||
$(RM) -r $(TARNAME)/tools/eslint-rules
|
||||
$(RM) -r $(TARNAME)/tools/license-builder.sh
|
||||
$(RM) -r $(TARNAME)/tools/node_modules
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { requireEslintTool } from '../tools/eslint.config_utils.mjs';
|
||||
import { requireEslintTool } from '../tools/eslint/eslint.config_utils.mjs';
|
||||
|
||||
const globals = requireEslintTool('globals');
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { requireEslintTool } from '../tools/eslint.config_utils.mjs';
|
||||
import { requireEslintTool } from '../tools/eslint/eslint.config_utils.mjs';
|
||||
|
||||
const globals = requireEslintTool('globals');
|
||||
|
||||
|
@ -5,13 +5,14 @@ import benchmarkConfig from './benchmark/eslint.config_partial.mjs';
|
||||
import docConfig from './doc/eslint.config_partial.mjs';
|
||||
import libConfig from './lib/eslint.config_partial.mjs';
|
||||
import testConfig from './test/eslint.config_partial.mjs';
|
||||
import toolsConfig from './tools/eslint.config_partial.mjs';
|
||||
import toolsConfig from './tools/eslint/eslint.config_partial.mjs';
|
||||
import {
|
||||
noRestrictedSyntaxCommonAll,
|
||||
noRestrictedSyntaxCommonLib,
|
||||
requireEslintTool,
|
||||
resolveEslintTool,
|
||||
} from './tools/eslint.config_utils.mjs';
|
||||
} from './tools/eslint/eslint.config_utils.mjs';
|
||||
import nodeCore from './tools/eslint/eslint-plugin-node-core.js';
|
||||
|
||||
const js = requireEslintTool('@eslint/js');
|
||||
const babelEslintParser = requireEslintTool('@babel/eslint-parser');
|
||||
@ -20,7 +21,6 @@ const jsdoc = requireEslintTool('eslint-plugin-jsdoc');
|
||||
const markdown = requireEslintTool('eslint-plugin-markdown');
|
||||
const stylisticJs = requireEslintTool('@stylistic/eslint-plugin-js');
|
||||
|
||||
const nodeCore = requireEslintTool('eslint-plugin-node-core');
|
||||
nodeCore.RULES_DIR = fileURLToPath(new URL('./tools/eslint-rules', import.meta.url));
|
||||
|
||||
// The Module._resolveFilename() monkeypatching is to make it so that ESLint is able to
|
||||
|
@ -3,7 +3,7 @@
|
||||
import {
|
||||
noRestrictedSyntaxCommonAll,
|
||||
noRestrictedSyntaxCommonLib,
|
||||
} from '../tools/eslint.config_utils.mjs';
|
||||
} from '../tools/eslint/eslint.config_utils.mjs';
|
||||
|
||||
export default [
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
import {
|
||||
noRestrictedSyntaxCommonAll,
|
||||
requireEslintTool,
|
||||
} from '../tools/eslint.config_utils.mjs';
|
||||
} from '../tools/eslint/eslint.config_utils.mjs';
|
||||
|
||||
const globals = requireEslintTool('globals');
|
||||
|
||||
|
@ -13,7 +13,7 @@ module.exports = {
|
||||
if (!cache) {
|
||||
cache = {};
|
||||
const files = fs.readdirSync(RULES_DIR)
|
||||
.filter(filename => filename.endsWith('.js'))
|
||||
.filter((filename) => filename.endsWith('.js'));
|
||||
for (const file of files) {
|
||||
const name = file.slice(0, -3);
|
||||
cache[name] = require(path.resolve(RULES_DIR, file));
|
@ -1,6 +1,6 @@
|
||||
import { createRequire } from 'node:module';
|
||||
|
||||
export const requireEslintTool = createRequire(new URL('./node_modules/eslint/', import.meta.url));
|
||||
export const requireEslintTool = createRequire(new URL('../node_modules/eslint/', import.meta.url));
|
||||
export const resolveEslintTool = (request) => requireEslintTool.resolve(request);
|
||||
|
||||
export const noRestrictedSyntaxCommonAll = [
|
Loading…
Reference in New Issue
Block a user