4
4
*/
5
5
"use strict"
6
6
7
- const { Range } = require ( "semver" ) // eslint-disable-line no-unused-vars
8
7
const getPackageJson = require ( "./get-package-json" )
9
8
const getSemverRange = require ( "./get-semver-range" )
10
9
11
10
/**
12
11
* Gets `version` property from a given option object.
13
12
*
14
13
* @param {Record<string, string>|undefined } option - An option object to get.
15
- * @returns {Range|undefined } The `allowModules` value, or `null`.
14
+ * @returns {import("semver"). Range|undefined } The `allowModules` value, or `null`.
16
15
*/
17
16
function getVersionRange ( option ) {
18
17
if ( option ?. version ) {
@@ -25,7 +24,7 @@ function getVersionRange(option) {
25
24
/**
26
25
* Get the `engines.node` field of package.json.
27
26
* @param {import('eslint').Rule.RuleContext } context The path to the current linting file.
28
- * @returns {Range|undefined } The range object of the `engines.node` field.
27
+ * @returns {import("semver"). Range|undefined } The range object of the `engines.node` field.
29
28
*/
30
29
function getEnginesNode ( context ) {
31
30
const filename = context . filename ?? context . getFilename ( )
@@ -45,15 +44,15 @@ function getEnginesNode(context) {
45
44
*
46
45
* @param {import('eslint').Rule.RuleContext } context The version range text.
47
46
* This will be used to look package.json up if `version` is not a valid version range.
48
- * @returns {Range } The configured version range.
47
+ * @returns {import("semver"). Range } The configured version range.
49
48
*/
50
49
module . exports = function getConfiguredNodeVersion ( context ) {
51
50
return (
52
51
getVersionRange ( context . options ?. [ 0 ] ) ??
53
52
getVersionRange ( context . settings ?. n ) ??
54
53
getVersionRange ( context . settings ?. node ) ??
55
54
getEnginesNode ( context ) ??
56
- /** @type {Range } */ ( getSemverRange ( ">=16.0.0" ) )
55
+ /** @type {import("semver"). Range } */ ( getSemverRange ( ">=16.0.0" ) )
57
56
)
58
57
}
59
58
0 commit comments