@atlaskit/eslint-plugin-design-system 7.0.1 → 7.0.3

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,17 @@
1
1
  # @atlaskit/eslint-plugin-design-system
2
2
 
3
+ ## 7.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`81c15e86b18`](https://bitbucket.org/atlassian/atlassian-frontend/commits/81c15e86b18) - Improved autofix for 50% border radius to shape token.
8
+
9
+ ## 7.0.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`50cf866a219`](https://bitbucket.org/atlassian/atlassian-frontend/commits/50cf866a219) - bump semver
14
+
3
15
  ## 7.0.1
4
16
 
5
17
  ### Patch Changes
@@ -15,16 +15,21 @@ var shapeProperties = ['borderTopLeftRadius', 'borderTopRightRadius', 'borderBot
15
15
  var borderSizeProperties = ['borderWidth', 'outlineWidth', 'borderRightWidth', 'borderLeftWidth', 'borderTopWidth', 'borderBottomWidth', 'borderInlineWidth', 'borderBlockWidth'];
16
16
  var radiusValueToToken = Object.fromEntries(_tokensRaw.shape.filter(function (t) {
17
17
  return t.name.startsWith('border.radius');
18
+ })
19
+ // we prefer using the default (border.radius) over its aliases
20
+ .filter(function (t) {
21
+ return !t.name.startsWith('border.radius.100');
18
22
  }).map(function (t) {
19
- var value = t.value === '4px' ? '3px' : t.value;
20
- return [value, t.name];
21
- }));
23
+ return [t.value, t.cleanName];
24
+ }).concat([['3px', 'border.radius']]) // add in an extra entry to resolve 3px to border.radius (normally 4px)
25
+ .concat([['50%', 'border.radius.circle']]) // add in an extra entry to resolve 50% to border.radius.circle (normally 2002rem)
26
+ );
22
27
  exports.radiusValueToToken = radiusValueToToken;
23
28
  var borderWidthValueToToken = Object.fromEntries(_tokensRaw.shape.filter(function (t) {
24
29
  return t.name.startsWith('border.width');
25
30
  }).map(function (t) {
26
- return [t.value, t.name];
27
- }));
31
+ return [t.value, t.cleanName];
32
+ }).concat([['2px', 'border.width']]));
28
33
  exports.borderWidthValueToToken = borderWidthValueToToken;
29
34
  function isRadiusProperty(propertyName) {
30
35
  return shapeProperties.includes(propertyName);
@@ -253,11 +253,14 @@ var getValueFromBinaryExpression = function getValueFromBinaryExpression(node, c
253
253
  return final;
254
254
  };
255
255
  var emRegex = /(.*\d+)em$/;
256
+ var percentageRegex = /(%$)/;
256
257
  var emToPixels = function emToPixels(value, fontSize) {
257
258
  if (typeof value === 'string') {
258
- var match = value.match(emRegex);
259
- if (match && typeof fontSize === 'number') {
260
- return Number(match[1]) * fontSize;
259
+ var emMatch = value.match(emRegex);
260
+ if (emMatch && typeof fontSize === 'number') {
261
+ return Number(emMatch[1]) * fontSize;
262
+ } else if (value.match(percentageRegex)) {
263
+ return value;
261
264
  } else {
262
265
  return null;
263
266
  }
@@ -273,7 +276,7 @@ var removePixelSuffix = function removePixelSuffix(value) {
273
276
  return Number(typeof value === 'string' ? value.replace('px', '') : value);
274
277
  };
275
278
  exports.removePixelSuffix = removePixelSuffix;
276
- var invalidSpacingUnitRegex = /(%$)|(\d+rem$)|(vw$)|(vh$)/;
279
+ var invalidSpacingUnitRegex = /(\d+rem$)|(vw$)|(vh$)/;
277
280
  var isValidSpacingValue = function isValidSpacingValue(value, fontSize) {
278
281
  if (typeof value === 'string') {
279
282
  if (invalidSpacingUnitRegex.test(value)) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-design-system",
3
- "version": "7.0.1",
3
+ "version": "7.0.3",
4
4
  "sideEffects": false
5
5
  }
@@ -2,11 +2,15 @@ import { isNodeOfType } from 'eslint-codemod-utils';
2
2
  import { shape as shapeTokens } from '@atlaskit/tokens/tokens-raw';
3
3
  const shapeProperties = ['borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomRightRadius', 'borderBottomLeftRadius', 'borderRadius'];
4
4
  const borderSizeProperties = ['borderWidth', 'outlineWidth', 'borderRightWidth', 'borderLeftWidth', 'borderTopWidth', 'borderBottomWidth', 'borderInlineWidth', 'borderBlockWidth'];
5
- export const radiusValueToToken = Object.fromEntries(shapeTokens.filter(t => t.name.startsWith('border.radius')).map(t => {
6
- const value = t.value === '4px' ? '3px' : t.value;
7
- return [value, t.name];
8
- }));
9
- export const borderWidthValueToToken = Object.fromEntries(shapeTokens.filter(t => t.name.startsWith('border.width')).map(t => [t.value, t.name]));
5
+ export const radiusValueToToken = Object.fromEntries(shapeTokens.filter(t => t.name.startsWith('border.radius'))
6
+ // we prefer using the default (border.radius) over its aliases
7
+ .filter(t => !t.name.startsWith('border.radius.100')).map(t => {
8
+ return [t.value, t.cleanName];
9
+ }).concat([['3px', 'border.radius']]) // add in an extra entry to resolve 3px to border.radius (normally 4px)
10
+ .concat([['50%', 'border.radius.circle']]) // add in an extra entry to resolve 50% to border.radius.circle (normally 2002rem)
11
+ );
12
+
13
+ export const borderWidthValueToToken = Object.fromEntries(shapeTokens.filter(t => t.name.startsWith('border.width')).map(t => [t.value, t.cleanName]).concat([['2px', 'border.width']]));
10
14
  export function isRadiusProperty(propertyName) {
11
15
  return shapeProperties.includes(propertyName);
12
16
  }
@@ -211,11 +211,14 @@ const getValueFromBinaryExpression = (node, context) => {
211
211
  return final;
212
212
  };
213
213
  const emRegex = /(.*\d+)em$/;
214
+ const percentageRegex = /(%$)/;
214
215
  export const emToPixels = (value, fontSize) => {
215
216
  if (typeof value === 'string') {
216
- const match = value.match(emRegex);
217
- if (match && typeof fontSize === 'number') {
218
- return Number(match[1]) * fontSize;
217
+ const emMatch = value.match(emRegex);
218
+ if (emMatch && typeof fontSize === 'number') {
219
+ return Number(emMatch[1]) * fontSize;
220
+ } else if (value.match(percentageRegex)) {
221
+ return value;
219
222
  } else {
220
223
  return null;
221
224
  }
@@ -229,7 +232,7 @@ export const removePixelSuffix = value => {
229
232
  }
230
233
  return Number(typeof value === 'string' ? value.replace('px', '') : value);
231
234
  };
232
- const invalidSpacingUnitRegex = /(%$)|(\d+rem$)|(vw$)|(vh$)/;
235
+ const invalidSpacingUnitRegex = /(\d+rem$)|(vw$)|(vh$)/;
233
236
  export const isValidSpacingValue = (value, fontSize) => {
234
237
  if (typeof value === 'string') {
235
238
  if (invalidSpacingUnitRegex.test(value)) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-design-system",
3
- "version": "7.0.1",
3
+ "version": "7.0.3",
4
4
  "sideEffects": false
5
5
  }
@@ -4,15 +4,21 @@ var shapeProperties = ['borderTopLeftRadius', 'borderTopRightRadius', 'borderBot
4
4
  var borderSizeProperties = ['borderWidth', 'outlineWidth', 'borderRightWidth', 'borderLeftWidth', 'borderTopWidth', 'borderBottomWidth', 'borderInlineWidth', 'borderBlockWidth'];
5
5
  export var radiusValueToToken = Object.fromEntries(shapeTokens.filter(function (t) {
6
6
  return t.name.startsWith('border.radius');
7
+ })
8
+ // we prefer using the default (border.radius) over its aliases
9
+ .filter(function (t) {
10
+ return !t.name.startsWith('border.radius.100');
7
11
  }).map(function (t) {
8
- var value = t.value === '4px' ? '3px' : t.value;
9
- return [value, t.name];
10
- }));
12
+ return [t.value, t.cleanName];
13
+ }).concat([['3px', 'border.radius']]) // add in an extra entry to resolve 3px to border.radius (normally 4px)
14
+ .concat([['50%', 'border.radius.circle']]) // add in an extra entry to resolve 50% to border.radius.circle (normally 2002rem)
15
+ );
16
+
11
17
  export var borderWidthValueToToken = Object.fromEntries(shapeTokens.filter(function (t) {
12
18
  return t.name.startsWith('border.width');
13
19
  }).map(function (t) {
14
- return [t.value, t.name];
15
- }));
20
+ return [t.value, t.cleanName];
21
+ }).concat([['2px', 'border.width']]));
16
22
  export function isRadiusProperty(propertyName) {
17
23
  return shapeProperties.includes(propertyName);
18
24
  }
@@ -219,11 +219,14 @@ var getValueFromBinaryExpression = function getValueFromBinaryExpression(node, c
219
219
  return final;
220
220
  };
221
221
  var emRegex = /(.*\d+)em$/;
222
+ var percentageRegex = /(%$)/;
222
223
  export var emToPixels = function emToPixels(value, fontSize) {
223
224
  if (typeof value === 'string') {
224
- var match = value.match(emRegex);
225
- if (match && typeof fontSize === 'number') {
226
- return Number(match[1]) * fontSize;
225
+ var emMatch = value.match(emRegex);
226
+ if (emMatch && typeof fontSize === 'number') {
227
+ return Number(emMatch[1]) * fontSize;
228
+ } else if (value.match(percentageRegex)) {
229
+ return value;
227
230
  } else {
228
231
  return null;
229
232
  }
@@ -237,7 +240,7 @@ export var removePixelSuffix = function removePixelSuffix(value) {
237
240
  }
238
241
  return Number(typeof value === 'string' ? value.replace('px', '') : value);
239
242
  };
240
- var invalidSpacingUnitRegex = /(%$)|(\d+rem$)|(vw$)|(vh$)/;
243
+ var invalidSpacingUnitRegex = /(\d+rem$)|(vw$)|(vh$)/;
241
244
  export var isValidSpacingValue = function isValidSpacingValue(value, fontSize) {
242
245
  if (typeof value === 'string') {
243
246
  if (invalidSpacingUnitRegex.test(value)) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-design-system",
3
- "version": "7.0.1",
3
+ "version": "7.0.3",
4
4
  "sideEffects": false
5
5
  }
@@ -1,10 +1,6 @@
1
1
  import { EslintNode } from 'eslint-codemod-utils';
2
- export declare const radiusValueToToken: {
3
- [k: string]: string;
4
- };
5
- export declare const borderWidthValueToToken: {
6
- [k: string]: string;
7
- };
2
+ export declare const radiusValueToToken: any;
3
+ export declare const borderWidthValueToToken: any;
8
4
  export declare function isRadiusProperty(propertyName: string): boolean;
9
5
  export declare function isBorderSizeProperty(propertyName: string): boolean;
10
6
  export declare function isShapeProperty(propertyName: string): boolean;
@@ -1,10 +1,6 @@
1
1
  import { EslintNode } from 'eslint-codemod-utils';
2
- export declare const radiusValueToToken: {
3
- [k: string]: string;
4
- };
5
- export declare const borderWidthValueToToken: {
6
- [k: string]: string;
7
- };
2
+ export declare const radiusValueToToken: any;
3
+ export declare const borderWidthValueToToken: any;
8
4
  export declare function isRadiusProperty(propertyName: string): boolean;
9
5
  export declare function isBorderSizeProperty(propertyName: string): boolean;
10
6
  export declare function isShapeProperty(propertyName: string): boolean;
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": "7.0.1",
4
+ "version": "7.0.3",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "publishConfig": {
7
7
  "registry": "https://registry.npmjs.org/"
@@ -33,12 +33,12 @@
33
33
  ".": "./src/index.tsx"
34
34
  },
35
35
  "dependencies": {
36
- "@atlaskit/tokens": "^1.10.0",
36
+ "@atlaskit/tokens": "^1.11.0",
37
37
  "@babel/runtime": "^7.0.0",
38
38
  "@typescript-eslint/utils": "^5.48.1",
39
39
  "ajv": "^6.12.6",
40
40
  "eslint-codemod-utils": "^1.8.6",
41
- "semver": "^7.3.0"
41
+ "semver": "^7.5.2"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@atlaskit/ds-lib": "^2.2.0",