@atlaskit/eslint-plugin-design-system 13.2.0 → 13.4.0
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 +18 -0
- package/README.md +1 -0
- package/dist/cjs/presets/all-flat.codegen.js +2 -1
- package/dist/cjs/presets/all.codegen.js +2 -1
- package/dist/cjs/presets/recommended-flat.codegen.js +2 -1
- package/dist/cjs/presets/recommended.codegen.js +2 -1
- package/dist/cjs/rules/consistent-css-prop-usage/index.js +14 -4
- package/dist/cjs/rules/ensure-design-token-usage/index.js +1 -0
- package/dist/cjs/rules/index.codegen.js +3 -1
- package/dist/cjs/rules/no-custom-icons/index.js +2 -0
- package/dist/cjs/rules/no-deprecated-apis/index.js +3 -1
- package/dist/cjs/rules/no-deprecated-imports/checks.js +3 -1
- package/dist/cjs/rules/no-legacy-icons/helpers.js +3 -1
- package/dist/cjs/rules/no-unsafe-design-token-usage/index.js +1 -0
- package/dist/cjs/rules/use-cx-function-in-xcss/index.js +97 -0
- package/dist/cjs/rules/use-heading/index.js +1 -0
- package/dist/cjs/rules/use-latest-xcss-syntax-typography/index.js +1 -0
- package/dist/cjs/rules/use-primitives/index.js +1 -0
- package/dist/cjs/rules/use-primitives-text/index.js +1 -0
- package/dist/cjs/rules/use-tokens-typography/index.js +1 -0
- package/dist/es2019/presets/all-flat.codegen.js +2 -1
- package/dist/es2019/presets/all.codegen.js +2 -1
- package/dist/es2019/presets/recommended-flat.codegen.js +2 -1
- package/dist/es2019/presets/recommended.codegen.js +2 -1
- package/dist/es2019/rules/consistent-css-prop-usage/index.js +14 -4
- package/dist/es2019/rules/ensure-design-token-usage/index.js +1 -0
- package/dist/es2019/rules/index.codegen.js +3 -1
- package/dist/es2019/rules/no-custom-icons/index.js +2 -0
- package/dist/es2019/rules/no-deprecated-apis/index.js +3 -1
- package/dist/es2019/rules/no-deprecated-imports/checks.js +3 -1
- package/dist/es2019/rules/no-legacy-icons/helpers.js +3 -1
- package/dist/es2019/rules/no-unsafe-design-token-usage/index.js +1 -0
- package/dist/es2019/rules/use-cx-function-in-xcss/index.js +70 -0
- package/dist/es2019/rules/use-heading/index.js +1 -0
- package/dist/es2019/rules/use-latest-xcss-syntax-typography/index.js +1 -0
- package/dist/es2019/rules/use-primitives/index.js +1 -0
- package/dist/es2019/rules/use-primitives-text/index.js +1 -0
- package/dist/es2019/rules/use-tokens-typography/index.js +1 -0
- package/dist/esm/presets/all-flat.codegen.js +2 -1
- package/dist/esm/presets/all.codegen.js +2 -1
- package/dist/esm/presets/recommended-flat.codegen.js +2 -1
- package/dist/esm/presets/recommended.codegen.js +2 -1
- package/dist/esm/rules/consistent-css-prop-usage/index.js +14 -4
- package/dist/esm/rules/ensure-design-token-usage/index.js +1 -0
- package/dist/esm/rules/index.codegen.js +3 -1
- package/dist/esm/rules/no-custom-icons/index.js +2 -0
- package/dist/esm/rules/no-deprecated-apis/index.js +3 -1
- package/dist/esm/rules/no-deprecated-imports/checks.js +3 -1
- package/dist/esm/rules/no-legacy-icons/helpers.js +3 -1
- package/dist/esm/rules/no-unsafe-design-token-usage/index.js +1 -0
- package/dist/esm/rules/use-cx-function-in-xcss/index.js +91 -0
- package/dist/esm/rules/use-heading/index.js +1 -0
- package/dist/esm/rules/use-latest-xcss-syntax-typography/index.js +1 -0
- package/dist/esm/rules/use-primitives/index.js +1 -0
- package/dist/esm/rules/use-primitives-text/index.js +1 -0
- package/dist/esm/rules/use-tokens-typography/index.js +1 -0
- package/dist/types/index.codegen.d.ts +9 -0
- package/dist/types/presets/all-flat.codegen.d.ts +1 -0
- package/dist/types/presets/all.codegen.d.ts +1 -0
- package/dist/types/presets/recommended-flat.codegen.d.ts +1 -0
- package/dist/types/presets/recommended.codegen.d.ts +1 -0
- package/dist/types/rules/index.codegen.d.ts +1 -0
- package/dist/types/rules/no-legacy-icons/helpers.d.ts +1 -1
- package/dist/types/rules/use-cx-function-in-xcss/index.d.ts +3 -0
- package/dist/types-ts4.5/index.codegen.d.ts +9 -0
- package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +1 -0
- package/dist/types-ts4.5/presets/all.codegen.d.ts +1 -0
- package/dist/types-ts4.5/presets/recommended-flat.codegen.d.ts +1 -0
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +1 -0
- package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
- package/dist/types-ts4.5/rules/no-legacy-icons/helpers.d.ts +1 -1
- package/dist/types-ts4.5/rules/use-cx-function-in-xcss/index.d.ts +3 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 13.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#133012](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/133012)
|
|
8
|
+
[`767ec60923d2e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/767ec60923d2e) -
|
|
9
|
+
Adds a new eslint rule to ensure that the cx function is used properly in xcss props. This is
|
|
10
|
+
required for smooth primitives migration onto compiled styles from emotion.
|
|
11
|
+
|
|
12
|
+
## 13.3.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#131514](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/131514)
|
|
17
|
+
[`74ddca032fe0f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/74ddca032fe0f) -
|
|
18
|
+
Fixes @atlaskit/eslint-plugin-ui-styling-standard/consistent-css-prop-usage to allow aliased
|
|
19
|
+
imports, eg., import { css as css2 } from '@compiled/react'
|
|
20
|
+
|
|
3
21
|
## 13.2.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -81,6 +81,7 @@ module.exports = {
|
|
|
81
81
|
| <a href="./packages/design-system/eslint-plugin/src/rules/no-unsupported-drag-and-drop-libraries/README.md">no-unsupported-drag-and-drop-libraries</a> | Disallow importing unsupported drag and drop modules. | Yes | | |
|
|
82
82
|
| <a href="./packages/design-system/eslint-plugin/src/rules/prefer-primitives/README.md">prefer-primitives</a> | Increase awareness of primitive components via code hints. Strictly used for education purposes and discoverability. To enforce usage please refer to the `use-primitives` rule. | | | |
|
|
83
83
|
| <a href="./packages/design-system/eslint-plugin/src/rules/use-button-group-label/README.md">use-button-group-label</a> | Ensures button groups are described to assistive technology by a direct label or by another element. | Yes | | Yes |
|
|
84
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-cx-function-in-xcss/README.md">use-cx-function-in-xcss</a> | Enforces cx function use to combine styles in xcss. | Yes | Yes | Yes |
|
|
84
85
|
| <a href="./packages/design-system/eslint-plugin/src/rules/use-datetime-picker-calendar-button/README.md">use-datetime-picker-calendar-button</a> | Encourages makers to use calendar button in Atlassian Design System's date picker and datetime picker components. | Yes | Yes | Yes |
|
|
85
86
|
| <a href="./packages/design-system/eslint-plugin/src/rules/use-drawer-label/README.md">use-drawer-label</a> | Encourages to provide accessible name for Atlassian Design System Drawer component. | Yes | | Yes |
|
|
86
87
|
| <a href="./packages/design-system/eslint-plugin/src/rules/use-heading/README.md">use-heading</a> | Encourage the usage of heading components. | | Yes | Yes |
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
9
|
-
* @codegen <<SignedSource::
|
|
9
|
+
* @codegen <<SignedSource::9b616276b6c3b9db3c1d886bf8de4fc4>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -44,6 +44,7 @@ var _default = exports.default = {
|
|
|
44
44
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
45
45
|
'@atlaskit/design-system/prefer-primitives': 'warn',
|
|
46
46
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
47
|
+
'@atlaskit/design-system/use-cx-function-in-xcss': 'error',
|
|
47
48
|
'@atlaskit/design-system/use-datetime-picker-calendar-button': 'warn',
|
|
48
49
|
'@atlaskit/design-system/use-drawer-label': 'warn',
|
|
49
50
|
'@atlaskit/design-system/use-heading': 'warn',
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
9
|
-
* @codegen <<SignedSource::
|
|
9
|
+
* @codegen <<SignedSource::96ec2e315f96de68a6448317cce334ce>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -43,6 +43,7 @@ var _default = exports.default = {
|
|
|
43
43
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
44
44
|
'@atlaskit/design-system/prefer-primitives': 'warn',
|
|
45
45
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
46
|
+
'@atlaskit/design-system/use-cx-function-in-xcss': 'error',
|
|
46
47
|
'@atlaskit/design-system/use-datetime-picker-calendar-button': 'warn',
|
|
47
48
|
'@atlaskit/design-system/use-drawer-label': 'warn',
|
|
48
49
|
'@atlaskit/design-system/use-heading': 'warn',
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
9
|
-
* @codegen <<SignedSource::
|
|
9
|
+
* @codegen <<SignedSource::4f6ee2ae56e1c0534f0f8e3fde314cc7>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -33,6 +33,7 @@ var _default = exports.default = {
|
|
|
33
33
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
34
34
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
35
35
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
36
|
+
'@atlaskit/design-system/use-cx-function-in-xcss': 'error',
|
|
36
37
|
'@atlaskit/design-system/use-datetime-picker-calendar-button': 'warn',
|
|
37
38
|
'@atlaskit/design-system/use-drawer-label': 'warn',
|
|
38
39
|
'@atlaskit/design-system/use-heading-level-in-spotlight-card': 'warn',
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
9
|
-
* @codegen <<SignedSource::
|
|
9
|
+
* @codegen <<SignedSource::85c1f4ada9dac0f66e87e3734a36cb6b>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -32,6 +32,7 @@ var _default = exports.default = {
|
|
|
32
32
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
33
33
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
34
34
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
35
|
+
'@atlaskit/design-system/use-cx-function-in-xcss': 'error',
|
|
35
36
|
'@atlaskit/design-system/use-datetime-picker-calendar-button': 'warn',
|
|
36
37
|
'@atlaskit/design-system/use-drawer-label': 'warn',
|
|
37
38
|
'@atlaskit/design-system/use-heading-level-in-spotlight-card': 'warn',
|
|
@@ -24,9 +24,19 @@ var _getImportNodeBySource = require("../utils/get-import-node-by-source");
|
|
|
24
24
|
var isDOMElementName = function isDOMElementName(elementName) {
|
|
25
25
|
return elementName.charAt(0) !== elementName.charAt(0).toUpperCase() && elementName.charAt(0) === elementName.charAt(0).toLowerCase();
|
|
26
26
|
};
|
|
27
|
-
function isCssCallExpression(node, cssFunctions) {
|
|
27
|
+
function isCssCallExpression(node, cssFunctions, context) {
|
|
28
28
|
cssFunctions = [].concat((0, _toConsumableArray2.default)(cssFunctions), ['cssMap']);
|
|
29
|
-
|
|
29
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'CallExpression') || !(0, _eslintCodemodUtils.isNodeOfType)(node.callee, 'Identifier')) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
var module = (0, _getImportNodeBySource.getModuleOfIdentifier)((0, _contextCompat.getSourceCode)(context), node.callee.name);
|
|
33
|
+
if (!module) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (!cssFunctions.includes(module.importName)) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return node.arguments.length > 0 && node.arguments[0].type === 'ObjectExpression';
|
|
30
40
|
}
|
|
31
41
|
function findSpreadProperties(node) {
|
|
32
42
|
return node.properties.filter(function (property) {
|
|
@@ -161,7 +171,7 @@ var JSXExpressionLinter = /*#__PURE__*/function () {
|
|
|
161
171
|
});
|
|
162
172
|
return;
|
|
163
173
|
}
|
|
164
|
-
if (identifier.parent && identifier.parent.init && !isCssCallExpression(identifier.parent.init, this.configuration.cssFunctions)) {
|
|
174
|
+
if (identifier.parent && identifier.parent.init && !isCssCallExpression(identifier.parent.init, this.configuration.cssFunctions, this.context)) {
|
|
165
175
|
// When variable value is not of type css({})
|
|
166
176
|
var value = identifier.parent.init;
|
|
167
177
|
if (!value) {
|
|
@@ -473,7 +483,7 @@ var JSXExpressionLinter = /*#__PURE__*/function () {
|
|
|
473
483
|
}
|
|
474
484
|
|
|
475
485
|
// Don't fix CallExpressions unless they're from cssFunctions or cssMap
|
|
476
|
-
if (expression.type === 'CallExpression' && !isCssCallExpression(expression, _this3.configuration.cssFunctions)) {
|
|
486
|
+
if (expression.type === 'CallExpression' && !isCssCallExpression(expression, _this3.configuration.cssFunctions, _this3.context)) {
|
|
477
487
|
return [];
|
|
478
488
|
}
|
|
479
489
|
if (expression.type === 'ObjectExpression') {
|
|
@@ -27,6 +27,7 @@ var defaultConfig = {
|
|
|
27
27
|
};
|
|
28
28
|
var createWithConfig = exports.createWithConfig = function createWithConfig(initialConfig) {
|
|
29
29
|
return function (context) {
|
|
30
|
+
// TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
|
|
30
31
|
var userConfig = context.options[0];
|
|
31
32
|
// merge configs
|
|
32
33
|
var config = {
|
|
@@ -37,6 +37,7 @@ var _noUnsafeStyleOverrides = _interopRequireDefault(require("./no-unsafe-style-
|
|
|
37
37
|
var _noUnsupportedDragAndDropLibraries = _interopRequireDefault(require("./no-unsupported-drag-and-drop-libraries"));
|
|
38
38
|
var _preferPrimitives = _interopRequireDefault(require("./prefer-primitives"));
|
|
39
39
|
var _useButtonGroupLabel = _interopRequireDefault(require("./use-button-group-label"));
|
|
40
|
+
var _useCxFunctionInXcss = _interopRequireDefault(require("./use-cx-function-in-xcss"));
|
|
40
41
|
var _useDatetimePickerCalendarButton = _interopRequireDefault(require("./use-datetime-picker-calendar-button"));
|
|
41
42
|
var _useDrawerLabel = _interopRequireDefault(require("./use-drawer-label"));
|
|
42
43
|
var _useHeading = _interopRequireDefault(require("./use-heading"));
|
|
@@ -56,7 +57,7 @@ var _useTokensTypography = _interopRequireDefault(require("./use-tokens-typograp
|
|
|
56
57
|
var _useVisuallyHidden = _interopRequireDefault(require("./use-visually-hidden"));
|
|
57
58
|
/**
|
|
58
59
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
59
|
-
* @codegen <<SignedSource::
|
|
60
|
+
* @codegen <<SignedSource::66749852497ab0f2dc3214dd47aaf598>>
|
|
60
61
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
61
62
|
*/
|
|
62
63
|
|
|
@@ -93,6 +94,7 @@ var rules = exports.rules = {
|
|
|
93
94
|
'no-unsupported-drag-and-drop-libraries': _noUnsupportedDragAndDropLibraries.default,
|
|
94
95
|
'prefer-primitives': _preferPrimitives.default,
|
|
95
96
|
'use-button-group-label': _useButtonGroupLabel.default,
|
|
97
|
+
'use-cx-function-in-xcss': _useCxFunctionInXcss.default,
|
|
96
98
|
'use-datetime-picker-calendar-button': _useDatetimePickerCalendarButton.default,
|
|
97
99
|
'use-drawer-label': _useDrawerLabel.default,
|
|
98
100
|
'use-heading': _useHeading.default,
|
|
@@ -38,6 +38,8 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
38
38
|
create: function create(context) {
|
|
39
39
|
var _context$options$;
|
|
40
40
|
var isIconBase = (0, _isFromImportSource.createIsFromImportSourceFor)('@atlaskit/icon', '@atlaskit/icon/base');
|
|
41
|
+
|
|
42
|
+
// TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
|
|
41
43
|
var _ref = (_context$options$ = context.options[0]) !== null && _context$options$ !== void 0 ? _context$options$ : {},
|
|
42
44
|
_ref$centralLocation = _ref.centralLocation,
|
|
43
45
|
centralLocation = _ref$centralLocation === void 0 ? '' : _ref$centralLocation,
|
|
@@ -73,7 +73,9 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
73
73
|
var _context$options$;
|
|
74
74
|
// Get the rule configuration specified otherwise use default config.
|
|
75
75
|
// A bit confusing as it seems that the default options have precedence over the user specified options.
|
|
76
|
-
var deprecatedConfig =
|
|
76
|
+
var deprecatedConfig =
|
|
77
|
+
// TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
|
|
78
|
+
((_context$options$ = context.options[0]) === null || _context$options$ === void 0 ? void 0 : _context$options$.deprecatedConfig) || (0, _getDeprecatedConfig.getConfig)('jsxAttributes');
|
|
77
79
|
return {
|
|
78
80
|
// find JSX attribute - find name of attribute - get source and find relevant identifiers.
|
|
79
81
|
JSXAttribute: function JSXAttribute(node) {
|
|
@@ -38,7 +38,9 @@ var createChecks = exports.createChecks = function createChecks(context) {
|
|
|
38
38
|
type = _ref.type,
|
|
39
39
|
node = _ref.node,
|
|
40
40
|
importNames = _ref.importNames;
|
|
41
|
-
var restrictedPathMessages =
|
|
41
|
+
var restrictedPathMessages =
|
|
42
|
+
// TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
|
|
43
|
+
((_context$options$ = context.options[0]) === null || _context$options$ === void 0 ? void 0 : _context$options$.deprecatedConfig) || (0, _getDeprecatedConfig.getConfig)('imports');
|
|
42
44
|
if (!(0, _types.isDeprecatedImportConfig)(restrictedPathMessages)) {
|
|
43
45
|
throw new Error('Config is invalid for deprecated imports');
|
|
44
46
|
}
|
|
@@ -321,7 +321,9 @@ var getLiteralStringValue = function getLiteralStringValue(value) {
|
|
|
321
321
|
}
|
|
322
322
|
return;
|
|
323
323
|
};
|
|
324
|
-
var createHelpers = exports.createHelpers = function createHelpers(
|
|
324
|
+
var createHelpers = exports.createHelpers = function createHelpers(ctx) {
|
|
325
|
+
// TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
|
|
326
|
+
var context = ctx;
|
|
325
327
|
/**
|
|
326
328
|
* Extracts the token name of a token() call from a JSXExpressionContainer
|
|
327
329
|
* @param value The JSXExpressionContainer to extract the token call from
|
|
@@ -54,6 +54,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
54
54
|
}]
|
|
55
55
|
},
|
|
56
56
|
create: function create(context) {
|
|
57
|
+
// TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
|
|
57
58
|
var config = _objectSpread({}, context.options[0]);
|
|
58
59
|
if (!config.fallbackUsage) {
|
|
59
60
|
config.fallbackUsage = config.shouldEnforceFallbacks ? 'forced' : 'none';
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
10
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
|
+
var rule = (0, _createRule.createLintRule)({
|
|
13
|
+
meta: {
|
|
14
|
+
name: 'use-cx-function-in-xcss',
|
|
15
|
+
fixable: 'code',
|
|
16
|
+
hasSuggestions: true,
|
|
17
|
+
type: 'problem',
|
|
18
|
+
docs: {
|
|
19
|
+
description: 'Enforces cx function use to combine styles in xcss.',
|
|
20
|
+
recommended: true,
|
|
21
|
+
severity: 'error'
|
|
22
|
+
},
|
|
23
|
+
messages: {
|
|
24
|
+
useCxFunc: "Use the cx function when combining styles in the xcss prop."
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
create: function create(context) {
|
|
28
|
+
var importStatement = null;
|
|
29
|
+
var primitiveNames = new Set();
|
|
30
|
+
return {
|
|
31
|
+
"ImportDeclaration[source.value='@atlaskit/css']": function ImportDeclarationSourceValueAtlaskit_css(node) {
|
|
32
|
+
importStatement = {
|
|
33
|
+
node: node
|
|
34
|
+
};
|
|
35
|
+
var _iterator = _createForOfIteratorHelper(node.specifiers),
|
|
36
|
+
_step;
|
|
37
|
+
try {
|
|
38
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
39
|
+
var specifier = _step.value;
|
|
40
|
+
if (specifier.type === 'ImportSpecifier' && specifier.imported.name === 'cx') {
|
|
41
|
+
importStatement.cxFuncLocalName = specifier.local.name;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
} catch (err) {
|
|
45
|
+
_iterator.e(err);
|
|
46
|
+
} finally {
|
|
47
|
+
_iterator.f();
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
'ImportDeclaration[source.value="@atlaskit/primitives/compiled"]': function ImportDeclarationSourceValueAtlaskit_primitives_compiled(node) {
|
|
51
|
+
var _iterator2 = _createForOfIteratorHelper(node.specifiers),
|
|
52
|
+
_step2;
|
|
53
|
+
try {
|
|
54
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
55
|
+
var specifier = _step2.value;
|
|
56
|
+
primitiveNames.add(specifier.local.name);
|
|
57
|
+
}
|
|
58
|
+
} catch (err) {
|
|
59
|
+
_iterator2.e(err);
|
|
60
|
+
} finally {
|
|
61
|
+
_iterator2.f();
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
'JSXAttribute > JSXIdentifier[name=/[xX]css$/]': function JSXAttribute__JSXIdentifierName_XXCss$_(node) {
|
|
65
|
+
var xcssValue = node.parent && (0, _eslintCodemodUtils.isNodeOfType)(node.parent, 'JSXAttribute') && node.parent.value && (0, _eslintCodemodUtils.isNodeOfType)(node.parent.value, 'JSXExpressionContainer') ? node.parent.value : undefined;
|
|
66
|
+
if (!xcssValue) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
var jsxElementName = node.parent.parent && (0, _eslintCodemodUtils.isNodeOfType)(node.parent.parent, 'JSXOpeningElement') && node.parent.parent.name && (0, _eslintCodemodUtils.isNodeOfType)(node.parent.parent.name, 'JSXIdentifier') ? node.parent.parent.name.name : undefined;
|
|
70
|
+
if (!jsxElementName) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
// check if this JSX element is from the primitives entry point and if prop value is an array
|
|
74
|
+
if (primitiveNames.has(jsxElementName) && xcssValue.expression.type === 'ArrayExpression') {
|
|
75
|
+
context.report({
|
|
76
|
+
node: xcssValue,
|
|
77
|
+
messageId: 'useCxFunc',
|
|
78
|
+
fix: function fix(fixer) {
|
|
79
|
+
var fixes = [];
|
|
80
|
+
var sourceCode = context.sourceCode;
|
|
81
|
+
var styles = sourceCode.getText(xcssValue.expression);
|
|
82
|
+
fixes.push(fixer.replaceText(xcssValue, (importStatement && importStatement.cxFuncLocalName ? "{".concat(importStatement.cxFuncLocalName) : "{cx") + "(".concat(styles.replace(/^\[/, '').replace(/\]$/, ''), ")}")));
|
|
83
|
+
if (!importStatement) {
|
|
84
|
+
fixes.push(fixer.insertTextBeforeRange([0, 0], "import { cx } from '@atlaskit/css';\n"));
|
|
85
|
+
} else if (!importStatement.cxFuncLocalName) {
|
|
86
|
+
var importText = sourceCode.getText(importStatement.node);
|
|
87
|
+
fixes.push(fixer.replaceText(importStatement.node, importText.includes('{') ? importText.replace(/import(.*) {\s?/, "import$1 { cx, ") : importText.replace(/ from /, ", { cx } from ")));
|
|
88
|
+
}
|
|
89
|
+
return fixes;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
var _default = exports.default = rule;
|
|
@@ -37,6 +37,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
create: function create(context) {
|
|
40
|
+
// TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
|
|
40
41
|
var config = (0, _config.getConfig)(context.options[0]);
|
|
41
42
|
return (0, _errorBoundary.errorBoundary)({
|
|
42
43
|
// transforms <h1>...</h1> usages
|
|
@@ -46,6 +46,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
create: function create(context) {
|
|
49
|
+
// TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
|
|
49
50
|
var config = (0, _config.getConfig)(context.options[0]);
|
|
50
51
|
return (0, _errorBoundary.errorBoundary)({
|
|
51
52
|
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Identifier[name=/(fontSize|lineHeight|fontWeight|letterSpacing)/]': function CallExpressionCalleeNameXcss_ObjectExpression__Property__IdentifierName_FontSizeLineHeightFontWeightLetterSpacing_(node) {
|
|
@@ -38,6 +38,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
create: function create(context) {
|
|
41
|
+
// TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
|
|
41
42
|
var config = (0, _config.getConfig)(context.options[0]);
|
|
42
43
|
return {
|
|
43
44
|
// transforms styled.<html>(...) usages
|
|
@@ -53,6 +53,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
create: function create(context) {
|
|
56
|
+
// TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
|
|
56
57
|
var config = (0, _config.getConfig)(context.options[0]);
|
|
57
58
|
return (0, _errorBoundary.errorBoundary)({
|
|
58
59
|
'JSXElement[openingElement.name.name=span]': function JSXElementOpeningElementNameNameSpan(node) {
|
|
@@ -14,6 +14,7 @@ var _restrictedCapitalisation = require("./transformers/restricted-capitalisatio
|
|
|
14
14
|
var _styleObject = require("./transformers/style-object");
|
|
15
15
|
var _untokenizedProperties = require("./transformers/untokenized-properties");
|
|
16
16
|
var create = function create(context) {
|
|
17
|
+
// TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
|
|
17
18
|
var config = (0, _config.getConfig)(context.options[0]);
|
|
18
19
|
return (0, _errorBoundary.errorBoundary)({
|
|
19
20
|
// const styles = css({ fontSize: '14px', ... }), styled.div({ fontSize: 14, ... })
|
|
@@ -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::9b616276b6c3b9db3c1d886bf8de4fc4>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -39,6 +39,7 @@ export default {
|
|
|
39
39
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
40
40
|
'@atlaskit/design-system/prefer-primitives': 'warn',
|
|
41
41
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
42
|
+
'@atlaskit/design-system/use-cx-function-in-xcss': 'error',
|
|
42
43
|
'@atlaskit/design-system/use-datetime-picker-calendar-button': 'warn',
|
|
43
44
|
'@atlaskit/design-system/use-drawer-label': 'warn',
|
|
44
45
|
'@atlaskit/design-system/use-heading': '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::96ec2e315f96de68a6448317cce334ce>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -38,6 +38,7 @@ export default {
|
|
|
38
38
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
39
39
|
'@atlaskit/design-system/prefer-primitives': 'warn',
|
|
40
40
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
41
|
+
'@atlaskit/design-system/use-cx-function-in-xcss': 'error',
|
|
41
42
|
'@atlaskit/design-system/use-datetime-picker-calendar-button': 'warn',
|
|
42
43
|
'@atlaskit/design-system/use-drawer-label': 'warn',
|
|
43
44
|
'@atlaskit/design-system/use-heading': '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::4f6ee2ae56e1c0534f0f8e3fde314cc7>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -28,6 +28,7 @@ export default {
|
|
|
28
28
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
29
29
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
30
30
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
31
|
+
'@atlaskit/design-system/use-cx-function-in-xcss': 'error',
|
|
31
32
|
'@atlaskit/design-system/use-datetime-picker-calendar-button': 'warn',
|
|
32
33
|
'@atlaskit/design-system/use-drawer-label': 'warn',
|
|
33
34
|
'@atlaskit/design-system/use-heading-level-in-spotlight-card': '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::85c1f4ada9dac0f66e87e3734a36cb6b>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -27,6 +27,7 @@ export default {
|
|
|
27
27
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
28
28
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
29
29
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
30
|
+
'@atlaskit/design-system/use-cx-function-in-xcss': 'error',
|
|
30
31
|
'@atlaskit/design-system/use-datetime-picker-calendar-button': 'warn',
|
|
31
32
|
'@atlaskit/design-system/use-drawer-label': 'warn',
|
|
32
33
|
'@atlaskit/design-system/use-heading-level-in-spotlight-card': 'warn',
|
|
@@ -11,9 +11,19 @@ import { createLintRule } from '../utils/create-rule';
|
|
|
11
11
|
import { getFirstSupportedImport } from '../utils/get-first-supported-import';
|
|
12
12
|
import { getModuleOfIdentifier } from '../utils/get-import-node-by-source';
|
|
13
13
|
const isDOMElementName = elementName => elementName.charAt(0) !== elementName.charAt(0).toUpperCase() && elementName.charAt(0) === elementName.charAt(0).toLowerCase();
|
|
14
|
-
function isCssCallExpression(node, cssFunctions) {
|
|
14
|
+
function isCssCallExpression(node, cssFunctions, context) {
|
|
15
15
|
cssFunctions = [...cssFunctions, 'cssMap'];
|
|
16
|
-
|
|
16
|
+
if (!isNodeOfType(node, 'CallExpression') || !isNodeOfType(node.callee, 'Identifier')) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const module = getModuleOfIdentifier(getSourceCode(context), node.callee.name);
|
|
20
|
+
if (!module) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (!cssFunctions.includes(module.importName)) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return node.arguments.length > 0 && node.arguments[0].type === 'ObjectExpression';
|
|
17
27
|
}
|
|
18
28
|
function findSpreadProperties(node) {
|
|
19
29
|
return node.properties.filter(property => property.type === 'SpreadElement' ||
|
|
@@ -135,7 +145,7 @@ class JSXExpressionLinter {
|
|
|
135
145
|
});
|
|
136
146
|
return;
|
|
137
147
|
}
|
|
138
|
-
if (identifier.parent && identifier.parent.init && !isCssCallExpression(identifier.parent.init, this.configuration.cssFunctions)) {
|
|
148
|
+
if (identifier.parent && identifier.parent.init && !isCssCallExpression(identifier.parent.init, this.configuration.cssFunctions, this.context)) {
|
|
139
149
|
// When variable value is not of type css({})
|
|
140
150
|
const value = identifier.parent.init;
|
|
141
151
|
if (!value) {
|
|
@@ -429,7 +439,7 @@ class JSXExpressionLinter {
|
|
|
429
439
|
}
|
|
430
440
|
|
|
431
441
|
// Don't fix CallExpressions unless they're from cssFunctions or cssMap
|
|
432
|
-
if (expression.type === 'CallExpression' && !isCssCallExpression(expression, this.configuration.cssFunctions)) {
|
|
442
|
+
if (expression.type === 'CallExpression' && !isCssCallExpression(expression, this.configuration.cssFunctions, this.context)) {
|
|
433
443
|
return [];
|
|
434
444
|
}
|
|
435
445
|
if (expression.type === 'ObjectExpression') {
|
|
@@ -18,6 +18,7 @@ const defaultConfig = {
|
|
|
18
18
|
failSilently: false
|
|
19
19
|
};
|
|
20
20
|
const createWithConfig = initialConfig => context => {
|
|
21
|
+
// TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
|
|
21
22
|
const userConfig = context.options[0];
|
|
22
23
|
// merge configs
|
|
23
24
|
const config = {
|
|
@@ -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::66749852497ab0f2dc3214dd47aaf598>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
import consistentCssPropUsage from './consistent-css-prop-usage';
|
|
@@ -35,6 +35,7 @@ import noUnsafeStyleOverrides from './no-unsafe-style-overrides';
|
|
|
35
35
|
import noUnsupportedDragAndDropLibraries from './no-unsupported-drag-and-drop-libraries';
|
|
36
36
|
import preferPrimitives from './prefer-primitives';
|
|
37
37
|
import useButtonGroupLabel from './use-button-group-label';
|
|
38
|
+
import useCxFunctionInXcss from './use-cx-function-in-xcss';
|
|
38
39
|
import useDatetimePickerCalendarButton from './use-datetime-picker-calendar-button';
|
|
39
40
|
import useDrawerLabel from './use-drawer-label';
|
|
40
41
|
import useHeading from './use-heading';
|
|
@@ -85,6 +86,7 @@ export const rules = {
|
|
|
85
86
|
'no-unsupported-drag-and-drop-libraries': noUnsupportedDragAndDropLibraries,
|
|
86
87
|
'prefer-primitives': preferPrimitives,
|
|
87
88
|
'use-button-group-label': useButtonGroupLabel,
|
|
89
|
+
'use-cx-function-in-xcss': useCxFunctionInXcss,
|
|
88
90
|
'use-datetime-picker-calendar-button': useDatetimePickerCalendarButton,
|
|
89
91
|
'use-drawer-label': useDrawerLabel,
|
|
90
92
|
'use-heading': useHeading,
|
|
@@ -33,6 +33,8 @@ const rule = createLintRule({
|
|
|
33
33
|
create(context) {
|
|
34
34
|
var _context$options$;
|
|
35
35
|
const isIconBase = createIsFromImportSourceFor('@atlaskit/icon', '@atlaskit/icon/base');
|
|
36
|
+
|
|
37
|
+
// TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
|
|
36
38
|
const {
|
|
37
39
|
centralLocation = '',
|
|
38
40
|
failSilently = false
|
|
@@ -67,7 +67,9 @@ const rule = createLintRule({
|
|
|
67
67
|
var _context$options$;
|
|
68
68
|
// Get the rule configuration specified otherwise use default config.
|
|
69
69
|
// A bit confusing as it seems that the default options have precedence over the user specified options.
|
|
70
|
-
const deprecatedConfig =
|
|
70
|
+
const deprecatedConfig =
|
|
71
|
+
// TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
|
|
72
|
+
((_context$options$ = context.options[0]) === null || _context$options$ === void 0 ? void 0 : _context$options$.deprecatedConfig) || getConfig('jsxAttributes');
|
|
71
73
|
return {
|
|
72
74
|
// find JSX attribute - find name of attribute - get source and find relevant identifiers.
|
|
73
75
|
JSXAttribute(node) {
|
|
@@ -30,7 +30,9 @@ export const createChecks = context => {
|
|
|
30
30
|
importNames
|
|
31
31
|
}) {
|
|
32
32
|
var _context$options$;
|
|
33
|
-
const restrictedPathMessages =
|
|
33
|
+
const restrictedPathMessages =
|
|
34
|
+
// TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
|
|
35
|
+
((_context$options$ = context.options[0]) === null || _context$options$ === void 0 ? void 0 : _context$options$.deprecatedConfig) || getConfig('imports');
|
|
34
36
|
if (!isDeprecatedImportConfig(restrictedPathMessages)) {
|
|
35
37
|
throw new Error('Config is invalid for deprecated imports');
|
|
36
38
|
}
|
|
@@ -300,7 +300,9 @@ const getLiteralStringValue = value => {
|
|
|
300
300
|
}
|
|
301
301
|
return;
|
|
302
302
|
};
|
|
303
|
-
export const createHelpers =
|
|
303
|
+
export const createHelpers = ctx => {
|
|
304
|
+
// TODO: JFP-2823 - this type cast was added due to Jira's ESLint v9 migration
|
|
305
|
+
const context = ctx;
|
|
304
306
|
/**
|
|
305
307
|
* Extracts the token name of a token() call from a JSXExpressionContainer
|
|
306
308
|
* @param value The JSXExpressionContainer to extract the token call from
|