UNPKG

eslint-plugin-fp-ts

Version:

fp-ts ESLint rules

51 lines (50 loc) 2.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = require("@typescript-eslint/utils"); var utils_2 = require("../utils"); exports.default = (0, utils_2.createRule)({ name: "no-pipeable", meta: { type: "problem", fixable: "code", schema: [], docs: { description: "Disallow imports from the 'pipeable' module", }, messages: { importPipeFromFunction: "The 'pipeable' module is deprecated. Import 'pipe' from the 'function' module instead", pipeableIsDeprecated: "The 'pipeable' module is deprecated and will be removed in future versions of fp-ts", }, }, defaultOptions: [], create: function (context) { return { ImportDeclaration: function (node) { var sourceValue = utils_1.ASTUtils.getStringIfConstant(node.source); var pipeableSourcePattern = /^fp-ts\/(lib\/)?pipeable/; if (sourceValue === null || sourceValue === void 0 ? void 0 : sourceValue.match(pipeableSourcePattern)) { if (node.specifiers.find(function (importClause) { var _a; return ((_a = importClause.imported) === null || _a === void 0 ? void 0 : _a.name) === "pipe"; })) { context.report({ node: node.source, messageId: "importPipeFromFunction", fix: function (fixer) { var quote = (0, utils_2.inferQuote)(node.source); return fixer.replaceText(node.source, "".concat(quote, "fp-ts/function").concat(quote)); }, }); } else { context.report({ node: node.source, messageId: "pipeableIsDeprecated", }); } } }, }; }, });