Sha256: 22a92dc6caeb0dd1e0ea88cb1da636269b68f8e0ba5bf796ddf787f3fd1666d8

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const mostRestrictiveKindForDeclaration_1 = __importDefault(require("./mostRestrictiveKindForDeclaration"));
function default_1() {
    return {
        name: '@resugar/codemod-declarations-block-scope',
        visitor: {
            VariableDeclaration(path, state) {
                const { node } = path;
                const options = (state && state.opts) || {};
                const onWarn = options.onWarn || (() => { });
                if (node.kind !== 'var') {
                    return;
                }
                let kind = mostRestrictiveKindForDeclaration_1.default(path);
                if (kind !== 'var') {
                    if (kind === 'const' && !constAllowed(path, options)) {
                        kind = 'let';
                    }
                    node.kind = kind;
                }
                else {
                    onWarn(node, 'unsupported-declaration', `'var' declaration cannot be converted to block scope`);
                }
            },
        },
    };
}
exports.default = default_1;
/**
 * Delegates to user-supplied options to determine whether `let` is allowed.
 */
function constAllowed(path, options) {
    let { disableConst } = options;
    if (typeof disableConst === 'function') {
        return !disableConst(path);
    }
    else {
        return !disableConst;
    }
}
//# sourceMappingURL=index.js.map

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wice_grid-7.1.0 node_modules/@resugar/codemod-declarations-block-scope/src/index.js