UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

44 lines (42 loc) 1.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BannedProperties = void 0; var _eslintCodemodUtils = require("eslint-codemod-utils"); var _isDecendantOfStyleBlock = require("../../utils/is-decendant-of-style-block"); var _isDecendantOfType = require("../../utils/is-decendant-of-type"); /* eslint-disable @repo/internal/react/require-jsdoc */ var BannedProperties = exports.BannedProperties = { lint: function lint(node, _ref) { var context = _ref.context, config = _ref.config; // Check whether all criteria needed to make a transformation are met var success = BannedProperties._check(node, { context: context, config: config }); if (success) { return context.report({ node: node, messageId: 'noBannedProperties', data: { property: (0, _eslintCodemodUtils.isNodeOfType)(node.key, 'Identifier') ? node.key.name : 'this property' } }); } }, _check: function _check(node, _ref2) { var config = _ref2.config; if (!config.patterns.includes('banned-properties')) { return false; } if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'Property')) { return false; } if (!(0, _isDecendantOfStyleBlock.isDecendantOfStyleBlock)(node) && !(0, _isDecendantOfType.isDecendantOfType)(node, 'JSXExpressionContainer')) { return false; } return true; } };