@atlaskit/eslint-plugin-design-system 13.18.1 → 13.19.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 +8 -0
- package/README.md +1 -0
- package/dist/cjs/presets/all-flat.codegen.js +2 -1
- package/dist/cjs/presets/all.codegen.js +2 -1
- package/dist/cjs/presets/recommended-flat.codegen.js +2 -1
- package/dist/cjs/presets/recommended.codegen.js +2 -1
- package/dist/cjs/rules/index.codegen.js +3 -1
- package/dist/cjs/rules/no-unused-css-map/index.js +51 -0
- package/dist/cjs/rules/no-unused-css-map/utils.js +162 -0
- package/dist/es2019/presets/all-flat.codegen.js +2 -1
- package/dist/es2019/presets/all.codegen.js +2 -1
- package/dist/es2019/presets/recommended-flat.codegen.js +2 -1
- package/dist/es2019/presets/recommended.codegen.js +2 -1
- package/dist/es2019/rules/index.codegen.js +3 -1
- package/dist/es2019/rules/no-unused-css-map/index.js +44 -0
- package/dist/es2019/rules/no-unused-css-map/utils.js +101 -0
- package/dist/esm/presets/all-flat.codegen.js +2 -1
- package/dist/esm/presets/all.codegen.js +2 -1
- package/dist/esm/presets/recommended-flat.codegen.js +2 -1
- package/dist/esm/presets/recommended.codegen.js +2 -1
- package/dist/esm/rules/index.codegen.js +3 -1
- package/dist/esm/rules/no-unused-css-map/index.js +45 -0
- package/dist/esm/rules/no-unused-css-map/utils.js +155 -0
- package/dist/types/index.codegen.d.ts +9 -0
- package/dist/types/presets/all-flat.codegen.d.ts +1 -0
- package/dist/types/presets/all.codegen.d.ts +1 -0
- package/dist/types/presets/recommended-flat.codegen.d.ts +1 -0
- package/dist/types/presets/recommended.codegen.d.ts +1 -0
- package/dist/types/rules/index.codegen.d.ts +1 -0
- package/dist/types/rules/no-unused-css-map/index.d.ts +3 -0
- package/dist/types/rules/no-unused-css-map/utils.d.ts +15 -0
- package/dist/types-ts4.5/index.codegen.d.ts +9 -0
- package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +1 -0
- package/dist/types-ts4.5/presets/all.codegen.d.ts +1 -0
- package/dist/types-ts4.5/presets/recommended-flat.codegen.d.ts +1 -0
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +1 -0
- package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
- package/dist/types-ts4.5/rules/no-unused-css-map/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/no-unused-css-map/utils.d.ts +15 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 13.19.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#187495](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/187495)
|
|
8
|
+
[`8c0b4fd35134d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8c0b4fd35134d) -
|
|
9
|
+
Introduces new ESLint rule to identify unused variables in cssMap.
|
|
10
|
+
|
|
3
11
|
## 13.18.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -91,6 +91,7 @@ module.exports = {
|
|
|
91
91
|
| <a href="./packages/design-system/eslint-plugin/src/rules/no-unsafe-design-token-usage/README.md">no-unsafe-design-token-usage</a> | Enforces design token usage is statically and locally analyzable. | Yes | Yes | |
|
|
92
92
|
| <a href="./packages/design-system/eslint-plugin/src/rules/no-unsafe-style-overrides/README.md">no-unsafe-style-overrides</a> | Discourage usage of unsafe style overrides used against the Atlassian Design System. | Yes | | |
|
|
93
93
|
| <a href="./packages/design-system/eslint-plugin/src/rules/no-unsupported-drag-and-drop-libraries/README.md">no-unsupported-drag-and-drop-libraries</a> | Disallow importing unsupported drag and drop modules. | Yes | | |
|
|
94
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-unused-css-map/README.md">no-unused-css-map</a> | Detects unused styles in cssMap objects to help keep code clean. | Yes | | |
|
|
94
95
|
| <a href="./packages/design-system/eslint-plugin/src/rules/no-utility-icons/README.md">no-utility-icons</a> | Disallow use of deprecated utility icons, in favor of core icons with `size="small"`. | Yes | Yes | Yes |
|
|
95
96
|
| <a href="./packages/design-system/eslint-plugin/src/rules/prefer-primitives/README.md">prefer-primitives</a> | Increase awareness of primitive components via code hints. Strictly used for education purposes and discoverability. To enforce usage please refer to the `use-primitives` rule. | | | |
|
|
96
97
|
| <a href="./packages/design-system/eslint-plugin/src/rules/use-button-group-label/README.md">use-button-group-label</a> | Ensures button groups are described to assistive technology by a direct label or by another element. | Yes | | Yes |
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
9
|
-
* @codegen <<SignedSource::
|
|
9
|
+
* @codegen <<SignedSource::e075ab709ebd382d6f5e39fd78de9d6d>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -54,6 +54,7 @@ var _default = exports.default = {
|
|
|
54
54
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
55
55
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
56
56
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
57
|
+
'@atlaskit/design-system/no-unused-css-map': 'warn',
|
|
57
58
|
'@atlaskit/design-system/no-utility-icons': 'warn',
|
|
58
59
|
'@atlaskit/design-system/prefer-primitives': 'warn',
|
|
59
60
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
9
|
-
* @codegen <<SignedSource::
|
|
9
|
+
* @codegen <<SignedSource::d78f5649534c2e153e3ce48063649a8a>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -53,6 +53,7 @@ var _default = exports.default = {
|
|
|
53
53
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
54
54
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
55
55
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
56
|
+
'@atlaskit/design-system/no-unused-css-map': 'warn',
|
|
56
57
|
'@atlaskit/design-system/no-utility-icons': 'warn',
|
|
57
58
|
'@atlaskit/design-system/prefer-primitives': 'warn',
|
|
58
59
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
9
|
-
* @codegen <<SignedSource::
|
|
9
|
+
* @codegen <<SignedSource::310988af3dc2559509bf99f2110134b8>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -41,6 +41,7 @@ var _default = exports.default = {
|
|
|
41
41
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
42
42
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
43
43
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
44
|
+
'@atlaskit/design-system/no-unused-css-map': 'warn',
|
|
44
45
|
'@atlaskit/design-system/no-utility-icons': 'warn',
|
|
45
46
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
46
47
|
'@atlaskit/design-system/use-correct-field': 'warn',
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
9
|
-
* @codegen <<SignedSource::
|
|
9
|
+
* @codegen <<SignedSource::ce9d9b39fba8bb67d218e48398271109>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -40,6 +40,7 @@ var _default = exports.default = {
|
|
|
40
40
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
41
41
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
42
42
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
43
|
+
'@atlaskit/design-system/no-unused-css-map': 'warn',
|
|
43
44
|
'@atlaskit/design-system/no-utility-icons': 'warn',
|
|
44
45
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
45
46
|
'@atlaskit/design-system/use-correct-field': 'warn',
|
|
@@ -47,6 +47,7 @@ var _noStyledTaggedTemplateExpression = _interopRequireDefault(require("./no-sty
|
|
|
47
47
|
var _noUnsafeDesignTokenUsage = _interopRequireDefault(require("./no-unsafe-design-token-usage"));
|
|
48
48
|
var _noUnsafeStyleOverrides = _interopRequireDefault(require("./no-unsafe-style-overrides"));
|
|
49
49
|
var _noUnsupportedDragAndDropLibraries = _interopRequireDefault(require("./no-unsupported-drag-and-drop-libraries"));
|
|
50
|
+
var _noUnusedCssMap = _interopRequireDefault(require("./no-unused-css-map"));
|
|
50
51
|
var _noUtilityIcons = _interopRequireDefault(require("./no-utility-icons"));
|
|
51
52
|
var _preferPrimitives = _interopRequireDefault(require("./prefer-primitives"));
|
|
52
53
|
var _useButtonGroupLabel = _interopRequireDefault(require("./use-button-group-label"));
|
|
@@ -72,7 +73,7 @@ var _useTokensTypography = _interopRequireDefault(require("./use-tokens-typograp
|
|
|
72
73
|
var _useVisuallyHidden = _interopRequireDefault(require("./use-visually-hidden"));
|
|
73
74
|
/**
|
|
74
75
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
75
|
-
* @codegen <<SignedSource::
|
|
76
|
+
* @codegen <<SignedSource::53ad66d79f989ce9beb46ee0186685b2>>
|
|
76
77
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
77
78
|
*/
|
|
78
79
|
|
|
@@ -119,6 +120,7 @@ var rules = exports.rules = {
|
|
|
119
120
|
'no-unsafe-design-token-usage': _noUnsafeDesignTokenUsage.default,
|
|
120
121
|
'no-unsafe-style-overrides': _noUnsafeStyleOverrides.default,
|
|
121
122
|
'no-unsupported-drag-and-drop-libraries': _noUnsupportedDragAndDropLibraries.default,
|
|
123
|
+
'no-unused-css-map': _noUnusedCssMap.default,
|
|
122
124
|
'no-utility-icons': _noUtilityIcons.default,
|
|
123
125
|
'prefer-primitives': _preferPrimitives.default,
|
|
124
126
|
'use-button-group-label': _useButtonGroupLabel.default,
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
8
|
+
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
9
|
+
var _createRule = require("../utils/create-rule");
|
|
10
|
+
var _utils = require("./utils");
|
|
11
|
+
var IMPORT_SOURCES = [_isSupportedImport.CSS_IN_JS_IMPORTS.compiled, _isSupportedImport.CSS_IN_JS_IMPORTS.atlaskitCss];
|
|
12
|
+
var createUnusedCssMapRule = function createUnusedCssMapRule(context) {
|
|
13
|
+
var _getSourceCode = (0, _contextCompat.getSourceCode)(context),
|
|
14
|
+
text = _getSourceCode.text;
|
|
15
|
+
if (IMPORT_SOURCES.every(function (importSource) {
|
|
16
|
+
return !text.includes(importSource);
|
|
17
|
+
})) {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
CallExpression: function CallExpression(node) {
|
|
22
|
+
var references = (0, _contextCompat.getScope)(context, node).references;
|
|
23
|
+
if (!(0, _isSupportedImport.isCssMap)(node.callee, references, IMPORT_SOURCES)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
var cssMapObject = (0, _utils.getCssMapObject)(node);
|
|
27
|
+
if (!cssMapObject) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
var unusedCssMapChecker = new _utils.UnusedCssMapChecker(cssMapObject, context, node);
|
|
31
|
+
unusedCssMapChecker.run();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
var noUnusedCssMapRule = (0, _createRule.createLintRule)({
|
|
36
|
+
meta: {
|
|
37
|
+
name: 'no-unused-css-map',
|
|
38
|
+
docs: {
|
|
39
|
+
description: 'Detects unused styles in cssMap objects to help keep code clean.',
|
|
40
|
+
recommended: true,
|
|
41
|
+
severity: 'warn'
|
|
42
|
+
},
|
|
43
|
+
messages: {
|
|
44
|
+
unusedCssMapStyle: 'Unused style "{{styleName}}" in cssMap. Consider removing it if not needed.'
|
|
45
|
+
},
|
|
46
|
+
schema: [],
|
|
47
|
+
type: 'suggestion'
|
|
48
|
+
},
|
|
49
|
+
create: createUnusedCssMapRule
|
|
50
|
+
});
|
|
51
|
+
var _default = exports.default = noUnusedCssMapRule;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getCssMapObject = exports.UnusedCssMapChecker = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
12
|
+
var _findVariable = require("@atlaskit/eslint-utils/find-variable");
|
|
13
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
14
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
15
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
16
|
+
var getCssMapObject = exports.getCssMapObject = function getCssMapObject(node) {
|
|
17
|
+
// We assume the argument `node` is already a cssMap() call.
|
|
18
|
+
|
|
19
|
+
// Things like the number of arguments to cssMap and the type of
|
|
20
|
+
// cssMap's argument are handled by the TypeScript compiler, so
|
|
21
|
+
// we don't bother with creating eslint errors for these here
|
|
22
|
+
|
|
23
|
+
if (node.arguments.length !== 1 || node.arguments[0].type !== 'ObjectExpression') {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
return node.arguments[0];
|
|
27
|
+
};
|
|
28
|
+
var UnusedCssMapChecker = exports.UnusedCssMapChecker = /*#__PURE__*/function () {
|
|
29
|
+
function UnusedCssMapChecker(cssMapObject, context, cssMapCallNode) {
|
|
30
|
+
(0, _classCallCheck2.default)(this, UnusedCssMapChecker);
|
|
31
|
+
this.cssMapObject = cssMapObject;
|
|
32
|
+
this.cssMapCallNode = cssMapCallNode;
|
|
33
|
+
this.report = context.report;
|
|
34
|
+
this.context = context;
|
|
35
|
+
}
|
|
36
|
+
return (0, _createClass2.default)(UnusedCssMapChecker, [{
|
|
37
|
+
key: "checkForUnusedStyles",
|
|
38
|
+
value: function checkForUnusedStyles() {
|
|
39
|
+
// Get all defined style keys
|
|
40
|
+
var definedStyles = new Map();
|
|
41
|
+
var _iterator = _createForOfIteratorHelper(this.cssMapObject.properties),
|
|
42
|
+
_step;
|
|
43
|
+
try {
|
|
44
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
45
|
+
var _property = _step.value;
|
|
46
|
+
if (_property.type === 'Property' && _property.key.type === 'Identifier') {
|
|
47
|
+
definedStyles.set(_property.key.name, _property);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} catch (err) {
|
|
51
|
+
_iterator.e(err);
|
|
52
|
+
} finally {
|
|
53
|
+
_iterator.f();
|
|
54
|
+
}
|
|
55
|
+
if (definedStyles.size === 0) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Find the variable that holds the cssMap result
|
|
60
|
+
var cssMapVariable = this.findCssMapVariable();
|
|
61
|
+
if (!cssMapVariable) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Early return if no references - all styles are unused
|
|
66
|
+
if (cssMapVariable.references.length === 0) {
|
|
67
|
+
var _iterator2 = _createForOfIteratorHelper(definedStyles),
|
|
68
|
+
_step2;
|
|
69
|
+
try {
|
|
70
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
71
|
+
var _step2$value = (0, _slicedToArray2.default)(_step2.value, 2),
|
|
72
|
+
styleName = _step2$value[0],
|
|
73
|
+
property = _step2$value[1];
|
|
74
|
+
this.report({
|
|
75
|
+
node: property.key,
|
|
76
|
+
messageId: 'unusedCssMapStyle',
|
|
77
|
+
data: {
|
|
78
|
+
styleName: styleName
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
} catch (err) {
|
|
83
|
+
_iterator2.e(err);
|
|
84
|
+
} finally {
|
|
85
|
+
_iterator2.f();
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
var usedStyles = new Set();
|
|
90
|
+
var _iterator3 = _createForOfIteratorHelper(cssMapVariable.references),
|
|
91
|
+
_step3;
|
|
92
|
+
try {
|
|
93
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
94
|
+
var ref = _step3.value;
|
|
95
|
+
var node = ref.identifier;
|
|
96
|
+
var parent = node.parent;
|
|
97
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'MemberExpression') {
|
|
98
|
+
if (!parent.computed && parent.property.type === 'Identifier') {
|
|
99
|
+
// Static access: styles.danger (not computed)
|
|
100
|
+
usedStyles.add(parent.property.name);
|
|
101
|
+
|
|
102
|
+
// Early exit if all styles are found
|
|
103
|
+
if (usedStyles.size === definedStyles.size) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
// Dynamic access: styles[key], styles['danger'], etc. (computed)
|
|
108
|
+
// Immediately exit - no styles will be reported as unused
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// No dynamic access - report all unused styles
|
|
115
|
+
} catch (err) {
|
|
116
|
+
_iterator3.e(err);
|
|
117
|
+
} finally {
|
|
118
|
+
_iterator3.f();
|
|
119
|
+
}
|
|
120
|
+
var _iterator4 = _createForOfIteratorHelper(definedStyles),
|
|
121
|
+
_step4;
|
|
122
|
+
try {
|
|
123
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
124
|
+
var _step4$value = (0, _slicedToArray2.default)(_step4.value, 2),
|
|
125
|
+
_styleName = _step4$value[0],
|
|
126
|
+
_property2 = _step4$value[1];
|
|
127
|
+
if (!usedStyles.has(_styleName)) {
|
|
128
|
+
this.report({
|
|
129
|
+
node: _property2.key,
|
|
130
|
+
messageId: 'unusedCssMapStyle',
|
|
131
|
+
data: {
|
|
132
|
+
styleName: _styleName
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
} catch (err) {
|
|
138
|
+
_iterator4.e(err);
|
|
139
|
+
} finally {
|
|
140
|
+
_iterator4.f();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}, {
|
|
144
|
+
key: "findCssMapVariable",
|
|
145
|
+
value: function findCssMapVariable() {
|
|
146
|
+
var callNode = this.cssMapCallNode;
|
|
147
|
+
var parent = callNode.parent;
|
|
148
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'VariableDeclarator' && parent.id.type === 'Identifier') {
|
|
149
|
+
return (0, _findVariable.findVariable)({
|
|
150
|
+
identifier: parent.id,
|
|
151
|
+
sourceCode: (0, _contextCompat.getSourceCode)(this.context)
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
}, {
|
|
157
|
+
key: "run",
|
|
158
|
+
value: function run() {
|
|
159
|
+
this.checkForUnusedStyles();
|
|
160
|
+
}
|
|
161
|
+
}]);
|
|
162
|
+
}();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::e075ab709ebd382d6f5e39fd78de9d6d>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -49,6 +49,7 @@ export default {
|
|
|
49
49
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
50
50
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
51
51
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
52
|
+
'@atlaskit/design-system/no-unused-css-map': 'warn',
|
|
52
53
|
'@atlaskit/design-system/no-utility-icons': 'warn',
|
|
53
54
|
'@atlaskit/design-system/prefer-primitives': 'warn',
|
|
54
55
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::d78f5649534c2e153e3ce48063649a8a>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -48,6 +48,7 @@ export default {
|
|
|
48
48
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
49
49
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
50
50
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
51
|
+
'@atlaskit/design-system/no-unused-css-map': 'warn',
|
|
51
52
|
'@atlaskit/design-system/no-utility-icons': 'warn',
|
|
52
53
|
'@atlaskit/design-system/prefer-primitives': 'warn',
|
|
53
54
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::310988af3dc2559509bf99f2110134b8>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -36,6 +36,7 @@ export default {
|
|
|
36
36
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
37
37
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
38
38
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
39
|
+
'@atlaskit/design-system/no-unused-css-map': 'warn',
|
|
39
40
|
'@atlaskit/design-system/no-utility-icons': 'warn',
|
|
40
41
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
41
42
|
'@atlaskit/design-system/use-correct-field': 'warn',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::ce9d9b39fba8bb67d218e48398271109>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -35,6 +35,7 @@ export default {
|
|
|
35
35
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
36
36
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
37
37
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
38
|
+
'@atlaskit/design-system/no-unused-css-map': 'warn',
|
|
38
39
|
'@atlaskit/design-system/no-utility-icons': 'warn',
|
|
39
40
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
40
41
|
'@atlaskit/design-system/use-correct-field': 'warn',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::53ad66d79f989ce9beb46ee0186685b2>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
import consistentCssPropUsage from './consistent-css-prop-usage';
|
|
@@ -45,6 +45,7 @@ import noStyledTaggedTemplateExpression from './no-styled-tagged-template-expres
|
|
|
45
45
|
import noUnsafeDesignTokenUsage from './no-unsafe-design-token-usage';
|
|
46
46
|
import noUnsafeStyleOverrides from './no-unsafe-style-overrides';
|
|
47
47
|
import noUnsupportedDragAndDropLibraries from './no-unsupported-drag-and-drop-libraries';
|
|
48
|
+
import noUnusedCssMap from './no-unused-css-map';
|
|
48
49
|
import noUtilityIcons from './no-utility-icons';
|
|
49
50
|
import preferPrimitives from './prefer-primitives';
|
|
50
51
|
import useButtonGroupLabel from './use-button-group-label';
|
|
@@ -111,6 +112,7 @@ export const rules = {
|
|
|
111
112
|
'no-unsafe-design-token-usage': noUnsafeDesignTokenUsage,
|
|
112
113
|
'no-unsafe-style-overrides': noUnsafeStyleOverrides,
|
|
113
114
|
'no-unsupported-drag-and-drop-libraries': noUnsupportedDragAndDropLibraries,
|
|
115
|
+
'no-unused-css-map': noUnusedCssMap,
|
|
114
116
|
'no-utility-icons': noUtilityIcons,
|
|
115
117
|
'prefer-primitives': preferPrimitives,
|
|
116
118
|
'use-button-group-label': useButtonGroupLabel,
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { getScope, getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
2
|
+
import { CSS_IN_JS_IMPORTS, isCssMap } from '@atlaskit/eslint-utils/is-supported-import';
|
|
3
|
+
import { createLintRule } from '../utils/create-rule';
|
|
4
|
+
import { getCssMapObject, UnusedCssMapChecker } from './utils';
|
|
5
|
+
const IMPORT_SOURCES = [CSS_IN_JS_IMPORTS.compiled, CSS_IN_JS_IMPORTS.atlaskitCss];
|
|
6
|
+
const createUnusedCssMapRule = context => {
|
|
7
|
+
const {
|
|
8
|
+
text
|
|
9
|
+
} = getSourceCode(context);
|
|
10
|
+
if (IMPORT_SOURCES.every(importSource => !text.includes(importSource))) {
|
|
11
|
+
return {};
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
CallExpression(node) {
|
|
15
|
+
const references = getScope(context, node).references;
|
|
16
|
+
if (!isCssMap(node.callee, references, IMPORT_SOURCES)) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const cssMapObject = getCssMapObject(node);
|
|
20
|
+
if (!cssMapObject) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const unusedCssMapChecker = new UnusedCssMapChecker(cssMapObject, context, node);
|
|
24
|
+
unusedCssMapChecker.run();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const noUnusedCssMapRule = createLintRule({
|
|
29
|
+
meta: {
|
|
30
|
+
name: 'no-unused-css-map',
|
|
31
|
+
docs: {
|
|
32
|
+
description: 'Detects unused styles in cssMap objects to help keep code clean.',
|
|
33
|
+
recommended: true,
|
|
34
|
+
severity: 'warn'
|
|
35
|
+
},
|
|
36
|
+
messages: {
|
|
37
|
+
unusedCssMapStyle: 'Unused style "{{styleName}}" in cssMap. Consider removing it if not needed.'
|
|
38
|
+
},
|
|
39
|
+
schema: [],
|
|
40
|
+
type: 'suggestion'
|
|
41
|
+
},
|
|
42
|
+
create: createUnusedCssMapRule
|
|
43
|
+
});
|
|
44
|
+
export default noUnusedCssMapRule;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
2
|
+
import { findVariable } from '@atlaskit/eslint-utils/find-variable';
|
|
3
|
+
export const getCssMapObject = node => {
|
|
4
|
+
// We assume the argument `node` is already a cssMap() call.
|
|
5
|
+
|
|
6
|
+
// Things like the number of arguments to cssMap and the type of
|
|
7
|
+
// cssMap's argument are handled by the TypeScript compiler, so
|
|
8
|
+
// we don't bother with creating eslint errors for these here
|
|
9
|
+
|
|
10
|
+
if (node.arguments.length !== 1 || node.arguments[0].type !== 'ObjectExpression') {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
return node.arguments[0];
|
|
14
|
+
};
|
|
15
|
+
export class UnusedCssMapChecker {
|
|
16
|
+
constructor(cssMapObject, context, cssMapCallNode) {
|
|
17
|
+
this.cssMapObject = cssMapObject;
|
|
18
|
+
this.cssMapCallNode = cssMapCallNode;
|
|
19
|
+
this.report = context.report;
|
|
20
|
+
this.context = context;
|
|
21
|
+
}
|
|
22
|
+
checkForUnusedStyles() {
|
|
23
|
+
// Get all defined style keys
|
|
24
|
+
const definedStyles = new Map();
|
|
25
|
+
for (const property of this.cssMapObject.properties) {
|
|
26
|
+
if (property.type === 'Property' && property.key.type === 'Identifier') {
|
|
27
|
+
definedStyles.set(property.key.name, property);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (definedStyles.size === 0) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Find the variable that holds the cssMap result
|
|
35
|
+
const cssMapVariable = this.findCssMapVariable();
|
|
36
|
+
if (!cssMapVariable) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Early return if no references - all styles are unused
|
|
41
|
+
if (cssMapVariable.references.length === 0) {
|
|
42
|
+
for (const [styleName, property] of definedStyles) {
|
|
43
|
+
this.report({
|
|
44
|
+
node: property.key,
|
|
45
|
+
messageId: 'unusedCssMapStyle',
|
|
46
|
+
data: {
|
|
47
|
+
styleName
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const usedStyles = new Set();
|
|
54
|
+
for (const ref of cssMapVariable.references) {
|
|
55
|
+
const node = ref.identifier;
|
|
56
|
+
const parent = node.parent;
|
|
57
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'MemberExpression') {
|
|
58
|
+
if (!parent.computed && parent.property.type === 'Identifier') {
|
|
59
|
+
// Static access: styles.danger (not computed)
|
|
60
|
+
usedStyles.add(parent.property.name);
|
|
61
|
+
|
|
62
|
+
// Early exit if all styles are found
|
|
63
|
+
if (usedStyles.size === definedStyles.size) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
// Dynamic access: styles[key], styles['danger'], etc. (computed)
|
|
68
|
+
// Immediately exit - no styles will be reported as unused
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// No dynamic access - report all unused styles
|
|
75
|
+
for (const [styleName, property] of definedStyles) {
|
|
76
|
+
if (!usedStyles.has(styleName)) {
|
|
77
|
+
this.report({
|
|
78
|
+
node: property.key,
|
|
79
|
+
messageId: 'unusedCssMapStyle',
|
|
80
|
+
data: {
|
|
81
|
+
styleName
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
findCssMapVariable() {
|
|
88
|
+
const callNode = this.cssMapCallNode;
|
|
89
|
+
const parent = callNode.parent;
|
|
90
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'VariableDeclarator' && parent.id.type === 'Identifier') {
|
|
91
|
+
return findVariable({
|
|
92
|
+
identifier: parent.id,
|
|
93
|
+
sourceCode: getSourceCode(this.context)
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
run() {
|
|
99
|
+
this.checkForUnusedStyles();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::e075ab709ebd382d6f5e39fd78de9d6d>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -49,6 +49,7 @@ export default {
|
|
|
49
49
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
50
50
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
51
51
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
52
|
+
'@atlaskit/design-system/no-unused-css-map': 'warn',
|
|
52
53
|
'@atlaskit/design-system/no-utility-icons': 'warn',
|
|
53
54
|
'@atlaskit/design-system/prefer-primitives': 'warn',
|
|
54
55
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::d78f5649534c2e153e3ce48063649a8a>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -48,6 +48,7 @@ export default {
|
|
|
48
48
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
49
49
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
50
50
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
51
|
+
'@atlaskit/design-system/no-unused-css-map': 'warn',
|
|
51
52
|
'@atlaskit/design-system/no-utility-icons': 'warn',
|
|
52
53
|
'@atlaskit/design-system/prefer-primitives': 'warn',
|
|
53
54
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::310988af3dc2559509bf99f2110134b8>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -36,6 +36,7 @@ export default {
|
|
|
36
36
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
37
37
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
38
38
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
39
|
+
'@atlaskit/design-system/no-unused-css-map': 'warn',
|
|
39
40
|
'@atlaskit/design-system/no-utility-icons': 'warn',
|
|
40
41
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
41
42
|
'@atlaskit/design-system/use-correct-field': 'warn',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::ce9d9b39fba8bb67d218e48398271109>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -35,6 +35,7 @@ export default {
|
|
|
35
35
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
36
36
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
37
37
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
38
|
+
'@atlaskit/design-system/no-unused-css-map': 'warn',
|
|
38
39
|
'@atlaskit/design-system/no-utility-icons': 'warn',
|
|
39
40
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
40
41
|
'@atlaskit/design-system/use-correct-field': 'warn',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::53ad66d79f989ce9beb46ee0186685b2>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
import consistentCssPropUsage from './consistent-css-prop-usage';
|
|
@@ -45,6 +45,7 @@ import noStyledTaggedTemplateExpression from './no-styled-tagged-template-expres
|
|
|
45
45
|
import noUnsafeDesignTokenUsage from './no-unsafe-design-token-usage';
|
|
46
46
|
import noUnsafeStyleOverrides from './no-unsafe-style-overrides';
|
|
47
47
|
import noUnsupportedDragAndDropLibraries from './no-unsupported-drag-and-drop-libraries';
|
|
48
|
+
import noUnusedCssMap from './no-unused-css-map';
|
|
48
49
|
import noUtilityIcons from './no-utility-icons';
|
|
49
50
|
import preferPrimitives from './prefer-primitives';
|
|
50
51
|
import useButtonGroupLabel from './use-button-group-label';
|
|
@@ -111,6 +112,7 @@ export var rules = {
|
|
|
111
112
|
'no-unsafe-design-token-usage': noUnsafeDesignTokenUsage,
|
|
112
113
|
'no-unsafe-style-overrides': noUnsafeStyleOverrides,
|
|
113
114
|
'no-unsupported-drag-and-drop-libraries': noUnsupportedDragAndDropLibraries,
|
|
115
|
+
'no-unused-css-map': noUnusedCssMap,
|
|
114
116
|
'no-utility-icons': noUtilityIcons,
|
|
115
117
|
'prefer-primitives': preferPrimitives,
|
|
116
118
|
'use-button-group-label': useButtonGroupLabel,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { getScope, getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
2
|
+
import { CSS_IN_JS_IMPORTS, isCssMap } from '@atlaskit/eslint-utils/is-supported-import';
|
|
3
|
+
import { createLintRule } from '../utils/create-rule';
|
|
4
|
+
import { getCssMapObject, UnusedCssMapChecker } from './utils';
|
|
5
|
+
var IMPORT_SOURCES = [CSS_IN_JS_IMPORTS.compiled, CSS_IN_JS_IMPORTS.atlaskitCss];
|
|
6
|
+
var createUnusedCssMapRule = function createUnusedCssMapRule(context) {
|
|
7
|
+
var _getSourceCode = getSourceCode(context),
|
|
8
|
+
text = _getSourceCode.text;
|
|
9
|
+
if (IMPORT_SOURCES.every(function (importSource) {
|
|
10
|
+
return !text.includes(importSource);
|
|
11
|
+
})) {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
CallExpression: function CallExpression(node) {
|
|
16
|
+
var references = getScope(context, node).references;
|
|
17
|
+
if (!isCssMap(node.callee, references, IMPORT_SOURCES)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
var cssMapObject = getCssMapObject(node);
|
|
21
|
+
if (!cssMapObject) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
var unusedCssMapChecker = new UnusedCssMapChecker(cssMapObject, context, node);
|
|
25
|
+
unusedCssMapChecker.run();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
var noUnusedCssMapRule = createLintRule({
|
|
30
|
+
meta: {
|
|
31
|
+
name: 'no-unused-css-map',
|
|
32
|
+
docs: {
|
|
33
|
+
description: 'Detects unused styles in cssMap objects to help keep code clean.',
|
|
34
|
+
recommended: true,
|
|
35
|
+
severity: 'warn'
|
|
36
|
+
},
|
|
37
|
+
messages: {
|
|
38
|
+
unusedCssMapStyle: 'Unused style "{{styleName}}" in cssMap. Consider removing it if not needed.'
|
|
39
|
+
},
|
|
40
|
+
schema: [],
|
|
41
|
+
type: 'suggestion'
|
|
42
|
+
},
|
|
43
|
+
create: createUnusedCssMapRule
|
|
44
|
+
});
|
|
45
|
+
export default noUnusedCssMapRule;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
5
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
6
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
7
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
8
|
+
import { findVariable } from '@atlaskit/eslint-utils/find-variable';
|
|
9
|
+
export var getCssMapObject = function getCssMapObject(node) {
|
|
10
|
+
// We assume the argument `node` is already a cssMap() call.
|
|
11
|
+
|
|
12
|
+
// Things like the number of arguments to cssMap and the type of
|
|
13
|
+
// cssMap's argument are handled by the TypeScript compiler, so
|
|
14
|
+
// we don't bother with creating eslint errors for these here
|
|
15
|
+
|
|
16
|
+
if (node.arguments.length !== 1 || node.arguments[0].type !== 'ObjectExpression') {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
return node.arguments[0];
|
|
20
|
+
};
|
|
21
|
+
export var UnusedCssMapChecker = /*#__PURE__*/function () {
|
|
22
|
+
function UnusedCssMapChecker(cssMapObject, context, cssMapCallNode) {
|
|
23
|
+
_classCallCheck(this, UnusedCssMapChecker);
|
|
24
|
+
this.cssMapObject = cssMapObject;
|
|
25
|
+
this.cssMapCallNode = cssMapCallNode;
|
|
26
|
+
this.report = context.report;
|
|
27
|
+
this.context = context;
|
|
28
|
+
}
|
|
29
|
+
return _createClass(UnusedCssMapChecker, [{
|
|
30
|
+
key: "checkForUnusedStyles",
|
|
31
|
+
value: function checkForUnusedStyles() {
|
|
32
|
+
// Get all defined style keys
|
|
33
|
+
var definedStyles = new Map();
|
|
34
|
+
var _iterator = _createForOfIteratorHelper(this.cssMapObject.properties),
|
|
35
|
+
_step;
|
|
36
|
+
try {
|
|
37
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
38
|
+
var _property = _step.value;
|
|
39
|
+
if (_property.type === 'Property' && _property.key.type === 'Identifier') {
|
|
40
|
+
definedStyles.set(_property.key.name, _property);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} catch (err) {
|
|
44
|
+
_iterator.e(err);
|
|
45
|
+
} finally {
|
|
46
|
+
_iterator.f();
|
|
47
|
+
}
|
|
48
|
+
if (definedStyles.size === 0) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Find the variable that holds the cssMap result
|
|
53
|
+
var cssMapVariable = this.findCssMapVariable();
|
|
54
|
+
if (!cssMapVariable) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Early return if no references - all styles are unused
|
|
59
|
+
if (cssMapVariable.references.length === 0) {
|
|
60
|
+
var _iterator2 = _createForOfIteratorHelper(definedStyles),
|
|
61
|
+
_step2;
|
|
62
|
+
try {
|
|
63
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
64
|
+
var _step2$value = _slicedToArray(_step2.value, 2),
|
|
65
|
+
styleName = _step2$value[0],
|
|
66
|
+
property = _step2$value[1];
|
|
67
|
+
this.report({
|
|
68
|
+
node: property.key,
|
|
69
|
+
messageId: 'unusedCssMapStyle',
|
|
70
|
+
data: {
|
|
71
|
+
styleName: styleName
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
} catch (err) {
|
|
76
|
+
_iterator2.e(err);
|
|
77
|
+
} finally {
|
|
78
|
+
_iterator2.f();
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
var usedStyles = new Set();
|
|
83
|
+
var _iterator3 = _createForOfIteratorHelper(cssMapVariable.references),
|
|
84
|
+
_step3;
|
|
85
|
+
try {
|
|
86
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
87
|
+
var ref = _step3.value;
|
|
88
|
+
var node = ref.identifier;
|
|
89
|
+
var parent = node.parent;
|
|
90
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'MemberExpression') {
|
|
91
|
+
if (!parent.computed && parent.property.type === 'Identifier') {
|
|
92
|
+
// Static access: styles.danger (not computed)
|
|
93
|
+
usedStyles.add(parent.property.name);
|
|
94
|
+
|
|
95
|
+
// Early exit if all styles are found
|
|
96
|
+
if (usedStyles.size === definedStyles.size) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
// Dynamic access: styles[key], styles['danger'], etc. (computed)
|
|
101
|
+
// Immediately exit - no styles will be reported as unused
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// No dynamic access - report all unused styles
|
|
108
|
+
} catch (err) {
|
|
109
|
+
_iterator3.e(err);
|
|
110
|
+
} finally {
|
|
111
|
+
_iterator3.f();
|
|
112
|
+
}
|
|
113
|
+
var _iterator4 = _createForOfIteratorHelper(definedStyles),
|
|
114
|
+
_step4;
|
|
115
|
+
try {
|
|
116
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
117
|
+
var _step4$value = _slicedToArray(_step4.value, 2),
|
|
118
|
+
_styleName = _step4$value[0],
|
|
119
|
+
_property2 = _step4$value[1];
|
|
120
|
+
if (!usedStyles.has(_styleName)) {
|
|
121
|
+
this.report({
|
|
122
|
+
node: _property2.key,
|
|
123
|
+
messageId: 'unusedCssMapStyle',
|
|
124
|
+
data: {
|
|
125
|
+
styleName: _styleName
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
} catch (err) {
|
|
131
|
+
_iterator4.e(err);
|
|
132
|
+
} finally {
|
|
133
|
+
_iterator4.f();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}, {
|
|
137
|
+
key: "findCssMapVariable",
|
|
138
|
+
value: function findCssMapVariable() {
|
|
139
|
+
var callNode = this.cssMapCallNode;
|
|
140
|
+
var parent = callNode.parent;
|
|
141
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'VariableDeclarator' && parent.id.type === 'Identifier') {
|
|
142
|
+
return findVariable({
|
|
143
|
+
identifier: parent.id,
|
|
144
|
+
sourceCode: getSourceCode(this.context)
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
}, {
|
|
150
|
+
key: "run",
|
|
151
|
+
value: function run() {
|
|
152
|
+
this.checkForUnusedStyles();
|
|
153
|
+
}
|
|
154
|
+
}]);
|
|
155
|
+
}();
|
|
@@ -57,6 +57,7 @@ export declare const plugin: {
|
|
|
57
57
|
'no-unsafe-design-token-usage': import("eslint").Rule.RuleModule;
|
|
58
58
|
'no-unsafe-style-overrides': import("eslint").Rule.RuleModule;
|
|
59
59
|
'no-unsupported-drag-and-drop-libraries': import("eslint").Rule.RuleModule;
|
|
60
|
+
'no-unused-css-map': import("eslint").Rule.RuleModule;
|
|
60
61
|
'no-utility-icons': import("eslint").Rule.RuleModule;
|
|
61
62
|
'prefer-primitives': import("eslint").Rule.RuleModule;
|
|
62
63
|
'use-button-group-label': import("eslint").Rule.RuleModule;
|
|
@@ -126,6 +127,7 @@ export declare const plugin: {
|
|
|
126
127
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
127
128
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
128
129
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
130
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
129
131
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
130
132
|
'@atlaskit/design-system/prefer-primitives': "warn";
|
|
131
133
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
@@ -197,6 +199,7 @@ export declare const plugin: {
|
|
|
197
199
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
198
200
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
199
201
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
202
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
200
203
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
201
204
|
'@atlaskit/design-system/prefer-primitives': "warn";
|
|
202
205
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
@@ -253,6 +256,7 @@ export declare const plugin: {
|
|
|
253
256
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
254
257
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
255
258
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
259
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
256
260
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
257
261
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
258
262
|
'@atlaskit/design-system/use-correct-field': "warn";
|
|
@@ -305,6 +309,7 @@ export declare const plugin: {
|
|
|
305
309
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
306
310
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
307
311
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
312
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
308
313
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
309
314
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
310
315
|
'@atlaskit/design-system/use-correct-field': "warn";
|
|
@@ -371,6 +376,7 @@ declare const configs: {
|
|
|
371
376
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
372
377
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
373
378
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
379
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
374
380
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
375
381
|
'@atlaskit/design-system/prefer-primitives': "warn";
|
|
376
382
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
@@ -442,6 +448,7 @@ declare const configs: {
|
|
|
442
448
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
443
449
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
444
450
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
451
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
445
452
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
446
453
|
'@atlaskit/design-system/prefer-primitives': "warn";
|
|
447
454
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
@@ -498,6 +505,7 @@ declare const configs: {
|
|
|
498
505
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
499
506
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
500
507
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
508
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
501
509
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
502
510
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
503
511
|
'@atlaskit/design-system/use-correct-field': "warn";
|
|
@@ -550,6 +558,7 @@ declare const configs: {
|
|
|
550
558
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
551
559
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
552
560
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
561
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
553
562
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
554
563
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
555
564
|
'@atlaskit/design-system/use-correct-field': "warn";
|
|
@@ -42,6 +42,7 @@ declare const _default: {
|
|
|
42
42
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
43
43
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
44
44
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
45
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
45
46
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
46
47
|
'@atlaskit/design-system/prefer-primitives': "warn";
|
|
47
48
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
@@ -42,6 +42,7 @@ declare const _default: {
|
|
|
42
42
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
43
43
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
44
44
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
45
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
45
46
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
46
47
|
'@atlaskit/design-system/prefer-primitives': "warn";
|
|
47
48
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
@@ -29,6 +29,7 @@ declare const _default: {
|
|
|
29
29
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
30
30
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
31
31
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
32
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
32
33
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
33
34
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
34
35
|
'@atlaskit/design-system/use-correct-field': "warn";
|
|
@@ -29,6 +29,7 @@ declare const _default: {
|
|
|
29
29
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
30
30
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
31
31
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
32
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
32
33
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
33
34
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
34
35
|
'@atlaskit/design-system/use-correct-field': "warn";
|
|
@@ -41,6 +41,7 @@ export declare const rules: {
|
|
|
41
41
|
'no-unsafe-design-token-usage': import("eslint").Rule.RuleModule;
|
|
42
42
|
'no-unsafe-style-overrides': import("eslint").Rule.RuleModule;
|
|
43
43
|
'no-unsupported-drag-and-drop-libraries': import("eslint").Rule.RuleModule;
|
|
44
|
+
'no-unused-css-map': import("eslint").Rule.RuleModule;
|
|
44
45
|
'no-utility-icons': import("eslint").Rule.RuleModule;
|
|
45
46
|
'prefer-primitives': import("eslint").Rule.RuleModule;
|
|
46
47
|
'use-button-group-label': import("eslint").Rule.RuleModule;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import type { CallExpression as ESCallExpression, ObjectExpression } from 'estree';
|
|
3
|
+
type CallExpression = ESCallExpression & Rule.NodeParentExtension;
|
|
4
|
+
export declare const getCssMapObject: (node: CallExpression) => ObjectExpression | undefined;
|
|
5
|
+
export declare class UnusedCssMapChecker {
|
|
6
|
+
private readonly cssMapObject;
|
|
7
|
+
private readonly cssMapCallNode;
|
|
8
|
+
private readonly report;
|
|
9
|
+
private readonly context;
|
|
10
|
+
constructor(cssMapObject: ObjectExpression, context: Rule.RuleContext, cssMapCallNode: CallExpression);
|
|
11
|
+
private checkForUnusedStyles;
|
|
12
|
+
private findCssMapVariable;
|
|
13
|
+
run(): void;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -57,6 +57,7 @@ export declare const plugin: {
|
|
|
57
57
|
'no-unsafe-design-token-usage': import("eslint").Rule.RuleModule;
|
|
58
58
|
'no-unsafe-style-overrides': import("eslint").Rule.RuleModule;
|
|
59
59
|
'no-unsupported-drag-and-drop-libraries': import("eslint").Rule.RuleModule;
|
|
60
|
+
'no-unused-css-map': import("eslint").Rule.RuleModule;
|
|
60
61
|
'no-utility-icons': import("eslint").Rule.RuleModule;
|
|
61
62
|
'prefer-primitives': import("eslint").Rule.RuleModule;
|
|
62
63
|
'use-button-group-label': import("eslint").Rule.RuleModule;
|
|
@@ -129,6 +130,7 @@ export declare const plugin: {
|
|
|
129
130
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
130
131
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
131
132
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
133
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
132
134
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
133
135
|
'@atlaskit/design-system/prefer-primitives': "warn";
|
|
134
136
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
@@ -203,6 +205,7 @@ export declare const plugin: {
|
|
|
203
205
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
204
206
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
205
207
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
208
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
206
209
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
207
210
|
'@atlaskit/design-system/prefer-primitives': "warn";
|
|
208
211
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
@@ -262,6 +265,7 @@ export declare const plugin: {
|
|
|
262
265
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
263
266
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
264
267
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
268
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
265
269
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
266
270
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
267
271
|
'@atlaskit/design-system/use-correct-field': "warn";
|
|
@@ -317,6 +321,7 @@ export declare const plugin: {
|
|
|
317
321
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
318
322
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
319
323
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
324
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
320
325
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
321
326
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
322
327
|
'@atlaskit/design-system/use-correct-field': "warn";
|
|
@@ -386,6 +391,7 @@ declare const configs: {
|
|
|
386
391
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
387
392
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
388
393
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
394
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
389
395
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
390
396
|
'@atlaskit/design-system/prefer-primitives': "warn";
|
|
391
397
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
@@ -460,6 +466,7 @@ declare const configs: {
|
|
|
460
466
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
461
467
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
462
468
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
469
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
463
470
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
464
471
|
'@atlaskit/design-system/prefer-primitives': "warn";
|
|
465
472
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
@@ -519,6 +526,7 @@ declare const configs: {
|
|
|
519
526
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
520
527
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
521
528
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
529
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
522
530
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
523
531
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
524
532
|
'@atlaskit/design-system/use-correct-field': "warn";
|
|
@@ -574,6 +582,7 @@ declare const configs: {
|
|
|
574
582
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
575
583
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
576
584
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
585
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
577
586
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
578
587
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
579
588
|
'@atlaskit/design-system/use-correct-field': "warn";
|
|
@@ -45,6 +45,7 @@ declare const _default: {
|
|
|
45
45
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
46
46
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
47
47
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
48
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
48
49
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
49
50
|
'@atlaskit/design-system/prefer-primitives': "warn";
|
|
50
51
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
@@ -45,6 +45,7 @@ declare const _default: {
|
|
|
45
45
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
46
46
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
47
47
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
48
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
48
49
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
49
50
|
'@atlaskit/design-system/prefer-primitives': "warn";
|
|
50
51
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
@@ -32,6 +32,7 @@ declare const _default: {
|
|
|
32
32
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
33
33
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
34
34
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
35
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
35
36
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
36
37
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
37
38
|
'@atlaskit/design-system/use-correct-field': "warn";
|
|
@@ -32,6 +32,7 @@ declare const _default: {
|
|
|
32
32
|
'@atlaskit/design-system/no-unsafe-design-token-usage': "error";
|
|
33
33
|
'@atlaskit/design-system/no-unsafe-style-overrides': "warn";
|
|
34
34
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': "error";
|
|
35
|
+
'@atlaskit/design-system/no-unused-css-map': "warn";
|
|
35
36
|
'@atlaskit/design-system/no-utility-icons': "warn";
|
|
36
37
|
'@atlaskit/design-system/use-button-group-label': "warn";
|
|
37
38
|
'@atlaskit/design-system/use-correct-field': "warn";
|
|
@@ -41,6 +41,7 @@ export declare const rules: {
|
|
|
41
41
|
'no-unsafe-design-token-usage': import("eslint").Rule.RuleModule;
|
|
42
42
|
'no-unsafe-style-overrides': import("eslint").Rule.RuleModule;
|
|
43
43
|
'no-unsupported-drag-and-drop-libraries': import("eslint").Rule.RuleModule;
|
|
44
|
+
'no-unused-css-map': import("eslint").Rule.RuleModule;
|
|
44
45
|
'no-utility-icons': import("eslint").Rule.RuleModule;
|
|
45
46
|
'prefer-primitives': import("eslint").Rule.RuleModule;
|
|
46
47
|
'use-button-group-label': import("eslint").Rule.RuleModule;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import type { CallExpression as ESCallExpression, ObjectExpression } from 'estree';
|
|
3
|
+
type CallExpression = ESCallExpression & Rule.NodeParentExtension;
|
|
4
|
+
export declare const getCssMapObject: (node: CallExpression) => ObjectExpression | undefined;
|
|
5
|
+
export declare class UnusedCssMapChecker {
|
|
6
|
+
private readonly cssMapObject;
|
|
7
|
+
private readonly cssMapCallNode;
|
|
8
|
+
private readonly report;
|
|
9
|
+
private readonly context;
|
|
10
|
+
constructor(cssMapObject: ObjectExpression, context: Rule.RuleContext, cssMapCallNode: CallExpression);
|
|
11
|
+
private checkForUnusedStyles;
|
|
12
|
+
private findCssMapVariable;
|
|
13
|
+
run(): void;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
package/package.json
CHANGED