Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Ian Clanton-Thuon <iclanton@users.noreply.github.com>
  • Loading branch information
D4N14L and iclanton authored Sep 25, 2023
1 parent bb2b7db commit 119eb2b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"changes": [
{
"packageName": "@rushstack/eslint-config",
"comment": "Adds an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix",
"comment": "Add an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix",
"type": "minor"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"changes": [
{
"packageName": "@rushstack/eslint-patch",
"comment": "Adds an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix",
"comment": "Add an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix",
"type": "minor"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"changes": [
{
"packageName": "@rushstack/heft-node-rig",
"comment": "Adds an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix. This change also includes the ESLint configurations sourced from \"@rushstack/eslint-config\"",
"comment": "Add an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix. This change also includes the ESLint configurations sourced from \"@rushstack/eslint-config\"",
"type": "minor"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"changes": [
{
"packageName": "@rushstack/heft-web-rig",
"comment": "Adds an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix. This chang",
"comment": "Add an optional patch which can be used to allow ESLint to extend configurations from packages that do not have the \"eslint-config-\" prefix. This change also includes the ESLint configurations sourced from \"@rushstack/eslint-config\"",
"type": "minor"
}
],
Expand Down
14 changes: 7 additions & 7 deletions eslint/eslint-patch/src/_patch-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ if (!eslintFolder) {
);
if (resolvedConfigArrayFactoryPath === currentModule.filename) {
configArrayFactoryPath = resolvedConfigArrayFactoryPath;
moduleResolverPath = path.join(eslintrcFolder, 'lib/shared/relative-module-resolver');
namingPath = path.join(eslintrcFolder, 'lib/shared/naming');
moduleResolverPath = `${eslintrcFolder}/lib/shared/relative-module-resolver`;
namingPath = `${eslintrcFolder}/lib/shared/naming`;
}
} catch (ex: unknown) {
// Module resolution failures are expected, as we're walking
Expand Down Expand Up @@ -157,9 +157,9 @@ if (!eslintFolder) {
// .../eslint/lib/cli-engine/config-array-factory.js
if (/[\\/]eslint[\\/]lib[\\/]cli-engine[\\/]config-array-factory\.js$/i.test(currentModule.filename)) {
eslintFolder = path.join(path.dirname(currentModule.filename), '../..');
configArrayFactoryPath = path.join(eslintFolder, 'lib/cli-engine/config-array-factory');
moduleResolverPath = path.join(eslintFolder, 'lib/shared/relative-module-resolver');
namingPath = path.join(eslintFolder, 'lib/shared/naming');
configArrayFactoryPath = `${eslintFolder}/lib/cli-engine/config-array-factory`;
moduleResolverPath = `${eslintFolder}/lib/shared/relative-module-resolver`;
namingPath = `${eslintFolder}/lib/shared/naming`;
break;
}

Expand All @@ -176,10 +176,10 @@ if (!eslintFolder) {
}

// Detect the ESLint package version
const eslintPackageJson = fs.readFileSync(path.join(eslintFolder, 'package.json')).toString();
const eslintPackageJson = fs.readFileSync(`${eslintFolder}/package.json`).toString();
const eslintPackageObject = JSON.parse(eslintPackageJson);
const eslintPackageVersion = eslintPackageObject.version;
const versionMatch = /^([0-9]+)\./.exec(eslintPackageVersion); // parse the SemVer MAJOR part
const versionMatch = parseInt(eslintPackageVersion, 10);
if (!versionMatch) {
throw new Error('Unable to parse ESLint version: ' + eslintPackageVersion);
}
Expand Down
1 change: 1 addition & 0 deletions eslint/eslint-patch/src/modern-module-resolution.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

// This is a workaround for https://github.com/eslint/eslint/issues/3458
//
// To correct how ESLint searches for plugin packages, add this line to the top of your project's .eslintrc.js file:
Expand Down

0 comments on commit 119eb2b

Please sign in to comment.