@atlaskit/eslint-plugin-design-system 8.28.0 → 8.29.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 +6 -0
- package/dist/cjs/rules/use-primitives/transformers/css-to-xcss.js +17 -3
- package/dist/cjs/rules/use-primitives/utils/is-valid-css-properties-to-transform.js +7 -0
- package/dist/es2019/rules/use-primitives/transformers/css-to-xcss.js +13 -1
- package/dist/es2019/rules/use-primitives/utils/is-valid-css-properties-to-transform.js +6 -1
- package/dist/esm/rules/use-primitives/transformers/css-to-xcss.js +16 -2
- package/dist/esm/rules/use-primitives/utils/is-valid-css-properties-to-transform.js +8 -1
- package/dist/types/rules/use-primitives/config/index.d.ts +1 -1
- package/dist/types/rules/use-primitives/transformers/css-to-xcss.d.ts +6 -0
- package/dist/types-ts4.5/rules/use-primitives/config/index.d.ts +1 -1
- package/dist/types-ts4.5/rules/use-primitives/transformers/css-to-xcss.d.ts +6 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 8.29.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#74069](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/74069) [`9bdcd6529453`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9bdcd6529453) - Allow use-primitives linting rule to lint style declarations with dimension properties.
|
|
8
|
+
|
|
3
9
|
## 8.28.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -4,10 +4,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.supportedStylesMap = exports.styledObjectToXcssTokens = exports.spaceTokenMap = exports.cssToXcssTransformer = void 0;
|
|
7
|
+
exports.supportedStylesMap = exports.supportedDimensionAttributesMap = exports.styledObjectToXcssTokens = exports.spaceTokenMap = exports.dimensionsMap = exports.cssToXcssTransformer = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
10
|
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
10
11
|
var _utils = require("../utils");
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
11
14
|
var cssToXcssTransformer = exports.cssToXcssTransformer = function cssToXcssTransformer(node, context, fixer) {
|
|
12
15
|
/**
|
|
13
16
|
* Note: The logic here is very similar to the logic in `shouldSuggestBox`. i.e.
|
|
@@ -90,7 +93,18 @@ var spaceTokenMap = exports.spaceTokenMap = {
|
|
|
90
93
|
'64px': 'space.800',
|
|
91
94
|
'80px': 'space.1000'
|
|
92
95
|
};
|
|
93
|
-
var
|
|
96
|
+
var dimensionsMap = exports.dimensionsMap = {
|
|
97
|
+
'100%': '100%'
|
|
98
|
+
};
|
|
99
|
+
var supportedDimensionAttributesMap = exports.supportedDimensionAttributesMap = {
|
|
100
|
+
width: dimensionsMap,
|
|
101
|
+
height: dimensionsMap,
|
|
102
|
+
minWidth: dimensionsMap,
|
|
103
|
+
minHeight: dimensionsMap,
|
|
104
|
+
maxWidth: dimensionsMap,
|
|
105
|
+
maxHeight: dimensionsMap
|
|
106
|
+
};
|
|
107
|
+
var supportedStylesMap = exports.supportedStylesMap = _objectSpread({
|
|
94
108
|
padding: spaceTokenMap,
|
|
95
109
|
paddingBlock: spaceTokenMap,
|
|
96
110
|
paddingBlockEnd: spaceTokenMap,
|
|
@@ -113,4 +127,4 @@ var supportedStylesMap = exports.supportedStylesMap = {
|
|
|
113
127
|
marginLeft: spaceTokenMap,
|
|
114
128
|
marginRight: spaceTokenMap,
|
|
115
129
|
marginTop: spaceTokenMap
|
|
116
|
-
};
|
|
130
|
+
}, supportedDimensionAttributesMap);
|
|
@@ -50,6 +50,13 @@ var isValidCssPropertiesToTransform = exports.isValidCssPropertiesToTransform =
|
|
|
50
50
|
return false;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
// Short-circuit when dimension properties found but pattern is not enabled in config
|
|
54
|
+
if (!config.patterns.includes('dimension-properties') && Object.keys(cssObject).some(function (attribute) {
|
|
55
|
+
return _cssToXcss.supportedDimensionAttributesMap[attribute];
|
|
56
|
+
})) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
|
|
53
60
|
// NOTE: Our approach with this lint rule is to strictly whitelist css properties we can map.
|
|
54
61
|
// It means we have to provide mappings for everything (e.g. `display: block`).
|
|
55
62
|
// However, from a maker's experience, it's much better that the rule doesn't report (if we miss a mapping)
|
|
@@ -82,6 +82,17 @@ export const spaceTokenMap = {
|
|
|
82
82
|
'64px': 'space.800',
|
|
83
83
|
'80px': 'space.1000'
|
|
84
84
|
};
|
|
85
|
+
export const dimensionsMap = {
|
|
86
|
+
'100%': '100%'
|
|
87
|
+
};
|
|
88
|
+
export const supportedDimensionAttributesMap = {
|
|
89
|
+
width: dimensionsMap,
|
|
90
|
+
height: dimensionsMap,
|
|
91
|
+
minWidth: dimensionsMap,
|
|
92
|
+
minHeight: dimensionsMap,
|
|
93
|
+
maxWidth: dimensionsMap,
|
|
94
|
+
maxHeight: dimensionsMap
|
|
95
|
+
};
|
|
85
96
|
export const supportedStylesMap = {
|
|
86
97
|
padding: spaceTokenMap,
|
|
87
98
|
paddingBlock: spaceTokenMap,
|
|
@@ -104,5 +115,6 @@ export const supportedStylesMap = {
|
|
|
104
115
|
marginInlineStart: spaceTokenMap,
|
|
105
116
|
marginLeft: spaceTokenMap,
|
|
106
117
|
marginRight: spaceTokenMap,
|
|
107
|
-
marginTop: spaceTokenMap
|
|
118
|
+
marginTop: spaceTokenMap,
|
|
119
|
+
...supportedDimensionAttributesMap
|
|
108
120
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
2
|
import * as ast from '../../../ast-nodes';
|
|
3
|
-
import { supportedStylesMap } from '../transformers/css-to-xcss';
|
|
3
|
+
import { supportedDimensionAttributesMap, supportedStylesMap } from '../transformers/css-to-xcss';
|
|
4
4
|
import { convertASTObjectExpressionToJSObject } from './convert-ast-object-expression-to-js-object';
|
|
5
5
|
export const isValidCssPropertiesToTransform = (node, config) => {
|
|
6
6
|
if (!node) {
|
|
@@ -36,6 +36,11 @@ export const isValidCssPropertiesToTransform = (node, config) => {
|
|
|
36
36
|
return false;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
// Short-circuit when dimension properties found but pattern is not enabled in config
|
|
40
|
+
if (!config.patterns.includes('dimension-properties') && Object.keys(cssObject).some(attribute => supportedDimensionAttributesMap[attribute])) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
39
44
|
// NOTE: Our approach with this lint rule is to strictly whitelist css properties we can map.
|
|
40
45
|
// It means we have to provide mappings for everything (e.g. `display: block`).
|
|
41
46
|
// However, from a maker's experience, it's much better that the rule doesn't report (if we miss a mapping)
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
+
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; }
|
|
4
|
+
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) { _defineProperty(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; }
|
|
2
5
|
import { getIdentifierInParentScope, identifier, isNodeOfType, literal } from 'eslint-codemod-utils';
|
|
3
6
|
import { getAttributeValueIdentifier, getFunctionArgumentAtPos, getJSXAttributeByName, getVariableDefinitionValue } from '../utils';
|
|
4
7
|
export var cssToXcssTransformer = function cssToXcssTransformer(node, context, fixer) {
|
|
@@ -83,7 +86,18 @@ export var spaceTokenMap = {
|
|
|
83
86
|
'64px': 'space.800',
|
|
84
87
|
'80px': 'space.1000'
|
|
85
88
|
};
|
|
86
|
-
export var
|
|
89
|
+
export var dimensionsMap = {
|
|
90
|
+
'100%': '100%'
|
|
91
|
+
};
|
|
92
|
+
export var supportedDimensionAttributesMap = {
|
|
93
|
+
width: dimensionsMap,
|
|
94
|
+
height: dimensionsMap,
|
|
95
|
+
minWidth: dimensionsMap,
|
|
96
|
+
minHeight: dimensionsMap,
|
|
97
|
+
maxWidth: dimensionsMap,
|
|
98
|
+
maxHeight: dimensionsMap
|
|
99
|
+
};
|
|
100
|
+
export var supportedStylesMap = _objectSpread({
|
|
87
101
|
padding: spaceTokenMap,
|
|
88
102
|
paddingBlock: spaceTokenMap,
|
|
89
103
|
paddingBlockEnd: spaceTokenMap,
|
|
@@ -106,4 +120,4 @@ export var supportedStylesMap = {
|
|
|
106
120
|
marginLeft: spaceTokenMap,
|
|
107
121
|
marginRight: spaceTokenMap,
|
|
108
122
|
marginTop: spaceTokenMap
|
|
109
|
-
};
|
|
123
|
+
}, supportedDimensionAttributesMap);
|
|
@@ -3,7 +3,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
|
|
|
3
3
|
var _excluded = ["unsupported"];
|
|
4
4
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
5
5
|
import * as ast from '../../../ast-nodes';
|
|
6
|
-
import { supportedStylesMap } from '../transformers/css-to-xcss';
|
|
6
|
+
import { supportedDimensionAttributesMap, supportedStylesMap } from '../transformers/css-to-xcss';
|
|
7
7
|
import { convertASTObjectExpressionToJSObject } from './convert-ast-object-expression-to-js-object';
|
|
8
8
|
export var isValidCssPropertiesToTransform = function isValidCssPropertiesToTransform(node, config) {
|
|
9
9
|
if (!node) {
|
|
@@ -40,6 +40,13 @@ export var isValidCssPropertiesToTransform = function isValidCssPropertiesToTran
|
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
// Short-circuit when dimension properties found but pattern is not enabled in config
|
|
44
|
+
if (!config.patterns.includes('dimension-properties') && Object.keys(cssObject).some(function (attribute) {
|
|
45
|
+
return supportedDimensionAttributesMap[attribute];
|
|
46
|
+
})) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
43
50
|
// NOTE: Our approach with this lint rule is to strictly whitelist css properties we can map.
|
|
44
51
|
// It means we have to provide mappings for everything (e.g. `display: block`).
|
|
45
52
|
// However, from a maker's experience, it's much better that the rule doesn't report (if we miss a mapping)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type Pattern = 'compiled-css-function' | 'compiled-styled-object' | 'css-template-literal' | 'css-property-with-tokens' | 'css-property-multiple-values' | 'multiple-properties';
|
|
1
|
+
type Pattern = 'compiled-css-function' | 'compiled-styled-object' | 'css-template-literal' | 'css-property-with-tokens' | 'css-property-multiple-values' | 'multiple-properties' | 'dimension-properties';
|
|
2
2
|
export interface RuleConfig {
|
|
3
3
|
patterns: Pattern[];
|
|
4
4
|
}
|
|
@@ -5,6 +5,12 @@ export declare const styledObjectToXcssTokens: (styles: ObjectExpression & Parti
|
|
|
5
5
|
export declare const spaceTokenMap: {
|
|
6
6
|
[key: string]: string;
|
|
7
7
|
};
|
|
8
|
+
export declare const dimensionsMap: {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const supportedDimensionAttributesMap: {
|
|
12
|
+
[key: string]: typeof spaceTokenMap;
|
|
13
|
+
};
|
|
8
14
|
export declare const supportedStylesMap: {
|
|
9
15
|
[key: string]: typeof spaceTokenMap;
|
|
10
16
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type Pattern = 'compiled-css-function' | 'compiled-styled-object' | 'css-template-literal' | 'css-property-with-tokens' | 'css-property-multiple-values' | 'multiple-properties';
|
|
1
|
+
type Pattern = 'compiled-css-function' | 'compiled-styled-object' | 'css-template-literal' | 'css-property-with-tokens' | 'css-property-multiple-values' | 'multiple-properties' | 'dimension-properties';
|
|
2
2
|
export interface RuleConfig {
|
|
3
3
|
patterns: Pattern[];
|
|
4
4
|
}
|
|
@@ -5,6 +5,12 @@ export declare const styledObjectToXcssTokens: (styles: ObjectExpression & Parti
|
|
|
5
5
|
export declare const spaceTokenMap: {
|
|
6
6
|
[key: string]: string;
|
|
7
7
|
};
|
|
8
|
+
export declare const dimensionsMap: {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const supportedDimensionAttributesMap: {
|
|
12
|
+
[key: string]: typeof spaceTokenMap;
|
|
13
|
+
};
|
|
8
14
|
export declare const supportedStylesMap: {
|
|
9
15
|
[key: string]: typeof spaceTokenMap;
|
|
10
16
|
};
|
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": "8.
|
|
4
|
+
"version": "8.29.0",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"registry": "https://registry.npmjs.org/"
|