Skip to content

Commit

Permalink
test: let original error throw if eslint cannot be found
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed May 3, 2022
1 parent a12fb7e commit e09c7eb
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/rules/__tests__/utils.test.ts
Expand Up @@ -11,21 +11,19 @@ import {
import { espreeParser } from './test-utils';

const findESLintVersion = (): number => {
try {
const eslintPath = require.resolve('eslint/package.json');
const eslintPath = require.resolve('eslint/package.json');

const eslintPackageJson =
// eslint-disable-next-line @typescript-eslint/no-require-imports
require(eslintPath) as JSONSchemaForNPMPackageJsonFiles;
const eslintPackageJson =
// eslint-disable-next-line @typescript-eslint/no-require-imports
require(eslintPath) as JSONSchemaForNPMPackageJsonFiles;

if (eslintPackageJson.version) {
const [majorVersion] = eslintPackageJson.version.split('.');
if (!eslintPackageJson.version) {
throw new Error('eslint package.json does not have a version!');
}

return parseInt(majorVersion, 10);
}
} catch {}
const [majorVersion] = eslintPackageJson.version.split('.');

throw new Error('Unable to detect ESLint version!');
return parseInt(majorVersion, 10);
};

const eslintVersion = findESLintVersion();
Expand Down

0 comments on commit e09c7eb

Please sign in to comment.