@atlaskit/eslint-plugin-design-system 11.10.0 → 12.0.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 +12 -0
- package/dist/cjs/ast-nodes/object-entry.js +1 -1
- package/dist/cjs/ast-nodes/root.js +1 -1
- package/dist/cjs/presets/all.codegen.js +1 -1
- package/dist/cjs/presets/recommended.codegen.js +1 -1
- package/dist/cjs/rules/consistent-css-prop-usage/index.js +1 -1
- package/dist/cjs/rules/ensure-design-token-usage/color.js +10 -10
- package/dist/cjs/rules/ensure-design-token-usage/index.js +12 -5
- package/dist/cjs/rules/ensure-design-token-usage/utils.js +3 -3
- package/dist/cjs/rules/no-deprecated-apis/index.js +1 -1
- package/dist/cjs/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind-all.js +1 -1
- package/dist/cjs/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind.js +1 -1
- package/dist/cjs/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-jsx-attribute.js +1 -1
- package/dist/cjs/rules/no-empty-styled-expression/index.js +1 -1
- package/dist/cjs/rules/no-html-anchor/node-types/jsx-element/index.js +1 -1
- package/dist/cjs/rules/no-html-anchor/node-types/styled-component/index.js +1 -1
- package/dist/cjs/rules/no-html-button/node-types/styled-component/index.js +1 -1
- package/dist/cjs/rules/no-invalid-css-map/index.js +1 -1
- package/dist/cjs/rules/no-invalid-css-map/utils.js +1 -1
- package/dist/cjs/rules/no-legacy-icons/helpers.js +40 -3
- package/dist/cjs/rules/no-margin/index.js +4 -4
- package/dist/cjs/rules/no-nested-styles/index.js +2 -2
- package/dist/cjs/rules/no-physical-properties/index.js +1 -1
- package/dist/cjs/rules/no-unsafe-design-token-usage/index.js +2 -2
- package/dist/cjs/rules/no-unsafe-style-overrides/index.js +1 -1
- package/dist/cjs/rules/use-heading/config/index.js +1 -1
- package/dist/cjs/rules/use-heading/index.js +13 -1
- package/dist/cjs/rules/use-heading-level-in-spotlight-card/index.js +1 -1
- package/dist/cjs/rules/use-href-in-link-item/index.js +1 -1
- package/dist/cjs/rules/use-latest-xcss-syntax/index.js +1 -1
- package/dist/cjs/rules/use-latest-xcss-syntax/transformers/style-property/index.js +1 -1
- package/dist/cjs/rules/use-latest-xcss-syntax-typography/config/index.js +3 -2
- package/dist/cjs/rules/use-latest-xcss-syntax-typography/index.js +24 -6
- package/dist/cjs/rules/use-primitives/config/index.js +41 -1
- package/dist/cjs/rules/use-primitives/index.js +14 -0
- package/dist/cjs/rules/use-primitives/transformers/compiled-styled/index.js +1 -1
- package/dist/cjs/rules/use-primitives/transformers/css-to-xcss.js +1 -1
- package/dist/cjs/rules/use-primitives/transformers/emotion-css/index.js +1 -1
- package/dist/cjs/rules/use-primitives/utils/get-variable-usage-count.js +1 -1
- package/dist/cjs/rules/use-primitives-text/config/index.js +11 -2
- package/dist/cjs/rules/use-primitives-text/index.js +27 -0
- package/dist/cjs/rules/use-primitives-text/transformers/emphasis-elements.js +1 -1
- package/dist/cjs/rules/use-primitives-text/transformers/paragraph-elements.js +1 -1
- package/dist/cjs/rules/use-primitives-text/transformers/span-elements.js +1 -1
- package/dist/cjs/rules/use-primitives-text/transformers/strong-elements.js +1 -1
- package/dist/cjs/rules/use-tokens-space/index.js +5 -5
- package/dist/cjs/rules/use-tokens-typography/config/index.js +1 -1
- package/dist/cjs/rules/use-tokens-typography/index.js +7 -6
- package/dist/cjs/rules/use-tokens-typography/transformers/font-family.js +3 -2
- package/dist/cjs/rules/use-tokens-typography/transformers/font-weight.js +3 -2
- package/dist/cjs/rules/use-tokens-typography/transformers/style-object.js +3 -9
- package/dist/cjs/rules/use-tokens-typography/transformers/untokenized-properties.js +2 -1
- package/dist/cjs/rules/use-visually-hidden/index.js +2 -2
- package/dist/cjs/rules/utils/create-no-exported-rule/check-if-supported-export.js +3 -3
- package/dist/cjs/rules/utils/create-no-exported-rule/main.js +1 -1
- package/dist/cjs/rules/utils/create-no-tagged-template-expression-rule/index.js +1 -1
- package/dist/cjs/rules/utils/get-first-supported-import.js +1 -1
- package/dist/cjs/rules/utils/get-is-exception.js +3 -3
- package/dist/cjs/rules/utils/is-node.js +16 -16
- package/dist/es2019/ast-nodes/object-entry.js +1 -1
- package/dist/es2019/ast-nodes/root.js +1 -1
- package/dist/es2019/presets/all.codegen.js +1 -1
- package/dist/es2019/presets/recommended.codegen.js +1 -1
- package/dist/es2019/rules/consistent-css-prop-usage/index.js +1 -1
- package/dist/es2019/rules/ensure-design-token-usage/color.js +10 -10
- package/dist/es2019/rules/ensure-design-token-usage/index.js +8 -1
- package/dist/es2019/rules/ensure-design-token-usage/utils.js +1 -1
- package/dist/es2019/rules/no-deprecated-apis/index.js +1 -1
- package/dist/es2019/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind-all.js +1 -1
- package/dist/es2019/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind.js +1 -1
- package/dist/es2019/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-jsx-attribute.js +1 -1
- package/dist/es2019/rules/no-empty-styled-expression/index.js +1 -1
- package/dist/es2019/rules/no-html-anchor/node-types/jsx-element/index.js +1 -1
- package/dist/es2019/rules/no-html-anchor/node-types/styled-component/index.js +1 -1
- package/dist/es2019/rules/no-html-button/node-types/styled-component/index.js +1 -1
- package/dist/es2019/rules/no-invalid-css-map/index.js +1 -1
- package/dist/es2019/rules/no-invalid-css-map/utils.js +1 -1
- package/dist/es2019/rules/no-legacy-icons/helpers.js +38 -3
- package/dist/es2019/rules/no-nested-styles/index.js +1 -1
- package/dist/es2019/rules/no-unsafe-style-overrides/index.js +1 -1
- package/dist/es2019/rules/use-heading/config/index.js +1 -1
- package/dist/es2019/rules/use-heading/index.js +12 -0
- package/dist/es2019/rules/use-heading-level-in-spotlight-card/index.js +1 -1
- package/dist/es2019/rules/use-href-in-link-item/index.js +1 -1
- package/dist/es2019/rules/use-latest-xcss-syntax/transformers/style-property/index.js +1 -1
- package/dist/es2019/rules/use-latest-xcss-syntax-typography/config/index.js +2 -1
- package/dist/es2019/rules/use-latest-xcss-syntax-typography/index.js +19 -1
- package/dist/es2019/rules/use-primitives/config/index.js +40 -0
- package/dist/es2019/rules/use-primitives/index.js +15 -1
- package/dist/es2019/rules/use-primitives/transformers/compiled-styled/index.js +1 -1
- package/dist/es2019/rules/use-primitives/transformers/css-to-xcss.js +1 -1
- package/dist/es2019/rules/use-primitives/transformers/emotion-css/index.js +1 -1
- package/dist/es2019/rules/use-primitives/utils/get-variable-usage-count.js +1 -1
- package/dist/es2019/rules/use-primitives-text/config/index.js +10 -1
- package/dist/es2019/rules/use-primitives-text/index.js +28 -1
- package/dist/es2019/rules/use-primitives-text/transformers/emphasis-elements.js +1 -1
- package/dist/es2019/rules/use-primitives-text/transformers/paragraph-elements.js +1 -1
- package/dist/es2019/rules/use-primitives-text/transformers/span-elements.js +1 -1
- package/dist/es2019/rules/use-primitives-text/transformers/strong-elements.js +1 -1
- package/dist/es2019/rules/use-tokens-typography/config/index.js +1 -1
- package/dist/es2019/rules/use-tokens-typography/index.js +2 -1
- package/dist/es2019/rules/use-tokens-typography/transformers/font-family.js +3 -2
- package/dist/es2019/rules/use-tokens-typography/transformers/font-weight.js +3 -2
- package/dist/es2019/rules/use-tokens-typography/transformers/style-object.js +3 -9
- package/dist/es2019/rules/use-tokens-typography/transformers/untokenized-properties.js +2 -1
- package/dist/es2019/rules/use-visually-hidden/index.js +2 -2
- package/dist/es2019/rules/utils/create-no-exported-rule/check-if-supported-export.js +1 -1
- package/dist/es2019/rules/utils/create-no-exported-rule/main.js +1 -1
- package/dist/es2019/rules/utils/create-no-tagged-template-expression-rule/index.js +1 -1
- package/dist/es2019/rules/utils/get-first-supported-import.js +1 -1
- package/dist/es2019/rules/utils/is-node.js +1 -1
- package/dist/esm/ast-nodes/object-entry.js +1 -1
- package/dist/esm/ast-nodes/root.js +1 -1
- package/dist/esm/presets/all.codegen.js +1 -1
- package/dist/esm/presets/recommended.codegen.js +1 -1
- package/dist/esm/rules/consistent-css-prop-usage/index.js +1 -1
- package/dist/esm/rules/ensure-design-token-usage/color.js +10 -10
- package/dist/esm/rules/ensure-design-token-usage/index.js +12 -5
- package/dist/esm/rules/ensure-design-token-usage/utils.js +4 -3
- package/dist/esm/rules/no-deprecated-apis/index.js +1 -1
- package/dist/esm/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind-all.js +1 -1
- package/dist/esm/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-bind.js +1 -1
- package/dist/esm/rules/no-direct-use-of-web-platform-drag-and-drop/checks/is-blocked-jsx-attribute.js +1 -1
- package/dist/esm/rules/no-empty-styled-expression/index.js +1 -1
- package/dist/esm/rules/no-html-anchor/node-types/jsx-element/index.js +1 -1
- package/dist/esm/rules/no-html-anchor/node-types/styled-component/index.js +1 -1
- package/dist/esm/rules/no-html-button/node-types/styled-component/index.js +1 -1
- package/dist/esm/rules/no-invalid-css-map/index.js +1 -1
- package/dist/esm/rules/no-invalid-css-map/utils.js +1 -1
- package/dist/esm/rules/no-legacy-icons/helpers.js +40 -3
- package/dist/esm/rules/no-margin/index.js +4 -4
- package/dist/esm/rules/no-nested-styles/index.js +2 -2
- package/dist/esm/rules/no-physical-properties/index.js +1 -1
- package/dist/esm/rules/no-unsafe-design-token-usage/index.js +2 -2
- package/dist/esm/rules/no-unsafe-style-overrides/index.js +1 -1
- package/dist/esm/rules/use-heading/config/index.js +1 -1
- package/dist/esm/rules/use-heading/index.js +13 -1
- package/dist/esm/rules/use-heading-level-in-spotlight-card/index.js +1 -1
- package/dist/esm/rules/use-href-in-link-item/index.js +1 -1
- package/dist/esm/rules/use-latest-xcss-syntax/index.js +1 -1
- package/dist/esm/rules/use-latest-xcss-syntax/transformers/style-property/index.js +1 -1
- package/dist/esm/rules/use-latest-xcss-syntax-typography/config/index.js +2 -1
- package/dist/esm/rules/use-latest-xcss-syntax-typography/index.js +25 -7
- package/dist/esm/rules/use-primitives/config/index.js +40 -0
- package/dist/esm/rules/use-primitives/index.js +15 -1
- package/dist/esm/rules/use-primitives/transformers/compiled-styled/index.js +1 -1
- package/dist/esm/rules/use-primitives/transformers/css-to-xcss.js +1 -1
- package/dist/esm/rules/use-primitives/transformers/emotion-css/index.js +1 -1
- package/dist/esm/rules/use-primitives/utils/get-variable-usage-count.js +1 -1
- package/dist/esm/rules/use-primitives-text/config/index.js +10 -1
- package/dist/esm/rules/use-primitives-text/index.js +28 -1
- package/dist/esm/rules/use-primitives-text/transformers/emphasis-elements.js +1 -1
- package/dist/esm/rules/use-primitives-text/transformers/paragraph-elements.js +1 -1
- package/dist/esm/rules/use-primitives-text/transformers/span-elements.js +1 -1
- package/dist/esm/rules/use-primitives-text/transformers/strong-elements.js +1 -1
- package/dist/esm/rules/use-tokens-space/index.js +5 -5
- package/dist/esm/rules/use-tokens-typography/config/index.js +1 -1
- package/dist/esm/rules/use-tokens-typography/index.js +7 -6
- package/dist/esm/rules/use-tokens-typography/transformers/font-family.js +3 -2
- package/dist/esm/rules/use-tokens-typography/transformers/font-weight.js +3 -2
- package/dist/esm/rules/use-tokens-typography/transformers/style-object.js +3 -9
- package/dist/esm/rules/use-tokens-typography/transformers/untokenized-properties.js +2 -1
- package/dist/esm/rules/use-visually-hidden/index.js +2 -2
- package/dist/esm/rules/utils/create-no-exported-rule/check-if-supported-export.js +5 -4
- package/dist/esm/rules/utils/create-no-exported-rule/main.js +1 -1
- package/dist/esm/rules/utils/create-no-tagged-template-expression-rule/index.js +1 -1
- package/dist/esm/rules/utils/get-first-supported-import.js +1 -1
- package/dist/esm/rules/utils/get-is-exception.js +3 -3
- package/dist/esm/rules/utils/is-node.js +23 -16
- package/dist/types/rules/use-latest-xcss-syntax-typography/config/index.d.ts +2 -1
- package/dist/types/rules/use-primitives/config/index.d.ts +2 -1
- package/dist/types/rules/use-primitives-text/config/index.d.ts +2 -1
- package/dist/types-ts4.5/rules/use-latest-xcss-syntax-typography/config/index.d.ts +6 -1
- package/dist/types-ts4.5/rules/use-primitives/config/index.d.ts +2 -1
- package/dist/types-ts4.5/rules/use-primitives-text/config/index.d.ts +2 -1
- package/package.json +3 -3
- package/dist/cjs/rules/utils/context-compat.js +0 -35
- package/dist/es2019/rules/utils/context-compat.js +0 -29
- package/dist/esm/rules/utils/context-compat.js +0 -29
- package/dist/types/rules/utils/context-compat.d.ts +0 -19
- package/dist/types-ts4.5/rules/utils/context-compat.d.ts +0 -19
|
@@ -463,10 +463,25 @@ var createImportFix = function createImportFix(_ref6) {
|
|
|
463
463
|
var importPath = migrationImportNode ? importSource.replace('/migration', '').split('--')[0] : getNewIconNameAndImportPath(importSource, shouldUseMigrationPath).importPath;
|
|
464
464
|
var useMigrationPath = legacyImportNode && importPath;
|
|
465
465
|
var useFinalPath = migrationImportNode && !shouldUseMigrationPath && importPath;
|
|
466
|
+
var programNode = legacyImportNode && findProgramNode(legacyImportNode);
|
|
466
467
|
if (useMigrationPath) {
|
|
467
|
-
|
|
468
|
+
if (newIconName) {
|
|
469
|
+
var isExisting = programNode ? alreadyHasImportedLocalName(programNode, newIconName, importPath) : false;
|
|
470
|
+
if (!isExisting) {
|
|
471
|
+
fixes.push(fixer.insertTextBefore(legacyImportNode, "import ".concat(newIconName, " from '").concat(importPath, "';\n")));
|
|
472
|
+
}
|
|
473
|
+
} else {
|
|
474
|
+
fixes.push(fixer.replaceText(legacyImportNode.source, "'".concat(literal(importPath), "'")));
|
|
475
|
+
}
|
|
468
476
|
} else if (useFinalPath) {
|
|
469
|
-
|
|
477
|
+
if (newIconName) {
|
|
478
|
+
var _isExisting = programNode ? alreadyHasImportedLocalName(programNode, newIconName, importPath) : false;
|
|
479
|
+
if (!_isExisting) {
|
|
480
|
+
fixes.push(fixer.insertTextBefore(migrationImportNode, "import ".concat(newIconName, " from '").concat(importPath, "';\n")));
|
|
481
|
+
}
|
|
482
|
+
} else {
|
|
483
|
+
fixes.push(fixer.replaceText(migrationImportNode.source, "'".concat(literal(importPath), "'")));
|
|
484
|
+
}
|
|
470
485
|
}
|
|
471
486
|
return fixes;
|
|
472
487
|
};
|
|
@@ -769,4 +784,26 @@ export var throwAutoErrors = function throwAutoErrors(_ref10) {
|
|
|
769
784
|
for (var _i3 = 0, _Object$entries3 = Object.entries(groupedErrorList); _i3 < _Object$entries3.length; _i3++) {
|
|
770
785
|
_loop();
|
|
771
786
|
}
|
|
772
|
-
};
|
|
787
|
+
};
|
|
788
|
+
function findProgramNode(node) {
|
|
789
|
+
while (node && node.parent) {
|
|
790
|
+
if (node.parent.type === 'Program') {
|
|
791
|
+
return node.parent;
|
|
792
|
+
}
|
|
793
|
+
node = node.parent;
|
|
794
|
+
}
|
|
795
|
+
return null;
|
|
796
|
+
}
|
|
797
|
+
function alreadyHasImportedLocalName(programNode, localName, importPath) {
|
|
798
|
+
if (!(programNode !== null && programNode !== void 0 && programNode.body)) {
|
|
799
|
+
return false;
|
|
800
|
+
}
|
|
801
|
+
return programNode.body.some(function (stmt) {
|
|
802
|
+
if (stmt.type === 'ImportDeclaration' && stmt.source.value === importPath) {
|
|
803
|
+
return stmt.specifiers.some(function (s) {
|
|
804
|
+
return s.local.name === localName;
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
return false;
|
|
808
|
+
});
|
|
809
|
+
}
|
|
@@ -20,16 +20,16 @@ var rule = createLintRule({
|
|
|
20
20
|
// CSSObjectExpression and StyledObjectExpression
|
|
21
21
|
// const cssObjectExpression = css({ margin: '4px' })
|
|
22
22
|
// const styledObjectExpression = styled.div({margin: '8px'})
|
|
23
|
-
'CallExpression[callee.name=css] > ObjectExpression, CallExpression[callee.object.name=styled] > ObjectExpression': function
|
|
23
|
+
'CallExpression[callee.name=css] > ObjectExpression, CallExpression[callee.object.name=styled] > ObjectExpression': function CallExpressionCalleeNameCss__ObjectExpression_CallExpressionCalleeObjectNameStyled__ObjectExpression(parentNode) {
|
|
24
24
|
if (!isNodeOfType(parentNode, 'ObjectExpression')) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
var
|
|
27
|
+
var _findObjectStyles = function findObjectStyles(node) {
|
|
28
28
|
if (!isNodeOfType(node, 'Property')) {
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
if (isNodeOfType(node.value, 'ObjectExpression')) {
|
|
32
|
-
return node.value.properties.forEach(
|
|
32
|
+
return node.value.properties.forEach(_findObjectStyles);
|
|
33
33
|
}
|
|
34
34
|
if (!isNodeOfType(node.key, 'Identifier')) {
|
|
35
35
|
return;
|
|
@@ -42,7 +42,7 @@ var rule = createLintRule({
|
|
|
42
42
|
}
|
|
43
43
|
return;
|
|
44
44
|
};
|
|
45
|
-
parentNode.properties.forEach(
|
|
45
|
+
parentNode.properties.forEach(_findObjectStyles);
|
|
46
46
|
},
|
|
47
47
|
// CSSTemplateLiteral and StyledTemplateLiteral
|
|
48
48
|
// const cssTemplateLiteral = css`color: red; margin: 12px`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
|
|
3
3
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
-
import { getScope } from '
|
|
4
|
+
import { getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
5
5
|
import { createLintRule } from '../utils/create-rule';
|
|
6
6
|
import { findIdentifierInParentScope } from '../utils/find-in-parent';
|
|
7
7
|
var allowedPrefix = [':', '&:'];
|
|
@@ -104,7 +104,7 @@ var rule = createLintRule({
|
|
|
104
104
|
},
|
|
105
105
|
create: function create(context) {
|
|
106
106
|
return {
|
|
107
|
-
'CallExpression[callee.name=css] > ObjectExpression Property,CallExpression[callee.name=xcss] > ObjectExpression Property': function
|
|
107
|
+
'CallExpression[callee.name=css] > ObjectExpression Property,CallExpression[callee.name=xcss] > ObjectExpression Property': function CallExpressionCalleeNameCss__ObjectExpression_PropertyCallExpressionCalleeNameXcss__ObjectExpression_Property(node) {
|
|
108
108
|
if (node.type !== 'Property' || node.value.type !== 'ObjectExpression') {
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
@@ -19,7 +19,7 @@ var rule = createLintRule({
|
|
|
19
19
|
},
|
|
20
20
|
create: function create(context) {
|
|
21
21
|
return {
|
|
22
|
-
'CallExpression[callee.name=css] > ObjectExpression Property,CallExpression[callee.name=xcss] > ObjectExpression Property': function
|
|
22
|
+
'CallExpression[callee.name=css] > ObjectExpression Property,CallExpression[callee.name=xcss] > ObjectExpression Property': function CallExpressionCalleeNameCss__ObjectExpression_PropertyCallExpressionCalleeNameXcss__ObjectExpression_Property(node) {
|
|
23
23
|
if (!isNodeOfType(node, 'Property')) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
@@ -74,7 +74,7 @@ var rule = createLintRule({
|
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
|
-
'ObjectExpression > Property > Literal': function
|
|
77
|
+
'ObjectExpression > Property > Literal': function ObjectExpression__Property__Literal(node) {
|
|
78
78
|
if (node.type !== 'Literal') {
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
@@ -100,7 +100,7 @@ var rule = createLintRule({
|
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
102
|
},
|
|
103
|
-
'CallExpression:matches([callee.name="token"], [callee.name="getTokenValue"])': function
|
|
103
|
+
'CallExpression:matches([callee.name="token"], [callee.name="getTokenValue"])': function CallExpressionMatchesCalleeNameToken_CalleeNameGetTokenValue(node) {
|
|
104
104
|
if (!isNodeOfType(node, 'CallExpression')) {
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
-
import { getSourceCode } from '
|
|
2
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
3
3
|
import { createLintRule } from '../utils/create-rule';
|
|
4
4
|
import { getModuleOfIdentifier } from '../utils/get-import-node-by-source';
|
|
5
5
|
import { getJSXElementName } from '../utils/jsx';
|
|
@@ -2,7 +2,7 @@ var defaults = {
|
|
|
2
2
|
failSilently: false,
|
|
3
3
|
patterns: ['native-elements'],
|
|
4
4
|
enableUnsafeAutofix: false,
|
|
5
|
-
enableUnsafeReport:
|
|
5
|
+
enableUnsafeReport: true
|
|
6
6
|
};
|
|
7
7
|
export var getConfig = function getConfig(overrides) {
|
|
8
8
|
return Object.assign({}, defaults, overrides);
|
|
@@ -9,6 +9,18 @@ var rule = createLintRule({
|
|
|
9
9
|
type: 'suggestion',
|
|
10
10
|
fixable: 'code',
|
|
11
11
|
hasSuggestions: true,
|
|
12
|
+
schema: [{
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
enableUnsafeReport: {
|
|
16
|
+
type: 'boolean'
|
|
17
|
+
},
|
|
18
|
+
enableUnsafeAutofix: {
|
|
19
|
+
type: 'boolean'
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
additionalProperties: false
|
|
23
|
+
}],
|
|
12
24
|
docs: {
|
|
13
25
|
description: 'Encourage the usage of heading components.',
|
|
14
26
|
recommended: false,
|
|
@@ -22,7 +34,7 @@ var rule = createLintRule({
|
|
|
22
34
|
var config = getConfig(context.options[0]);
|
|
23
35
|
return errorBoundary({
|
|
24
36
|
// transforms <h1>...</h1> usages
|
|
25
|
-
'JSXElement[openingElement.name.name=/^h[0-6]$/]': function
|
|
37
|
+
'JSXElement[openingElement.name.name=/^h[0-6]$/]': function JSXElementOpeningElementNameName_H06$_(node) {
|
|
26
38
|
return NativeElements.lint(node, {
|
|
27
39
|
context: context,
|
|
28
40
|
config: config
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
|
|
3
3
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
-
import { getScope } from '
|
|
4
|
+
import { getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
5
5
|
import { createLintRule } from '../utils/create-rule';
|
|
6
6
|
import { getImportName } from '../utils/get-import-name';
|
|
7
7
|
export var headingLevelRequiredSuggestionText = 'Add a `headingLevel` that is of a contextually relevant level.';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
|
|
3
3
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
-
import { getScope } from '
|
|
4
|
+
import { getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
5
5
|
import { createLintRule } from '../utils/create-rule';
|
|
6
6
|
import { getImportName } from '../utils/get-import-name';
|
|
7
7
|
import { getUniqueButtonItemName, hasImportOfName, hrefHasInvalidValue, insertButtonItemDefaultImport, insertButtonItemImport } from './utils';
|
|
@@ -18,7 +18,7 @@ var rule = createLintRule({
|
|
|
18
18
|
},
|
|
19
19
|
create: function create(context) {
|
|
20
20
|
return {
|
|
21
|
-
'CallExpression[callee.name="xcss"] ObjectExpression Property': function
|
|
21
|
+
'CallExpression[callee.name="xcss"] ObjectExpression Property': function CallExpressionCalleeNameXcss_ObjectExpression_Property(node) {
|
|
22
22
|
return StyleProperty.lint(node, {
|
|
23
23
|
context: context
|
|
24
24
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
2
2
|
|
|
3
3
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
4
5
|
import * as ast from '../../../../ast-nodes';
|
|
5
|
-
import { getSourceCode } from '../../../utils/context-compat';
|
|
6
6
|
import { styleMap } from './style-map';
|
|
7
7
|
import supported from './supported';
|
|
8
8
|
var messageId = 'noRawSpacingValues';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
export var PATTERNS = ['restricted-property', 'wrapped-token-value', 'restricted-capitalisation'];
|
|
1
2
|
var defaults = {
|
|
2
3
|
failSilently: false,
|
|
3
|
-
patterns: [
|
|
4
|
+
patterns: [].concat(PATTERNS)
|
|
4
5
|
};
|
|
5
6
|
export var getConfig = function getConfig(overrides) {
|
|
6
7
|
return Object.assign({}, defaults, overrides);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createLintRule } from '../utils/create-rule';
|
|
2
2
|
import { errorBoundary } from '../utils/error-boundary';
|
|
3
|
-
import { getConfig } from './config';
|
|
3
|
+
import { getConfig, PATTERNS } from './config';
|
|
4
4
|
import { RestrictedCapitalisation, RestrictedProperty, WrappedTokenValue } from './linters';
|
|
5
5
|
var typescriptErrorMessage = 'There is ongoing work to make this a TypeScript error. Once that happens, you will have to delete/refactor anyway.';
|
|
6
6
|
var rule = createLintRule({
|
|
@@ -9,6 +9,24 @@ var rule = createLintRule({
|
|
|
9
9
|
type: 'problem',
|
|
10
10
|
fixable: 'code',
|
|
11
11
|
hasSuggestions: false,
|
|
12
|
+
schema: [{
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
failSilently: {
|
|
16
|
+
type: 'boolean'
|
|
17
|
+
},
|
|
18
|
+
patterns: {
|
|
19
|
+
maxLength: PATTERNS.length,
|
|
20
|
+
type: 'array',
|
|
21
|
+
items: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
enum: PATTERNS
|
|
24
|
+
},
|
|
25
|
+
uniqueItems: true
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
additionalProperties: false
|
|
29
|
+
}],
|
|
12
30
|
docs: {
|
|
13
31
|
description: 'Prohibits use of unsafe styling properties in xcss. Please use Text/Heading primitives instead.',
|
|
14
32
|
recommended: true,
|
|
@@ -24,37 +42,37 @@ var rule = createLintRule({
|
|
|
24
42
|
create: function create(context) {
|
|
25
43
|
var config = getConfig(context.options[0]);
|
|
26
44
|
return errorBoundary({
|
|
27
|
-
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Identifier[name=/(fontSize|lineHeight|fontWeight|letterSpacing)/]': function
|
|
45
|
+
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Identifier[name=/(fontSize|lineHeight|fontWeight|letterSpacing)/]': function CallExpressionCalleeNameXcss_ObjectExpression__Property__IdentifierName_FontSizeLineHeightFontWeightLetterSpacing_(node) {
|
|
28
46
|
return RestrictedProperty.lint(node, {
|
|
29
47
|
context: context,
|
|
30
48
|
config: config
|
|
31
49
|
});
|
|
32
50
|
},
|
|
33
|
-
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Literal[value=/(fontSize|lineHeight|fontWeight|letterSpacing)/]': function
|
|
51
|
+
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Literal[value=/(fontSize|lineHeight|fontWeight|letterSpacing)/]': function CallExpressionCalleeNameXcss_ObjectExpression__Property__LiteralValue_FontSizeLineHeightFontWeightLetterSpacing_(node) {
|
|
34
52
|
return RestrictedProperty.lint(node, {
|
|
35
53
|
context: context,
|
|
36
54
|
config: config
|
|
37
55
|
});
|
|
38
56
|
},
|
|
39
|
-
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Identifier[name=textTransform]': function
|
|
57
|
+
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Identifier[name=textTransform]': function CallExpressionCalleeNameXcss_ObjectExpression__Property__IdentifierNameTextTransform(node) {
|
|
40
58
|
return RestrictedCapitalisation.lint(node, {
|
|
41
59
|
context: context,
|
|
42
60
|
config: config
|
|
43
61
|
});
|
|
44
62
|
},
|
|
45
|
-
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Literal[value=textTransform]': function
|
|
63
|
+
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Literal[value=textTransform]': function CallExpressionCalleeNameXcss_ObjectExpression__Property__LiteralValueTextTransform(node) {
|
|
46
64
|
return RestrictedCapitalisation.lint(node, {
|
|
47
65
|
context: context,
|
|
48
66
|
config: config
|
|
49
67
|
});
|
|
50
68
|
},
|
|
51
|
-
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Identifier[name=/(font|fontFamily|fontWeight)/]': function
|
|
69
|
+
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Identifier[name=/(font|fontFamily|fontWeight)/]': function CallExpressionCalleeNameXcss_ObjectExpression__Property__IdentifierName_FontFontFamilyFontWeight_(node) {
|
|
52
70
|
return WrappedTokenValue.lint(node, {
|
|
53
71
|
context: context,
|
|
54
72
|
config: config
|
|
55
73
|
});
|
|
56
74
|
},
|
|
57
|
-
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Literal[value=/(font|fontFamily|fontWeight)/]': function
|
|
75
|
+
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Literal[value=/(font|fontFamily|fontWeight)/]': function CallExpressionCalleeNameXcss_ObjectExpression__Property__LiteralValue_FontFontFamilyFontWeight_(node) {
|
|
58
76
|
return WrappedTokenValue.lint(node, {
|
|
59
77
|
context: context,
|
|
60
78
|
config: config
|
|
@@ -1,3 +1,43 @@
|
|
|
1
|
+
export var VALID_PATTERNS = [
|
|
2
|
+
// this enables the rule to look for a pattern like:
|
|
3
|
+
// const myStyles = css({...})
|
|
4
|
+
'compiled-css-function',
|
|
5
|
+
// this enables the rule to look for a pattern like:
|
|
6
|
+
// const MyComponent = styled.div({...})
|
|
7
|
+
'compiled-styled-object',
|
|
8
|
+
// this enables the rule to look for a pattern like:
|
|
9
|
+
// css({ padding: `I AM A TEMPLATE LITERAL` })
|
|
10
|
+
// or styled.div({ padding: `I AM A TEMPLATE LITERAL` })
|
|
11
|
+
'css-template-literal',
|
|
12
|
+
// this enables the rule to look for a pattern like:
|
|
13
|
+
// css({ padding: token(...) })
|
|
14
|
+
// or styled.div({ padding: token(...) })
|
|
15
|
+
'css-property-with-tokens',
|
|
16
|
+
// this enables the rule to look for a pattern like:
|
|
17
|
+
// css({ padding: '8px 16px' })
|
|
18
|
+
// or styled.div({ padding: css({ padding: '8px 16px' }) })
|
|
19
|
+
// ... and they could be tokenised
|
|
20
|
+
// ... and they could be using template literals
|
|
21
|
+
'css-property-multiple-values',
|
|
22
|
+
// This enables the rule to look for a pattern like:
|
|
23
|
+
// ```
|
|
24
|
+
// const styles = css({ // or `styled.div({`
|
|
25
|
+
// padding: '8px',
|
|
26
|
+
// margin: '8px',
|
|
27
|
+
// })
|
|
28
|
+
'multiple-properties',
|
|
29
|
+
// This enables the rule to look for supported dimension properties set as 100% like:
|
|
30
|
+
// ```
|
|
31
|
+
// const styles = css({ // or `styled.div({`
|
|
32
|
+
// padding: '8px',
|
|
33
|
+
// margin: '8px',
|
|
34
|
+
// width: '100%',
|
|
35
|
+
// })
|
|
36
|
+
'dimension-properties',
|
|
37
|
+
// This enables the rule to look for JSX elements that are defined before the styles
|
|
38
|
+
'jsx-order-fix',
|
|
39
|
+
// This enables a fix for string style properties being incorrectly transformed
|
|
40
|
+
'string-style-property-fix'];
|
|
1
41
|
var defaults = {
|
|
2
42
|
patterns: ['compiled-css-function']
|
|
3
43
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLintRule } from '../utils/create-rule';
|
|
2
|
-
import { getConfig } from './config';
|
|
2
|
+
import { getConfig, VALID_PATTERNS } from './config';
|
|
3
3
|
import { CompiledStyled, EmotionCSS } from './transformers';
|
|
4
4
|
var boxDocsUrl = 'https://atlassian.design/components/primitives/box';
|
|
5
5
|
var rule = createLintRule({
|
|
@@ -13,6 +13,20 @@ var rule = createLintRule({
|
|
|
13
13
|
recommended: false,
|
|
14
14
|
severity: 'warn'
|
|
15
15
|
},
|
|
16
|
+
schema: [{
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
patterns: {
|
|
20
|
+
type: 'array',
|
|
21
|
+
maxLength: VALID_PATTERNS.length,
|
|
22
|
+
items: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
enum: VALID_PATTERNS
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
additionalProperties: false
|
|
29
|
+
}],
|
|
16
30
|
messages: {
|
|
17
31
|
preferPrimitivesBox: "This element can be replaced with a \"Box\" primitive. See ".concat(boxDocsUrl, " for additional guidance.")
|
|
18
32
|
}
|
|
@@ -2,8 +2,8 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
2
2
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
3
3
|
|
|
4
4
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
5
|
+
import { getScope, getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
5
6
|
import * as ast from '../../../../ast-nodes';
|
|
6
|
-
import { getScope, getSourceCode } from '../../../utils/context-compat';
|
|
7
7
|
import { isValidCssPropertiesToTransform } from '../../utils';
|
|
8
8
|
import { validateStyles } from '../../utils/validate-styles';
|
|
9
9
|
import { convertJsxCallSite } from './convert-jsx-call-site';
|
|
@@ -3,8 +3,8 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
3
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
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; }
|
|
5
5
|
import { getIdentifierInParentScope, identifier, isNodeOfType, literal } from 'eslint-codemod-utils';
|
|
6
|
+
import { getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
6
7
|
import { allSpaceMap, positiveSpaceMap } from '../../../common/token-maps.partial';
|
|
7
|
-
import { getScope } from '../../utils/context-compat';
|
|
8
8
|
import { getAttributeValueIdentifier, getFunctionArgumentAtPos, getJSXAttributeByName, getVariableDefinitionValue } from '../utils';
|
|
9
9
|
export var cssToXcssTransformer = function cssToXcssTransformer(node, context, fixer) {
|
|
10
10
|
/**
|
|
@@ -2,8 +2,8 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
2
2
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
3
3
|
|
|
4
4
|
import { getIdentifierInParentScope, isNodeOfType } from 'eslint-codemod-utils';
|
|
5
|
+
import { getScope, getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
5
6
|
import * as ast from '../../../../ast-nodes';
|
|
6
|
-
import { getScope, getSourceCode } from '../../../utils/context-compat';
|
|
7
7
|
import { getVariableDefinitionValue, getVariableUsagesCount, isValidCssPropertiesToTransform } from '../../utils';
|
|
8
8
|
import { validateStyles } from '../../utils/validate-styles';
|
|
9
9
|
import { cssToXcssTransformer } from '../css-to-xcss';
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
export var PATTERNS = [
|
|
2
|
+
// <p>text</p>
|
|
3
|
+
'paragraph-elements',
|
|
4
|
+
// <span>text</span>
|
|
5
|
+
'span-elements',
|
|
6
|
+
// <strong>text</strong>
|
|
7
|
+
'strong-elements',
|
|
8
|
+
// <em>text</em>
|
|
9
|
+
'emphasis-elements'];
|
|
1
10
|
var defaults = {
|
|
2
11
|
failSilently: false,
|
|
3
12
|
patterns: ['paragraph-elements', 'span-elements', 'strong-elements', 'emphasis-elements'],
|
|
4
13
|
inheritColor: false,
|
|
5
14
|
enableUnsafeAutofix: false,
|
|
6
|
-
enableUnsafeReport:
|
|
15
|
+
enableUnsafeReport: true
|
|
7
16
|
};
|
|
8
17
|
export var getConfig = function getConfig(overrides) {
|
|
9
18
|
return Object.assign({}, defaults, overrides);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createLintRule } from '../utils/create-rule';
|
|
2
2
|
import { errorBoundary } from '../utils/error-boundary';
|
|
3
|
-
import { getConfig } from './config';
|
|
3
|
+
import { getConfig, PATTERNS } from './config';
|
|
4
4
|
import { EmphasisElements, ParagraphElements, SpanElements, StrongElements } from './transformers';
|
|
5
5
|
var textDocsUrl = 'https://atlassian.design/components/primitives/text';
|
|
6
6
|
var rule = createLintRule({
|
|
@@ -9,6 +9,33 @@ var rule = createLintRule({
|
|
|
9
9
|
type: 'suggestion',
|
|
10
10
|
fixable: 'code',
|
|
11
11
|
hasSuggestions: true,
|
|
12
|
+
schema: [{
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
failSilently: {
|
|
16
|
+
type: 'boolean'
|
|
17
|
+
},
|
|
18
|
+
inheritColor: {
|
|
19
|
+
type: 'boolean'
|
|
20
|
+
},
|
|
21
|
+
enableUnsafeAutofix: {
|
|
22
|
+
type: 'boolean'
|
|
23
|
+
},
|
|
24
|
+
enableUnsafeReport: {
|
|
25
|
+
type: 'boolean'
|
|
26
|
+
},
|
|
27
|
+
patterns: {
|
|
28
|
+
maxLength: PATTERNS.length,
|
|
29
|
+
type: 'array',
|
|
30
|
+
items: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
enum: PATTERNS
|
|
33
|
+
},
|
|
34
|
+
uniqueItems: true
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
additionalProperties: false
|
|
38
|
+
}],
|
|
12
39
|
docs: {
|
|
13
40
|
description: 'Encourage the usage of text components.',
|
|
14
41
|
recommended: false,
|
|
@@ -5,8 +5,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
5
5
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
6
6
|
|
|
7
7
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
8
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
8
9
|
import * as ast from '../../../ast-nodes';
|
|
9
|
-
import { getSourceCode } from '../../utils/context-compat';
|
|
10
10
|
import { addColorInheritAttributeFix, allowedAttrs, updateTestIdAttributeFix } from './common';
|
|
11
11
|
export var EmphasisElements = {
|
|
12
12
|
lint: function lint(node, _ref) {
|
|
@@ -5,8 +5,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
5
5
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
6
6
|
|
|
7
7
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
8
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
8
9
|
import * as ast from '../../../ast-nodes';
|
|
9
|
-
import { getSourceCode } from '../../utils/context-compat';
|
|
10
10
|
import { addColorInheritAttributeFix, allowedAttrs, updateTestIdAttributeFix } from './common';
|
|
11
11
|
export var ParagraphElements = {
|
|
12
12
|
lint: function lint(node, _ref) {
|
|
@@ -5,8 +5,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
5
5
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
6
6
|
|
|
7
7
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
8
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
8
9
|
import * as ast from '../../../ast-nodes';
|
|
9
|
-
import { getSourceCode } from '../../utils/context-compat';
|
|
10
10
|
import { addColorInheritAttributeFix, allowedAttrs, hasTextChildrenOnly, updateTestIdAttributeFix } from './common';
|
|
11
11
|
export var SpanElements = {
|
|
12
12
|
lint: function lint(node, _ref) {
|
|
@@ -5,8 +5,8 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
5
5
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
6
6
|
|
|
7
7
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
8
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
8
9
|
import * as ast from '../../../ast-nodes';
|
|
9
|
-
import { getSourceCode } from '../../utils/context-compat';
|
|
10
10
|
import { addColorInheritAttributeFix, allowedAttrs, updateTestIdAttributeFix } from './common';
|
|
11
11
|
export var StrongElements = {
|
|
12
12
|
lint: function lint(node, _ref) {
|
|
@@ -17,27 +17,27 @@ var rule = createLintRule({
|
|
|
17
17
|
},
|
|
18
18
|
create: function create(context) {
|
|
19
19
|
return {
|
|
20
|
-
'CallExpression[callee.name="css"] ObjectExpression Property': function
|
|
20
|
+
'CallExpression[callee.name="css"] ObjectExpression Property': function CallExpressionCalleeNameCss_ObjectExpression_Property(node) {
|
|
21
21
|
return StyleProperty.lint(node, {
|
|
22
22
|
context: context
|
|
23
23
|
});
|
|
24
24
|
},
|
|
25
|
-
'CallExpression[callee.name="keyframes"] ObjectExpression Property': function
|
|
25
|
+
'CallExpression[callee.name="keyframes"] ObjectExpression Property': function CallExpressionCalleeNameKeyframes_ObjectExpression_Property(node) {
|
|
26
26
|
return StyleProperty.lint(node, {
|
|
27
27
|
context: context
|
|
28
28
|
});
|
|
29
29
|
},
|
|
30
|
-
'CallExpression[callee.name="cssMap"] ObjectExpression Property': function
|
|
30
|
+
'CallExpression[callee.name="cssMap"] ObjectExpression Property': function CallExpressionCalleeNameCssMap_ObjectExpression_Property(node) {
|
|
31
31
|
return StyleProperty.lint(node, {
|
|
32
32
|
context: context
|
|
33
33
|
});
|
|
34
34
|
},
|
|
35
|
-
'CallExpression[callee.object.name=styled] ObjectExpression Property': function
|
|
35
|
+
'CallExpression[callee.object.name=styled] ObjectExpression Property': function CallExpressionCalleeObjectNameStyled_ObjectExpression_Property(node) {
|
|
36
36
|
return StyleProperty.lint(node, {
|
|
37
37
|
context: context
|
|
38
38
|
});
|
|
39
39
|
},
|
|
40
|
-
'CallExpression[callee.object.name=styled2] ObjectExpression Property': function
|
|
40
|
+
'CallExpression[callee.object.name=styled2] ObjectExpression Property': function CallExpressionCalleeObjectNameStyled2_ObjectExpression_Property(node) {
|
|
41
41
|
return StyleProperty.lint(node, {
|
|
42
42
|
context: context
|
|
43
43
|
});
|
|
@@ -28,7 +28,7 @@ var defaultConfig = {
|
|
|
28
28
|
failSilently: false,
|
|
29
29
|
shouldEnforceFallbacks: false,
|
|
30
30
|
enableUnsafeAutofix: false,
|
|
31
|
-
patterns: ['style-object']
|
|
31
|
+
patterns: ['style-object', 'font-weight', 'font-family', 'untokenized-properties', 'banned-properties', 'restricted-capitalisation']
|
|
32
32
|
};
|
|
33
33
|
export var getConfig = function getConfig(overrides) {
|
|
34
34
|
return Object.assign({}, defaultConfig, overrides);
|
|
@@ -18,35 +18,35 @@ var create = function create(context) {
|
|
|
18
18
|
});
|
|
19
19
|
},
|
|
20
20
|
// const styles = css({ fontWeight: 600, 'bold', ... })
|
|
21
|
-
'ObjectExpression > Property > Identifier[name=/^fontWeight$/]': function
|
|
21
|
+
'ObjectExpression > Property > Identifier[name=/^fontWeight$/]': function ObjectExpression__Property__IdentifierName_FontWeight$_(node) {
|
|
22
22
|
return FontWeight.lint(node.parent, {
|
|
23
23
|
context: context,
|
|
24
24
|
config: config
|
|
25
25
|
});
|
|
26
26
|
},
|
|
27
27
|
// const styles = css({ fontFamily: 'Arial, sans-serif', ... })
|
|
28
|
-
'ObjectExpression > Property > Identifier[name=/^fontFamily$/]': function
|
|
28
|
+
'ObjectExpression > Property > Identifier[name=/^fontFamily$/]': function ObjectExpression__Property__IdentifierName_FontFamily$_(node) {
|
|
29
29
|
return FontFamily.lint(node.parent, {
|
|
30
30
|
context: context,
|
|
31
31
|
config: config
|
|
32
32
|
});
|
|
33
33
|
},
|
|
34
34
|
// const styles = css({ font: 'bold 36px Helvetica, Arial', ... })
|
|
35
|
-
'ObjectExpression > Property > Identifier[name=/^font$/]': function
|
|
35
|
+
'ObjectExpression > Property > Identifier[name=/^font$/]': function ObjectExpression__Property__IdentifierName_Font$_(node) {
|
|
36
36
|
return UntokenizedProperties.lint(node.parent, {
|
|
37
37
|
context: context,
|
|
38
38
|
config: config
|
|
39
39
|
});
|
|
40
40
|
},
|
|
41
41
|
// const styles = css({ lineHeight: 1.2, letterSpacing: 0.003, ... })
|
|
42
|
-
'ObjectExpression > Property > Identifier[name=/^(lineHeight|letterSpacing)$/]': function
|
|
42
|
+
'ObjectExpression > Property > Identifier[name=/^(lineHeight|letterSpacing)$/]': function ObjectExpression__Property__IdentifierName_LineHeightLetterSpacing$_(node) {
|
|
43
43
|
return BannedProperties.lint(node.parent, {
|
|
44
44
|
context: context,
|
|
45
45
|
config: config
|
|
46
46
|
});
|
|
47
47
|
},
|
|
48
48
|
// const styles = css({ textTransform: 'uppercase', ... })
|
|
49
|
-
'ObjectExpression > Property > Identifier[name=/^textTransform$/]': function
|
|
49
|
+
'ObjectExpression > Property > Identifier[name=/^textTransform$/]': function ObjectExpression__Property__IdentifierName_TextTransform$_(node) {
|
|
50
50
|
return RestrictedCapitalisation.lint(node.parent, {
|
|
51
51
|
context: context,
|
|
52
52
|
config: config
|
|
@@ -66,7 +66,8 @@ var rule = createLintRule({
|
|
|
66
66
|
severity: 'warn'
|
|
67
67
|
},
|
|
68
68
|
messages: {
|
|
69
|
-
noRawTypographyValues: 'Typography primitives or tokens should be used instead of hard-coded values
|
|
69
|
+
noRawTypographyValues: 'Typography primitives or tokens should be used instead of hard-coded values.',
|
|
70
|
+
noFontSizeTypographyToken: 'Using tokens with the `fontSize` property is invalid. Any `font.heading` or `font.body` tokens must use the CSS `font` property.',
|
|
70
71
|
noRawFontWeightValues: 'Font weight tokens should be used instead of hard-coded values.',
|
|
71
72
|
noRawFontFamilyValues: 'Font family tokens should be used instead of hard-coded values.',
|
|
72
73
|
noUntokenizedProperties: 'Use typography tokens for `{{property}}`.',
|