Sha256: 2b0803e7418c4edc3f86324b20ee95253f91a551b4c1a98200ebf7323fc5c80b

Contents?: true

Size: 1.93 KB

Versions: 43

Compression:

Stored size: 1.93 KB

Contents

/**
 * @author Toru Nagashima
 * See LICENSE file in root directory for full license.
 */
"use strict"

const { Range } = require("semver") //eslint-disable-line no-unused-vars
const { ReferenceTracker } = require("eslint-utils")
const getConfiguredNodeVersion = require("./get-configured-node-version")
const getSemverRange = require("./get-semver-range")

/**
 * Parses the options.
 * @param {RuleContext} context The rule context.
 * @returns {{version:Range,ignores:Set<string>}} Parsed value.
 */
function parseOptions(context) {
    const raw = context.options[0] || {}
    const filePath = context.getFilename()
    const version = getConfiguredNodeVersion(raw.version, filePath)
    const ignores = new Set(raw.ignores || [])

    return Object.freeze({ version, ignores })
}

/**
 * Verify the code to report unsupported APIs.
 * @param {RuleContext} context The rule context.
 * @param {{modules:object,globals:object}} trackMap The map for APIs to report.
 * @returns {void}
 */
module.exports = function checkUnsupportedBuiltins(context, trackMap) {
    const options = parseOptions(context)
    const tracker = new ReferenceTracker(context.getScope(), {
        mode: "legacy",
    })
    const references = [
        ...tracker.iterateCjsReferences(trackMap.modules || {}),
        ...tracker.iterateEsmReferences(trackMap.modules || {}),
        ...tracker.iterateGlobalReferences(trackMap.globals || {}),
    ]

    for (const { node, path, info } of references) {
        const name = path.join(".")
        const supported = options.version.intersects(
            getSemverRange(`<${info.supported}`)
        )

        if (supported && !options.ignores.has(name)) {
            context.report({
                node,
                messageId: "unsupported",
                data: {
                    name,
                    supported: info.supported,
                    version: options.version.raw,
                },
            })
        }
    }
}

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
govuk_publishing_components-18.0.0 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js
govuk_publishing_components-17.21.0 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js
govuk_publishing_components-17.20.0 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js
govuk_publishing_components-17.19.1 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js
govuk_publishing_components-17.19.0 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js
govuk_publishing_components-17.18.0 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js
govuk_publishing_components-17.17.0 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js
govuk_publishing_components-17.16.0 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js
govuk_publishing_components-17.15.0 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js
govuk_publishing_components-17.14.0 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js
govuk_publishing_components-17.13.0 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js
govuk_publishing_components-17.12.2 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js
govuk_publishing_components-17.12.1 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js
govuk_publishing_components-17.12.0 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js
govuk_publishing_components-17.11.0 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js
govuk_publishing_components-17.10.0 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js
govuk_publishing_components-17.9.0 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js
govuk_publishing_components-17.8.0 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js
govuk_publishing_components-17.7.0 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js
govuk_publishing_components-17.6.1 node_modules/eslint-plugin-node/lib/util/check-unsupported-builtins.js