@atlaskit/eslint-plugin-design-system 9.3.1 → 9.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +36 -35
- package/constellation/index/usage.mdx +36 -35
- package/constellation/no-direct-use-of-web-platform-drag-and-drop/usage.mdx +140 -0
- package/constellation/use-tokens-typography/usage.mdx +6 -2
- package/dist/cjs/presets/all.codegen.js +2 -1
- package/dist/cjs/presets/recommended.codegen.js +2 -1
- package/dist/cjs/rules/index.codegen.js +3 -1
- package/dist/cjs/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-add-event-listener.js +31 -0
- package/dist/cjs/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind-all.js +63 -0
- package/dist/cjs/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind.js +48 -0
- package/dist/cjs/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-jsx-attribute.js +55 -0
- package/dist/cjs/rules/no-direct-use-of-web-platform-drag-and-drop/index.js +55 -0
- package/dist/cjs/rules/no-direct-use-of-web-platform-drag-and-drop/shared/blocked.js +8 -0
- package/dist/cjs/rules/no-direct-use-of-web-platform-drag-and-drop/shared/is-blocked-event-binding.js +31 -0
- package/dist/cjs/rules/use-tokens-typography/config/index.js +5 -1
- package/dist/cjs/rules/use-tokens-typography/index.js +2 -1
- package/dist/cjs/rules/use-tokens-typography/transformers/style-object.js +16 -9
- package/dist/cjs/rules/use-tokens-typography/utils.js +9 -9
- package/dist/es2019/presets/all.codegen.js +2 -1
- package/dist/es2019/presets/recommended.codegen.js +2 -1
- package/dist/es2019/rules/index.codegen.js +3 -1
- package/dist/es2019/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-add-event-listener.js +25 -0
- package/dist/es2019/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind-all.js +38 -0
- package/dist/es2019/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind.js +33 -0
- package/dist/es2019/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-jsx-attribute.js +49 -0
- package/dist/es2019/rules/no-direct-use-of-web-platform-drag-and-drop/index.js +49 -0
- package/dist/es2019/rules/no-direct-use-of-web-platform-drag-and-drop/shared/blocked.js +2 -0
- package/dist/es2019/rules/no-direct-use-of-web-platform-drag-and-drop/shared/is-blocked-event-binding.js +25 -0
- package/dist/es2019/rules/use-tokens-typography/config/index.js +5 -1
- package/dist/es2019/rules/use-tokens-typography/index.js +2 -1
- package/dist/es2019/rules/use-tokens-typography/transformers/style-object.js +16 -9
- package/dist/es2019/rules/use-tokens-typography/utils.js +8 -9
- package/dist/esm/presets/all.codegen.js +2 -1
- package/dist/esm/presets/recommended.codegen.js +2 -1
- package/dist/esm/rules/index.codegen.js +3 -1
- package/dist/esm/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-add-event-listener.js +25 -0
- package/dist/esm/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind-all.js +59 -0
- package/dist/esm/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind.js +44 -0
- package/dist/esm/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-jsx-attribute.js +49 -0
- package/dist/esm/rules/no-direct-use-of-web-platform-drag-and-drop/index.js +49 -0
- package/dist/esm/rules/no-direct-use-of-web-platform-drag-and-drop/shared/blocked.js +2 -0
- package/dist/esm/rules/no-direct-use-of-web-platform-drag-and-drop/shared/is-blocked-event-binding.js +25 -0
- package/dist/esm/rules/use-tokens-typography/config/index.js +5 -1
- package/dist/esm/rules/use-tokens-typography/index.js +2 -1
- package/dist/esm/rules/use-tokens-typography/transformers/style-object.js +16 -9
- package/dist/esm/rules/use-tokens-typography/utils.js +9 -9
- package/dist/types/index.codegen.d.ts +2 -0
- package/dist/types/presets/all.codegen.d.ts +2 -1
- package/dist/types/presets/recommended.codegen.d.ts +2 -1
- package/dist/types/rules/index.codegen.d.ts +1 -0
- package/dist/types/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-add-event-listener.d.ts +2 -0
- package/dist/types/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind-all.d.ts +3 -0
- package/dist/types/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind.d.ts +3 -0
- package/dist/types/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-jsx-attribute.d.ts +3 -0
- package/dist/types/rules/no-direct-use-of-web-platform-drag-and-drop/index.d.ts +2 -0
- package/dist/types/rules/no-direct-use-of-web-platform-drag-and-drop/shared/blocked.d.ts +2 -0
- package/dist/types/rules/no-direct-use-of-web-platform-drag-and-drop/shared/is-blocked-event-binding.d.ts +2 -0
- package/dist/types/rules/use-tokens-typography/config/index.d.ts +1 -0
- package/dist/types/rules/use-tokens-typography/transformers/style-object.d.ts +6 -2
- package/dist/types/rules/use-tokens-typography/utils.d.ts +1 -1
- package/dist/types-ts4.5/index.codegen.d.ts +2 -0
- package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +2 -1
- package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
- package/dist/types-ts4.5/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-add-event-listener.d.ts +2 -0
- package/dist/types-ts4.5/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind-all.d.ts +3 -0
- package/dist/types-ts4.5/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind.d.ts +3 -0
- package/dist/types-ts4.5/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-jsx-attribute.d.ts +3 -0
- package/dist/types-ts4.5/rules/no-direct-use-of-web-platform-drag-and-drop/index.d.ts +2 -0
- package/dist/types-ts4.5/rules/no-direct-use-of-web-platform-drag-and-drop/shared/blocked.d.ts +2 -0
- package/dist/types-ts4.5/rules/no-direct-use-of-web-platform-drag-and-drop/shared/is-blocked-event-binding.d.ts +2 -0
- package/dist/types-ts4.5/rules/use-tokens-typography/config/index.d.ts +1 -0
- package/dist/types-ts4.5/rules/use-tokens-typography/transformers/style-object.d.ts +6 -2
- package/dist/types-ts4.5/rules/use-tokens-typography/utils.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind-all.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isBlockedBindAll = isBlockedBindAll;
|
|
7
|
+
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
8
|
+
var _getImportNodeBySource = require("../../utils/get-import-node-by-source");
|
|
9
|
+
var _isBlockedEventBinding = require("../shared/is-blocked-event-binding");
|
|
10
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
11
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } // eslint-disable-next-line import/no-extraneous-dependencies
|
|
13
|
+
function isBlockedBindAll(context, node) {
|
|
14
|
+
var callee = node.callee;
|
|
15
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(callee, 'Identifier')) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
if (callee.name !== 'bindAll') {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
var module = (0, _getImportNodeBySource.getModuleOfIdentifier)(context.sourceCode, 'bindAll');
|
|
22
|
+
if ((module === null || module === void 0 ? void 0 : module.moduleName) !== 'bind-event-listener') {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
var secondArg = node.arguments[1];
|
|
26
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(secondArg, 'ArrayExpression')) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
var _iterator = _createForOfIteratorHelper(secondArg.elements),
|
|
30
|
+
_step;
|
|
31
|
+
try {
|
|
32
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
33
|
+
var element = _step.value;
|
|
34
|
+
if (!element) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(element, 'ObjectExpression')) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
var _iterator2 = _createForOfIteratorHelper(element.properties),
|
|
41
|
+
_step2;
|
|
42
|
+
try {
|
|
43
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
44
|
+
var property = _step2.value;
|
|
45
|
+
if ((0, _isBlockedEventBinding.isBlockedEventBinding)(property)) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
} catch (err) {
|
|
50
|
+
_iterator2.e(err);
|
|
51
|
+
} finally {
|
|
52
|
+
_iterator2.f();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// no exit conditions hit
|
|
57
|
+
} catch (err) {
|
|
58
|
+
_iterator.e(err);
|
|
59
|
+
} finally {
|
|
60
|
+
_iterator.f();
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isBlockedBind = isBlockedBind;
|
|
7
|
+
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
8
|
+
var _getImportNodeBySource = require("../../utils/get-import-node-by-source");
|
|
9
|
+
var _isBlockedEventBinding = require("../shared/is-blocked-event-binding");
|
|
10
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
11
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } // eslint-disable-next-line import/no-extraneous-dependencies
|
|
13
|
+
function isBlockedBind(context, node) {
|
|
14
|
+
var callee = node.callee;
|
|
15
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(callee, 'Identifier')) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
if (callee.name !== 'bind') {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
var module = (0, _getImportNodeBySource.getModuleOfIdentifier)(context.sourceCode, 'bind');
|
|
22
|
+
if ((module === null || module === void 0 ? void 0 : module.moduleName) !== 'bind-event-listener') {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
var secondArg = node.arguments[1];
|
|
26
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(secondArg, 'ObjectExpression')) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// using a for loop for speed 🚀
|
|
31
|
+
var _iterator = _createForOfIteratorHelper(secondArg.properties),
|
|
32
|
+
_step;
|
|
33
|
+
try {
|
|
34
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
35
|
+
var property = _step.value;
|
|
36
|
+
if ((0, _isBlockedEventBinding.isBlockedEventBinding)(property)) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// no exit conditions hit
|
|
42
|
+
} catch (err) {
|
|
43
|
+
_iterator.e(err);
|
|
44
|
+
} finally {
|
|
45
|
+
_iterator.f();
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isBlockedJSXAttribute = isBlockedJSXAttribute;
|
|
7
|
+
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
8
|
+
var _getImportNodeBySource = require("../../utils/get-import-node-by-source");
|
|
9
|
+
var _blocked = require("../shared/blocked");
|
|
10
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
11
|
+
|
|
12
|
+
function getJSXElementNameFromAttribute(attribute) {
|
|
13
|
+
var parent = attribute.parent;
|
|
14
|
+
if (!parent) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(parent, 'JSXOpeningElement')) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
var identifier = parent.name;
|
|
21
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(identifier, 'JSXIdentifier')) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return identifier.name;
|
|
25
|
+
}
|
|
26
|
+
function isOnIntrinsicJSXElement(attribute) {
|
|
27
|
+
var name = getJSXElementNameFromAttribute(attribute);
|
|
28
|
+
if (!name) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
var firstLetter = name.at(0);
|
|
32
|
+
if (!firstLetter) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return firstLetter === firstLetter.toLocaleLowerCase();
|
|
36
|
+
}
|
|
37
|
+
function isOnBoxPrimitive(context, attribute) {
|
|
38
|
+
if (getJSXElementNameFromAttribute(attribute) !== 'Box') {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
var module = (0, _getImportNodeBySource.getModuleOfIdentifier)(context.sourceCode, 'Box');
|
|
42
|
+
return (module === null || module === void 0 ? void 0 : module.moduleName) === '@atlaskit/primitives';
|
|
43
|
+
}
|
|
44
|
+
function isBlockedJSXAttribute(context, node) {
|
|
45
|
+
var attributeName = node.name;
|
|
46
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(attributeName, 'JSXIdentifier')) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// not using a blocked attribute name, can continue on
|
|
51
|
+
if (!_blocked.blockedJSXAttributeLookup.has(attributeName.name)) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
return isOnIntrinsicJSXElement(node) || isOnBoxPrimitive(context, node);
|
|
55
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
8
|
+
var _createRule = require("../utils/create-rule");
|
|
9
|
+
var _isBlockedAddEventListener = require("./checks/is-blocked-add-event-listener");
|
|
10
|
+
var _isBlockedBind = require("./checks/is-blocked-bind");
|
|
11
|
+
var _isBlockedBindAll = require("./checks/is-blocked-bind-all");
|
|
12
|
+
var _isBlockedJsxAttribute = require("./checks/is-blocked-jsx-attribute");
|
|
13
|
+
var rule = (0, _createRule.createLintRule)({
|
|
14
|
+
meta: {
|
|
15
|
+
name: 'no-direct-use-of-web-platform-drag-and-drop',
|
|
16
|
+
type: 'problem',
|
|
17
|
+
docs: {
|
|
18
|
+
recommended: true,
|
|
19
|
+
severity: 'error',
|
|
20
|
+
description: 'Disallow using direct use of native drag and drop (please use Pragmatic drag and drop)'
|
|
21
|
+
},
|
|
22
|
+
messages: {
|
|
23
|
+
usePragmaticDnd: 'Please use Pragmatic drag and drop, which makes web platform drag and drop safe and easy to work with.'
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
create: function create(context) {
|
|
27
|
+
return {
|
|
28
|
+
JSXAttribute: function JSXAttribute(node) {
|
|
29
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXAttribute')) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if ((0, _isBlockedJsxAttribute.isBlockedJSXAttribute)(context, node)) {
|
|
33
|
+
context.report({
|
|
34
|
+
messageId: 'usePragmaticDnd',
|
|
35
|
+
node: node
|
|
36
|
+
});
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
CallExpression: function CallExpression(node) {
|
|
41
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'CallExpression')) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if ((0, _isBlockedAddEventListener.isBlockedAddEventListener)(node) || (0, _isBlockedBind.isBlockedBind)(context, node) || (0, _isBlockedBindAll.isBlockedBindAll)(context, node)) {
|
|
45
|
+
context.report({
|
|
46
|
+
messageId: 'usePragmaticDnd',
|
|
47
|
+
node: node
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
var _default = exports.default = rule;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.blockedJSXAttributeLookup = exports.blockedEventNameLookup = void 0;
|
|
7
|
+
var blockedJSXAttributeLookup = exports.blockedJSXAttributeLookup = new Set(['onDragStart', 'onDragEnter', 'onDragLeave', 'onDragOver', 'onDrag', 'onDrop', 'onDragEnd']);
|
|
8
|
+
var blockedEventNameLookup = exports.blockedEventNameLookup = new Set(['dragstart', 'dragenter', 'dragleave', 'dragover', 'drag', 'drop', 'dragend']);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isBlockedEventBinding = isBlockedEventBinding;
|
|
7
|
+
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
8
|
+
var _blocked = require("./blocked");
|
|
9
|
+
function isBlockedEventBinding(property) {
|
|
10
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(property, 'Property')) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// are we looking at the "type" property?
|
|
15
|
+
|
|
16
|
+
var key = property.key;
|
|
17
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(key, 'Identifier')) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (key.name !== 'type') {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// is the "type" property value blocked?
|
|
25
|
+
|
|
26
|
+
var value = property.value;
|
|
27
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(value, 'Literal')) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return typeof value.value === 'string' && _blocked.blockedEventNameLookup.has(value.value);
|
|
31
|
+
}
|
|
@@ -11,12 +11,16 @@ var ruleSchema = exports.ruleSchema = {
|
|
|
11
11
|
properties: {
|
|
12
12
|
failSilently: {
|
|
13
13
|
type: 'boolean'
|
|
14
|
+
},
|
|
15
|
+
shouldEnforceFallbacks: {
|
|
16
|
+
type: 'boolean'
|
|
14
17
|
}
|
|
15
18
|
}
|
|
16
19
|
}
|
|
17
20
|
};
|
|
18
21
|
var defaultConfig = {
|
|
19
|
-
failSilently: false
|
|
22
|
+
failSilently: false,
|
|
23
|
+
shouldEnforceFallbacks: true
|
|
20
24
|
};
|
|
21
25
|
var getConfig = exports.getConfig = function getConfig(overrides) {
|
|
22
26
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
@@ -15,7 +15,8 @@ var create = function create(context) {
|
|
|
15
15
|
ObjectExpression: function ObjectExpression(node) {
|
|
16
16
|
return (0, _errorBoundary.errorBoundary)(function () {
|
|
17
17
|
return _styleObject.StyleObject.lint(node, {
|
|
18
|
-
context: context
|
|
18
|
+
context: context,
|
|
19
|
+
config: config
|
|
19
20
|
});
|
|
20
21
|
}, {
|
|
21
22
|
config: config
|
|
@@ -13,7 +13,8 @@ var _utils2 = require("../utils");
|
|
|
13
13
|
|
|
14
14
|
var StyleObject = exports.StyleObject = {
|
|
15
15
|
lint: function lint(node, _ref) {
|
|
16
|
-
var context = _ref.context
|
|
16
|
+
var context = _ref.context,
|
|
17
|
+
config = _ref.config;
|
|
17
18
|
// To force the correct node type
|
|
18
19
|
if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'ObjectExpression')) {
|
|
19
20
|
return {
|
|
@@ -23,7 +24,8 @@ var StyleObject = exports.StyleObject = {
|
|
|
23
24
|
|
|
24
25
|
// Check whether all criteria needed to make a transformation are met
|
|
25
26
|
var _StyleObject$_check = StyleObject._check(node, {
|
|
26
|
-
context: context
|
|
27
|
+
context: context,
|
|
28
|
+
config: config
|
|
27
29
|
}),
|
|
28
30
|
success = _StyleObject$_check.success,
|
|
29
31
|
refs = _StyleObject$_check.refs;
|
|
@@ -34,6 +36,7 @@ var StyleObject = exports.StyleObject = {
|
|
|
34
36
|
fontSizeRaw = refs.fontSizeRaw,
|
|
35
37
|
tokensImportNode = refs.tokensImportNode,
|
|
36
38
|
themeImportNode = refs.themeImportNode,
|
|
39
|
+
shouldAddFallback = refs.shouldAddFallback,
|
|
37
40
|
shouldAddFallbackImport = refs.shouldAddFallbackImport;
|
|
38
41
|
var fontSizeValue = (0, _utils.normaliseValue)('fontSize', fontSizeRaw);
|
|
39
42
|
|
|
@@ -116,16 +119,17 @@ var StyleObject = exports.StyleObject = {
|
|
|
116
119
|
var nodesToReplace = [fontSizeNode, fontWeightNode, lineHeightNode, fontFamilyNode, fontStyleNode, letterSpacingNode].filter(_utils2.notUndefined);
|
|
117
120
|
var fontFamilyTokenName = fontFamilyToAdd ? "font.family.brand.".concat(fontFamilyToAdd) : '';
|
|
118
121
|
var fontWeightReplacementToken = shouldAddFontWeight ? (0, _utils2.findFontWeightTokenForValue)(fontWeightValue) : undefined;
|
|
119
|
-
var fontWeightReplacement = fontWeightReplacementToken && (0, _utils2.getTokenProperty)('fontWeight', fontWeightReplacementToken.tokenName, fontWeightValue);
|
|
122
|
+
var fontWeightReplacement = fontWeightReplacementToken && (0, _utils2.getTokenProperty)('fontWeight', fontWeightReplacementToken.tokenName, shouldAddFallback ? fontWeightValue : undefined);
|
|
120
123
|
var fontFamilyReplacement = fontFamilyToAdd && (fontFamilyToAdd === 'original' ? (0, _utils2.convertPropertyNodeToStringableNode)(
|
|
121
124
|
// This will always exist if fontFamilyToAdd === 'original', TS can't figure that out.
|
|
122
|
-
fontFamilyNode) : (0, _utils2.getTokenProperty)('fontFamily', fontFamilyTokenName, (0, _utils2.findFontFamilyValueForToken)(fontFamilyTokenName)));
|
|
125
|
+
fontFamilyNode) : (0, _utils2.getTokenProperty)('fontFamily', fontFamilyTokenName, shouldAddFallback ? (0, _utils2.findFontFamilyValueForToken)(fontFamilyTokenName) : undefined));
|
|
123
126
|
var fontStyleReplacement = fontStyleToAdd && (0, _utils2.getLiteralProperty)('fontStyle', fontStyleToAdd);
|
|
124
127
|
var fixerRefs = {
|
|
125
128
|
matchingToken: matchingToken,
|
|
126
129
|
nodesToReplace: nodesToReplace,
|
|
127
130
|
tokensImportNode: tokensImportNode,
|
|
128
131
|
themeImportNode: themeImportNode,
|
|
132
|
+
shouldAddFallback: shouldAddFallback,
|
|
129
133
|
shouldAddFallbackImport: shouldAddFallbackImport,
|
|
130
134
|
fontWeightReplacement: fontWeightReplacement,
|
|
131
135
|
fontFamilyReplacement: fontFamilyReplacement,
|
|
@@ -151,7 +155,8 @@ var StyleObject = exports.StyleObject = {
|
|
|
151
155
|
return;
|
|
152
156
|
},
|
|
153
157
|
_check: function _check(node, _ref2) {
|
|
154
|
-
var context = _ref2.context
|
|
158
|
+
var context = _ref2.context,
|
|
159
|
+
config = _ref2.config;
|
|
155
160
|
if (!(0, _isNode.isDecendantOfStyleBlock)(node) && !(0, _isNode.isDecendantOfType)(node, 'JSXExpressionContainer')) {
|
|
156
161
|
return {
|
|
157
162
|
success: false
|
|
@@ -181,13 +186,13 @@ var StyleObject = exports.StyleObject = {
|
|
|
181
186
|
success: false
|
|
182
187
|
};
|
|
183
188
|
}
|
|
184
|
-
|
|
189
|
+
var shouldAddFallback = Boolean(config.shouldEnforceFallbacks);
|
|
185
190
|
// This exists purely because we're not inlining the fallback values
|
|
186
191
|
// and instead referencing a `fontFallback` object that exists in @atlaskit/theme/typography.
|
|
187
192
|
// This is a temporary measure until fallbacks are no longer required
|
|
188
|
-
var shouldAddFallbackImport = 'full';
|
|
193
|
+
var shouldAddFallbackImport = shouldAddFallback && 'full';
|
|
189
194
|
var themeImportDeclaration = _astNodes.Root.findImportsByModule(context.getSourceCode().ast.body, '@atlaskit/theme/typography');
|
|
190
|
-
if (themeImportDeclaration.length) {
|
|
195
|
+
if (themeImportDeclaration.length && shouldAddFallback) {
|
|
191
196
|
// Import exists, check if specifier exists
|
|
192
197
|
shouldAddFallbackImport = 'specifier';
|
|
193
198
|
var fallbackImport = themeImportDeclaration[0].specifiers.find(function (specifier) {
|
|
@@ -213,6 +218,7 @@ var StyleObject = exports.StyleObject = {
|
|
|
213
218
|
fontSizeRaw: fontSizeRaw,
|
|
214
219
|
tokensImportNode: tokensImportDeclaration[0],
|
|
215
220
|
themeImportNode: themeImportDeclaration[0],
|
|
221
|
+
shouldAddFallback: shouldAddFallback,
|
|
216
222
|
shouldAddFallbackImport: shouldAddFallbackImport
|
|
217
223
|
}
|
|
218
224
|
};
|
|
@@ -223,6 +229,7 @@ var StyleObject = exports.StyleObject = {
|
|
|
223
229
|
nodesToReplace = refs.nodesToReplace,
|
|
224
230
|
tokensImportNode = refs.tokensImportNode,
|
|
225
231
|
themeImportNode = refs.themeImportNode,
|
|
232
|
+
shouldAddFallback = refs.shouldAddFallback,
|
|
226
233
|
shouldAddFallbackImport = refs.shouldAddFallbackImport,
|
|
227
234
|
fontWeightReplacement = refs.fontWeightReplacement,
|
|
228
235
|
fontFamilyReplacement = refs.fontFamilyReplacement,
|
|
@@ -239,7 +246,7 @@ var StyleObject = exports.StyleObject = {
|
|
|
239
246
|
return (!tokensImportNode ? [(0, _utils2.insertTokensImport)(root, fixer)] : []).concat(fallbackImport ? [fallbackImport] : [], nodesToReplace.map(function (node, index) {
|
|
240
247
|
// Replace first node with token, delete remaining nodes. Guaranteed to be fontSize
|
|
241
248
|
if (index === 0) {
|
|
242
|
-
return fixer.replaceText(node, "".concat((0, _utils2.getTokenProperty)('font', matchingToken.tokenName, fallbackName, true)));
|
|
249
|
+
return fixer.replaceText(node, "".concat((0, _utils2.getTokenProperty)('font', matchingToken.tokenName, shouldAddFallback ? fallbackName : undefined, true)));
|
|
243
250
|
}
|
|
244
251
|
|
|
245
252
|
// We don't replace fontWeight/fontFamily/fontStyle here in case it occurs before the font property.
|
|
@@ -119,20 +119,20 @@ function isValidPropertyNode(node) {
|
|
|
119
119
|
}
|
|
120
120
|
return true;
|
|
121
121
|
}
|
|
122
|
-
function getTokenNode(tokenName,
|
|
123
|
-
var
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
122
|
+
function getTokenNode(tokenName, fallbackValue) {
|
|
123
|
+
var isFallbackMember = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
124
|
+
var callExpressionArgs = [(0, _eslintCodemodUtils.literal)({
|
|
125
|
+
value: "'".concat(tokenName, "'")
|
|
126
|
+
})];
|
|
127
|
+
if (fallbackValue) {
|
|
128
|
+
var fallback = isFallbackMember ? createMemberExpressionFromArray(fallbackValue.split('.')) : (0, _eslintCodemodUtils.literal)(fallbackValue);
|
|
129
|
+
callExpressionArgs.push(fallback);
|
|
128
130
|
}
|
|
129
131
|
return (0, _eslintCodemodUtils.callExpression)({
|
|
130
132
|
callee: (0, _eslintCodemodUtils.identifier)({
|
|
131
133
|
name: 'token'
|
|
132
134
|
}),
|
|
133
|
-
arguments:
|
|
134
|
-
value: "'".concat(tokenName, "'")
|
|
135
|
-
}), fallback],
|
|
135
|
+
arguments: callExpressionArgs,
|
|
136
136
|
optional: false
|
|
137
137
|
});
|
|
138
138
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::1ab11547db880eba1206f334a9b2150f>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -15,6 +15,7 @@ export default {
|
|
|
15
15
|
'@atlaskit/design-system/no-deprecated-apis': 'error',
|
|
16
16
|
'@atlaskit/design-system/no-deprecated-design-token-usage': 'warn',
|
|
17
17
|
'@atlaskit/design-system/no-deprecated-imports': 'error',
|
|
18
|
+
'@atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop': 'error',
|
|
18
19
|
'@atlaskit/design-system/no-empty-styled-expression': 'warn',
|
|
19
20
|
'@atlaskit/design-system/no-exported-css': 'warn',
|
|
20
21
|
'@atlaskit/design-system/no-exported-keyframes': 'warn',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::05b4fe8f97edc4f7e46ded52b4917037>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -13,6 +13,7 @@ export default {
|
|
|
13
13
|
'@atlaskit/design-system/no-deprecated-apis': 'error',
|
|
14
14
|
'@atlaskit/design-system/no-deprecated-design-token-usage': 'warn',
|
|
15
15
|
'@atlaskit/design-system/no-deprecated-imports': 'error',
|
|
16
|
+
'@atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop': 'error',
|
|
16
17
|
'@atlaskit/design-system/no-empty-styled-expression': 'warn',
|
|
17
18
|
'@atlaskit/design-system/no-exported-css': 'warn',
|
|
18
19
|
'@atlaskit/design-system/no-exported-keyframes': 'warn',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::293575f7bd0150862f792e3fffc286c4>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
import consistentCssPropUsage from './consistent-css-prop-usage';
|
|
@@ -12,6 +12,7 @@ import noCssTaggedTemplateExpression from './no-css-tagged-template-expression';
|
|
|
12
12
|
import noDeprecatedApis from './no-deprecated-apis';
|
|
13
13
|
import noDeprecatedDesignTokenUsage from './no-deprecated-design-token-usage';
|
|
14
14
|
import noDeprecatedImports from './no-deprecated-imports';
|
|
15
|
+
import noDirectUseOfWebPlatformDragAndDrop from './no-direct-use-of-web-platform-drag-and-drop';
|
|
15
16
|
import noEmptyStyledExpression from './no-empty-styled-expression';
|
|
16
17
|
import noExportedCss from './no-exported-css';
|
|
17
18
|
import noExportedKeyframes from './no-exported-keyframes';
|
|
@@ -46,6 +47,7 @@ export default {
|
|
|
46
47
|
'no-deprecated-apis': noDeprecatedApis,
|
|
47
48
|
'no-deprecated-design-token-usage': noDeprecatedDesignTokenUsage,
|
|
48
49
|
'no-deprecated-imports': noDeprecatedImports,
|
|
50
|
+
'no-direct-use-of-web-platform-drag-and-drop': noDirectUseOfWebPlatformDragAndDrop,
|
|
49
51
|
'no-empty-styled-expression': noEmptyStyledExpression,
|
|
50
52
|
'no-exported-css': noExportedCss,
|
|
51
53
|
'no-exported-keyframes': noExportedKeyframes,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
+
import { blockedEventNameLookup } from '../shared/blocked';
|
|
3
|
+
export function isBlockedAddEventListener(node) {
|
|
4
|
+
const callee = node.callee;
|
|
5
|
+
if (!isNodeOfType(callee, 'MemberExpression')) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
const property = callee.property;
|
|
9
|
+
if (!isNodeOfType(property, 'Identifier')) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
if (property.name !== 'addEventListener') {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// check the first argument
|
|
17
|
+
const first = node.arguments[0];
|
|
18
|
+
|
|
19
|
+
// only checking literals for this eslint rule
|
|
20
|
+
if (!isNodeOfType(first, 'Literal')) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
const value = first.value;
|
|
24
|
+
return typeof value === 'string' && blockedEventNameLookup.has(value);
|
|
25
|
+
}
|
package/dist/es2019/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind-all.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
+
|
|
3
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
+
import { getModuleOfIdentifier } from '../../utils/get-import-node-by-source';
|
|
5
|
+
import { isBlockedEventBinding } from '../shared/is-blocked-event-binding';
|
|
6
|
+
export function isBlockedBindAll(context, node) {
|
|
7
|
+
const callee = node.callee;
|
|
8
|
+
if (!isNodeOfType(callee, 'Identifier')) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (callee.name !== 'bindAll') {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const module = getModuleOfIdentifier(context.sourceCode, 'bindAll');
|
|
15
|
+
if ((module === null || module === void 0 ? void 0 : module.moduleName) !== 'bind-event-listener') {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const secondArg = node.arguments[1];
|
|
19
|
+
if (!isNodeOfType(secondArg, 'ArrayExpression')) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
for (const element of secondArg.elements) {
|
|
23
|
+
if (!element) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (!isNodeOfType(element, 'ObjectExpression')) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
for (const property of element.properties) {
|
|
30
|
+
if (isBlockedEventBinding(property)) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// no exit conditions hit
|
|
37
|
+
return false;
|
|
38
|
+
}
|
package/dist/es2019/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
+
|
|
3
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
+
import { getModuleOfIdentifier } from '../../utils/get-import-node-by-source';
|
|
5
|
+
import { isBlockedEventBinding } from '../shared/is-blocked-event-binding';
|
|
6
|
+
export function isBlockedBind(context, node) {
|
|
7
|
+
const callee = node.callee;
|
|
8
|
+
if (!isNodeOfType(callee, 'Identifier')) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (callee.name !== 'bind') {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const module = getModuleOfIdentifier(context.sourceCode, 'bind');
|
|
15
|
+
if ((module === null || module === void 0 ? void 0 : module.moduleName) !== 'bind-event-listener') {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const secondArg = node.arguments[1];
|
|
19
|
+
if (!isNodeOfType(secondArg, 'ObjectExpression')) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// using a for loop for speed 🚀
|
|
24
|
+
|
|
25
|
+
for (const property of secondArg.properties) {
|
|
26
|
+
if (isBlockedEventBinding(property)) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// no exit conditions hit
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
+
|
|
3
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
+
import { getModuleOfIdentifier } from '../../utils/get-import-node-by-source';
|
|
5
|
+
import { blockedJSXAttributeLookup } from '../shared/blocked';
|
|
6
|
+
function getJSXElementNameFromAttribute(attribute) {
|
|
7
|
+
const parent = attribute.parent;
|
|
8
|
+
if (!parent) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
if (!isNodeOfType(parent, 'JSXOpeningElement')) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const identifier = parent.name;
|
|
15
|
+
if (!isNodeOfType(identifier, 'JSXIdentifier')) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return identifier.name;
|
|
19
|
+
}
|
|
20
|
+
function isOnIntrinsicJSXElement(attribute) {
|
|
21
|
+
const name = getJSXElementNameFromAttribute(attribute);
|
|
22
|
+
if (!name) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const firstLetter = name.at(0);
|
|
26
|
+
if (!firstLetter) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return firstLetter === firstLetter.toLocaleLowerCase();
|
|
30
|
+
}
|
|
31
|
+
function isOnBoxPrimitive(context, attribute) {
|
|
32
|
+
if (getJSXElementNameFromAttribute(attribute) !== 'Box') {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const module = getModuleOfIdentifier(context.sourceCode, 'Box');
|
|
36
|
+
return (module === null || module === void 0 ? void 0 : module.moduleName) === '@atlaskit/primitives';
|
|
37
|
+
}
|
|
38
|
+
export function isBlockedJSXAttribute(context, node) {
|
|
39
|
+
const attributeName = node.name;
|
|
40
|
+
if (!isNodeOfType(attributeName, 'JSXIdentifier')) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// not using a blocked attribute name, can continue on
|
|
45
|
+
if (!blockedJSXAttributeLookup.has(attributeName.name)) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return isOnIntrinsicJSXElement(node) || isOnBoxPrimitive(context, node);
|
|
49
|
+
}
|