UNPKG

@exadel/eslint-plugin-esl

Version:

Helper ESLint rules to find and migrate ESL (@exadel/esl) library deprecations

27 lines (26 loc) 1.52 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const semver_1 = require("semver"); const log_1 = require("../../core/log"); const check_version_1 = require("../../core/check-version"); const deprecated_class_method_1 = require("../../core/deprecated-class-method"); const AVAILABLE_SINCE = '5.0.0-beta.24'; const isActual = (0, semver_1.lte)(check_version_1.ESL_PACKAGE_VERSION, AVAILABLE_SINCE); /** Rule for deprecated methods */ exports.default = isActual ? (0, deprecated_class_method_1.buildRule)({ className: 'ESLMediaRuleList', deprecatedMethod: 'parse', getReplacementMethod: (expression) => { const args = expression.arguments; const isLiteral = (node) => (node === null || node === void 0 ? void 0 : node.type) === 'Literal' || (node === null || node === void 0 ? void 0 : node.type) === 'TemplateLiteral'; if (expression.type === 'CallExpression' && args.length === 1) return 'parseQuery'; if (expression.type === 'CallExpression' && args.length === 2 && isLiteral(args[1])) return 'parseTuple'; if (expression.type === 'CallExpression' && args.length === 3) return 'parseTuple'; return { message: 'ESLMediaRuleList.parseQuery or ESLMediaRuleList.parseTuple' }; } }) : (0, log_1.buildLoggingRule)(`'ESLMediaRuleList.parse' was updated in v${AVAILABLE_SINCE}. Rule 'deprecated-4/media-rule-list-parse' is skipped.`);