@exadel/eslint-plugin-esl
Version:
Helper ESLint rules to find and migrate ESL (@exadel/esl) library deprecations
33 lines (32 loc) • 1.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildRule = buildRule;
const meta = {
type: 'suggestion',
docs: {
description: 'replace deprecated path with a recommended one or use the library root & tree shaking',
recommended: true
}
};
/** Builds deprecation rule from {@link ESLintDeprecationCfg} object */
function buildRule(configs) {
configs = Array.isArray(configs) ? configs : [configs];
const create = (context) => ({
ImportSpecifier(node) {
const importedValue = node.imported;
if (importedValue.type !== 'Identifier')
return null;
const importedSource = node.parent.source.value;
for (const cfg of configs) {
if (importedValue.name === cfg.alias && importedSource === cfg.deprecationPath) {
context.report({
node,
message: `[ESL Lint]: Deprecated path for ${cfg.alias}, use ${cfg.recommendedPath} instead`
});
}
}
return null;
}
});
return { meta, create };
}