@atlaskit/eslint-plugin-ui-styling-standard 2.1.9 → 2.1.10
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 -1
- package/dist/cjs/index.codegen.js +2 -2
- package/dist/cjs/presets/all-flat.codegen.js +2 -2
- package/dist/cjs/presets/all.codegen.js +2 -2
- package/dist/cjs/presets/recommended-flat.codegen.js +2 -2
- package/dist/cjs/presets/recommended.codegen.js +2 -2
- package/dist/cjs/rules/atlaskit-theme/index.js +159 -52
- package/dist/cjs/rules/index.codegen.js +2 -2
- package/dist/es2019/index.codegen.js +2 -2
- package/dist/es2019/presets/all-flat.codegen.js +2 -2
- package/dist/es2019/presets/all.codegen.js +2 -2
- package/dist/es2019/presets/recommended-flat.codegen.js +2 -2
- package/dist/es2019/presets/recommended.codegen.js +2 -2
- package/dist/es2019/rules/atlaskit-theme/index.js +117 -50
- package/dist/es2019/rules/index.codegen.js +2 -2
- package/dist/esm/index.codegen.js +2 -2
- package/dist/esm/presets/all-flat.codegen.js +2 -2
- package/dist/esm/presets/all.codegen.js +2 -2
- package/dist/esm/presets/recommended-flat.codegen.js +2 -2
- package/dist/esm/presets/recommended.codegen.js +2 -2
- package/dist/esm/rules/atlaskit-theme/index.js +159 -53
- package/dist/esm/rules/index.codegen.js +2 -2
- package/dist/types/index.codegen.d.ts +2 -2
- package/dist/types/presets/all-flat.codegen.d.ts +2 -2
- package/dist/types/presets/all.codegen.d.ts +2 -2
- package/dist/types/presets/recommended-flat.codegen.d.ts +2 -2
- package/dist/types/presets/recommended.codegen.d.ts +2 -2
- package/dist/types/rules/index.codegen.d.ts +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-ui-styling-standard
|
|
2
2
|
|
|
3
|
+
## 2.1.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`62aaaa3da8184`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/62aaaa3da8184) -
|
|
8
|
+
Speed up the atlaskit-theme lint rule by skipping files that do not import the banned theme
|
|
9
|
+
mixins, and by checking each Compiled call once instead of every nested identifier.
|
|
10
|
+
|
|
3
11
|
## 2.1.9
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ module.exports = {
|
|
|
38
38
|
## Rules
|
|
39
39
|
|
|
40
40
|
<!-- START_RULE_TABLE_CODEGEN -->
|
|
41
|
-
<!-- @codegenCommand
|
|
41
|
+
<!-- @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen -->
|
|
42
42
|
|
|
43
43
|
| Rule | Description | Recommended | Fixable | Suggestions |
|
|
44
44
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | ------- | ----------- |
|
|
@@ -20,8 +20,8 @@ var _index = require("./rules/index.codegen");
|
|
|
20
20
|
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; }
|
|
21
21
|
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) { (0, _defineProperty2.default)(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; } /**
|
|
22
22
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
23
|
-
* @codegen <<SignedSource::
|
|
24
|
-
* @codegenCommand
|
|
23
|
+
* @codegen <<SignedSource::ef33ad38180e99be70285ddb225c56b9>>
|
|
24
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
25
25
|
*/
|
|
26
26
|
// this uses require because not all node versions this package supports use the same import assertions/attributes
|
|
27
27
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
@@ -9,8 +9,8 @@ var atlaskitDesignSystemPlugin = _interopRequireWildcard(require("@atlaskit/esli
|
|
|
9
9
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
10
10
|
/**
|
|
11
11
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
12
|
-
* @codegen <<SignedSource::
|
|
13
|
-
* @codegenCommand
|
|
12
|
+
* @codegen <<SignedSource::ff4acc6ff3441b1ae527ac8371a3717b>>
|
|
13
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
var config = {
|
|
@@ -6,8 +6,8 @@ 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::
|
|
10
|
-
* @codegenCommand
|
|
9
|
+
* @codegen <<SignedSource::64e947d21ff9764f69587dd1641711b6>>
|
|
10
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
var config = {
|
|
@@ -9,8 +9,8 @@ var atlaskitDesignSystemPlugin = _interopRequireWildcard(require("@atlaskit/esli
|
|
|
9
9
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
10
10
|
/**
|
|
11
11
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
12
|
-
* @codegen <<SignedSource::
|
|
13
|
-
* @codegenCommand
|
|
12
|
+
* @codegen <<SignedSource::ff4acc6ff3441b1ae527ac8371a3717b>>
|
|
13
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
var config = {
|
|
@@ -6,8 +6,8 @@ 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::
|
|
10
|
-
* @codegenCommand
|
|
9
|
+
* @codegen <<SignedSource::64e947d21ff9764f69587dd1641711b6>>
|
|
10
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
var config = {
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = void 0;
|
|
8
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
7
9
|
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
8
10
|
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
9
11
|
var _createRule = require("../utils/create-rule");
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return reference.identifier === node && ((_reference$resolved = reference.resolved) === null || _reference$resolved === void 0 ? void 0 : _reference$resolved.defs.some(hasImportSpecifier));
|
|
14
|
-
});
|
|
15
|
-
};
|
|
12
|
+
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; } } }; }
|
|
13
|
+
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; } }
|
|
14
|
+
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
15
|
var isTypographyImportSpecifier = function isTypographyImportSpecifier(def) {
|
|
17
16
|
var _def$parent, _def$parent2, _def$parent3;
|
|
18
17
|
return def.node.type === 'ImportSpecifier' && def.node.imported.type === 'Identifier' && ((_def$parent = def.parent) === null || _def$parent === void 0 ? void 0 : _def$parent.type) === 'ImportDeclaration' && (def.node.imported.name === 'typography' && ((_def$parent2 = def.parent) === null || _def$parent2 === void 0 ? void 0 : _def$parent2.source.value) === '@atlaskit/theme' || ((_def$parent3 = def.parent) === null || _def$parent3 === void 0 ? void 0 : _def$parent3.source.value) === '@atlaskit/theme/typography');
|
|
@@ -25,26 +24,107 @@ var isSkeletonShimmerImportSpecifier = function isSkeletonShimmerImportSpecifier
|
|
|
25
24
|
var _def$parent7, _def$parent8, _def$parent9;
|
|
26
25
|
return def.node.type === 'ImportSpecifier' && def.node.imported.type === 'Identifier' && ((_def$parent7 = def.parent) === null || _def$parent7 === void 0 ? void 0 : _def$parent7.type) === 'ImportDeclaration' && def.node.imported.name === 'skeletonShimmer' && typeof ((_def$parent8 = def.parent) === null || _def$parent8 === void 0 ? void 0 : _def$parent8.source.value) === 'string' && ((_def$parent9 = def.parent) === null || _def$parent9 === void 0 || (_def$parent9 = _def$parent9.source.value) === null || _def$parent9 === void 0 ? void 0 : _def$parent9.startsWith('@atlaskit/theme'));
|
|
27
26
|
};
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
var bannedImportChecks = [{
|
|
28
|
+
messageId: 'usingTypography',
|
|
29
|
+
isBanned: isTypographyImportSpecifier
|
|
30
|
+
}, {
|
|
31
|
+
messageId: 'usingElevation',
|
|
32
|
+
isBanned: isElevationImportSpecifier
|
|
33
|
+
}, {
|
|
34
|
+
messageId: 'usingSkeletonShimmer',
|
|
35
|
+
isBanned: isSkeletonShimmerImportSpecifier
|
|
36
|
+
}];
|
|
37
|
+
function isAstNode(value) {
|
|
38
|
+
return (0, _typeof2.default)(value) === 'object' && value !== null && 'type' in value && typeof value.type === 'string';
|
|
39
|
+
}
|
|
40
|
+
function hasBannedThemeImport(sourceCode) {
|
|
41
|
+
var _iterator = _createForOfIteratorHelper(sourceCode.ast.body),
|
|
42
|
+
_step;
|
|
43
|
+
try {
|
|
44
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
45
|
+
var statement = _step.value;
|
|
46
|
+
if (statement.type !== 'ImportDeclaration' || typeof statement.source.value !== 'string') {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
var source = statement.source.value;
|
|
50
|
+
if (!source.startsWith('@atlaskit/theme')) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
var _iterator2 = _createForOfIteratorHelper(statement.specifiers),
|
|
54
|
+
_step2;
|
|
55
|
+
try {
|
|
56
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
57
|
+
var specifier = _step2.value;
|
|
58
|
+
if (specifier.type !== 'ImportSpecifier' || specifier.imported.type !== 'Identifier') {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
var name = specifier.imported.name;
|
|
62
|
+
if (source === '@atlaskit/theme/typography' || source === '@atlaskit/theme/elevation') {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
if (source === '@atlaskit/theme' && (name === 'typography' || name === 'elevation')) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
if (name === 'skeletonShimmer') {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
} catch (err) {
|
|
73
|
+
_iterator2.e(err);
|
|
74
|
+
} finally {
|
|
75
|
+
_iterator2.f();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
} catch (err) {
|
|
79
|
+
_iterator.e(err);
|
|
80
|
+
} finally {
|
|
81
|
+
_iterator.f();
|
|
34
82
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
function visitIdentifiers(node, visit) {
|
|
86
|
+
if (node.type === 'Identifier' && 'name' in node && typeof node.name === 'string') {
|
|
87
|
+
visit(node);
|
|
40
88
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
89
|
+
for (var _i = 0, _Object$keys = Object.keys(node); _i < _Object$keys.length; _i++) {
|
|
90
|
+
var key = _Object$keys[_i];
|
|
91
|
+
if (key === 'parent') {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
var value = node[key];
|
|
95
|
+
if (Array.isArray(value)) {
|
|
96
|
+
var _iterator3 = _createForOfIteratorHelper(value),
|
|
97
|
+
_step3;
|
|
98
|
+
try {
|
|
99
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
100
|
+
var child = _step3.value;
|
|
101
|
+
if (isAstNode(child)) {
|
|
102
|
+
visitIdentifiers(child, visit);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
} catch (err) {
|
|
106
|
+
_iterator3.e(err);
|
|
107
|
+
} finally {
|
|
108
|
+
_iterator3.f();
|
|
109
|
+
}
|
|
110
|
+
} else if (isAstNode(value)) {
|
|
111
|
+
visitIdentifiers(value, visit);
|
|
112
|
+
}
|
|
46
113
|
}
|
|
47
|
-
}
|
|
114
|
+
}
|
|
115
|
+
function findReferencedVariable(scope, identifier) {
|
|
116
|
+
var current = scope;
|
|
117
|
+
while (current) {
|
|
118
|
+
var variable = current.set.get(identifier.name);
|
|
119
|
+
if (variable !== null && variable !== void 0 && variable.references.some(function (reference) {
|
|
120
|
+
return reference.identifier === identifier;
|
|
121
|
+
})) {
|
|
122
|
+
return variable;
|
|
123
|
+
}
|
|
124
|
+
current = current.upper;
|
|
125
|
+
}
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
48
128
|
var rule = (0, _createRule.createLintRule)({
|
|
49
129
|
meta: {
|
|
50
130
|
name: 'atlaskit-theme',
|
|
@@ -62,41 +142,68 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
62
142
|
type: 'problem'
|
|
63
143
|
},
|
|
64
144
|
create: function create(context) {
|
|
145
|
+
var sourceCode = (0, _contextCompat.getSourceCode)(context);
|
|
146
|
+
if (!hasBannedThemeImport(sourceCode)) {
|
|
147
|
+
return {};
|
|
148
|
+
}
|
|
65
149
|
var importSources = (0, _isSupportedImport.getImportSources)(context);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
150
|
+
var reported = new WeakSet();
|
|
151
|
+
var reportBannedIdentifier = function reportBannedIdentifier(identifier, scope) {
|
|
152
|
+
if (identifier.name === 'fontFallback' || reported.has(identifier)) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
var variable = findReferencedVariable(scope, identifier);
|
|
156
|
+
if (!variable) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
var didReport = false;
|
|
160
|
+
for (var _i2 = 0, _bannedImportChecks = bannedImportChecks; _i2 < _bannedImportChecks.length; _i2++) {
|
|
161
|
+
var _bannedImportChecks$_ = _bannedImportChecks[_i2],
|
|
162
|
+
messageId = _bannedImportChecks$_.messageId,
|
|
163
|
+
isBanned = _bannedImportChecks$_.isBanned;
|
|
164
|
+
if (variable.defs.some(isBanned)) {
|
|
165
|
+
context.report({
|
|
166
|
+
messageId: messageId,
|
|
167
|
+
node: identifier
|
|
168
|
+
});
|
|
169
|
+
didReport = true;
|
|
81
170
|
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
171
|
+
}
|
|
172
|
+
if (didReport) {
|
|
173
|
+
reported.add(identifier);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
var lintCompiledInvocation = function lintCompiledInvocation(node) {
|
|
177
|
+
if (node.type !== 'CallExpression' && node.type !== 'TaggedTemplateExpression') {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
var calleeOrTag = node.type === 'CallExpression' ? node.callee : node.tag;
|
|
181
|
+
var scope = (0, _contextCompat.getScope)(context, node);
|
|
182
|
+
if (!(0, _isSupportedImport.isCompiled)(calleeOrTag, scope.references, importSources)) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
var roots = node.type === 'CallExpression' ? node.arguments : node.quasi.expressions;
|
|
186
|
+
var _iterator4 = _createForOfIteratorHelper(roots),
|
|
187
|
+
_step4;
|
|
188
|
+
try {
|
|
189
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
190
|
+
var root = _step4.value;
|
|
191
|
+
if (isAstNode(root)) {
|
|
192
|
+
visitIdentifiers(root, function (identifier) {
|
|
193
|
+
return reportBannedIdentifier(identifier, scope);
|
|
194
|
+
});
|
|
96
195
|
}
|
|
97
196
|
}
|
|
197
|
+
} catch (err) {
|
|
198
|
+
_iterator4.e(err);
|
|
199
|
+
} finally {
|
|
200
|
+
_iterator4.f();
|
|
98
201
|
}
|
|
99
202
|
};
|
|
203
|
+
return {
|
|
204
|
+
CallExpression: lintCompiledInvocation,
|
|
205
|
+
TaggedTemplateExpression: lintCompiledInvocation
|
|
206
|
+
};
|
|
100
207
|
}
|
|
101
208
|
});
|
|
102
209
|
var _default = exports.default = rule;
|
|
@@ -25,8 +25,8 @@ var _noUnusedCssmapProperties = _interopRequireDefault(require("./no-unused-cssm
|
|
|
25
25
|
var _useCompiled = _interopRequireDefault(require("./use-compiled"));
|
|
26
26
|
/**
|
|
27
27
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
28
|
-
* @codegen <<SignedSource::
|
|
29
|
-
* @codegenCommand
|
|
28
|
+
* @codegen <<SignedSource::fe6f7ad579eba2900d5adf5ee934c020>>
|
|
29
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
var rules = exports.rules = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
4
|
-
* @codegenCommand
|
|
3
|
+
* @codegen <<SignedSource::ef33ad38180e99be70285ddb225c56b9>>
|
|
4
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import allFlat from './presets/all-flat.codegen';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
4
|
-
* @codegenCommand
|
|
3
|
+
* @codegen <<SignedSource::ff4acc6ff3441b1ae527ac8371a3717b>>
|
|
4
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import * as atlaskitDesignSystemPlugin from '@atlaskit/eslint-plugin-design-system';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
4
|
-
* @codegenCommand
|
|
3
|
+
* @codegen <<SignedSource::64e947d21ff9764f69587dd1641711b6>>
|
|
4
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
const config = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
4
|
-
* @codegenCommand
|
|
3
|
+
* @codegen <<SignedSource::ff4acc6ff3441b1ae527ac8371a3717b>>
|
|
4
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import * as atlaskitDesignSystemPlugin from '@atlaskit/eslint-plugin-design-system';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
4
|
-
* @codegenCommand
|
|
3
|
+
* @codegen <<SignedSource::64e947d21ff9764f69587dd1641711b6>>
|
|
4
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
const config = {
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getScope, getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
2
2
|
import { getImportSources, isCompiled } from '@atlaskit/eslint-utils/is-supported-import';
|
|
3
3
|
import { createLintRule } from '../utils/create-rule';
|
|
4
|
-
const isIdentifierReferenced = (hasImportSpecifier, node, references) => references.some(reference => {
|
|
5
|
-
var _reference$resolved;
|
|
6
|
-
return reference.identifier === node && ((_reference$resolved = reference.resolved) === null || _reference$resolved === void 0 ? void 0 : _reference$resolved.defs.some(hasImportSpecifier));
|
|
7
|
-
});
|
|
8
4
|
const isTypographyImportSpecifier = def => {
|
|
9
5
|
var _def$parent, _def$parent2, _def$parent3;
|
|
10
6
|
return def.node.type === 'ImportSpecifier' && def.node.imported.type === 'Identifier' && ((_def$parent = def.parent) === null || _def$parent === void 0 ? void 0 : _def$parent.type) === 'ImportDeclaration' && (def.node.imported.name === 'typography' && ((_def$parent2 = def.parent) === null || _def$parent2 === void 0 ? void 0 : _def$parent2.source.value) === '@atlaskit/theme' || ((_def$parent3 = def.parent) === null || _def$parent3 === void 0 ? void 0 : _def$parent3.source.value) === '@atlaskit/theme/typography');
|
|
@@ -17,26 +13,79 @@ const isSkeletonShimmerImportSpecifier = def => {
|
|
|
17
13
|
var _def$parent7, _def$parent8, _def$parent9, _def$parent9$source$v;
|
|
18
14
|
return def.node.type === 'ImportSpecifier' && def.node.imported.type === 'Identifier' && ((_def$parent7 = def.parent) === null || _def$parent7 === void 0 ? void 0 : _def$parent7.type) === 'ImportDeclaration' && def.node.imported.name === 'skeletonShimmer' && typeof ((_def$parent8 = def.parent) === null || _def$parent8 === void 0 ? void 0 : _def$parent8.source.value) === 'string' && ((_def$parent9 = def.parent) === null || _def$parent9 === void 0 ? void 0 : (_def$parent9$source$v = _def$parent9.source.value) === null || _def$parent9$source$v === void 0 ? void 0 : _def$parent9$source$v.startsWith('@atlaskit/theme'));
|
|
19
15
|
};
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
const bannedImportChecks = [{
|
|
17
|
+
messageId: 'usingTypography',
|
|
18
|
+
isBanned: isTypographyImportSpecifier
|
|
19
|
+
}, {
|
|
20
|
+
messageId: 'usingElevation',
|
|
21
|
+
isBanned: isElevationImportSpecifier
|
|
22
|
+
}, {
|
|
23
|
+
messageId: 'usingSkeletonShimmer',
|
|
24
|
+
isBanned: isSkeletonShimmerImportSpecifier
|
|
25
|
+
}];
|
|
26
|
+
function isAstNode(value) {
|
|
27
|
+
return typeof value === 'object' && value !== null && 'type' in value && typeof value.type === 'string';
|
|
28
|
+
}
|
|
29
|
+
function hasBannedThemeImport(sourceCode) {
|
|
30
|
+
for (const statement of sourceCode.ast.body) {
|
|
31
|
+
if (statement.type !== 'ImportDeclaration' || typeof statement.source.value !== 'string') {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const source = statement.source.value;
|
|
35
|
+
if (!source.startsWith('@atlaskit/theme')) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
for (const specifier of statement.specifiers) {
|
|
39
|
+
if (specifier.type !== 'ImportSpecifier' || specifier.imported.type !== 'Identifier') {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const {
|
|
43
|
+
name
|
|
44
|
+
} = specifier.imported;
|
|
45
|
+
if (source === '@atlaskit/theme/typography' || source === '@atlaskit/theme/elevation') {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
if (source === '@atlaskit/theme' && (name === 'typography' || name === 'elevation')) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
if (name === 'skeletonShimmer') {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
26
55
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
function visitIdentifiers(node, visit) {
|
|
59
|
+
if (node.type === 'Identifier' && 'name' in node && typeof node.name === 'string') {
|
|
60
|
+
visit(node);
|
|
32
61
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
62
|
+
for (const key of Object.keys(node)) {
|
|
63
|
+
if (key === 'parent') {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const value = node[key];
|
|
67
|
+
if (Array.isArray(value)) {
|
|
68
|
+
for (const child of value) {
|
|
69
|
+
if (isAstNode(child)) {
|
|
70
|
+
visitIdentifiers(child, visit);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
} else if (isAstNode(value)) {
|
|
74
|
+
visitIdentifiers(value, visit);
|
|
75
|
+
}
|
|
38
76
|
}
|
|
39
|
-
}
|
|
77
|
+
}
|
|
78
|
+
function findReferencedVariable(scope, identifier) {
|
|
79
|
+
let current = scope;
|
|
80
|
+
while (current) {
|
|
81
|
+
const variable = current.set.get(identifier.name);
|
|
82
|
+
if (variable !== null && variable !== void 0 && variable.references.some(reference => reference.identifier === identifier)) {
|
|
83
|
+
return variable;
|
|
84
|
+
}
|
|
85
|
+
current = current.upper;
|
|
86
|
+
}
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
40
89
|
const rule = createLintRule({
|
|
41
90
|
meta: {
|
|
42
91
|
name: 'atlaskit-theme',
|
|
@@ -54,39 +103,57 @@ const rule = createLintRule({
|
|
|
54
103
|
type: 'problem'
|
|
55
104
|
},
|
|
56
105
|
create(context) {
|
|
106
|
+
const sourceCode = getSourceCode(context);
|
|
107
|
+
if (!hasBannedThemeImport(sourceCode)) {
|
|
108
|
+
return {};
|
|
109
|
+
}
|
|
57
110
|
const importSources = getImportSources(context);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
111
|
+
const reported = new WeakSet();
|
|
112
|
+
const reportBannedIdentifier = (identifier, scope) => {
|
|
113
|
+
if (identifier.name === 'fontFallback' || reported.has(identifier)) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const variable = findReferencedVariable(scope, identifier);
|
|
117
|
+
if (!variable) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
let didReport = false;
|
|
121
|
+
for (const {
|
|
122
|
+
messageId,
|
|
123
|
+
isBanned
|
|
124
|
+
} of bannedImportChecks) {
|
|
125
|
+
if (variable.defs.some(isBanned)) {
|
|
126
|
+
context.report({
|
|
127
|
+
messageId,
|
|
128
|
+
node: identifier
|
|
129
|
+
});
|
|
130
|
+
didReport = true;
|
|
72
131
|
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
132
|
+
}
|
|
133
|
+
if (didReport) {
|
|
134
|
+
reported.add(identifier);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const lintCompiledInvocation = node => {
|
|
138
|
+
if (node.type !== 'CallExpression' && node.type !== 'TaggedTemplateExpression') {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const calleeOrTag = node.type === 'CallExpression' ? node.callee : node.tag;
|
|
142
|
+
const scope = getScope(context, node);
|
|
143
|
+
if (!isCompiled(calleeOrTag, scope.references, importSources)) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const roots = node.type === 'CallExpression' ? node.arguments : node.quasi.expressions;
|
|
147
|
+
for (const root of roots) {
|
|
148
|
+
if (isAstNode(root)) {
|
|
149
|
+
visitIdentifiers(root, identifier => reportBannedIdentifier(identifier, scope));
|
|
87
150
|
}
|
|
88
151
|
}
|
|
89
152
|
};
|
|
153
|
+
return {
|
|
154
|
+
CallExpression: lintCompiledInvocation,
|
|
155
|
+
TaggedTemplateExpression: lintCompiledInvocation
|
|
156
|
+
};
|
|
90
157
|
}
|
|
91
158
|
});
|
|
92
159
|
export default rule;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
4
|
-
* @codegenCommand
|
|
3
|
+
* @codegen <<SignedSource::fe6f7ad579eba2900d5adf5ee934c020>>
|
|
4
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import atlaskitTheme from './atlaskit-theme';
|
|
@@ -3,8 +3,8 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
3
|
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; }
|
|
4
4
|
/**
|
|
5
5
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
6
|
-
* @codegen <<SignedSource::
|
|
7
|
-
* @codegenCommand
|
|
6
|
+
* @codegen <<SignedSource::ef33ad38180e99be70285ddb225c56b9>>
|
|
7
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import allFlat from './presets/all-flat.codegen';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
4
|
-
* @codegenCommand
|
|
3
|
+
* @codegen <<SignedSource::ff4acc6ff3441b1ae527ac8371a3717b>>
|
|
4
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import * as atlaskitDesignSystemPlugin from '@atlaskit/eslint-plugin-design-system';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
4
|
-
* @codegenCommand
|
|
3
|
+
* @codegen <<SignedSource::64e947d21ff9764f69587dd1641711b6>>
|
|
4
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
var config = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
4
|
-
* @codegenCommand
|
|
3
|
+
* @codegen <<SignedSource::ff4acc6ff3441b1ae527ac8371a3717b>>
|
|
4
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import * as atlaskitDesignSystemPlugin from '@atlaskit/eslint-plugin-design-system';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
4
|
-
* @codegenCommand
|
|
3
|
+
* @codegen <<SignedSource::64e947d21ff9764f69587dd1641711b6>>
|
|
4
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
var config = {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
+
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; } } }; }
|
|
3
|
+
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; } }
|
|
4
|
+
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; }
|
|
5
|
+
import { getScope, getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
2
6
|
import { getImportSources, isCompiled } from '@atlaskit/eslint-utils/is-supported-import';
|
|
3
7
|
import { createLintRule } from '../utils/create-rule';
|
|
4
|
-
var isIdentifierReferenced = function isIdentifierReferenced(hasImportSpecifier, node, references) {
|
|
5
|
-
return references.some(function (reference) {
|
|
6
|
-
var _reference$resolved;
|
|
7
|
-
return reference.identifier === node && ((_reference$resolved = reference.resolved) === null || _reference$resolved === void 0 ? void 0 : _reference$resolved.defs.some(hasImportSpecifier));
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
8
|
var isTypographyImportSpecifier = function isTypographyImportSpecifier(def) {
|
|
11
9
|
var _def$parent, _def$parent2, _def$parent3;
|
|
12
10
|
return def.node.type === 'ImportSpecifier' && def.node.imported.type === 'Identifier' && ((_def$parent = def.parent) === null || _def$parent === void 0 ? void 0 : _def$parent.type) === 'ImportDeclaration' && (def.node.imported.name === 'typography' && ((_def$parent2 = def.parent) === null || _def$parent2 === void 0 ? void 0 : _def$parent2.source.value) === '@atlaskit/theme' || ((_def$parent3 = def.parent) === null || _def$parent3 === void 0 ? void 0 : _def$parent3.source.value) === '@atlaskit/theme/typography');
|
|
@@ -19,26 +17,107 @@ var isSkeletonShimmerImportSpecifier = function isSkeletonShimmerImportSpecifier
|
|
|
19
17
|
var _def$parent7, _def$parent8, _def$parent9;
|
|
20
18
|
return def.node.type === 'ImportSpecifier' && def.node.imported.type === 'Identifier' && ((_def$parent7 = def.parent) === null || _def$parent7 === void 0 ? void 0 : _def$parent7.type) === 'ImportDeclaration' && def.node.imported.name === 'skeletonShimmer' && typeof ((_def$parent8 = def.parent) === null || _def$parent8 === void 0 ? void 0 : _def$parent8.source.value) === 'string' && ((_def$parent9 = def.parent) === null || _def$parent9 === void 0 || (_def$parent9 = _def$parent9.source.value) === null || _def$parent9 === void 0 ? void 0 : _def$parent9.startsWith('@atlaskit/theme'));
|
|
21
19
|
};
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
var bannedImportChecks = [{
|
|
21
|
+
messageId: 'usingTypography',
|
|
22
|
+
isBanned: isTypographyImportSpecifier
|
|
23
|
+
}, {
|
|
24
|
+
messageId: 'usingElevation',
|
|
25
|
+
isBanned: isElevationImportSpecifier
|
|
26
|
+
}, {
|
|
27
|
+
messageId: 'usingSkeletonShimmer',
|
|
28
|
+
isBanned: isSkeletonShimmerImportSpecifier
|
|
29
|
+
}];
|
|
30
|
+
function isAstNode(value) {
|
|
31
|
+
return _typeof(value) === 'object' && value !== null && 'type' in value && typeof value.type === 'string';
|
|
32
|
+
}
|
|
33
|
+
function hasBannedThemeImport(sourceCode) {
|
|
34
|
+
var _iterator = _createForOfIteratorHelper(sourceCode.ast.body),
|
|
35
|
+
_step;
|
|
36
|
+
try {
|
|
37
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
38
|
+
var statement = _step.value;
|
|
39
|
+
if (statement.type !== 'ImportDeclaration' || typeof statement.source.value !== 'string') {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
var source = statement.source.value;
|
|
43
|
+
if (!source.startsWith('@atlaskit/theme')) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
var _iterator2 = _createForOfIteratorHelper(statement.specifiers),
|
|
47
|
+
_step2;
|
|
48
|
+
try {
|
|
49
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
50
|
+
var specifier = _step2.value;
|
|
51
|
+
if (specifier.type !== 'ImportSpecifier' || specifier.imported.type !== 'Identifier') {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
var name = specifier.imported.name;
|
|
55
|
+
if (source === '@atlaskit/theme/typography' || source === '@atlaskit/theme/elevation') {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
if (source === '@atlaskit/theme' && (name === 'typography' || name === 'elevation')) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
if (name === 'skeletonShimmer') {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
} catch (err) {
|
|
66
|
+
_iterator2.e(err);
|
|
67
|
+
} finally {
|
|
68
|
+
_iterator2.f();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
} catch (err) {
|
|
72
|
+
_iterator.e(err);
|
|
73
|
+
} finally {
|
|
74
|
+
_iterator.f();
|
|
28
75
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
function visitIdentifiers(node, visit) {
|
|
79
|
+
if (node.type === 'Identifier' && 'name' in node && typeof node.name === 'string') {
|
|
80
|
+
visit(node);
|
|
34
81
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
82
|
+
for (var _i = 0, _Object$keys = Object.keys(node); _i < _Object$keys.length; _i++) {
|
|
83
|
+
var key = _Object$keys[_i];
|
|
84
|
+
if (key === 'parent') {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
var value = node[key];
|
|
88
|
+
if (Array.isArray(value)) {
|
|
89
|
+
var _iterator3 = _createForOfIteratorHelper(value),
|
|
90
|
+
_step3;
|
|
91
|
+
try {
|
|
92
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
93
|
+
var child = _step3.value;
|
|
94
|
+
if (isAstNode(child)) {
|
|
95
|
+
visitIdentifiers(child, visit);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
} catch (err) {
|
|
99
|
+
_iterator3.e(err);
|
|
100
|
+
} finally {
|
|
101
|
+
_iterator3.f();
|
|
102
|
+
}
|
|
103
|
+
} else if (isAstNode(value)) {
|
|
104
|
+
visitIdentifiers(value, visit);
|
|
105
|
+
}
|
|
40
106
|
}
|
|
41
|
-
}
|
|
107
|
+
}
|
|
108
|
+
function findReferencedVariable(scope, identifier) {
|
|
109
|
+
var current = scope;
|
|
110
|
+
while (current) {
|
|
111
|
+
var variable = current.set.get(identifier.name);
|
|
112
|
+
if (variable !== null && variable !== void 0 && variable.references.some(function (reference) {
|
|
113
|
+
return reference.identifier === identifier;
|
|
114
|
+
})) {
|
|
115
|
+
return variable;
|
|
116
|
+
}
|
|
117
|
+
current = current.upper;
|
|
118
|
+
}
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
42
121
|
var rule = createLintRule({
|
|
43
122
|
meta: {
|
|
44
123
|
name: 'atlaskit-theme',
|
|
@@ -56,41 +135,68 @@ var rule = createLintRule({
|
|
|
56
135
|
type: 'problem'
|
|
57
136
|
},
|
|
58
137
|
create: function create(context) {
|
|
138
|
+
var sourceCode = getSourceCode(context);
|
|
139
|
+
if (!hasBannedThemeImport(sourceCode)) {
|
|
140
|
+
return {};
|
|
141
|
+
}
|
|
59
142
|
var importSources = getImportSources(context);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
143
|
+
var reported = new WeakSet();
|
|
144
|
+
var reportBannedIdentifier = function reportBannedIdentifier(identifier, scope) {
|
|
145
|
+
if (identifier.name === 'fontFallback' || reported.has(identifier)) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
var variable = findReferencedVariable(scope, identifier);
|
|
149
|
+
if (!variable) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
var didReport = false;
|
|
153
|
+
for (var _i2 = 0, _bannedImportChecks = bannedImportChecks; _i2 < _bannedImportChecks.length; _i2++) {
|
|
154
|
+
var _bannedImportChecks$_ = _bannedImportChecks[_i2],
|
|
155
|
+
messageId = _bannedImportChecks$_.messageId,
|
|
156
|
+
isBanned = _bannedImportChecks$_.isBanned;
|
|
157
|
+
if (variable.defs.some(isBanned)) {
|
|
158
|
+
context.report({
|
|
159
|
+
messageId: messageId,
|
|
160
|
+
node: identifier
|
|
161
|
+
});
|
|
162
|
+
didReport = true;
|
|
75
163
|
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
164
|
+
}
|
|
165
|
+
if (didReport) {
|
|
166
|
+
reported.add(identifier);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
var lintCompiledInvocation = function lintCompiledInvocation(node) {
|
|
170
|
+
if (node.type !== 'CallExpression' && node.type !== 'TaggedTemplateExpression') {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
var calleeOrTag = node.type === 'CallExpression' ? node.callee : node.tag;
|
|
174
|
+
var scope = getScope(context, node);
|
|
175
|
+
if (!isCompiled(calleeOrTag, scope.references, importSources)) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
var roots = node.type === 'CallExpression' ? node.arguments : node.quasi.expressions;
|
|
179
|
+
var _iterator4 = _createForOfIteratorHelper(roots),
|
|
180
|
+
_step4;
|
|
181
|
+
try {
|
|
182
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
183
|
+
var root = _step4.value;
|
|
184
|
+
if (isAstNode(root)) {
|
|
185
|
+
visitIdentifiers(root, function (identifier) {
|
|
186
|
+
return reportBannedIdentifier(identifier, scope);
|
|
187
|
+
});
|
|
90
188
|
}
|
|
91
189
|
}
|
|
190
|
+
} catch (err) {
|
|
191
|
+
_iterator4.e(err);
|
|
192
|
+
} finally {
|
|
193
|
+
_iterator4.f();
|
|
92
194
|
}
|
|
93
195
|
};
|
|
196
|
+
return {
|
|
197
|
+
CallExpression: lintCompiledInvocation,
|
|
198
|
+
TaggedTemplateExpression: lintCompiledInvocation
|
|
199
|
+
};
|
|
94
200
|
}
|
|
95
201
|
});
|
|
96
202
|
export default rule;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
4
|
-
* @codegenCommand
|
|
3
|
+
* @codegen <<SignedSource::fe6f7ad579eba2900d5adf5ee934c020>>
|
|
4
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import atlaskitTheme from './atlaskit-theme';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
4
|
-
* @codegenCommand
|
|
3
|
+
* @codegen <<SignedSource::ef33ad38180e99be70285ddb225c56b9>>
|
|
4
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
import type { ESLint } from 'eslint';
|
|
7
7
|
export declare const plugin: ESLint.Plugin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
4
|
-
* @codegenCommand
|
|
3
|
+
* @codegen <<SignedSource::ff4acc6ff3441b1ae527ac8371a3717b>>
|
|
4
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
import type { Linter } from 'eslint';
|
|
7
7
|
declare const config: Linter.FlatConfig;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
4
|
-
* @codegenCommand
|
|
3
|
+
* @codegen <<SignedSource::64e947d21ff9764f69587dd1641711b6>>
|
|
4
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
import type { ESLint } from 'eslint';
|
|
7
7
|
declare const config: ESLint.ConfigData;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
4
|
-
* @codegenCommand
|
|
3
|
+
* @codegen <<SignedSource::ff4acc6ff3441b1ae527ac8371a3717b>>
|
|
4
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
import type { Linter } from 'eslint';
|
|
7
7
|
declare const config: Linter.FlatConfig;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
4
|
-
* @codegenCommand
|
|
3
|
+
* @codegen <<SignedSource::64e947d21ff9764f69587dd1641711b6>>
|
|
4
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
import type { ESLint } from 'eslint';
|
|
7
7
|
declare const config: ESLint.ConfigData;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
4
|
-
* @codegenCommand
|
|
3
|
+
* @codegen <<SignedSource::fe6f7ad579eba2900d5adf5ee934c020>>
|
|
4
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
import type { Rule } from 'eslint';
|
|
7
7
|
export declare const rules: Record<string, Rule.RuleModule>;
|
package/package.json
CHANGED