UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

52 lines (51 loc) • 2.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _eslintCodemodUtils = require("eslint-codemod-utils"); var _createLintRule = require("../utils/create-lint-rule"); var _paths = require("./paths"); var rule = (0, _createLintRule.createLintRule)({ meta: { name: 'no-unsupported-drag-and-drop-libraries', type: 'problem', docs: { description: 'Disallow importing unsupported drag and drop modules.', recommended: true, severity: 'error' }, messages: { path: 'Replace the unsupported {{importSource}} library with @atlaskit/pragmatic-drag-and-drop, choosing the adapter for the drag source and migrating handlers and cleanup. Follow https://atlassian.design/components/pragmatic-drag-and-drop. {{customMessage}}' } }, create: function create(context) { function checkNode(node) { if ((0, _eslintCodemodUtils.isNodeOfType)(node, 'ExportAllDeclaration') || (0, _eslintCodemodUtils.isNodeOfType)(node, 'ExportNamedDeclaration') || (0, _eslintCodemodUtils.isNodeOfType)(node, 'ImportDeclaration')) { _paths.restrictedPaths.find(function (_ref) { var _node$source; var path = _ref.path, message = _ref.message; var source = (_node$source = node.source) === null || _node$source === void 0 || (_node$source = _node$source.value) === null || _node$source === void 0 ? void 0 : _node$source.toString(); if (source && (source === path || source.startsWith(path))) { context.report({ node: node, messageId: 'path', data: { importSource: source, customMessage: message } }); } }); } } return { ImportDeclaration: checkNode, ExportAllDeclaration: checkNode, ExportNamedDeclaration: checkNode, ExportDefaultDeclaration: checkNode }; } }); var _default = exports.default = rule;