@atlaskit/eslint-plugin-design-system 13.1.0 → 13.1.2

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/eslint-plugin-design-system
2
2
 
3
+ ## 13.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#131298](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/131298)
8
+ [`13ebcc2fd6d07`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/13ebcc2fd6d07) -
9
+ Update `use-modal-dialog-close-button` rule to include code within expression containers and
10
+ logical expressions.
11
+
12
+ ## 13.1.1
13
+
14
+ ### Patch Changes
15
+
16
+ - [#127093](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/127093)
17
+ [`1378ea7a99ce1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1378ea7a99ce1) -
18
+ Upgrades `jscodeshift` to handle generics properly.
19
+ - Updated dependencies
20
+
3
21
  ## 13.1.0
4
22
 
5
23
  ### Minor Changes
@@ -391,7 +391,6 @@ var createChecks = exports.createChecks = function createChecks(context) {
391
391
 
392
392
  // Legacy icons rendered as JSX elements
393
393
  if (Object.keys(legacyIconImports).includes(name)) {
394
- var _size, _size2;
395
394
  // Determine if inside a new button - if so:
396
395
  // - Assume spread props are safe - still error if props explicitly set to unmigratable values
397
396
  var insideNewButton = (0, _helpers.isInsideNewButton)(node, newButtonImports);
@@ -487,7 +486,7 @@ var createChecks = exports.createChecks = function createChecks(context) {
487
486
  var migrationMapObject = (0, _helpers.getMigrationMapObject)(legacyIconImports[name].packageName);
488
487
  var upcomingIcon = (0, _helpers.getUpcomingIcons)(legacyIconImports[name].packageName);
489
488
  var newIcon = migrationMapObject === null || migrationMapObject === void 0 ? void 0 : migrationMapObject.newIcon;
490
- var isNewIconMigratable = (0, _helpers.canAutoMigrateNewIconBasedOnSize)(upcomingIcon ? upcomingIcon.sizeGuidance[(_size = size) !== null && _size !== void 0 ? _size : 'medium'] : migrationMapObject === null || migrationMapObject === void 0 ? void 0 : migrationMapObject.sizeGuidance[(_size2 = size) !== null && _size2 !== void 0 ? _size2 : 'medium']);
489
+ var isNewIconMigratable = (0, _helpers.canAutoMigrateNewIconBasedOnSize)(upcomingIcon ? upcomingIcon.sizeGuidance[size !== null && size !== void 0 ? size : 'medium'] : migrationMapObject === null || migrationMapObject === void 0 ? void 0 : migrationMapObject.sizeGuidance[size !== null && size !== void 0 ? size : 'medium']);
491
490
 
492
491
  // Add spacing if:
493
492
  // 1. size is medium for core/utility icons or small for utility icons, or not set (default is medium for core and small for utility icons)
@@ -77,34 +77,58 @@ var rule = (0, _createRule.createLintRule)({
77
77
  }
78
78
  var modalHeaderNode = null;
79
79
  var closeButtonNode = null;
80
- var _searchChildren = function searchChildren(node) {
80
+ var checkNode = function checkNode(node) {
81
+ if (modalHeaderNode && closeButtonNode) {
82
+ return;
83
+ }
84
+
85
+ // Add expression conatiner's body if an expression container
86
+ if ((0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXExpressionContainer')) {
87
+ if (((0, _eslintCodemodUtils.isNodeOfType)(node.expression, 'ArrowFunctionExpression') || (0, _eslintCodemodUtils.isNodeOfType)(node.expression, 'FunctionExpression')) && (0, _eslintCodemodUtils.isNodeOfType)(node.expression.body, 'JSXElement')) {
88
+ searchNode(node.expression.body, true);
89
+ } else if ((0, _eslintCodemodUtils.isNodeOfType)(node.expression, 'LogicalExpression')) {
90
+ var _node$expression = node.expression,
91
+ left = _node$expression.left,
92
+ right = _node$expression.right;
93
+ [left, right].forEach(function (e) {
94
+ if ((0, _eslintCodemodUtils.isNodeOfType)(e, 'JSXElement')) {
95
+ searchNode(e, true);
96
+ }
97
+ });
98
+ }
99
+ }
100
+
101
+ // Skip if not a JSX Element
102
+ if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXElement')) {
103
+ return;
104
+ }
105
+
106
+ // Skip if opening element is not an identifier
107
+ if (!(0, _eslintCodemodUtils.isNodeOfType)(node.openingElement.name, 'JSXIdentifier')) {
108
+ return;
109
+ }
110
+
111
+ // if child is CloseButton, return true
112
+ if (node.openingElement.name.name === closeButtonLocalName) {
113
+ closeButtonNode = node;
114
+ } else if (node.openingElement.name.name === modalHeaderLocalName) {
115
+ modalHeaderNode = node;
116
+ }
117
+ if (node.children) {
118
+ searchNode(node);
119
+ }
120
+ };
121
+ var searchNode = function searchNode(node) {
122
+ var searchSelf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
123
+ if (searchSelf) {
124
+ checkNode(node);
125
+ }
81
126
  var _iterator = _createForOfIteratorHelper(node.children),
82
127
  _step;
83
128
  try {
84
129
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
85
130
  var child = _step.value;
86
- if (modalHeaderNode && closeButtonNode) {
87
- continue;
88
- }
89
- // Skip if not a JSX Element
90
- if (!(0, _eslintCodemodUtils.isNodeOfType)(child, 'JSXElement')) {
91
- continue;
92
- }
93
-
94
- // Skip if opening element is not an identifier
95
- if (!(0, _eslintCodemodUtils.isNodeOfType)(child.openingElement.name, 'JSXIdentifier')) {
96
- continue;
97
- }
98
-
99
- // if child is CloseButton, return true
100
- if (child.openingElement.name.name === closeButtonLocalName) {
101
- closeButtonNode = child;
102
- } else if (child.openingElement.name.name === modalHeaderLocalName) {
103
- modalHeaderNode = child;
104
- }
105
- if (child.children) {
106
- _searchChildren(child);
107
- }
131
+ checkNode(child);
108
132
  }
109
133
  } catch (err) {
110
134
  _iterator.e(err);
@@ -112,7 +136,7 @@ var rule = (0, _createRule.createLintRule)({
112
136
  _iterator.f();
113
137
  }
114
138
  };
115
- _searchChildren(node);
139
+ searchNode(node);
116
140
 
117
141
  // If there is a close button, skip the rest, as this satisfies the rule.
118
142
  if (closeButtonNode) {
@@ -14,7 +14,6 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
14
14
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
15
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
16
  var getStack = function getStack(context, node) {
17
- var _scope;
18
17
  var _getSourceCode = (0, _contextCompat.getSourceCode)(context),
19
18
  scopeManager = _getSourceCode.scopeManager;
20
19
  var stack = {
@@ -46,7 +45,7 @@ var getStack = function getStack(context, node) {
46
45
  }
47
46
  }
48
47
  return _objectSpread(_objectSpread({}, stack), {}, {
49
- scope: (_scope = scope) !== null && _scope !== void 0 ? _scope : (0, _contextCompat.getScope)(context, node)
48
+ scope: scope !== null && scope !== void 0 ? scope : (0, _contextCompat.getScope)(context, node)
50
49
  });
51
50
  };
52
51
  var matches = function matches(defs, refs) {
@@ -70,33 +70,57 @@ const rule = createLintRule({
70
70
  }
71
71
  let modalHeaderNode = null;
72
72
  let closeButtonNode = null;
73
- const searchChildren = node => {
74
- for (let child of node.children) {
75
- if (modalHeaderNode && closeButtonNode) {
76
- continue;
77
- }
78
- // Skip if not a JSX Element
79
- if (!isNodeOfType(child, 'JSXElement')) {
80
- continue;
81
- }
73
+ const checkNode = node => {
74
+ if (modalHeaderNode && closeButtonNode) {
75
+ return;
76
+ }
82
77
 
83
- // Skip if opening element is not an identifier
84
- if (!isNodeOfType(child.openingElement.name, 'JSXIdentifier')) {
85
- continue;
78
+ // Add expression conatiner's body if an expression container
79
+ if (isNodeOfType(node, 'JSXExpressionContainer')) {
80
+ if ((isNodeOfType(node.expression, 'ArrowFunctionExpression') || isNodeOfType(node.expression, 'FunctionExpression')) && isNodeOfType(node.expression.body, 'JSXElement')) {
81
+ searchNode(node.expression.body, true);
82
+ } else if (isNodeOfType(node.expression, 'LogicalExpression')) {
83
+ const {
84
+ left,
85
+ right
86
+ } = node.expression;
87
+ [left, right].forEach(e => {
88
+ if (isNodeOfType(e, 'JSXElement')) {
89
+ searchNode(e, true);
90
+ }
91
+ });
86
92
  }
93
+ }
87
94
 
88
- // if child is CloseButton, return true
89
- if (child.openingElement.name.name === closeButtonLocalName) {
90
- closeButtonNode = child;
91
- } else if (child.openingElement.name.name === modalHeaderLocalName) {
92
- modalHeaderNode = child;
93
- }
94
- if (child.children) {
95
- searchChildren(child);
96
- }
95
+ // Skip if not a JSX Element
96
+ if (!isNodeOfType(node, 'JSXElement')) {
97
+ return;
98
+ }
99
+
100
+ // Skip if opening element is not an identifier
101
+ if (!isNodeOfType(node.openingElement.name, 'JSXIdentifier')) {
102
+ return;
103
+ }
104
+
105
+ // if child is CloseButton, return true
106
+ if (node.openingElement.name.name === closeButtonLocalName) {
107
+ closeButtonNode = node;
108
+ } else if (node.openingElement.name.name === modalHeaderLocalName) {
109
+ modalHeaderNode = node;
110
+ }
111
+ if (node.children) {
112
+ searchNode(node);
113
+ }
114
+ };
115
+ const searchNode = (node, searchSelf = false) => {
116
+ if (searchSelf) {
117
+ checkNode(node);
118
+ }
119
+ for (let child of node.children) {
120
+ checkNode(child);
97
121
  }
98
122
  };
99
- searchChildren(node);
123
+ searchNode(node);
100
124
 
101
125
  // If there is a close button, skip the rest, as this satisfies the rule.
102
126
  if (closeButtonNode) {
@@ -385,7 +385,6 @@ export var createChecks = function createChecks(context) {
385
385
 
386
386
  // Legacy icons rendered as JSX elements
387
387
  if (Object.keys(legacyIconImports).includes(name)) {
388
- var _size, _size2;
389
388
  // Determine if inside a new button - if so:
390
389
  // - Assume spread props are safe - still error if props explicitly set to unmigratable values
391
390
  var insideNewButton = isInsideNewButton(node, newButtonImports);
@@ -481,7 +480,7 @@ export var createChecks = function createChecks(context) {
481
480
  var migrationMapObject = getMigrationMapObject(legacyIconImports[name].packageName);
482
481
  var upcomingIcon = getUpcomingIcons(legacyIconImports[name].packageName);
483
482
  var newIcon = migrationMapObject === null || migrationMapObject === void 0 ? void 0 : migrationMapObject.newIcon;
484
- var isNewIconMigratable = canAutoMigrateNewIconBasedOnSize(upcomingIcon ? upcomingIcon.sizeGuidance[(_size = size) !== null && _size !== void 0 ? _size : 'medium'] : migrationMapObject === null || migrationMapObject === void 0 ? void 0 : migrationMapObject.sizeGuidance[(_size2 = size) !== null && _size2 !== void 0 ? _size2 : 'medium']);
483
+ var isNewIconMigratable = canAutoMigrateNewIconBasedOnSize(upcomingIcon ? upcomingIcon.sizeGuidance[size !== null && size !== void 0 ? size : 'medium'] : migrationMapObject === null || migrationMapObject === void 0 ? void 0 : migrationMapObject.sizeGuidance[size !== null && size !== void 0 ? size : 'medium']);
485
484
 
486
485
  // Add spacing if:
487
486
  // 1. size is medium for core/utility icons or small for utility icons, or not set (default is medium for core and small for utility icons)
@@ -73,34 +73,58 @@ var rule = createLintRule({
73
73
  }
74
74
  var modalHeaderNode = null;
75
75
  var closeButtonNode = null;
76
- var _searchChildren = function searchChildren(node) {
76
+ var checkNode = function checkNode(node) {
77
+ if (modalHeaderNode && closeButtonNode) {
78
+ return;
79
+ }
80
+
81
+ // Add expression conatiner's body if an expression container
82
+ if (isNodeOfType(node, 'JSXExpressionContainer')) {
83
+ if ((isNodeOfType(node.expression, 'ArrowFunctionExpression') || isNodeOfType(node.expression, 'FunctionExpression')) && isNodeOfType(node.expression.body, 'JSXElement')) {
84
+ searchNode(node.expression.body, true);
85
+ } else if (isNodeOfType(node.expression, 'LogicalExpression')) {
86
+ var _node$expression = node.expression,
87
+ left = _node$expression.left,
88
+ right = _node$expression.right;
89
+ [left, right].forEach(function (e) {
90
+ if (isNodeOfType(e, 'JSXElement')) {
91
+ searchNode(e, true);
92
+ }
93
+ });
94
+ }
95
+ }
96
+
97
+ // Skip if not a JSX Element
98
+ if (!isNodeOfType(node, 'JSXElement')) {
99
+ return;
100
+ }
101
+
102
+ // Skip if opening element is not an identifier
103
+ if (!isNodeOfType(node.openingElement.name, 'JSXIdentifier')) {
104
+ return;
105
+ }
106
+
107
+ // if child is CloseButton, return true
108
+ if (node.openingElement.name.name === closeButtonLocalName) {
109
+ closeButtonNode = node;
110
+ } else if (node.openingElement.name.name === modalHeaderLocalName) {
111
+ modalHeaderNode = node;
112
+ }
113
+ if (node.children) {
114
+ searchNode(node);
115
+ }
116
+ };
117
+ var searchNode = function searchNode(node) {
118
+ var searchSelf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
119
+ if (searchSelf) {
120
+ checkNode(node);
121
+ }
77
122
  var _iterator = _createForOfIteratorHelper(node.children),
78
123
  _step;
79
124
  try {
80
125
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
81
126
  var child = _step.value;
82
- if (modalHeaderNode && closeButtonNode) {
83
- continue;
84
- }
85
- // Skip if not a JSX Element
86
- if (!isNodeOfType(child, 'JSXElement')) {
87
- continue;
88
- }
89
-
90
- // Skip if opening element is not an identifier
91
- if (!isNodeOfType(child.openingElement.name, 'JSXIdentifier')) {
92
- continue;
93
- }
94
-
95
- // if child is CloseButton, return true
96
- if (child.openingElement.name.name === closeButtonLocalName) {
97
- closeButtonNode = child;
98
- } else if (child.openingElement.name.name === modalHeaderLocalName) {
99
- modalHeaderNode = child;
100
- }
101
- if (child.children) {
102
- _searchChildren(child);
103
- }
127
+ checkNode(child);
104
128
  }
105
129
  } catch (err) {
106
130
  _iterator.e(err);
@@ -108,7 +132,7 @@ var rule = createLintRule({
108
132
  _iterator.f();
109
133
  }
110
134
  };
111
- _searchChildren(node);
135
+ searchNode(node);
112
136
 
113
137
  // If there is a close button, skip the rest, as this satisfies the rule.
114
138
  if (closeButtonNode) {
@@ -7,7 +7,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
7
  import { getScope, getSourceCode } from '@atlaskit/eslint-utils/context-compat';
8
8
  import { isStyledComponent } from './is-styled-component';
9
9
  var getStack = function getStack(context, node) {
10
- var _scope;
11
10
  var _getSourceCode = getSourceCode(context),
12
11
  scopeManager = _getSourceCode.scopeManager;
13
12
  var stack = {
@@ -39,7 +38,7 @@ var getStack = function getStack(context, node) {
39
38
  }
40
39
  }
41
40
  return _objectSpread(_objectSpread({}, stack), {}, {
42
- scope: (_scope = scope) !== null && _scope !== void 0 ? _scope : getScope(context, node)
41
+ scope: scope !== null && scope !== void 0 ? scope : getScope(context, node)
43
42
  });
44
43
  };
45
44
  var matches = function matches(defs, refs) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-design-system",
3
3
  "description": "The essential plugin for use with the Atlassian Design System.",
4
- "version": "13.1.0",
4
+ "version": "13.1.2",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {
@@ -45,7 +45,7 @@
45
45
  "dependencies": {
46
46
  "@atlaskit/eslint-utils": "^2.0.0",
47
47
  "@atlaskit/icon": "^25.0.0",
48
- "@atlaskit/icon-lab": "^4.2.0",
48
+ "@atlaskit/icon-lab": "^4.3.0",
49
49
  "@atlaskit/tokens": "^4.5.0",
50
50
  "@babel/runtime": "^7.0.0",
51
51
  "@typescript-eslint/utils": "^7.1.0",
@@ -72,7 +72,7 @@
72
72
  "@types/estraverse": "^5.1.7",
73
73
  "@types/json-schema": "^7.0.15",
74
74
  "eslint": "^8.57.0",
75
- "jscodeshift": "^0.13.0",
75
+ "jscodeshift": "^17.0.0",
76
76
  "outdent": "^0.5.0",
77
77
  "react": "^18.2.0",
78
78
  "ts-jest": "^29.2.2",