@atlaskit/eslint-plugin-design-system 10.17.1 → 10.17.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 +18 -0
- package/dist/cjs/rules/no-legacy-icons/helpers.js +6 -3
- package/dist/cjs/rules/use-latest-xcss-syntax-typography/index.js +4 -5
- package/dist/cjs/rules/use-latest-xcss-syntax-typography/linters/banned-property/index.js +44 -7
- package/dist/es2019/rules/no-legacy-icons/helpers.js +6 -3
- package/dist/es2019/rules/use-latest-xcss-syntax-typography/index.js +3 -4
- package/dist/es2019/rules/use-latest-xcss-syntax-typography/linters/banned-property/index.js +32 -5
- package/dist/esm/rules/no-legacy-icons/helpers.js +6 -3
- package/dist/esm/rules/use-latest-xcss-syntax-typography/index.js +3 -4
- package/dist/esm/rules/use-latest-xcss-syntax-typography/linters/banned-property/index.js +44 -5
- package/dist/types/rules/use-latest-xcss-syntax-typography/index.d.ts +0 -1
- package/dist/types/rules/use-latest-xcss-syntax-typography/linters/banned-property/index.d.ts +1 -0
- package/dist/types-ts4.5/rules/use-latest-xcss-syntax-typography/index.d.ts +0 -1
- package/dist/types-ts4.5/rules/use-latest-xcss-syntax-typography/linters/banned-property/index.d.ts +1 -0
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 10.17.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#134533](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/134533)
|
|
8
|
+
[`729d2ac5a7b41`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/729d2ac5a7b41) -
|
|
9
|
+
Disallow letter spacing and disallow font weight only when heading font token is used for
|
|
10
|
+
`use-latest-xcss-syntax-typography` rule.
|
|
11
|
+
|
|
12
|
+
## 10.17.2
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#133689](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/133689)
|
|
17
|
+
[`5b1de3a5df2be`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5b1de3a5df2be) -
|
|
18
|
+
Fix bug in no-legacy-icons where in certain tooling, the token() function wasn't recognised
|
|
19
|
+
correctly when resolving icon colors.
|
|
20
|
+
|
|
3
21
|
## 10.17.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -9,7 +9,6 @@ exports.locToString = exports.isSize = exports.isInsideNewButton = exports.isIns
|
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
11
11
|
var _UNSAFE_migrationMap = _interopRequireWildcard(require("@atlaskit/icon/UNSAFE_migration-map"));
|
|
12
|
-
var _getImportName = require("../utils/get-import-name");
|
|
13
12
|
var _upcomingIcons = require("./upcoming-icons");
|
|
14
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
15
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -322,8 +321,12 @@ var createHelpers = exports.createHelpers = function createHelpers(context) {
|
|
|
322
321
|
* @returns The value of the token call, or null if it could not be extracted
|
|
323
322
|
*/
|
|
324
323
|
var getTokenCallValue = function getTokenCallValue(value) {
|
|
325
|
-
|
|
326
|
-
|
|
324
|
+
/**
|
|
325
|
+
* Previously, we used getImportName() to extract the token name from a token() call.
|
|
326
|
+
* However, this was failing in the Issue Automat so we are now using a simpler approach.
|
|
327
|
+
*/
|
|
328
|
+
|
|
329
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(value, 'JSXExpressionContainer') && (0, _eslintCodemodUtils.isNodeOfType)(value.expression, 'CallExpression') && 'name' in value.expression.callee && value.expression.callee.name === 'token') {
|
|
327
330
|
// propName={token("color...."}
|
|
328
331
|
return getLiteralStringValue(value.expression.arguments[0]);
|
|
329
332
|
}
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
var _createRule = require("../utils/create-rule");
|
|
8
8
|
var _errorBoundary = require("../utils/error-boundary");
|
|
9
9
|
var _config = require("./config");
|
|
10
10
|
var _linters = require("./linters");
|
|
11
|
-
var error = exports.error = "Don't set fontSize, lineHeight, fontWeight properties on xcss. They are unsafe as they allow invalid combinations of typography tokens. There is ongoing work to make this a TypeScript error. Once that happens, you will have to delete/refactor anyway.";
|
|
12
11
|
var rule = (0, _createRule.createLintRule)({
|
|
13
12
|
meta: {
|
|
14
13
|
name: 'use-latest-xcss-syntax-typography',
|
|
@@ -21,18 +20,18 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
21
20
|
severity: 'warn'
|
|
22
21
|
},
|
|
23
22
|
messages: {
|
|
24
|
-
noUnsafeTypographyProperties: error
|
|
23
|
+
noUnsafeTypographyProperties: "Don't set '{{ property }}' on xcss. They are unsafe as they allow invalid combinations of typography tokens. There is ongoing work to make this a TypeScript error. Once that happens, you will have to delete/refactor anyway."
|
|
25
24
|
}
|
|
26
25
|
},
|
|
27
26
|
create: function create(context) {
|
|
28
27
|
var config = (0, _config.getConfig)(context.options[0]);
|
|
29
28
|
return (0, _errorBoundary.errorBoundary)({
|
|
30
|
-
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Identifier[name=/(fontSize|lineHeight|fontWeight)/]': function
|
|
29
|
+
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Identifier[name=/(fontSize|lineHeight|fontWeight|letterSpacing)/]': function CallExpressionCalleeNameXcssObjectExpressionPropertyIdentifierNameFontSizeLineHeightFontWeightLetterSpacing(node) {
|
|
31
30
|
return _linters.BannedProperty.lint(node, {
|
|
32
31
|
context: context
|
|
33
32
|
});
|
|
34
33
|
},
|
|
35
|
-
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Literal[value=/(fontSize|lineHeight|fontWeight)/]': function
|
|
34
|
+
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Literal[value=/(fontSize|lineHeight|fontWeight|letterSpacing)/]': function CallExpressionCalleeNameXcssObjectExpressionPropertyLiteralValueFontSizeLineHeightFontWeightLetterSpacing(node) {
|
|
36
35
|
return _linters.BannedProperty.lint(node, {
|
|
37
36
|
context: context
|
|
38
37
|
});
|
|
@@ -4,15 +4,52 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.BannedProperty = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
7
|
+
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
8
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } /* eslint-disable @repo/internal/react/require-jsdoc */
|
|
10
11
|
var BannedProperty = exports.BannedProperty = {
|
|
11
12
|
lint: function lint(node, _ref) {
|
|
12
13
|
var context = _ref.context;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
if (BannedProperty._check(node)) {
|
|
15
|
+
var property = 'fontSize, lineHeight, fontWeight or letterSpacing';
|
|
16
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(node, 'Identifier')) {
|
|
17
|
+
property = node.name;
|
|
18
|
+
} else if ((0, _eslintCodemodUtils.isNodeOfType)(node, 'Literal')) {
|
|
19
|
+
property = String(node.value);
|
|
20
|
+
}
|
|
21
|
+
context.report({
|
|
22
|
+
node: node,
|
|
23
|
+
messageId: 'noUnsafeTypographyProperties',
|
|
24
|
+
data: {
|
|
25
|
+
property: property
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
_check: function _check(node) {
|
|
31
|
+
// Prevent font weight being used in combination with heading tokens
|
|
32
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(node, 'Identifier') && node.name === 'fontWeight' || (0, _eslintCodemodUtils.isNodeOfType)(node, 'Literal') && node.value === 'fontWeight') {
|
|
33
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(node.parent.parent, 'ObjectExpression')) {
|
|
34
|
+
var _iterator = _createForOfIteratorHelper(node.parent.parent.properties),
|
|
35
|
+
_step;
|
|
36
|
+
try {
|
|
37
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
38
|
+
var property = _step.value;
|
|
39
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(property, 'Property') && (0, _eslintCodemodUtils.isNodeOfType)(property.value, 'CallExpression') && (0, _eslintCodemodUtils.isNodeOfType)(property.value.callee, 'Identifier') && (0, _eslintCodemodUtils.isNodeOfType)(property.value.arguments[0], 'Literal')) {
|
|
40
|
+
if (property.value.callee.name === 'token' && typeof property.value.arguments[0].value === 'string' && property.value.arguments[0].value.includes('font.heading')) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} catch (err) {
|
|
46
|
+
_iterator.e(err);
|
|
47
|
+
} finally {
|
|
48
|
+
_iterator.f();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
17
54
|
}
|
|
18
55
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isNodeOfType, literal } from 'eslint-codemod-utils';
|
|
2
2
|
import baseMigrationMap, { migrationOutcomeDescriptionMap } from '@atlaskit/icon/UNSAFE_migration-map';
|
|
3
|
-
import { getImportName } from '../utils/get-import-name';
|
|
4
3
|
import { upcomingIcons } from './upcoming-icons';
|
|
5
4
|
const sizes = ['small', 'medium', 'large', 'xlarge'];
|
|
6
5
|
export const isSize = size => sizes.includes(size);
|
|
@@ -308,8 +307,12 @@ export const createHelpers = context => {
|
|
|
308
307
|
* @returns The value of the token call, or null if it could not be extracted
|
|
309
308
|
*/
|
|
310
309
|
const getTokenCallValue = value => {
|
|
311
|
-
|
|
312
|
-
|
|
310
|
+
/**
|
|
311
|
+
* Previously, we used getImportName() to extract the token name from a token() call.
|
|
312
|
+
* However, this was failing in the Issue Automat so we are now using a simpler approach.
|
|
313
|
+
*/
|
|
314
|
+
|
|
315
|
+
if (isNodeOfType(value, 'JSXExpressionContainer') && isNodeOfType(value.expression, 'CallExpression') && 'name' in value.expression.callee && value.expression.callee.name === 'token') {
|
|
313
316
|
// propName={token("color...."}
|
|
314
317
|
return getLiteralStringValue(value.expression.arguments[0]);
|
|
315
318
|
}
|
|
@@ -2,7 +2,6 @@ import { createLintRule } from '../utils/create-rule';
|
|
|
2
2
|
import { errorBoundary } from '../utils/error-boundary';
|
|
3
3
|
import { getConfig } from './config';
|
|
4
4
|
import { BannedProperty } from './linters';
|
|
5
|
-
export const error = `Don't set fontSize, lineHeight, fontWeight properties on xcss. They are unsafe as they allow invalid combinations of typography tokens. There is ongoing work to make this a TypeScript error. Once that happens, you will have to delete/refactor anyway.`;
|
|
6
5
|
const rule = createLintRule({
|
|
7
6
|
meta: {
|
|
8
7
|
name: 'use-latest-xcss-syntax-typography',
|
|
@@ -15,16 +14,16 @@ const rule = createLintRule({
|
|
|
15
14
|
severity: 'warn'
|
|
16
15
|
},
|
|
17
16
|
messages: {
|
|
18
|
-
noUnsafeTypographyProperties: error
|
|
17
|
+
noUnsafeTypographyProperties: `Don't set '{{ property }}' on xcss. They are unsafe as they allow invalid combinations of typography tokens. There is ongoing work to make this a TypeScript error. Once that happens, you will have to delete/refactor anyway.`
|
|
19
18
|
}
|
|
20
19
|
},
|
|
21
20
|
create(context) {
|
|
22
21
|
const config = getConfig(context.options[0]);
|
|
23
22
|
return errorBoundary({
|
|
24
|
-
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Identifier[name=/(fontSize|lineHeight|fontWeight)/]': node => BannedProperty.lint(node, {
|
|
23
|
+
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Identifier[name=/(fontSize|lineHeight|fontWeight|letterSpacing)/]': node => BannedProperty.lint(node, {
|
|
25
24
|
context
|
|
26
25
|
}),
|
|
27
|
-
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Literal[value=/(fontSize|lineHeight|fontWeight)/]': node => BannedProperty.lint(node, {
|
|
26
|
+
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Literal[value=/(fontSize|lineHeight|fontWeight|letterSpacing)/]': node => BannedProperty.lint(node, {
|
|
28
27
|
context
|
|
29
28
|
})
|
|
30
29
|
}, config);
|
package/dist/es2019/rules/use-latest-xcss-syntax-typography/linters/banned-property/index.js
CHANGED
|
@@ -1,13 +1,40 @@
|
|
|
1
1
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
4
|
export const BannedProperty = {
|
|
5
5
|
lint(node, {
|
|
6
6
|
context
|
|
7
7
|
}) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
if (BannedProperty._check(node)) {
|
|
9
|
+
let property = 'fontSize, lineHeight, fontWeight or letterSpacing';
|
|
10
|
+
if (isNodeOfType(node, 'Identifier')) {
|
|
11
|
+
property = node.name;
|
|
12
|
+
} else if (isNodeOfType(node, 'Literal')) {
|
|
13
|
+
property = String(node.value);
|
|
14
|
+
}
|
|
15
|
+
context.report({
|
|
16
|
+
node,
|
|
17
|
+
messageId: 'noUnsafeTypographyProperties',
|
|
18
|
+
data: {
|
|
19
|
+
property
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
_check(node) {
|
|
25
|
+
// Prevent font weight being used in combination with heading tokens
|
|
26
|
+
if (isNodeOfType(node, 'Identifier') && node.name === 'fontWeight' || isNodeOfType(node, 'Literal') && node.value === 'fontWeight') {
|
|
27
|
+
if (isNodeOfType(node.parent.parent, 'ObjectExpression')) {
|
|
28
|
+
for (const property of node.parent.parent.properties) {
|
|
29
|
+
if (isNodeOfType(property, 'Property') && isNodeOfType(property.value, 'CallExpression') && isNodeOfType(property.value.callee, 'Identifier') && isNodeOfType(property.value.arguments[0], 'Literal')) {
|
|
30
|
+
if (property.value.callee.name === 'token' && typeof property.value.arguments[0].value === 'string' && property.value.arguments[0].value.includes('font.heading')) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
12
39
|
}
|
|
13
40
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import { isNodeOfType, literal } from 'eslint-codemod-utils';
|
|
3
3
|
import baseMigrationMap, { migrationOutcomeDescriptionMap } from '@atlaskit/icon/UNSAFE_migration-map';
|
|
4
|
-
import { getImportName } from '../utils/get-import-name';
|
|
5
4
|
import { upcomingIcons } from './upcoming-icons';
|
|
6
5
|
var sizes = ['small', 'medium', 'large', 'xlarge'];
|
|
7
6
|
export var isSize = function isSize(size) {
|
|
@@ -312,8 +311,12 @@ export var createHelpers = function createHelpers(context) {
|
|
|
312
311
|
* @returns The value of the token call, or null if it could not be extracted
|
|
313
312
|
*/
|
|
314
313
|
var getTokenCallValue = function getTokenCallValue(value) {
|
|
315
|
-
|
|
316
|
-
|
|
314
|
+
/**
|
|
315
|
+
* Previously, we used getImportName() to extract the token name from a token() call.
|
|
316
|
+
* However, this was failing in the Issue Automat so we are now using a simpler approach.
|
|
317
|
+
*/
|
|
318
|
+
|
|
319
|
+
if (isNodeOfType(value, 'JSXExpressionContainer') && isNodeOfType(value.expression, 'CallExpression') && 'name' in value.expression.callee && value.expression.callee.name === 'token') {
|
|
317
320
|
// propName={token("color...."}
|
|
318
321
|
return getLiteralStringValue(value.expression.arguments[0]);
|
|
319
322
|
}
|
|
@@ -2,7 +2,6 @@ import { createLintRule } from '../utils/create-rule';
|
|
|
2
2
|
import { errorBoundary } from '../utils/error-boundary';
|
|
3
3
|
import { getConfig } from './config';
|
|
4
4
|
import { BannedProperty } from './linters';
|
|
5
|
-
export var error = "Don't set fontSize, lineHeight, fontWeight properties on xcss. They are unsafe as they allow invalid combinations of typography tokens. There is ongoing work to make this a TypeScript error. Once that happens, you will have to delete/refactor anyway.";
|
|
6
5
|
var rule = createLintRule({
|
|
7
6
|
meta: {
|
|
8
7
|
name: 'use-latest-xcss-syntax-typography',
|
|
@@ -15,18 +14,18 @@ var rule = createLintRule({
|
|
|
15
14
|
severity: 'warn'
|
|
16
15
|
},
|
|
17
16
|
messages: {
|
|
18
|
-
noUnsafeTypographyProperties: error
|
|
17
|
+
noUnsafeTypographyProperties: "Don't set '{{ property }}' on xcss. They are unsafe as they allow invalid combinations of typography tokens. There is ongoing work to make this a TypeScript error. Once that happens, you will have to delete/refactor anyway."
|
|
19
18
|
}
|
|
20
19
|
},
|
|
21
20
|
create: function create(context) {
|
|
22
21
|
var config = getConfig(context.options[0]);
|
|
23
22
|
return errorBoundary({
|
|
24
|
-
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Identifier[name=/(fontSize|lineHeight|fontWeight)/]': function
|
|
23
|
+
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Identifier[name=/(fontSize|lineHeight|fontWeight|letterSpacing)/]': function CallExpressionCalleeNameXcssObjectExpressionPropertyIdentifierNameFontSizeLineHeightFontWeightLetterSpacing(node) {
|
|
25
24
|
return BannedProperty.lint(node, {
|
|
26
25
|
context: context
|
|
27
26
|
});
|
|
28
27
|
},
|
|
29
|
-
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Literal[value=/(fontSize|lineHeight|fontWeight)/]': function
|
|
28
|
+
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Literal[value=/(fontSize|lineHeight|fontWeight|letterSpacing)/]': function CallExpressionCalleeNameXcssObjectExpressionPropertyLiteralValueFontSizeLineHeightFontWeightLetterSpacing(node) {
|
|
30
29
|
return BannedProperty.lint(node, {
|
|
31
30
|
context: context
|
|
32
31
|
});
|
|
@@ -1,12 +1,51 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
3
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
1
4
|
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
7
|
export var BannedProperty = {
|
|
5
8
|
lint: function lint(node, _ref) {
|
|
6
9
|
var context = _ref.context;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
if (BannedProperty._check(node)) {
|
|
11
|
+
var property = 'fontSize, lineHeight, fontWeight or letterSpacing';
|
|
12
|
+
if (isNodeOfType(node, 'Identifier')) {
|
|
13
|
+
property = node.name;
|
|
14
|
+
} else if (isNodeOfType(node, 'Literal')) {
|
|
15
|
+
property = String(node.value);
|
|
16
|
+
}
|
|
17
|
+
context.report({
|
|
18
|
+
node: node,
|
|
19
|
+
messageId: 'noUnsafeTypographyProperties',
|
|
20
|
+
data: {
|
|
21
|
+
property: property
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
_check: function _check(node) {
|
|
27
|
+
// Prevent font weight being used in combination with heading tokens
|
|
28
|
+
if (isNodeOfType(node, 'Identifier') && node.name === 'fontWeight' || isNodeOfType(node, 'Literal') && node.value === 'fontWeight') {
|
|
29
|
+
if (isNodeOfType(node.parent.parent, 'ObjectExpression')) {
|
|
30
|
+
var _iterator = _createForOfIteratorHelper(node.parent.parent.properties),
|
|
31
|
+
_step;
|
|
32
|
+
try {
|
|
33
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
34
|
+
var property = _step.value;
|
|
35
|
+
if (isNodeOfType(property, 'Property') && isNodeOfType(property.value, 'CallExpression') && isNodeOfType(property.value.callee, 'Identifier') && isNodeOfType(property.value.arguments[0], 'Literal')) {
|
|
36
|
+
if (property.value.callee.name === 'token' && typeof property.value.arguments[0].value === 'string' && property.value.arguments[0].value.includes('font.heading')) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
} catch (err) {
|
|
42
|
+
_iterator.e(err);
|
|
43
|
+
} finally {
|
|
44
|
+
_iterator.f();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
11
50
|
}
|
|
12
51
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
|
-
export declare const error = "Don't set fontSize, lineHeight, fontWeight properties on xcss. They are unsafe as they allow invalid combinations of typography tokens. There is ongoing work to make this a TypeScript error. Once that happens, you will have to delete/refactor anyway.";
|
|
3
2
|
declare const rule: Rule.RuleModule;
|
|
4
3
|
export default rule;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
|
-
export declare const error = "Don't set fontSize, lineHeight, fontWeight properties on xcss. They are unsafe as they allow invalid combinations of typography tokens. There is ongoing work to make this a TypeScript error. Once that happens, you will have to delete/refactor anyway.";
|
|
3
2
|
declare const rule: Rule.RuleModule;
|
|
4
3
|
export default rule;
|
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": "10.17.
|
|
4
|
+
"version": "10.17.3",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"publishConfig": {
|
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
"name": "ESLint plugin",
|
|
18
18
|
"category": "Tooling"
|
|
19
19
|
},
|
|
20
|
-
"runReact18": true
|
|
20
|
+
"runReact18": true,
|
|
21
|
+
"toolingLabels": [
|
|
22
|
+
"linting"
|
|
23
|
+
]
|
|
21
24
|
},
|
|
22
25
|
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
23
26
|
"main": "dist/cjs/index.js",
|