@atlaskit/eslint-plugin-ui-styling-standard 2.1.9 → 2.2.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 +16 -0
- package/README.md +2 -1
- package/dist/cjs/index.codegen.js +2 -2
- package/dist/cjs/presets/all-flat.codegen.js +3 -2
- package/dist/cjs/presets/all.codegen.js +3 -2
- package/dist/cjs/presets/recommended-flat.codegen.js +3 -2
- package/dist/cjs/presets/recommended.codegen.js +3 -2
- package/dist/cjs/rules/atlaskit-theme/index.js +159 -52
- package/dist/cjs/rules/index.codegen.js +4 -2
- package/dist/cjs/rules/no-atlaskit-theme/index.js +34 -0
- package/dist/es2019/index.codegen.js +2 -2
- package/dist/es2019/presets/all-flat.codegen.js +3 -2
- package/dist/es2019/presets/all.codegen.js +3 -2
- package/dist/es2019/presets/recommended-flat.codegen.js +3 -2
- package/dist/es2019/presets/recommended.codegen.js +3 -2
- package/dist/es2019/rules/atlaskit-theme/index.js +117 -50
- package/dist/es2019/rules/index.codegen.js +4 -2
- package/dist/es2019/rules/no-atlaskit-theme/index.js +28 -0
- package/dist/esm/index.codegen.js +2 -2
- package/dist/esm/presets/all-flat.codegen.js +3 -2
- package/dist/esm/presets/all.codegen.js +3 -2
- package/dist/esm/presets/recommended-flat.codegen.js +3 -2
- package/dist/esm/presets/recommended.codegen.js +3 -2
- package/dist/esm/rules/atlaskit-theme/index.js +159 -53
- package/dist/esm/rules/index.codegen.js +4 -2
- package/dist/esm/rules/no-atlaskit-theme/index.js +28 -0
- 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/dist/types/rules/no-atlaskit-theme/index.d.ts +3 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-ui-styling-standard
|
|
2
2
|
|
|
3
|
+
## 2.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`a5d06059c9ac7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a5d06059c9ac7) -
|
|
8
|
+
Add the no-atlaskit-theme lint rule and enable it as a warning in the recommended config. Imports
|
|
9
|
+
from @atlaskit/theme are flagged without failing lint.
|
|
10
|
+
|
|
11
|
+
## 2.1.10
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`62aaaa3da8184`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/62aaaa3da8184) -
|
|
16
|
+
Speed up the atlaskit-theme lint rule by skipping files that do not import the banned theme
|
|
17
|
+
mixins, and by checking each Compiled call once instead of every nested identifier.
|
|
18
|
+
|
|
3
19
|
## 2.1.9
|
|
4
20
|
|
|
5
21
|
### 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
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | ------- | ----------- |
|
|
@@ -47,6 +47,7 @@ module.exports = {
|
|
|
47
47
|
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/enforce-style-prop/README.md">enforce-style-prop</a> | Disallows usage of static styles in the `style` attribute in components | Yes | | |
|
|
48
48
|
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/local-cx-xcss/README.md">local-cx-xcss</a> | Ensures the cx() function, which is part of the XCSS API, is only used within the xcss prop. This aids tracking what styles are applied to a jsx element. | Yes | | |
|
|
49
49
|
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-array-arguments/README.md">no-array-arguments</a> | Prevents usage of array arguments to style declaration functions | Yes | Yes | |
|
|
50
|
+
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-atlaskit-theme/README.md">no-atlaskit-theme</a> | Disallow imports from `@atlaskit/theme` | Yes | | |
|
|
50
51
|
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-classname-prop/README.md">no-classname-prop</a> | Disallows usage of the `className` prop in JSX | Yes | | |
|
|
51
52
|
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-container-queries/README.md">no-container-queries</a> | Prevents usage of @container query within css styling | Yes | | |
|
|
52
53
|
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-dynamic-styles/README.md">no-dynamic-styles</a> | Disallows use of dynamic styles in CSS-in-JS calls | Yes | | |
|
|
@@ -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::7f3972a0198dc6de5194e21d5f32c3b0>>
|
|
13
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
var config = {
|
|
@@ -24,6 +24,7 @@ var config = {
|
|
|
24
24
|
'@atlaskit/ui-styling-standard/enforce-style-prop': 'error',
|
|
25
25
|
'@atlaskit/ui-styling-standard/local-cx-xcss': 'error',
|
|
26
26
|
'@atlaskit/ui-styling-standard/no-array-arguments': 'error',
|
|
27
|
+
'@atlaskit/ui-styling-standard/no-atlaskit-theme': 'warn',
|
|
27
28
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'error',
|
|
28
29
|
'@atlaskit/ui-styling-standard/no-container-queries': 'error',
|
|
29
30
|
'@atlaskit/ui-styling-standard/no-dynamic-styles': 'error',
|
|
@@ -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::138a044301c208ca5eecc78433523b0b>>
|
|
10
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
var config = {
|
|
@@ -18,6 +18,7 @@ var config = {
|
|
|
18
18
|
'@atlaskit/ui-styling-standard/enforce-style-prop': 'error',
|
|
19
19
|
'@atlaskit/ui-styling-standard/local-cx-xcss': 'error',
|
|
20
20
|
'@atlaskit/ui-styling-standard/no-array-arguments': 'error',
|
|
21
|
+
'@atlaskit/ui-styling-standard/no-atlaskit-theme': 'warn',
|
|
21
22
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'error',
|
|
22
23
|
'@atlaskit/ui-styling-standard/no-container-queries': 'error',
|
|
23
24
|
'@atlaskit/ui-styling-standard/no-dynamic-styles': 'error',
|
|
@@ -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::7f3972a0198dc6de5194e21d5f32c3b0>>
|
|
13
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
var config = {
|
|
@@ -24,6 +24,7 @@ var config = {
|
|
|
24
24
|
'@atlaskit/ui-styling-standard/enforce-style-prop': 'error',
|
|
25
25
|
'@atlaskit/ui-styling-standard/local-cx-xcss': 'error',
|
|
26
26
|
'@atlaskit/ui-styling-standard/no-array-arguments': 'error',
|
|
27
|
+
'@atlaskit/ui-styling-standard/no-atlaskit-theme': 'warn',
|
|
27
28
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'error',
|
|
28
29
|
'@atlaskit/ui-styling-standard/no-container-queries': 'error',
|
|
29
30
|
'@atlaskit/ui-styling-standard/no-dynamic-styles': 'error',
|
|
@@ -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::138a044301c208ca5eecc78433523b0b>>
|
|
10
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
var config = {
|
|
@@ -18,6 +18,7 @@ var config = {
|
|
|
18
18
|
'@atlaskit/ui-styling-standard/enforce-style-prop': 'error',
|
|
19
19
|
'@atlaskit/ui-styling-standard/local-cx-xcss': 'error',
|
|
20
20
|
'@atlaskit/ui-styling-standard/no-array-arguments': 'error',
|
|
21
|
+
'@atlaskit/ui-styling-standard/no-atlaskit-theme': 'warn',
|
|
21
22
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'error',
|
|
22
23
|
'@atlaskit/ui-styling-standard/no-container-queries': 'error',
|
|
23
24
|
'@atlaskit/ui-styling-standard/no-dynamic-styles': 'error',
|
|
@@ -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;
|
|
@@ -10,6 +10,7 @@ var _convertPropsSyntax = _interopRequireDefault(require("./convert-props-syntax
|
|
|
10
10
|
var _enforceStyleProp = _interopRequireDefault(require("./enforce-style-prop"));
|
|
11
11
|
var _localCxXcss = _interopRequireDefault(require("./local-cx-xcss"));
|
|
12
12
|
var _noArrayArguments = _interopRequireDefault(require("./no-array-arguments"));
|
|
13
|
+
var _noAtlaskitTheme = _interopRequireDefault(require("./no-atlaskit-theme"));
|
|
13
14
|
var _noClassnameProp = _interopRequireDefault(require("./no-classname-prop"));
|
|
14
15
|
var _noContainerQueries = _interopRequireDefault(require("./no-container-queries"));
|
|
15
16
|
var _noDynamicStyles = _interopRequireDefault(require("./no-dynamic-styles"));
|
|
@@ -25,8 +26,8 @@ var _noUnusedCssmapProperties = _interopRequireDefault(require("./no-unused-cssm
|
|
|
25
26
|
var _useCompiled = _interopRequireDefault(require("./use-compiled"));
|
|
26
27
|
/**
|
|
27
28
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
28
|
-
* @codegen <<SignedSource::
|
|
29
|
-
* @codegenCommand
|
|
29
|
+
* @codegen <<SignedSource::094f8a058153c7e839c5d98d2718ca4e>>
|
|
30
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
30
31
|
*/
|
|
31
32
|
|
|
32
33
|
var rules = exports.rules = {
|
|
@@ -35,6 +36,7 @@ var rules = exports.rules = {
|
|
|
35
36
|
'enforce-style-prop': _enforceStyleProp.default,
|
|
36
37
|
'local-cx-xcss': _localCxXcss.default,
|
|
37
38
|
'no-array-arguments': _noArrayArguments.default,
|
|
39
|
+
'no-atlaskit-theme': _noAtlaskitTheme.default,
|
|
38
40
|
'no-classname-prop': _noClassnameProp.default,
|
|
39
41
|
'no-container-queries': _noContainerQueries.default,
|
|
40
42
|
'no-dynamic-styles': _noDynamicStyles.default,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _createRule = require("../utils/create-rule");
|
|
8
|
+
var rule = (0, _createRule.createLintRule)({
|
|
9
|
+
meta: {
|
|
10
|
+
name: 'no-atlaskit-theme',
|
|
11
|
+
docs: {
|
|
12
|
+
description: 'Disallow imports from `@atlaskit/theme`',
|
|
13
|
+
recommended: true,
|
|
14
|
+
severity: 'warn'
|
|
15
|
+
},
|
|
16
|
+
messages: {
|
|
17
|
+
'no-atlaskit-theme': 'Do not import `@atlaskit/theme`. Use `@atlaskit/tokens` or Atlassian Design System components instead.'
|
|
18
|
+
},
|
|
19
|
+
type: 'problem'
|
|
20
|
+
},
|
|
21
|
+
create: function create(context) {
|
|
22
|
+
return {
|
|
23
|
+
// esquery regexes cannot contain a raw `/`, so the path separator is `\x2F`.
|
|
24
|
+
// Unanchored at the end, so this matches `@atlaskit/theme` and any subpath.
|
|
25
|
+
'ImportDeclaration[source.value=/^@atlaskit\\x2Ftheme(\\x2F|$)/]': function ImportDeclarationSourceValue_AtlaskitX2FthemeX2F$_(node) {
|
|
26
|
+
context.report({
|
|
27
|
+
node: node,
|
|
28
|
+
messageId: 'no-atlaskit-theme'
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
var _default = exports.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::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::7f3972a0198dc6de5194e21d5f32c3b0>>
|
|
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';
|
|
@@ -16,6 +16,7 @@ const config = {
|
|
|
16
16
|
'@atlaskit/ui-styling-standard/enforce-style-prop': 'error',
|
|
17
17
|
'@atlaskit/ui-styling-standard/local-cx-xcss': 'error',
|
|
18
18
|
'@atlaskit/ui-styling-standard/no-array-arguments': 'error',
|
|
19
|
+
'@atlaskit/ui-styling-standard/no-atlaskit-theme': 'warn',
|
|
19
20
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'error',
|
|
20
21
|
'@atlaskit/ui-styling-standard/no-container-queries': 'error',
|
|
21
22
|
'@atlaskit/ui-styling-standard/no-dynamic-styles': 'error',
|
|
@@ -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::138a044301c208ca5eecc78433523b0b>>
|
|
4
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
const config = {
|
|
@@ -12,6 +12,7 @@ const config = {
|
|
|
12
12
|
'@atlaskit/ui-styling-standard/enforce-style-prop': 'error',
|
|
13
13
|
'@atlaskit/ui-styling-standard/local-cx-xcss': 'error',
|
|
14
14
|
'@atlaskit/ui-styling-standard/no-array-arguments': 'error',
|
|
15
|
+
'@atlaskit/ui-styling-standard/no-atlaskit-theme': 'warn',
|
|
15
16
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'error',
|
|
16
17
|
'@atlaskit/ui-styling-standard/no-container-queries': 'error',
|
|
17
18
|
'@atlaskit/ui-styling-standard/no-dynamic-styles': 'error',
|
|
@@ -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::7f3972a0198dc6de5194e21d5f32c3b0>>
|
|
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';
|
|
@@ -16,6 +16,7 @@ const config = {
|
|
|
16
16
|
'@atlaskit/ui-styling-standard/enforce-style-prop': 'error',
|
|
17
17
|
'@atlaskit/ui-styling-standard/local-cx-xcss': 'error',
|
|
18
18
|
'@atlaskit/ui-styling-standard/no-array-arguments': 'error',
|
|
19
|
+
'@atlaskit/ui-styling-standard/no-atlaskit-theme': 'warn',
|
|
19
20
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'error',
|
|
20
21
|
'@atlaskit/ui-styling-standard/no-container-queries': 'error',
|
|
21
22
|
'@atlaskit/ui-styling-standard/no-dynamic-styles': 'error',
|
|
@@ -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::138a044301c208ca5eecc78433523b0b>>
|
|
4
|
+
* @codegenCommand afm workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
const config = {
|
|
@@ -12,6 +12,7 @@ const config = {
|
|
|
12
12
|
'@atlaskit/ui-styling-standard/enforce-style-prop': 'error',
|
|
13
13
|
'@atlaskit/ui-styling-standard/local-cx-xcss': 'error',
|
|
14
14
|
'@atlaskit/ui-styling-standard/no-array-arguments': 'error',
|
|
15
|
+
'@atlaskit/ui-styling-standard/no-atlaskit-theme': 'warn',
|
|
15
16
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'error',
|
|
16
17
|
'@atlaskit/ui-styling-standard/no-container-queries': 'error',
|
|
17
18
|
'@atlaskit/ui-styling-standard/no-dynamic-styles': 'error',
|