@atlaskit/eslint-plugin-design-system 8.0.0 → 8.0.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 +12 -0
- package/dist/cjs/rules/ensure-design-token-usage/index.js +1 -8
- package/dist/cjs/rules/ensure-design-token-usage/spacing-utils.js +1 -3
- package/dist/cjs/rules/ensure-design-token-usage/spacing.js +1 -2
- package/dist/cjs/rules/utils/is-node.js +8 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/rules/ensure-design-token-usage/index.js +2 -8
- package/dist/es2019/rules/ensure-design-token-usage/spacing-utils.js +0 -1
- package/dist/es2019/rules/ensure-design-token-usage/spacing.js +3 -4
- package/dist/es2019/rules/utils/is-node.js +6 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/rules/ensure-design-token-usage/index.js +2 -9
- package/dist/esm/rules/ensure-design-token-usage/spacing-utils.js +0 -1
- package/dist/esm/rules/ensure-design-token-usage/spacing.js +3 -4
- package/dist/esm/rules/utils/is-node.js +8 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/rules/ensure-design-token-usage/spacing-utils.d.ts +0 -1
- package/dist/types-ts4.5/rules/ensure-design-token-usage/spacing-utils.d.ts +0 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 8.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`05a00999956`](https://bitbucket.org/atlassian/atlassian-frontend/commits/05a00999956) - `TODO` comments are no longer added when applying a spacing fix from `ensure-design-token-usage`.
|
|
8
|
+
|
|
9
|
+
## 8.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`278fb6833be`](https://bitbucket.org/atlassian/atlassian-frontend/commits/278fb6833be) - The `ensure-design-token-usage` rule no longer lints against styles inside `xcss` as it already has type-safety built in for properties that accept tokens.
|
|
14
|
+
|
|
3
15
|
## 8.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
|
@@ -107,7 +107,6 @@ var createWithConfig = function createWithConfig(initialConfig) {
|
|
|
107
107
|
// if we can't get a processed css we bail
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
|
-
var parentNode = (0, _spacingUtils.findParentNodeForLine)(node);
|
|
111
110
|
var globalFontSize = (0, _spacingUtils.getFontSizeValueInScope)(processedCssLines);
|
|
112
111
|
var textForSource = context.getSourceCode().getText(node.quasi);
|
|
113
112
|
var allReplacedValues = [];
|
|
@@ -219,17 +218,11 @@ var createWithConfig = function createWithConfig(initialConfig) {
|
|
|
219
218
|
if (completeSource !== textForSource) {
|
|
220
219
|
// means we found some replacement values, we'll give the option to fix them
|
|
221
220
|
|
|
222
|
-
var replacementComments = "".concat(allReplacedValues.map(function (replacedProperties) {
|
|
223
|
-
var _replacedProperties = (0, _slicedToArray2.default)(replacedProperties, 1),
|
|
224
|
-
propertyName = _replacedProperties[0];
|
|
225
|
-
var replacedValues = replacedProperties.slice(1).join(' ');
|
|
226
|
-
return "".concat(_spacingUtils.replacementComment, " `").concat(propertyName, ": ").concat(replacedValues, "`");
|
|
227
|
-
}).join('\n'), "\n");
|
|
228
221
|
context.report({
|
|
229
222
|
node: node,
|
|
230
223
|
messageId: 'autofixesPossible',
|
|
231
224
|
fix: function fix(fixer) {
|
|
232
|
-
return (!tokenNode && config.applyImport ? [(0, _spacingUtils.insertTokensImport)(fixer)] : []).concat([fixer.
|
|
225
|
+
return (!tokenNode && config.applyImport ? [(0, _spacingUtils.insertTokensImport)(fixer)] : []).concat([fixer.replaceText(node.quasi, completeSource)]);
|
|
233
226
|
}
|
|
234
227
|
});
|
|
235
228
|
}
|
|
@@ -23,7 +23,7 @@ exports.isTokenValueString = isTokenValueString;
|
|
|
23
23
|
exports.isZero = exports.isValidSpacingValue = void 0;
|
|
24
24
|
exports.normaliseValue = normaliseValue;
|
|
25
25
|
exports.processCssNode = processCssNode;
|
|
26
|
-
exports.
|
|
26
|
+
exports.removePixelSuffix = void 0;
|
|
27
27
|
exports.splitCssProperties = splitCssProperties;
|
|
28
28
|
exports.splitShorthandValues = void 0;
|
|
29
29
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
@@ -32,8 +32,6 @@ var _tokensRaw = require("@atlaskit/tokens/tokens-raw");
|
|
|
32
32
|
var _isColor = require("../utils/is-color");
|
|
33
33
|
var _shape = require("./shape");
|
|
34
34
|
var _typography = require("./typography");
|
|
35
|
-
var replacementComment = '// TODO Delete this comment after verifying space token -> previous value';
|
|
36
|
-
exports.replacementComment = replacementComment;
|
|
37
35
|
var properties = ['padding', 'paddingBlock', 'paddingInline', 'paddingLeft', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'marginInline', 'marginInlineStart', 'marginInlineEnd', 'marginBlock', 'marginBlockStart', 'marginBlockEnd', 'margin', 'gap', 'rowGap', 'gridRowGap', 'columnGap', 'gridColumnGap', 'top', 'left', 'right', 'bottom', 'inlineStart', 'inlineEnd', 'blockStart', 'blockEnd', 'outline-offset'];
|
|
38
36
|
var spacingValueToToken = Object.fromEntries(_tokensRaw.spacing.map(function (token) {
|
|
39
37
|
return [token.value, token.name];
|
|
@@ -63,12 +63,11 @@ var lintObjectForSpacing = function lintObjectForSpacing(node, context, ruleConf
|
|
|
63
63
|
payload: "".concat(propertyName, ":").concat(pixelValue)
|
|
64
64
|
},
|
|
65
65
|
fix: function fix(fixer) {
|
|
66
|
-
var _node$loc;
|
|
67
66
|
var replacementNode = (0, _spacingUtils.getTokenReplacement)(propertyName, pixelValue);
|
|
68
67
|
if (!replacementNode) {
|
|
69
68
|
return null;
|
|
70
69
|
}
|
|
71
|
-
return (!tokenNode && ruleConfig.applyImport ? [(0, _spacingUtils.insertTokensImport)(fixer)] : []).concat([fixer.
|
|
70
|
+
return (!tokenNode && ruleConfig.applyImport ? [(0, _spacingUtils.insertTokensImport)(fixer)] : []).concat([fixer.replaceText(node, (0, _eslintCodemodUtils.property)(_objectSpread(_objectSpread({}, node), {}, {
|
|
72
71
|
value: replacementNode
|
|
73
72
|
})).toString())]);
|
|
74
73
|
}
|
|
@@ -57,6 +57,9 @@ var isCssInJsObjectNode = function isCssInJsObjectNode(node) {
|
|
|
57
57
|
return (node === null || node === void 0 ? void 0 : node.type) === 'CallExpression' && node.callee.type === 'MemberExpression' && node.callee.object.type === 'Identifier' && cssInJsCallees.includes(node.callee.object.name);
|
|
58
58
|
};
|
|
59
59
|
exports.isCssInJsObjectNode = isCssInJsObjectNode;
|
|
60
|
+
var isXcssCallNode = function isXcssCallNode(node) {
|
|
61
|
+
return (node === null || node === void 0 ? void 0 : node.type) === 'CallExpression' && node.callee.type === 'Identifier' && node.callee.name === 'xcss';
|
|
62
|
+
};
|
|
60
63
|
var isDecendantOfStyleBlock = function isDecendantOfStyleBlock(node) {
|
|
61
64
|
if (node.type === 'VariableDeclarator') {
|
|
62
65
|
if (node.id.type !== 'Identifier') {
|
|
@@ -85,6 +88,11 @@ var isDecendantOfStyleBlock = function isDecendantOfStyleBlock(node) {
|
|
|
85
88
|
return varName.includes(el);
|
|
86
89
|
});
|
|
87
90
|
}
|
|
91
|
+
|
|
92
|
+
// xcss contains types for all properties that accept tokens, so ignore xcss for linting as it will report false positives
|
|
93
|
+
if (isXcssCallNode(node)) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
88
96
|
if (isCssInJsCallNode(node) || isCssInJsObjectNode(node) || isCssInJsTemplateNode(node)) {
|
|
89
97
|
return true;
|
|
90
98
|
}
|
package/dist/cjs/version.json
CHANGED
|
@@ -5,7 +5,7 @@ import { isDecendantOfGlobalToken, isDecendantOfStyleBlock, isDecendantOfType }
|
|
|
5
5
|
import { lintJSXIdentifierForColor, lintJSXLiteralForColor, lintJSXMemberForColor, lintObjectForColor, lintTemplateIdentifierForColor } from './color';
|
|
6
6
|
import ruleMeta from './rule-meta';
|
|
7
7
|
import { lintObjectForSpacing } from './spacing';
|
|
8
|
-
import { convertHyphenatedNameToCamelCase, emToPixels,
|
|
8
|
+
import { convertHyphenatedNameToCamelCase, emToPixels, getDomainsForProperty, getFontSizeFromNode, getFontSizeValueInScope, getTokenReplacement, getValueFromShorthand, includesTokenString, insertTokensImport, isAuto, isTokenValueString, isValidSpacingValue, isZero, processCssNode, splitShorthandValues } from './spacing-utils';
|
|
9
9
|
const defaultConfig = {
|
|
10
10
|
domains: ['color', 'spacing'],
|
|
11
11
|
applyImport: true,
|
|
@@ -90,7 +90,6 @@ const createWithConfig = initialConfig => context => {
|
|
|
90
90
|
// if we can't get a processed css we bail
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
|
-
const parentNode = findParentNodeForLine(node);
|
|
94
93
|
const globalFontSize = getFontSizeValueInScope(processedCssLines);
|
|
95
94
|
const textForSource = context.getSourceCode().getText(node.quasi);
|
|
96
95
|
const allReplacedValues = [];
|
|
@@ -188,16 +187,11 @@ const createWithConfig = initialConfig => context => {
|
|
|
188
187
|
if (completeSource !== textForSource) {
|
|
189
188
|
// means we found some replacement values, we'll give the option to fix them
|
|
190
189
|
|
|
191
|
-
const replacementComments = `${allReplacedValues.map(replacedProperties => {
|
|
192
|
-
const [propertyName] = replacedProperties;
|
|
193
|
-
const replacedValues = replacedProperties.slice(1).join(' ');
|
|
194
|
-
return `${replacementComment} \`${propertyName}: ${replacedValues}\``;
|
|
195
|
-
}).join('\n')}\n`;
|
|
196
190
|
context.report({
|
|
197
191
|
node,
|
|
198
192
|
messageId: 'autofixesPossible',
|
|
199
193
|
fix: fixer => {
|
|
200
|
-
return (!tokenNode && config.applyImport ? [insertTokensImport(fixer)] : []).concat([fixer.
|
|
194
|
+
return (!tokenNode && config.applyImport ? [insertTokensImport(fixer)] : []).concat([fixer.replaceText(node.quasi, completeSource)]);
|
|
201
195
|
}
|
|
202
196
|
});
|
|
203
197
|
}
|
|
@@ -3,7 +3,6 @@ import { spacing as spacingScale } from '@atlaskit/tokens/tokens-raw';
|
|
|
3
3
|
import { isColorCssPropertyName } from '../utils/is-color';
|
|
4
4
|
import { borderWidthValueToToken, isBorderRadius, isBorderSizeProperty, isShapeProperty, radiusValueToToken } from './shape';
|
|
5
5
|
import { isCodeFontFamily, isFontFamily, isFontSize, isFontSizeSmall, isTypographyProperty, typographyValueToToken } from './typography';
|
|
6
|
-
export const replacementComment = '// TODO Delete this comment after verifying space token -> previous value';
|
|
7
6
|
const properties = ['padding', 'paddingBlock', 'paddingInline', 'paddingLeft', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'marginInline', 'marginInlineStart', 'marginInlineEnd', 'marginBlock', 'marginBlockStart', 'marginBlockEnd', 'margin', 'gap', 'rowGap', 'gridRowGap', 'columnGap', 'gridColumnGap', 'top', 'left', 'right', 'bottom', 'inlineStart', 'inlineEnd', 'blockStart', 'blockEnd', 'outline-offset'];
|
|
8
7
|
const spacingValueToToken = Object.fromEntries(spacingScale.map(token => [token.value, token.name]));
|
|
9
8
|
export function findIdentifierInParentScope({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isNodeOfType,
|
|
2
|
-
import { emToPixels, findTokenNameByPropertyValue, getRawExpression, getTokenNodeForValue, getTokenReplacement, getValue, insertTokensImport, isAuto, isCalc, isValidSpacingValue, isZero,
|
|
1
|
+
import { isNodeOfType, property } from 'eslint-codemod-utils';
|
|
2
|
+
import { emToPixels, findTokenNameByPropertyValue, getRawExpression, getTokenNodeForValue, getTokenReplacement, getValue, insertTokensImport, isAuto, isCalc, isValidSpacingValue, isZero, splitShorthandValues } from './spacing-utils';
|
|
3
3
|
export const lintObjectForSpacing = (node, context, ruleConfig, fontSize, tokenNode) => {
|
|
4
4
|
if (isNodeOfType(node.value, 'Literal') && !isValidSpacingValue(node.value.value, fontSize)) {
|
|
5
5
|
context.report({
|
|
@@ -51,12 +51,11 @@ export const lintObjectForSpacing = (node, context, ruleConfig, fontSize, tokenN
|
|
|
51
51
|
payload: `${propertyName}:${pixelValue}`
|
|
52
52
|
},
|
|
53
53
|
fix: fixer => {
|
|
54
|
-
var _node$loc;
|
|
55
54
|
const replacementNode = getTokenReplacement(propertyName, pixelValue);
|
|
56
55
|
if (!replacementNode) {
|
|
57
56
|
return null;
|
|
58
57
|
}
|
|
59
|
-
return (!tokenNode && ruleConfig.applyImport ? [insertTokensImport(fixer)] : []).concat([fixer.
|
|
58
|
+
return (!tokenNode && ruleConfig.applyImport ? [insertTokensImport(fixer)] : []).concat([fixer.replaceText(node, property({
|
|
60
59
|
...node,
|
|
61
60
|
value: replacementNode
|
|
62
61
|
}).toString())]);
|
|
@@ -37,6 +37,7 @@ const cssInJsCallees = ['css', 'styled', 'styled2'];
|
|
|
37
37
|
export const isCssInJsTemplateNode = node => (node === null || node === void 0 ? void 0 : node.type) === 'TaggedTemplateExpression' && node.tag.type === 'MemberExpression' && node.tag.object.type === 'Identifier' && node.tag.object.name === 'styled';
|
|
38
38
|
export const isCssInJsCallNode = node => (node === null || node === void 0 ? void 0 : node.type) === 'CallExpression' && node.callee.type === 'Identifier' && cssInJsCallees.includes(node.callee.name);
|
|
39
39
|
export const isCssInJsObjectNode = node => (node === null || node === void 0 ? void 0 : node.type) === 'CallExpression' && node.callee.type === 'MemberExpression' && node.callee.object.type === 'Identifier' && cssInJsCallees.includes(node.callee.object.name);
|
|
40
|
+
const isXcssCallNode = node => (node === null || node === void 0 ? void 0 : node.type) === 'CallExpression' && node.callee.type === 'Identifier' && node.callee.name === 'xcss';
|
|
40
41
|
export const isDecendantOfStyleBlock = node => {
|
|
41
42
|
if (node.type === 'VariableDeclarator') {
|
|
42
43
|
if (node.id.type !== 'Identifier') {
|
|
@@ -61,6 +62,11 @@ export const isDecendantOfStyleBlock = node => {
|
|
|
61
62
|
const varName = node.id.name.toLowerCase();
|
|
62
63
|
return ['style', 'css', 'theme'].some(el => varName.includes(el));
|
|
63
64
|
}
|
|
65
|
+
|
|
66
|
+
// xcss contains types for all properties that accept tokens, so ignore xcss for linting as it will report false positives
|
|
67
|
+
if (isXcssCallNode(node)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
64
70
|
if (isCssInJsCallNode(node) || isCssInJsObjectNode(node) || isCssInJsTemplateNode(node)) {
|
|
65
71
|
return true;
|
|
66
72
|
}
|
package/dist/es2019/version.json
CHANGED
|
@@ -6,7 +6,7 @@ import { isDecendantOfGlobalToken, isDecendantOfStyleBlock, isDecendantOfType }
|
|
|
6
6
|
import { lintJSXIdentifierForColor, lintJSXLiteralForColor, lintJSXMemberForColor, lintObjectForColor, lintTemplateIdentifierForColor } from './color';
|
|
7
7
|
import ruleMeta from './rule-meta';
|
|
8
8
|
import { lintObjectForSpacing } from './spacing';
|
|
9
|
-
import { convertHyphenatedNameToCamelCase, emToPixels,
|
|
9
|
+
import { convertHyphenatedNameToCamelCase, emToPixels, getDomainsForProperty, getFontSizeFromNode, getFontSizeValueInScope, getTokenReplacement, getValueFromShorthand, includesTokenString, insertTokensImport, isAuto, isTokenValueString, isValidSpacingValue, isZero, processCssNode, splitShorthandValues } from './spacing-utils';
|
|
10
10
|
var defaultConfig = {
|
|
11
11
|
domains: ['color', 'spacing'],
|
|
12
12
|
applyImport: true,
|
|
@@ -100,7 +100,6 @@ var createWithConfig = function createWithConfig(initialConfig) {
|
|
|
100
100
|
// if we can't get a processed css we bail
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
|
-
var parentNode = findParentNodeForLine(node);
|
|
104
103
|
var globalFontSize = getFontSizeValueInScope(processedCssLines);
|
|
105
104
|
var textForSource = context.getSourceCode().getText(node.quasi);
|
|
106
105
|
var allReplacedValues = [];
|
|
@@ -212,17 +211,11 @@ var createWithConfig = function createWithConfig(initialConfig) {
|
|
|
212
211
|
if (completeSource !== textForSource) {
|
|
213
212
|
// means we found some replacement values, we'll give the option to fix them
|
|
214
213
|
|
|
215
|
-
var replacementComments = "".concat(allReplacedValues.map(function (replacedProperties) {
|
|
216
|
-
var _replacedProperties = _slicedToArray(replacedProperties, 1),
|
|
217
|
-
propertyName = _replacedProperties[0];
|
|
218
|
-
var replacedValues = replacedProperties.slice(1).join(' ');
|
|
219
|
-
return "".concat(replacementComment, " `").concat(propertyName, ": ").concat(replacedValues, "`");
|
|
220
|
-
}).join('\n'), "\n");
|
|
221
214
|
context.report({
|
|
222
215
|
node: node,
|
|
223
216
|
messageId: 'autofixesPossible',
|
|
224
217
|
fix: function fix(fixer) {
|
|
225
|
-
return (!tokenNode && config.applyImport ? [insertTokensImport(fixer)] : []).concat([fixer.
|
|
218
|
+
return (!tokenNode && config.applyImport ? [insertTokensImport(fixer)] : []).concat([fixer.replaceText(node.quasi, completeSource)]);
|
|
226
219
|
}
|
|
227
220
|
});
|
|
228
221
|
}
|
|
@@ -4,7 +4,6 @@ import { spacing as spacingScale } from '@atlaskit/tokens/tokens-raw';
|
|
|
4
4
|
import { isColorCssPropertyName } from '../utils/is-color';
|
|
5
5
|
import { borderWidthValueToToken, isBorderRadius, isBorderSizeProperty, isShapeProperty, radiusValueToToken } from './shape';
|
|
6
6
|
import { isCodeFontFamily, isFontFamily, isFontSize, isFontSizeSmall, isTypographyProperty, typographyValueToToken } from './typography';
|
|
7
|
-
export var replacementComment = '// TODO Delete this comment after verifying space token -> previous value';
|
|
8
7
|
var properties = ['padding', 'paddingBlock', 'paddingInline', 'paddingLeft', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'marginInline', 'marginInlineStart', 'marginInlineEnd', 'marginBlock', 'marginBlockStart', 'marginBlockEnd', 'margin', 'gap', 'rowGap', 'gridRowGap', 'columnGap', 'gridColumnGap', 'top', 'left', 'right', 'bottom', 'inlineStart', 'inlineEnd', 'blockStart', 'blockEnd', 'outline-offset'];
|
|
9
8
|
var spacingValueToToken = Object.fromEntries(spacingScale.map(function (token) {
|
|
10
9
|
return [token.value, token.name];
|
|
@@ -2,8 +2,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
|
-
import { isNodeOfType,
|
|
6
|
-
import { emToPixels, findTokenNameByPropertyValue, getRawExpression, getTokenNodeForValue, getTokenReplacement, getValue, insertTokensImport, isAuto, isCalc, isValidSpacingValue, isZero,
|
|
5
|
+
import { isNodeOfType, property } from 'eslint-codemod-utils';
|
|
6
|
+
import { emToPixels, findTokenNameByPropertyValue, getRawExpression, getTokenNodeForValue, getTokenReplacement, getValue, insertTokensImport, isAuto, isCalc, isValidSpacingValue, isZero, splitShorthandValues } from './spacing-utils';
|
|
7
7
|
export var lintObjectForSpacing = function lintObjectForSpacing(node, context, ruleConfig, fontSize, tokenNode) {
|
|
8
8
|
if (isNodeOfType(node.value, 'Literal') && !isValidSpacingValue(node.value.value, fontSize)) {
|
|
9
9
|
context.report({
|
|
@@ -56,12 +56,11 @@ export var lintObjectForSpacing = function lintObjectForSpacing(node, context, r
|
|
|
56
56
|
payload: "".concat(propertyName, ":").concat(pixelValue)
|
|
57
57
|
},
|
|
58
58
|
fix: function fix(fixer) {
|
|
59
|
-
var _node$loc;
|
|
60
59
|
var replacementNode = getTokenReplacement(propertyName, pixelValue);
|
|
61
60
|
if (!replacementNode) {
|
|
62
61
|
return null;
|
|
63
62
|
}
|
|
64
|
-
return (!tokenNode && ruleConfig.applyImport ? [insertTokensImport(fixer)] : []).concat([fixer.
|
|
63
|
+
return (!tokenNode && ruleConfig.applyImport ? [insertTokensImport(fixer)] : []).concat([fixer.replaceText(node, property(_objectSpread(_objectSpread({}, node), {}, {
|
|
65
64
|
value: replacementNode
|
|
66
65
|
})).toString())]);
|
|
67
66
|
}
|
|
@@ -44,6 +44,9 @@ export var isCssInJsCallNode = function isCssInJsCallNode(node) {
|
|
|
44
44
|
export var isCssInJsObjectNode = function isCssInJsObjectNode(node) {
|
|
45
45
|
return (node === null || node === void 0 ? void 0 : node.type) === 'CallExpression' && node.callee.type === 'MemberExpression' && node.callee.object.type === 'Identifier' && cssInJsCallees.includes(node.callee.object.name);
|
|
46
46
|
};
|
|
47
|
+
var isXcssCallNode = function isXcssCallNode(node) {
|
|
48
|
+
return (node === null || node === void 0 ? void 0 : node.type) === 'CallExpression' && node.callee.type === 'Identifier' && node.callee.name === 'xcss';
|
|
49
|
+
};
|
|
47
50
|
export var isDecendantOfStyleBlock = function isDecendantOfStyleBlock(node) {
|
|
48
51
|
if (node.type === 'VariableDeclarator') {
|
|
49
52
|
if (node.id.type !== 'Identifier') {
|
|
@@ -72,6 +75,11 @@ export var isDecendantOfStyleBlock = function isDecendantOfStyleBlock(node) {
|
|
|
72
75
|
return varName.includes(el);
|
|
73
76
|
});
|
|
74
77
|
}
|
|
78
|
+
|
|
79
|
+
// xcss contains types for all properties that accept tokens, so ignore xcss for linting as it will report false positives
|
|
80
|
+
if (isXcssCallNode(node)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
75
83
|
if (isCssInJsCallNode(node) || isCssInJsObjectNode(node) || isCssInJsTemplateNode(node)) {
|
|
76
84
|
return true;
|
|
77
85
|
}
|
package/dist/esm/version.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Rule, Scope } from 'eslint';
|
|
2
2
|
import { EslintNode, ObjectExpression, TaggedTemplateExpression } from 'eslint-codemod-utils';
|
|
3
3
|
import { Domains } from './types';
|
|
4
|
-
export declare const replacementComment = "// TODO Delete this comment after verifying space token -> previous value";
|
|
5
4
|
export type ProcessedCSSLines = [string, string][];
|
|
6
5
|
export declare function findIdentifierInParentScope({ scope, identifierName, }: {
|
|
7
6
|
scope: Scope.Scope;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Rule, Scope } from 'eslint';
|
|
2
2
|
import { EslintNode, ObjectExpression, TaggedTemplateExpression } from 'eslint-codemod-utils';
|
|
3
3
|
import { Domains } from './types';
|
|
4
|
-
export declare const replacementComment = "// TODO Delete this comment after verifying space token -> previous value";
|
|
5
4
|
export type ProcessedCSSLines = [
|
|
6
5
|
string,
|
|
7
6
|
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.0.
|
|
4
|
+
"version": "8.0.2",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
".": "./src/index.tsx"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@atlaskit/tokens": "^1.
|
|
36
|
+
"@atlaskit/tokens": "^1.12.0",
|
|
37
37
|
"@babel/runtime": "^7.0.0",
|
|
38
38
|
"@typescript-eslint/utils": "^5.48.1",
|
|
39
39
|
"ajv": "^6.12.6",
|