tools: move ESLint to tools/eslint

Greatly simplify how ESLint and its plugins are installed.

PR-URL: https://github.com/nodejs/node/pull/53413
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
pull/53411/head
Michaël Zasso 2024-06-19 21:54:08 +02:00 committed by GitHub
parent 67c19c2900
commit 2eff28fb7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3134 changed files with 7891 additions and 5211 deletions

View File

@ -23,5 +23,5 @@ indent_size = unset
indent_style = unset
trim_trailing_whitespace = unset
[{test/fixtures,deps,tools/node_modules,tools/gyp,tools/icu,tools/msvs}/**]
[{test/fixtures,deps,tools/eslint/node_modules,tools/gyp,tools/icu,tools/msvs}/**]
insert_final_newline = false

View File

@ -96,7 +96,7 @@ jobs:
echo "TAR_DIR=$RUNNER_TEMP/`basename tarballs/*.tar.gz .tar.gz`" >> $GITHUB_ENV
- name: Copy directories needed for testing
run: |
cp -r tools/node_modules $TAR_DIR/tools
cp -r tools/eslint $TAR_DIR/tools
cp -r tools/eslint-rules $TAR_DIR/tools
- name: Build
run: |

View File

@ -2003,7 +2003,7 @@ The externally maintained libraries used by Node.js are:
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
- ESLint, located at tools/node_modules/eslint, is licensed as follows:
- ESLint, located at tools/eslint/node_modules/eslint, is licensed as follows:
"""
Copyright OpenJS Foundation and other contributors, <www.openjsf.org>

View File

@ -1192,7 +1192,7 @@ $(TARBALL): release-only doc-only
$(RM) -r $(TARNAME)/tools/eslint
$(RM) -r $(TARNAME)/tools/eslint-rules
$(RM) -r $(TARNAME)/tools/license-builder.sh
$(RM) -r $(TARNAME)/tools/node_modules
$(RM) -r $(TARNAME)/tools/eslint/node_modules
$(RM) -r $(TARNAME)/tools/osx-*
$(RM) -r $(TARNAME)/tools/osx-pkg.pmdoc
find $(TARNAME)/deps/v8/test/* -type d ! -regex '.*/test/torque$$' | xargs $(RM) -r
@ -1378,7 +1378,7 @@ format-md:
LINT_JS_TARGETS = eslint.config.mjs benchmark doc lib test tools
run-lint-js = tools/node_modules/eslint/bin/eslint.js --cache \
run-lint-js = tools/eslint/node_modules/eslint/bin/eslint.js --cache \
--max-warnings=0 --report-unused-disable-directives $(LINT_JS_TARGETS)
run-lint-js-fix = $(run-lint-js) --fix
@ -1402,7 +1402,7 @@ lint-js lint-js-doc:
jslint: lint-js
$(warning Please use lint-js instead of jslint)
run-lint-js-ci = tools/node_modules/eslint/bin/eslint.js \
run-lint-js-ci = tools/eslint/node_modules/eslint/bin/eslint.js \
--max-warnings=0 --report-unused-disable-directives -f tap \
-o test-eslint.tap $(LINT_JS_TARGETS)
@ -1562,7 +1562,7 @@ lint-yaml:
.PHONY: lint
.PHONY: lint-ci
ifneq ("","$(wildcard tools/node_modules/eslint/)")
ifneq ("","$(wildcard tools/eslint/node_modules/eslint/)")
lint: ## Run JS, C++, MD and doc linters.
@EXIT_STATUS=0 ; \
$(MAKE) lint-js || EXIT_STATUS=$$? ; \

View File

@ -11,7 +11,7 @@ const path = require('path');
// indispensible part of the CLI.
// NOTE: not all tools are present in tarball hence need to filter
const availableCli = [
'tools/node_modules/eslint/bin/eslint.js',
'tools/eslint/node_modules/eslint/bin/eslint.js',
'deps/npm/bin/npx-cli.js',
'deps/npm/bin/npm-cli.js',
'deps/corepack/dist/corepack.js',

View File

@ -854,7 +854,7 @@ might impact an LTS release.
| `src/node_api.*` | @nodejs/node-api |
| `src/node_crypto.*`, `src/crypto` | @nodejs/crypto |
| `test/*` | @nodejs/testing |
| `tools/node_modules/eslint`, `eslint.config.mjs` | @nodejs/linting |
| `tools/eslint`, `eslint.config.mjs` | @nodejs/linting |
| build | @nodejs/build |
| `src/module_wrap.*`, `lib/internal/modules/*`, `lib/internal/vm/module.js` | @nodejs/modules |
| GYP | @nodejs/gyp |

View File

@ -4,7 +4,7 @@ exclude = [
"tools/cpplint.py",
"tools/gyp",
"tools/inspector_protocol",
"tools/node_modules",
"tools/eslint/node_modules",
]
line-length = 172
target-version = "py37"

View File

@ -472,7 +472,7 @@ Skip the rest of the tests if the current terminal is a dumb terminal
### `skipIfEslintMissing()`
Skip the rest of the tests in the current file when `ESLint` is not available
at `tools/node_modules/eslint`
at `tools/eslint/node_modules/eslint`
### `skipIfInspectorDisabled()`

View File

@ -517,7 +517,7 @@ function hasMultiLocalhost() {
function skipIfEslintMissing() {
if (!fs.existsSync(
path.join(__dirname, '..', '..', 'tools', 'node_modules', 'eslint'),
path.join(__dirname, '..', '..', 'tools', 'eslint', 'node_modules', 'eslint'),
)) {
skip('missing ESLint');
}

View File

@ -6,7 +6,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
}
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/alphabetize-errors');
new RuleTester().run('alphabetize-errors', rule, {

View File

@ -7,7 +7,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/alphabetize-primordials');
new RuleTester()

View File

@ -5,7 +5,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
}
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/async-iife-no-unused-result');
const message = 'The result of an immediately-invoked async function needs ' +

View File

@ -7,7 +7,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/avoid-prototype-pollution');
new RuleTester()

View File

@ -7,7 +7,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/crypto-check');
const message = 'Please add a hasCrypto check to allow this test to be ' +

View File

@ -7,7 +7,7 @@ if (!common.hasIntl)
common.skip('missing Intl');
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/documented-deprecation-codes');
const mdFile = 'doc/api/deprecations.md';

View File

@ -6,7 +6,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
}
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/documented-errors');
const invalidCode = 'UNDOCUMENTED ERROR CODE';

View File

@ -7,7 +7,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skipIfEslintMissing();
const { RuleTester } = require('../../tools/node_modules/eslint');
const { RuleTester } = require('../../tools/eslint/node_modules/eslint');
const rule = require('../../tools/eslint-rules/no-duplicate-requires');
new RuleTester({

View File

@ -7,7 +7,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/eslint-check');
const message = 'Please add a skipIfEslintMissing() call to allow this ' +
@ -19,16 +19,16 @@ new RuleTester().run('eslint-check', rule, {
'foo;',
'require("common")\n' +
'common.skipIfEslintMissing();\n' +
'require("../../tools/node_modules/eslint")',
'require("../../tools/eslint/node_modules/eslint")',
],
invalid: [
{
code: 'require("common")\n' +
'require("../../tools/node_modules/eslint").RuleTester',
'require("../../tools/eslint/node_modules/eslint").RuleTester',
errors: [{ message }],
output: 'require("common")\n' +
'common.skipIfEslintMissing();\n' +
'require("../../tools/node_modules/eslint").RuleTester'
'require("../../tools/eslint/node_modules/eslint").RuleTester'
},
]
});

View File

@ -6,7 +6,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
}
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/inspector-check');
const message = 'Please add a skipIfInspectorDisabled() call to allow this ' +

View File

@ -7,7 +7,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/lowercase-name-for-primitive');
new RuleTester().run('lowercase-name-for-primitive', rule, {

View File

@ -7,7 +7,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skipIfEslintMissing();
const { RuleTester } = require('../../tools/node_modules/eslint');
const { RuleTester } = require('../../tools/eslint/node_modules/eslint');
const rule = require('../../tools/eslint-rules/no-array-destructuring');
const USE_OBJ_DESTRUCTURING =

View File

@ -7,7 +7,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/no-unescaped-regexp-dot');
new RuleTester().run('no-unescaped-regexp-dot', rule, {

View File

@ -7,7 +7,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/non-ascii-character');
new RuleTester().run('non-ascii-characters', rule, {

View File

@ -7,7 +7,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/prefer-assert-iferror');
new RuleTester().run('prefer-assert-iferror', rule, {

View File

@ -7,7 +7,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/prefer-assert-methods');
new RuleTester().run('prefer-assert-methods', rule, {

View File

@ -7,7 +7,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/prefer-common-mustnotcall');
const message = 'Please use common.mustNotCall(msg) instead of ' +

View File

@ -7,7 +7,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/prefer-common-mustsucceed');
const msg1 = 'Please use common.mustSucceed instead of ' +

View File

@ -7,7 +7,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/prefer-primordials');
new RuleTester({

View File

@ -7,7 +7,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/prefer-proto');
new RuleTester().run('prefer-common-mustsucceed', rule, {

View File

@ -9,7 +9,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/prefer-util-format-errors');
new RuleTester()

View File

@ -7,7 +7,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/require-common-first');
new RuleTester({

View File

@ -7,7 +7,7 @@ if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skipIfEslintMissing();
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/required-modules');
new RuleTester({

View File

@ -17,68 +17,32 @@ NPM="$ROOT/deps/npm/bin/npm-cli.js"
. "$ROOT/tools/dep_updaters/utils.sh"
NEW_VERSION=$("$NODE" "$NPM" view eslint dist-tags.latest)
CURRENT_VERSION=$("$NODE" -p "require('./tools/node_modules/eslint/package.json').version")
CURRENT_VERSION=$("$NODE" -p "require('./tools/eslint/node_modules/eslint/package.json').version")
# This function exit with 0 if new version and current version are the same
compare_dependency_version "eslint" "$NEW_VERSION" "$CURRENT_VERSION"
cd "$( dirname "$0" )" || exit
rm -rf ../node_modules/eslint
(
rm -rf eslint-tmp
mkdir eslint-tmp
cd eslint-tmp || exit
rm -rf ../eslint/node_modules ../eslint/package-lock.json
"$NODE" "$NPM" init --yes
"$NODE" "$NPM" install \
cd ../eslint
"$NODE" "$NPM" install \
--ignore-scripts \
--install-strategy=shallow \
--no-bin-links \
"eslint@$NEW_VERSION"
# Uninstall plugins that we want to install so that they are removed from
# devDependencies. Otherwise --omit=dev will cause them to be skipped.
(
cd node_modules/eslint
"$NODE" "$NPM" uninstall \
--install-links=false \
--ignore-scripts \
eslint-formatter-tap \
eslint-plugin-jsdoc \
eslint-plugin-markdown \
globals \
@babel/core \
@babel/eslint-parser \
@babel/plugin-syntax-import-attributes \
@stylistic/eslint-plugin-js
)
(
cd node_modules/eslint
"$NODE" "$NPM" install \
--ignore-scripts \
--install-links=false \
--no-bin-links \
--no-save \
--omit=dev \
--omit=peer \
eslint-formatter-tap \
eslint-plugin-jsdoc \
eslint-plugin-markdown \
globals \
@babel/core \
@babel/eslint-parser \
@babel/plugin-syntax-import-attributes \
@stylistic/eslint-plugin-js
)
# Use dmn to remove some unneeded files.
"$NODE" "$NPM" exec --package=dmn@2.2.2 --yes -- dmn -f clean
# TODO: Get this into dmn.
find node_modules -name .package-lock.json -exec rm {} \;
find node_modules -name 'README*' -exec rm {} \;
)
"eslint@$NEW_VERSION" \
eslint-formatter-tap \
eslint-plugin-jsdoc \
eslint-plugin-markdown \
globals \
@babel/core \
@babel/eslint-parser \
@babel/plugin-syntax-import-attributes \
@stylistic/eslint-plugin-js
mv eslint-tmp/node_modules/eslint ../node_modules/eslint
rm -rf eslint-tmp/
# Use dmn to remove some unneeded files.
"$NODE" "$NPM" exec --package=dmn@3.0.1 --yes -- dmn -f clean
# TODO: Get this into dmn.
find node_modules \( -name .package-lock.json -or -name 'README*' \) -exec rm {} \;
# The last line of the script should always print the new version,
# as we need to add it to $GITHUB_ENV variable.

View File

@ -22,7 +22,7 @@ module.exports = {
let hasEslintCheck = false;
function testEslintUsage(context, node) {
if (utils.isRequired(node, ['../../tools/node_modules/eslint'])) {
if (utils.isRequired(node, ['../../tools/eslint/node_modules/eslint'])) {
missingCheckNodes.push(node);
}

View 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(import.meta.url));
export const resolveEslintTool = (request) => requireEslintTool.resolve(request);
export const noRestrictedSyntaxCommonAll = [

View File

@ -1,6 +1,6 @@
{
"name": "@babel/code-frame",
"version": "7.24.6",
"version": "7.24.7",
"description": "Generate errors that contain a code frame that point to source locations.",
"author": "The Babel Team (https://babel.dev/team)",
"homepage": "https://babel.dev/docs/en/next/babel-code-frame",
@ -16,7 +16,7 @@
},
"main": "./lib/index.js",
"dependencies": {
"@babel/highlight": "^7.24.6",
"@babel/highlight": "^7.24.7",
"picocolors": "^1.0.0"
},
"devDependencies": {

View File

@ -95,6 +95,7 @@
"deno": "1",
"ios": "12",
"samsung": "10",
"rhino": "1.7.15",
"opera_mobile": "48",
"electron": "4.0"
},
@ -125,6 +126,7 @@
"deno": "1",
"ios": "10",
"samsung": "5",
"rhino": "1.7.15",
"opera_mobile": "41",
"electron": "1.2"
},
@ -322,6 +324,7 @@
"deno": "1",
"ios": "10",
"samsung": "5",
"rhino": "1.7.15",
"opera_mobile": "41",
"electron": "1.2"
},
@ -1195,6 +1198,7 @@
"deno": "1",
"ios": "10",
"samsung": "5",
"rhino": "1.7.15",
"opera_mobile": "41",
"electron": "1.2"
},
@ -1208,6 +1212,7 @@
"deno": "1",
"ios": "11.3",
"samsung": "8",
"rhino": "1.7.15",
"opera_mobile": "46",
"electron": "3.0"
},
@ -1403,6 +1408,7 @@
"deno": "1",
"ios": "9",
"samsung": "5",
"rhino": "1.7.15",
"opera_mobile": "36",
"electron": "0.37"
},
@ -1470,6 +1476,7 @@
"deno": "1",
"ios": "10",
"samsung": "5",
"rhino": "1.7.15",
"opera_mobile": "37",
"electron": "1.1"
},
@ -2062,6 +2069,7 @@
"deno": "1",
"ios": "9",
"samsung": "5",
"rhino": "1.7.15",
"opera_mobile": "41",
"electron": "1.2"
},
@ -2075,6 +2083,7 @@
"deno": "1",
"ios": "9",
"samsung": "5",
"rhino": "1.7.15",
"opera_mobile": "41",
"electron": "1.2"
}

View File

@ -4,9 +4,10 @@
"opera": "98",
"edge": "112",
"firefox": "116",
"safari": "tp",
"safari": "17",
"node": "20",
"deno": "1.32",
"ios": "17",
"opera_mobile": "75",
"electron": "24.0"
},
@ -374,6 +375,7 @@
"deno": "1",
"ios": "11.3",
"samsung": "8",
"rhino": "1.7.15",
"opera_mobile": "46",
"electron": "3.0"
},
@ -466,6 +468,7 @@
"deno": "1",
"ios": "9",
"samsung": "4",
"rhino": "1.7.15",
"opera_mobile": "32",
"electron": "0.30"
},
@ -599,6 +602,7 @@
"deno": "1",
"ios": "10",
"samsung": "5",
"rhino": "1.7.15",
"opera_mobile": "36",
"electron": "0.37"
},
@ -612,6 +616,7 @@
"deno": "1",
"ios": "9",
"samsung": "4",
"rhino": "1.7.15",
"opera_mobile": "32",
"electron": "0.30"
},

View File

@ -1,6 +1,6 @@
{
"name": "@babel/compat-data",
"version": "7.24.6",
"version": "7.24.7",
"author": "The Babel Team (https://babel.dev/team)",
"license": "MIT",
"description": "",

View File

@ -224,7 +224,7 @@ var _transformAst = require("./transform-ast.js");
var _parse = require("./parse.js");
var thisFile = require("./index.js");
;
const version = exports.version = "7.24.6";
const version = exports.version = "7.24.7";
const DEFAULT_EXTENSIONS = exports.DEFAULT_EXTENSIONS = Object.freeze([".js", ".jsx", ".es6", ".es", ".mjs", ".cjs"]);
;
{

Some files were not shown because too many files have changed in this diff Show More