@atlaskit/eslint-plugin-design-system 8.2.0 → 8.2.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,18 @@
1
1
  # @atlaskit/eslint-plugin-design-system
2
2
 
3
+ ## 8.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1859bc0b8c7`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1859bc0b8c7) - Update the casing on `xcss` to ensure consistency with the API and package consumption.
8
+
9
+ ## 8.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`52b35a6b571`](https://bitbucket.org/atlassian/atlassian-frontend/commits/52b35a6b571) - - Fixed an issue where the `ensure-design-token-usage` rule may incorrectly report variables that reference tokens as an error.
14
+ - Fixed an issue where the `ensure-design-token-usage` rule may handle expressions that span multiple lines in template literals incorrectly.
15
+
3
16
  ## 8.2.0
4
17
 
5
18
  ### Minor Changes
package/README.md CHANGED
@@ -49,7 +49,7 @@ module.exports = {
49
49
 
50
50
  | Rule | Description | Recommended | Fixable | Suggestions |
51
51
  | ------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------- | ------- | ----------- |
52
- | <a href="./src/rules/consistent-css-prop-usage/README.md">consistent-css-prop-usage</a> | Ensures consistency with CSS and xCSS prop usages | Yes | Yes | |
52
+ | <a href="./src/rules/consistent-css-prop-usage/README.md">consistent-css-prop-usage</a> | Ensures consistency with CSS and xcss prop usages | Yes | Yes | |
53
53
  | <a href="./src/rules/ensure-design-token-usage/README.md">ensure-design-token-usage</a> | Enforces usage of design tokens rather than hard-coded values. | Yes | Yes | Yes |
54
54
  | <a href="./src/rules/ensure-design-token-usage-preview/README.md">ensure-design-token-usage/preview</a> | Enforces usage of pre-release design tokens rather than hard-coded values. | | Yes | Yes |
55
55
  | <a href="./src/rules/icon-label/README.md">icon-label</a> | Enforces accessible usage of icon labels when composed with Atlassian Design System components. | Yes | Yes | |
@@ -13,7 +13,7 @@ This plugin contains rules that should be used when working with the [Atlassian
13
13
 
14
14
  | Rule | Description | Recommended | Fixable | Suggestions |
15
15
  | ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------- | ------- | ----------- |
16
- | <a href="#consistent-css-prop-usage">consistent-css-prop-usage</a> | Ensures consistency with CSS and xCSS prop usages | Yes | Yes | |
16
+ | <a href="#consistent-css-prop-usage">consistent-css-prop-usage</a> | Ensures consistency with CSS and xcss prop usages | Yes | Yes | |
17
17
  | <a href="#ensure-design-token-usage">ensure-design-token-usage</a> | Enforces usage of design tokens rather than hard-coded values. | Yes | Yes | Yes |
18
18
  | <a href="#ensure-design-token-usage-preview">ensure-design-token-usage/preview</a> | Enforces usage of pre-release design tokens rather than hard-coded values. | | Yes | Yes |
19
19
  | <a href="#icon-label">icon-label</a> | Enforces accessible usage of icon labels when composed with Atlassian Design System components. | Yes | Yes | |
@@ -111,7 +111,7 @@ var rule = (0, _createRule.createLintRule)({
111
111
  meta: {
112
112
  name: 'consistent-css-prop-usage',
113
113
  docs: {
114
- description: 'Ensures consistency with CSS and xCSS prop usages',
114
+ description: 'Ensures consistency with CSS and xcss prop usages',
115
115
  url: 'https://developer.atlassian.com/cloud/framework/atlassian-frontend/development/styling',
116
116
  recommended: true,
117
117
  severity: 'error'
@@ -168,6 +168,9 @@ var createWithConfig = function createWithConfig(initialConfig) {
168
168
  numericOrNanValue = _ref4[0],
169
169
  pxValue = _ref4[1],
170
170
  originalValue = _ref4[2];
171
+ if (!originalValue) {
172
+ return originalValue;
173
+ }
171
174
  if ((0, _spacingUtils.isTokenValueString)(originalValue)) {
172
175
  // if the value is already valid, nothing to report or replace
173
176
  return originalValue;
@@ -150,7 +150,7 @@ var getRawExpression = function getRawExpression(node, context) {
150
150
  var _node$range = (0, _slicedToArray2.default)(node.range, 2),
151
151
  start = _node$range[0],
152
152
  end = _node$range[1];
153
- return context.getSourceCode().getText().substring(start, end);
153
+ return context.getSourceCode().getText().substring(start, end).replaceAll('\n', '');
154
154
  };
155
155
  exports.getRawExpression = getRawExpression;
156
156
  var getValueFromIdentifier = function getValueFromIdentifier(node, context) {
@@ -456,7 +456,6 @@ function getFontSizeValueInScope(cssProperties) {
456
456
  /**
457
457
  * Attempts to remove all non-essential words & characters from a style block.
458
458
  * Including selectors and queries
459
- * Adapted from ensure-design-token-usage
460
459
  * @param styleString string of css properties
461
460
  */
462
461
  function splitCssProperties(styleString) {
@@ -31,6 +31,11 @@ var lintObjectForSpacing = function lintObjectForSpacing(node, context, ruleConf
31
31
  var isFontFamily = /fontFamily/.test(propertyName);
32
32
  var value = (0, _spacingUtils.getValue)(node.value, context);
33
33
 
34
+ // Value is a token string (e.g. set via a variable)
35
+ if (typeof value === 'string' && /\${token\(.*\)}/.test(value)) {
36
+ return;
37
+ }
38
+
34
39
  // value is either NaN or it can't be resolved (e.g. em, 100% etc...)
35
40
  if (!(value && (0, _spacingUtils.isValidSpacingValue)(value, fontSize))) {
36
41
  return context.report({
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-design-system",
3
- "version": "8.2.0",
3
+ "version": "8.2.2",
4
4
  "sideEffects": false
5
5
  }
@@ -97,7 +97,7 @@ const rule = createLintRule({
97
97
  meta: {
98
98
  name: 'consistent-css-prop-usage',
99
99
  docs: {
100
- description: 'Ensures consistency with CSS and xCSS prop usages',
100
+ description: 'Ensures consistency with CSS and xcss prop usages',
101
101
  url: 'https://developer.atlassian.com/cloud/framework/atlassian-frontend/development/styling',
102
102
  recommended: true,
103
103
  severity: 'error'
@@ -136,6 +136,9 @@ const createWithConfig = initialConfig => context => {
136
136
  .map((value, index) => [
137
137
  // if emToPX conversion fails we'll default to original value
138
138
  emToPixels(value, globalFontSize) || value, processedValues[index], originalValues[index]]).map(([numericOrNanValue, pxValue, originalValue]) => {
139
+ if (!originalValue) {
140
+ return originalValue;
141
+ }
139
142
  if (isTokenValueString(originalValue)) {
140
143
  // if the value is already valid, nothing to report or replace
141
144
  return originalValue;
@@ -111,7 +111,7 @@ export const getRawExpression = (node, context) => {
111
111
  return null;
112
112
  }
113
113
  const [start, end] = node.range;
114
- return context.getSourceCode().getText().substring(start, end);
114
+ return context.getSourceCode().getText().substring(start, end).replaceAll('\n', '');
115
115
  };
116
116
  const getValueFromIdentifier = (node, context) => {
117
117
  if (!isNodeOfType(node, 'Identifier')) {
@@ -398,7 +398,6 @@ export function getFontSizeValueInScope(cssProperties) {
398
398
  /**
399
399
  * Attempts to remove all non-essential words & characters from a style block.
400
400
  * Including selectors and queries
401
- * Adapted from ensure-design-token-usage
402
401
  * @param styleString string of css properties
403
402
  */
404
403
  export function splitCssProperties(styleString) {
@@ -20,6 +20,11 @@ export const lintObjectForSpacing = (node, context, ruleConfig, fontSize, tokenN
20
20
  const isFontFamily = /fontFamily/.test(propertyName);
21
21
  const value = getValue(node.value, context);
22
22
 
23
+ // Value is a token string (e.g. set via a variable)
24
+ if (typeof value === 'string' && /\${token\(.*\)}/.test(value)) {
25
+ return;
26
+ }
27
+
23
28
  // value is either NaN or it can't be resolved (e.g. em, 100% etc...)
24
29
  if (!(value && isValidSpacingValue(value, fontSize))) {
25
30
  return context.report({
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-design-system",
3
- "version": "8.2.0",
3
+ "version": "8.2.2",
4
4
  "sideEffects": false
5
5
  }
@@ -104,7 +104,7 @@ var rule = createLintRule({
104
104
  meta: {
105
105
  name: 'consistent-css-prop-usage',
106
106
  docs: {
107
- description: 'Ensures consistency with CSS and xCSS prop usages',
107
+ description: 'Ensures consistency with CSS and xcss prop usages',
108
108
  url: 'https://developer.atlassian.com/cloud/framework/atlassian-frontend/development/styling',
109
109
  recommended: true,
110
110
  severity: 'error'
@@ -161,6 +161,9 @@ var createWithConfig = function createWithConfig(initialConfig) {
161
161
  numericOrNanValue = _ref4[0],
162
162
  pxValue = _ref4[1],
163
163
  originalValue = _ref4[2];
164
+ if (!originalValue) {
165
+ return originalValue;
166
+ }
164
167
  if (isTokenValueString(originalValue)) {
165
168
  // if the value is already valid, nothing to report or replace
166
169
  return originalValue;
@@ -120,7 +120,7 @@ export var getRawExpression = function getRawExpression(node, context) {
120
120
  var _node$range = _slicedToArray(node.range, 2),
121
121
  start = _node$range[0],
122
122
  end = _node$range[1];
123
- return context.getSourceCode().getText().substring(start, end);
123
+ return context.getSourceCode().getText().substring(start, end).replaceAll('\n', '');
124
124
  };
125
125
  var getValueFromIdentifier = function getValueFromIdentifier(node, context) {
126
126
  if (!isNodeOfType(node, 'Identifier')) {
@@ -417,7 +417,6 @@ export function getFontSizeValueInScope(cssProperties) {
417
417
  /**
418
418
  * Attempts to remove all non-essential words & characters from a style block.
419
419
  * Including selectors and queries
420
- * Adapted from ensure-design-token-usage
421
420
  * @param styleString string of css properties
422
421
  */
423
422
  export function splitCssProperties(styleString) {
@@ -24,6 +24,11 @@ export var lintObjectForSpacing = function lintObjectForSpacing(node, context, r
24
24
  var isFontFamily = /fontFamily/.test(propertyName);
25
25
  var value = getValue(node.value, context);
26
26
 
27
+ // Value is a token string (e.g. set via a variable)
28
+ if (typeof value === 'string' && /\${token\(.*\)}/.test(value)) {
29
+ return;
30
+ }
31
+
27
32
  // value is either NaN or it can't be resolved (e.g. em, 100% etc...)
28
33
  if (!(value && isValidSpacingValue(value, fontSize))) {
29
34
  return context.report({
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-design-system",
3
- "version": "8.2.0",
3
+ "version": "8.2.2",
4
4
  "sideEffects": false
5
5
  }
@@ -77,7 +77,6 @@ export declare function getFontSizeValueInScope(cssProperties: ProcessedCSSLines
77
77
  /**
78
78
  * Attempts to remove all non-essential words & characters from a style block.
79
79
  * Including selectors and queries
80
- * Adapted from ensure-design-token-usage
81
80
  * @param styleString string of css properties
82
81
  */
83
82
  export declare function splitCssProperties(styleString: string): string[];
@@ -80,7 +80,6 @@ export declare function getFontSizeValueInScope(cssProperties: ProcessedCSSLines
80
80
  /**
81
81
  * Attempts to remove all non-essential words & characters from a style block.
82
82
  * Including selectors and queries
83
- * Adapted from ensure-design-token-usage
84
83
  * @param styleString string of css properties
85
84
  */
86
85
  export declare function splitCssProperties(styleString: string): string[];
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.2.0",
4
+ "version": "8.2.2",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "publishConfig": {
7
7
  "registry": "https://registry.npmjs.org/"