Skip to content

Commit

Permalink
Fix version check
Browse files Browse the repository at this point in the history
  • Loading branch information
D4N14L committed Sep 26, 2023
1 parent 6103a23 commit af3dc78
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions eslint/eslint-patch/src/_patch-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,15 @@ if (!eslintFolder) {
}

// Detect the ESLint package version
const eslintPackageJson = fs.readFileSync(`${eslintFolder}/package.json`).toString();
const eslintPackageJsonPath: string = `${eslintFolder}/package.json`;
const eslintPackageJson = fs.readFileSync(eslintPackageJsonPath).toString();
const eslintPackageObject = JSON.parse(eslintPackageJson);
const eslintPackageVersion = eslintPackageObject.version;
let eslintMajorVersion: number;
try {
eslintMajorVersion = parseInt(eslintPackageVersion, 10);
} catch (e) {
throw new Error(`Unable to parse ESLint version "${eslintPackageVersion}": ${e}`);
const eslintMajorVersion: number = parseInt(eslintPackageVersion, 10);
if (isNaN(eslintMajorVersion)) {
throw new Error(
`Unable to parse ESLint version "${eslintPackageVersion}" in file "${eslintPackageJsonPath}"`
);
}

if (!(eslintMajorVersion >= 6 && eslintMajorVersion <= 8)) {
Expand Down

0 comments on commit af3dc78

Please sign in to comment.