@atlaskit/eslint-plugin-ui-styling-standard 1.1.0 → 1.1.1
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 +6 -0
- package/README.md +17 -17
- package/dist/cjs/rules/atlaskit-theme/index.js +9 -8
- package/dist/cjs/rules/convert-props-syntax/index.js +5 -3
- package/dist/cjs/rules/enforce-style-prop/index.js +7 -6
- package/dist/cjs/rules/local-cx-xcss/index.js +3 -2
- package/dist/cjs/rules/no-array-arguments/index.js +4 -3
- package/dist/cjs/rules/no-container-queries/index.js +3 -2
- package/dist/cjs/rules/no-dynamic-styles/index.js +3 -2
- package/dist/cjs/rules/no-important-styles/index.js +3 -2
- package/dist/cjs/rules/no-imported-style-values/index.js +6 -5
- package/dist/cjs/rules/no-nested-selectors/index.js +4 -3
- package/dist/cjs/rules/no-styled/index.js +4 -3
- package/dist/cjs/rules/no-unsafe-selectors/index.js +3 -2
- package/dist/cjs/rules/no-unsafe-selectors/source-position-utils.js +2 -1
- package/dist/cjs/rules/no-unsafe-selectors/walk-css-map.js +5 -4
- package/dist/cjs/rules/no-unsafe-values/index.js +3 -2
- package/dist/cjs/rules/use-compiled/index.js +3 -2
- package/dist/cjs/rules/use-compiled/is-safe.js +3 -2
- package/dist/cjs/rules/use-compiled/utils.js +2 -1
- package/dist/es2019/rules/atlaskit-theme/index.js +5 -4
- package/dist/es2019/rules/convert-props-syntax/index.js +6 -3
- package/dist/es2019/rules/enforce-style-prop/index.js +6 -5
- package/dist/es2019/rules/local-cx-xcss/index.js +3 -2
- package/dist/es2019/rules/no-array-arguments/index.js +3 -2
- package/dist/es2019/rules/no-container-queries/index.js +2 -1
- package/dist/es2019/rules/no-dynamic-styles/index.js +2 -1
- package/dist/es2019/rules/no-important-styles/index.js +2 -1
- package/dist/es2019/rules/no-imported-style-values/index.js +4 -3
- package/dist/es2019/rules/no-nested-selectors/index.js +3 -2
- package/dist/es2019/rules/no-styled/index.js +5 -4
- package/dist/es2019/rules/no-unsafe-selectors/index.js +2 -1
- package/dist/es2019/rules/no-unsafe-selectors/source-position-utils.js +2 -1
- package/dist/es2019/rules/no-unsafe-selectors/walk-css-map.js +3 -2
- package/dist/es2019/rules/no-unsafe-values/index.js +2 -1
- package/dist/es2019/rules/use-compiled/index.js +3 -2
- package/dist/es2019/rules/use-compiled/is-safe.js +3 -2
- package/dist/es2019/rules/use-compiled/utils.js +2 -1
- package/dist/esm/rules/atlaskit-theme/index.js +9 -8
- package/dist/esm/rules/convert-props-syntax/index.js +5 -3
- package/dist/esm/rules/enforce-style-prop/index.js +7 -6
- package/dist/esm/rules/local-cx-xcss/index.js +3 -2
- package/dist/esm/rules/no-array-arguments/index.js +4 -3
- package/dist/esm/rules/no-container-queries/index.js +3 -2
- package/dist/esm/rules/no-dynamic-styles/index.js +3 -2
- package/dist/esm/rules/no-important-styles/index.js +3 -2
- package/dist/esm/rules/no-imported-style-values/index.js +6 -5
- package/dist/esm/rules/no-nested-selectors/index.js +4 -3
- package/dist/esm/rules/no-styled/index.js +5 -4
- package/dist/esm/rules/no-unsafe-selectors/index.js +3 -2
- package/dist/esm/rules/no-unsafe-selectors/source-position-utils.js +2 -1
- package/dist/esm/rules/no-unsafe-selectors/walk-css-map.js +5 -4
- package/dist/esm/rules/no-unsafe-values/index.js +3 -2
- package/dist/esm/rules/use-compiled/index.js +3 -2
- package/dist/esm/rules/use-compiled/is-safe.js +3 -2
- package/dist/esm/rules/use-compiled/utils.js +2 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -42,23 +42,23 @@ module.exports = {
|
|
|
42
42
|
|
|
43
43
|
| Rule | Description | Recommended | Fixable | Suggestions |
|
|
44
44
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | ------- | ----------- |
|
|
45
|
-
| <a href="./
|
|
46
|
-
| <a href="./
|
|
47
|
-
| <a href="./
|
|
48
|
-
| <a href="./
|
|
49
|
-
| <a href="./
|
|
50
|
-
| <a href="./
|
|
51
|
-
| <a href="./
|
|
52
|
-
| <a href="./
|
|
53
|
-
| <a href="./
|
|
54
|
-
| <a href="./
|
|
55
|
-
| <a href="./
|
|
56
|
-
| <a href="./
|
|
57
|
-
| <a href="./
|
|
58
|
-
| <a href="./
|
|
59
|
-
| <a href="./
|
|
60
|
-
| <a href="./
|
|
61
|
-
| <a href="./
|
|
45
|
+
| <a href="./src/rules/atlaskit-theme/README.md">atlaskit-theme</a> | Ban certain usages of `@atlaskit/theme` that `@compiled/react` does not understand | Yes | | |
|
|
46
|
+
| <a href="./src/rules/convert-props-syntax/README.md">convert-props-syntax</a> | Convert props syntax that is unsupported by styled-components@<4 or @emotion/styled to props syntax that is supported. This is useful when used in conjunction with `no-styled-tagged-template-expression`, as output from the latter may use props syntax unsupported by those libraries. | Yes | Yes | |
|
|
47
|
+
| <a href="./src/rules/enforce-style-prop/README.md">enforce-style-prop</a> | Disallows usage of static styles in the `style` attribute in components | Yes | | |
|
|
48
|
+
| <a href="./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
|
+
| <a href="./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="./src/rules/no-classname-prop/README.md">no-classname-prop</a> | Disallows usage of the `className` prop in JSX | Yes | | |
|
|
51
|
+
| <a href="./src/rules/no-container-queries/README.md">no-container-queries</a> | Prevents usage of @container query within css styling | Yes | | |
|
|
52
|
+
| <a href="./src/rules/no-dynamic-styles/README.md">no-dynamic-styles</a> | Disallows use of dynamic styles in CSS-in-JS calls | Yes | | |
|
|
53
|
+
| <a href="./src/rules/no-exported-styles/README.md">no-exported-styles</a> | Disallows exports of css, keyframes, styled and xcss | Yes | | |
|
|
54
|
+
| <a href="./src/rules/no-global-styles/README.md">no-global-styles</a> | Prevents global styles through CSS-in-JS or CSS module imports | Yes | | |
|
|
55
|
+
| <a href="./src/rules/no-important-styles/README.md">no-important-styles</a> | Disallows important style declarations | Yes | | |
|
|
56
|
+
| <a href="./src/rules/no-imported-style-values/README.md">no-imported-style-values</a> | Disallows imports of style values | Yes | | |
|
|
57
|
+
| <a href="./src/rules/no-nested-selectors/README.md">no-nested-selectors</a> | Prevents usage of nested selectors within css styling | Yes | | |
|
|
58
|
+
| <a href="./src/rules/no-styled/README.md">no-styled</a> | Disallows usage of the `styled` imports | Yes | | |
|
|
59
|
+
| <a href="./src/rules/no-unsafe-selectors/README.md">no-unsafe-selectors</a> | Disallows use of nested styles in `css` functions. | Yes | Yes | Yes |
|
|
60
|
+
| <a href="./src/rules/no-unsafe-values/README.md">no-unsafe-values</a> | Disallows styles that are difficult/impossible to statically anaylze. | Yes | | |
|
|
61
|
+
| <a href="./src/rules/use-compiled/README.md">use-compiled</a> | Ensures usage of `@compiled/react` instead of other CSS-in-JS libraries | Yes | Yes | |
|
|
62
62
|
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/consistent-css-prop-usage/usage">@atlaskit/design-system/consistent-css-prop-usage</a> | Ensures consistency with `css` and `xcss` prop usages | Yes | Yes | |
|
|
63
63
|
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-css-tagged-template-expression/usage">@atlaskit/design-system/no-css-tagged-template-expression</a> | Disallows any `css` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
|
|
64
64
|
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-keyframes-tagged-template-expression/usage">@atlaskit/design-system/no-keyframes-tagged-template-expression</a> | Disallows any `keyframe` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.rule = exports.default = void 0;
|
|
7
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
7
8
|
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
8
9
|
var _createRule = require("../utils/create-rule");
|
|
9
10
|
var isIdentifierReferenced = function isIdentifierReferenced(hasImportSpecifier, node, references) {
|
|
@@ -63,10 +64,10 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
63
64
|
create: function create(context) {
|
|
64
65
|
var importSources = (0, _isSupportedImport.getImportSources)(context);
|
|
65
66
|
return {
|
|
66
|
-
'CallExpression Identifier': function
|
|
67
|
-
var
|
|
68
|
-
references =
|
|
69
|
-
var ancestors =
|
|
67
|
+
'CallExpression Identifier': function CallExpression_Identifier(node) {
|
|
68
|
+
var _getScope = (0, _contextCompat.getScope)(context, node),
|
|
69
|
+
references = _getScope.references;
|
|
70
|
+
var ancestors = (0, _contextCompat.getAncestors)(context, node);
|
|
70
71
|
|
|
71
72
|
// Check if ancestor node is a call expression to Compiled
|
|
72
73
|
if (ancestors.some(function (ancestor) {
|
|
@@ -79,10 +80,10 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
},
|
|
82
|
-
'TaggedTemplateExpression Identifier': function
|
|
83
|
-
var
|
|
84
|
-
references =
|
|
85
|
-
var ancestors =
|
|
83
|
+
'TaggedTemplateExpression Identifier': function TaggedTemplateExpression_Identifier(node) {
|
|
84
|
+
var _getScope2 = (0, _contextCompat.getScope)(context, node),
|
|
85
|
+
references = _getScope2.references;
|
|
86
|
+
var ancestors = (0, _contextCompat.getAncestors)(context, node);
|
|
86
87
|
|
|
87
88
|
// Check if ancestor node is a tagged template expression to Compiled
|
|
88
89
|
if (ancestors.some(function (ancestor) {
|
|
@@ -8,6 +8,7 @@ exports.rule = exports.default = void 0;
|
|
|
8
8
|
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
9
9
|
var _eslintScope = require("eslint-scope");
|
|
10
10
|
var _estraverse = _interopRequireDefault(require("estraverse"));
|
|
11
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
11
12
|
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
12
13
|
var _createRule = require("../utils/create-rule");
|
|
13
14
|
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; } } }; }
|
|
@@ -218,7 +219,7 @@ var lintArguments = function lintArguments(context, args) {
|
|
|
218
219
|
_estraverse.default.traverse(property.value, {
|
|
219
220
|
enter: function enter(node, _parent) {
|
|
220
221
|
if (node.type === 'ArrowFunctionExpression') {
|
|
221
|
-
var propNames = parseArrowFunctionExpression(node,
|
|
222
|
+
var propNames = parseArrowFunctionExpression(node, (0, _contextCompat.getSourceCode)(context));
|
|
222
223
|
if (!propNames) {
|
|
223
224
|
// We've encountered a CSS value we don't recognise, skip.
|
|
224
225
|
return;
|
|
@@ -256,7 +257,7 @@ var lintArguments = function lintArguments(context, args) {
|
|
|
256
257
|
node: argument,
|
|
257
258
|
messageId: 'unsupported-prop-syntax',
|
|
258
259
|
fix: function fix(fixer) {
|
|
259
|
-
var sourceCode =
|
|
260
|
+
var sourceCode = (0, _contextCompat.getSourceCode)(context);
|
|
260
261
|
return fixPropsObjectUsages(fixer, sourceCode, argument,
|
|
261
262
|
// The
|
|
262
263
|
// allProps.some((propUsage) => !propUsage.valid)
|
|
@@ -387,7 +388,8 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
387
388
|
return {
|
|
388
389
|
CallExpression: function CallExpression(node) {
|
|
389
390
|
var _node$parent, _node$parent2;
|
|
390
|
-
var
|
|
391
|
+
var _getScope = (0, _contextCompat.getScope)(context, node),
|
|
392
|
+
references = _getScope.references;
|
|
391
393
|
|
|
392
394
|
// Rule should ignore .attrs() calls
|
|
393
395
|
if (node.callee.type === 'MemberExpression' && node.callee.property.type === 'Identifier' && node.callee.property.name === 'attrs') {
|
|
@@ -6,12 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.rule = exports.default = void 0;
|
|
7
7
|
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
8
8
|
var _allowedFunctionCalls = require("@atlaskit/eslint-utils/allowed-function-calls");
|
|
9
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
9
10
|
var _findVariable3 = require("@atlaskit/eslint-utils/find-variable");
|
|
10
11
|
var _createRule = require("../utils/create-rule");
|
|
11
12
|
var isParameter = function isParameter(context, identifier) {
|
|
12
13
|
var _findVariable;
|
|
13
14
|
var definitions = (_findVariable = (0, _findVariable3.findVariable)({
|
|
14
|
-
sourceCode:
|
|
15
|
+
sourceCode: (0, _contextCompat.getSourceCode)(context),
|
|
15
16
|
identifier: identifier
|
|
16
17
|
})) === null || _findVariable === void 0 ? void 0 : _findVariable.defs;
|
|
17
18
|
if (!definitions || !definitions.length) {
|
|
@@ -23,7 +24,7 @@ var isParameter = function isParameter(context, identifier) {
|
|
|
23
24
|
var isIdentifierAllowed = function isIdentifierAllowed(context, identifier) {
|
|
24
25
|
var _variable$identifiers;
|
|
25
26
|
var variable = (0, _findVariable3.findVariable)({
|
|
26
|
-
sourceCode:
|
|
27
|
+
sourceCode: (0, _contextCompat.getSourceCode)(context),
|
|
27
28
|
identifier: identifier
|
|
28
29
|
});
|
|
29
30
|
if (!variable) {
|
|
@@ -83,7 +84,7 @@ function isPropertyValueAllowed(property, context) {
|
|
|
83
84
|
return isIdentifierAllowed(context, property.value);
|
|
84
85
|
} else if (property.value.type === 'CallExpression' && property.value.callee.type === 'Identifier') {
|
|
85
86
|
var variable = (0, _findVariable3.findVariable)({
|
|
86
|
-
sourceCode:
|
|
87
|
+
sourceCode: (0, _contextCompat.getSourceCode)(context),
|
|
87
88
|
identifier: property.value.callee
|
|
88
89
|
});
|
|
89
90
|
// Anything returned by getAllowedFunctionCalls should be used in css prop instead
|
|
@@ -97,7 +98,7 @@ function isPropertyValueAllowed(property, context) {
|
|
|
97
98
|
} else if (property.value.type === 'MemberExpression' && property.value.object.type === 'Identifier') {
|
|
98
99
|
var _findVariable2;
|
|
99
100
|
var definitions = (_findVariable2 = (0, _findVariable3.findVariable)({
|
|
100
|
-
sourceCode:
|
|
101
|
+
sourceCode: (0, _contextCompat.getSourceCode)(context),
|
|
101
102
|
identifier: property.value.object
|
|
102
103
|
})) === null || _findVariable2 === void 0 ? void 0 : _findVariable2.defs;
|
|
103
104
|
if (!definitions || !definitions.length) {
|
|
@@ -139,7 +140,7 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
139
140
|
},
|
|
140
141
|
create: function create(context) {
|
|
141
142
|
return {
|
|
142
|
-
'JSXAttribute[name.name="style"] > JSXExpressionContainer': function
|
|
143
|
+
'JSXAttribute[name.name="style"] > JSXExpressionContainer': function JSXAttributeNameNameStyle__JSXExpressionContainer(node) {
|
|
143
144
|
var _node$expression$expr, _expression;
|
|
144
145
|
if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXExpressionContainer')) {
|
|
145
146
|
return;
|
|
@@ -170,7 +171,7 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
170
171
|
* ```
|
|
171
172
|
*/
|
|
172
173
|
var variable = (0, _findVariable3.findVariable)({
|
|
173
|
-
sourceCode:
|
|
174
|
+
sourceCode: (0, _contextCompat.getSourceCode)(context),
|
|
174
175
|
identifier: node.expression
|
|
175
176
|
});
|
|
176
177
|
|
|
@@ -4,8 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.rule = exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
8
8
|
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
9
|
+
var _createRule = require("../utils/create-rule");
|
|
9
10
|
var IMPORT_SOURCES = [_isSupportedImport.CSS_IN_JS_IMPORTS.compiled, _isSupportedImport.CSS_IN_JS_IMPORTS.atlaskitCss];
|
|
10
11
|
function getParentJSXAttribute(node) {
|
|
11
12
|
var parent = node.parent;
|
|
@@ -33,7 +34,7 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
33
34
|
create: function create(context) {
|
|
34
35
|
return {
|
|
35
36
|
'CallExpression[callee.name="cx"]': function CallExpressionCalleeNameCx(node) {
|
|
36
|
-
if (node.type === 'CallExpression' && (0, _isSupportedImport.isCxFunction)(node.callee,
|
|
37
|
+
if (node.type === 'CallExpression' && (0, _isSupportedImport.isCxFunction)(node.callee, (0, _contextCompat.getScope)(context, node).references, IMPORT_SOURCES)) {
|
|
37
38
|
var parentJSXAttribute = getParentJSXAttribute(node);
|
|
38
39
|
var propName = parentJSXAttribute === null || parentJSXAttribute === void 0 ? void 0 : parentJSXAttribute.name.name.toString();
|
|
39
40
|
if (propName && /[xX]css$/.test(propName)) {
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.rule = exports.default = void 0;
|
|
7
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
7
8
|
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
8
9
|
var _createRule = require("../utils/create-rule");
|
|
9
10
|
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; } } }; }
|
|
@@ -40,8 +41,8 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
40
41
|
var importSources = (0, _isSupportedImport.getImportSources)(context);
|
|
41
42
|
return {
|
|
42
43
|
CallExpression: function CallExpression(node) {
|
|
43
|
-
var
|
|
44
|
-
references =
|
|
44
|
+
var _getScope = (0, _contextCompat.getScope)(context, node),
|
|
45
|
+
references = _getScope.references;
|
|
45
46
|
if (!(0, _isSupportedImport.hasStyleObjectArguments)(node.callee, references, importSources)) {
|
|
46
47
|
return;
|
|
47
48
|
}
|
|
@@ -70,7 +71,7 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
70
71
|
var items = argument.elements.filter(function (value) {
|
|
71
72
|
return value !== null;
|
|
72
73
|
}).map(function (element) {
|
|
73
|
-
return
|
|
74
|
+
return (0, _contextCompat.getSourceCode)(context).getText(element);
|
|
74
75
|
});
|
|
75
76
|
return fixer.replaceText(argument, items.join(', '));
|
|
76
77
|
}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.rule = exports.default = void 0;
|
|
8
8
|
var _estraverse = _interopRequireDefault(require("estraverse"));
|
|
9
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
9
10
|
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
10
11
|
var _createRule = require("../utils/create-rule");
|
|
11
12
|
/* eslint-disable @atlassian/tangerine/import/entry-points */
|
|
@@ -40,8 +41,8 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
40
41
|
var importSources = (0, _isSupportedImport.getImportSources)(context);
|
|
41
42
|
return {
|
|
42
43
|
CallExpression: function CallExpression(node) {
|
|
43
|
-
var
|
|
44
|
-
references =
|
|
44
|
+
var _getScope = (0, _contextCompat.getScope)(context, node),
|
|
45
|
+
references = _getScope.references;
|
|
45
46
|
if ((0, _isSupportedImport.isCss)(node.callee, references, importSources) || (0, _isSupportedImport.isStyled)(node.callee, references, importSources) || (0, _isSupportedImport.isKeyframes)(node.callee, references, importSources) || (0, _isSupportedImport.isCssMap)(node.callee, references, importSources) || (0, _isSupportedImport.isXcss)(node.callee, references, importSources)) {
|
|
46
47
|
_estraverse.default.traverse(node, {
|
|
47
48
|
enter: function enter(node) {
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.rule = exports.default = void 0;
|
|
8
8
|
var _esquery = _interopRequireDefault(require("esquery"));
|
|
9
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
9
10
|
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
10
11
|
var _createRule = require("../utils/create-rule");
|
|
11
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; } } }; }
|
|
@@ -41,8 +42,8 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
41
42
|
var importSources = (0, _isSupportedImport.getImportSources)(context);
|
|
42
43
|
return {
|
|
43
44
|
CallExpression: function CallExpression(node) {
|
|
44
|
-
var
|
|
45
|
-
references =
|
|
45
|
+
var _getScope = (0, _contextCompat.getScope)(context, node),
|
|
46
|
+
references = _getScope.references;
|
|
46
47
|
if (!(0, _isSupportedImport.hasStyleObjectArguments)(node.callee, references, importSources)) {
|
|
47
48
|
return;
|
|
48
49
|
}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.rule = exports.default = void 0;
|
|
8
8
|
var _esquery = _interopRequireDefault(require("esquery"));
|
|
9
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
9
10
|
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
10
11
|
var _schema = require("@atlaskit/eslint-utils/schema");
|
|
11
12
|
var _createRuleWithTypedConfig = require("../utils/create-rule-with-typed-config");
|
|
@@ -35,8 +36,8 @@ var rule = exports.rule = (0, _createRuleWithTypedConfig.createLintRuleWithTyped
|
|
|
35
36
|
var importSources = _ref.importSources;
|
|
36
37
|
return {
|
|
37
38
|
CallExpression: function CallExpression(node) {
|
|
38
|
-
var
|
|
39
|
-
references =
|
|
39
|
+
var _getScope = (0, _contextCompat.getScope)(context, node),
|
|
40
|
+
references = _getScope.references;
|
|
40
41
|
if (!(0, _isSupportedImport.hasStyleObjectArguments)(node.callee, references, importSources)) {
|
|
41
42
|
return;
|
|
42
43
|
}
|
|
@@ -8,6 +8,7 @@ exports.rule = exports.default = void 0;
|
|
|
8
8
|
var _esquery = _interopRequireDefault(require("esquery"));
|
|
9
9
|
var _estraverse = _interopRequireDefault(require("estraverse"));
|
|
10
10
|
var _allowedFunctionCalls = require("@atlaskit/eslint-utils/allowed-function-calls");
|
|
11
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
11
12
|
var _findVariable = require("@atlaskit/eslint-utils/find-variable");
|
|
12
13
|
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
13
14
|
var _createRule = require("../utils/create-rule");
|
|
@@ -58,7 +59,7 @@ var schema = [{
|
|
|
58
59
|
var isIdentifierImported = function isIdentifierImported(identifier, context, functionAllowList, keysAllowList) {
|
|
59
60
|
var variable = (0, _findVariable.findVariable)({
|
|
60
61
|
identifier: identifier,
|
|
61
|
-
sourceCode:
|
|
62
|
+
sourceCode: (0, _contextCompat.getSourceCode)(context)
|
|
62
63
|
});
|
|
63
64
|
if (!variable) {
|
|
64
65
|
return false;
|
|
@@ -158,19 +159,19 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
158
159
|
if (callExpression.callee !== identifier) {
|
|
159
160
|
return false;
|
|
160
161
|
}
|
|
161
|
-
return (0, _isSupportedImport.isCxFunction)(identifier,
|
|
162
|
+
return (0, _isSupportedImport.isCxFunction)(identifier, (0, _contextCompat.getScope)(context, identifier).references, importSources);
|
|
162
163
|
};
|
|
163
164
|
return {
|
|
164
165
|
// Checking css/cssMap/keyframes/styled/xcss calls
|
|
165
166
|
CallExpression: function CallExpression(node) {
|
|
166
|
-
var
|
|
167
|
-
references =
|
|
167
|
+
var _getScope = (0, _contextCompat.getScope)(context, node),
|
|
168
|
+
references = _getScope.references;
|
|
168
169
|
if (!(0, _isSupportedImport.hasStyleObjectArguments)(node.callee, references, importSources)) {
|
|
169
170
|
return;
|
|
170
171
|
}
|
|
171
172
|
node.arguments.forEach(checkForIdentifiers);
|
|
172
173
|
},
|
|
173
|
-
'JSXAttribute[name.name=/^(style|css|xcss)$/]': function
|
|
174
|
+
'JSXAttribute[name.name=/^(style|css|xcss)$/]': function JSXAttributeNameName_StyleCssXcss$_(jsxAttribute) {
|
|
174
175
|
if (jsxAttribute.type !== 'JSXAttribute') {
|
|
175
176
|
return;
|
|
176
177
|
}
|
|
@@ -8,8 +8,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.rule = exports.default = void 0;
|
|
9
9
|
var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
|
|
10
10
|
var _postcssSelectorParser = _interopRequireWildcard(require("postcss-selector-parser"));
|
|
11
|
-
var
|
|
11
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
12
12
|
var _schema = require("@atlaskit/eslint-utils/schema");
|
|
13
|
+
var _walkStyleProperties = require("@atlaskit/eslint-utils/walk-style-properties");
|
|
13
14
|
var _createRuleWithTypedConfig = require("../utils/create-rule-with-typed-config");
|
|
14
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
15
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -63,8 +64,8 @@ var rule = exports.rule = (0, _createRuleWithTypedConfig.createLintRuleWithTyped
|
|
|
63
64
|
var importSources = _ref.importSources;
|
|
64
65
|
return {
|
|
65
66
|
CallExpression: function CallExpression(node) {
|
|
66
|
-
var
|
|
67
|
-
references =
|
|
67
|
+
var _getScope = (0, _contextCompat.getScope)(context, node),
|
|
68
|
+
references = _getScope.references;
|
|
68
69
|
(0, _walkStyleProperties.walkStyleProperties)(node, references, importSources, function (_ref2) {
|
|
69
70
|
var key = _ref2.key,
|
|
70
71
|
value = _ref2.value;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.rule = exports.default = void 0;
|
|
7
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
7
8
|
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
8
9
|
var _createRule = require("../utils/create-rule");
|
|
9
10
|
var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
@@ -22,7 +23,7 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
22
23
|
create: function create(context) {
|
|
23
24
|
return {
|
|
24
25
|
CallExpression: function CallExpression(node) {
|
|
25
|
-
var references =
|
|
26
|
+
var references = (0, _contextCompat.getScope)(context, node).references;
|
|
26
27
|
var importSources = (0, _isSupportedImport.getImportSources)(context);
|
|
27
28
|
if ((0, _isSupportedImport.isStyled)(node, references, importSources)) {
|
|
28
29
|
context.report({
|
|
@@ -32,10 +33,10 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
32
33
|
}
|
|
33
34
|
},
|
|
34
35
|
MemberExpression: function MemberExpression(node) {
|
|
35
|
-
var references =
|
|
36
|
+
var references = (0, _contextCompat.getScope)(context, node).references;
|
|
36
37
|
var importSources = (0, _isSupportedImport.getImportSources)(context);
|
|
37
38
|
if (node.object.type === 'Identifier' && (0, _isSupportedImport.isStyled)(node.object, references, importSources)) {
|
|
38
|
-
var parent =
|
|
39
|
+
var parent = (0, _contextCompat.getAncestors)(context, node).at(-1);
|
|
39
40
|
if (parent && (parent.type === 'CallExpression' || parent.type === 'MemberExpression')) {
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
|
|
9
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
9
10
|
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
10
11
|
var _schema = require("@atlaskit/eslint-utils/schema");
|
|
11
12
|
var _walkStyleProperties = require("@atlaskit/eslint-utils/walk-style-properties");
|
|
@@ -85,8 +86,8 @@ var rule = (0, _createRuleWithTypedConfig.createLintRuleWithTypedConfig)({
|
|
|
85
86
|
});
|
|
86
87
|
},
|
|
87
88
|
CallExpression: function CallExpression(node) {
|
|
88
|
-
var
|
|
89
|
-
references =
|
|
89
|
+
var _getScope = (0, _contextCompat.getScope)(context, node),
|
|
90
|
+
references = _getScope.references;
|
|
90
91
|
var isXcssCall = (0, _isSupportedImport.isXcss)(node, references, config.importSources);
|
|
91
92
|
(0, _walkStyleProperties.walkStyleProperties)(node, references, config.importSources, function (_ref) {
|
|
92
93
|
var key = _ref.key,
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.getRangeFromNode = getRangeFromNode;
|
|
8
8
|
exports.getSourceLocationFromRange = getSourceLocationFromRange;
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
10
11
|
function getRangeFromNode(_ref) {
|
|
11
12
|
var node = _ref.node,
|
|
12
13
|
sourceNode = _ref.sourceNode;
|
|
@@ -34,7 +35,7 @@ function getSourceLocationFromRange(context, _ref2) {
|
|
|
34
35
|
var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
35
36
|
start = _ref3[0],
|
|
36
37
|
end = _ref3[1];
|
|
37
|
-
var sourceCode =
|
|
38
|
+
var sourceCode = (0, _contextCompat.getSourceCode)(context);
|
|
38
39
|
return {
|
|
39
40
|
start: sourceCode.getLocFromIndex(start),
|
|
40
41
|
end: sourceCode.getLocFromIndex(end)
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.walkCssMap = walkCssMap;
|
|
8
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
9
10
|
/**
|
|
10
11
|
* This util is intentionally not in `@atlaskit/eslint-utils` at this time.
|
|
11
12
|
*
|
|
@@ -16,7 +17,7 @@ function walkCssMap(_ref) {
|
|
|
16
17
|
var context = _ref.context,
|
|
17
18
|
importSources = _ref.importSources,
|
|
18
19
|
visitor = _ref.visitor;
|
|
19
|
-
var program =
|
|
20
|
+
var program = (0, _contextCompat.getSourceCode)(context).ast;
|
|
20
21
|
var importDeclaration = program.body.find(function (node) {
|
|
21
22
|
return node.type === 'ImportDeclaration' && importSources.includes(node.source.value);
|
|
22
23
|
});
|
|
@@ -26,9 +27,9 @@ function walkCssMap(_ref) {
|
|
|
26
27
|
if (!specifier) {
|
|
27
28
|
return;
|
|
28
29
|
}
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
variable =
|
|
30
|
+
var _getSourceCode$scopeM = (0, _contextCompat.getSourceCode)(context).scopeManager.getDeclaredVariables(specifier),
|
|
31
|
+
_getSourceCode$scopeM2 = (0, _slicedToArray2.default)(_getSourceCode$scopeM, 1),
|
|
32
|
+
variable = _getSourceCode$scopeM2[0];
|
|
32
33
|
if (!variable) {
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.rule = exports.default = void 0;
|
|
7
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
7
8
|
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
8
9
|
var _createRule = require("../utils/create-rule");
|
|
9
10
|
var _messages = require("./messages");
|
|
@@ -67,8 +68,8 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
67
68
|
var importSources = (0, _isSupportedImport.getImportSources)(context);
|
|
68
69
|
return {
|
|
69
70
|
CallExpression: function CallExpression(node) {
|
|
70
|
-
var
|
|
71
|
-
references =
|
|
71
|
+
var _getScope = (0, _contextCompat.getScope)(context, node),
|
|
72
|
+
references = _getScope.references;
|
|
72
73
|
if (!(0, _isSupportedImport.isCss)(node.callee, references, importSources) && !(0, _isSupportedImport.isStyled)(node.callee, references, importSources) && !(0, _isSupportedImport.isKeyframes)(node.callee, references, importSources) && !(0, _isSupportedImport.isCssMap)(node.callee, references, importSources) && !(0, _isSupportedImport.isXcss)(node.callee, references, importSources)) {
|
|
73
74
|
return;
|
|
74
75
|
}
|
|
@@ -9,10 +9,11 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
9
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
11
|
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
12
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
12
13
|
var _findVariable = require("@atlaskit/eslint-utils/find-variable");
|
|
13
14
|
var _createRule = require("../utils/create-rule");
|
|
14
|
-
var _utils = require("./utils");
|
|
15
15
|
var _isSafe = require("./is-safe");
|
|
16
|
+
var _utils = require("./utils");
|
|
16
17
|
var SUPPORTED_EMOTION_IMPORTS = new Set(['css', 'keyframes', 'ClassNames', 'jsx']);
|
|
17
18
|
var SUPPORTED_IMPORT_MAP = {
|
|
18
19
|
'@emotion/core': SUPPORTED_EMOTION_IMPORTS,
|
|
@@ -63,7 +64,7 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
63
64
|
var config = readConfig(context);
|
|
64
65
|
return {
|
|
65
66
|
Program: function Program() {
|
|
66
|
-
var pragma =
|
|
67
|
+
var pragma = (0, _contextCompat.getAllComments)(context).find(function (n) {
|
|
67
68
|
return n.value.includes('@jsxImportSource @emotion/react');
|
|
68
69
|
});
|
|
69
70
|
if (!pragma) {
|
|
@@ -8,6 +8,7 @@ exports.isSafeKeyframes = isSafeKeyframes;
|
|
|
8
8
|
exports.isSafeStyled = isSafeStyled;
|
|
9
9
|
exports.isSafeUsage = isSafeUsage;
|
|
10
10
|
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
11
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
11
12
|
var _findVariable = require("@atlaskit/eslint-utils/find-variable");
|
|
12
13
|
function isSafeUsage(_ref) {
|
|
13
14
|
var context = _ref.context,
|
|
@@ -20,14 +21,14 @@ function isSafeUsage(_ref) {
|
|
|
20
21
|
if (importName === 'css') {
|
|
21
22
|
var css = (0, _findVariable.findVariable)({
|
|
22
23
|
identifier: specifier.local,
|
|
23
|
-
sourceCode:
|
|
24
|
+
sourceCode: (0, _contextCompat.getSourceCode)(context)
|
|
24
25
|
});
|
|
25
26
|
return css !== null && isSafeCss(css);
|
|
26
27
|
}
|
|
27
28
|
if (importName === 'keyframes') {
|
|
28
29
|
var keyframes = (0, _findVariable.findVariable)({
|
|
29
30
|
identifier: specifier.local,
|
|
30
|
-
sourceCode:
|
|
31
|
+
sourceCode: (0, _contextCompat.getSourceCode)(context)
|
|
31
32
|
});
|
|
32
33
|
return keyframes !== null && isSafeKeyframes(keyframes);
|
|
33
34
|
}
|
|
@@ -7,8 +7,9 @@ exports.getFirstImportFromSource = getFirstImportFromSource;
|
|
|
7
7
|
exports.isImportDefaultSpecifier = isImportDefaultSpecifier;
|
|
8
8
|
exports.isImportNamespaceSpecifier = isImportNamespaceSpecifier;
|
|
9
9
|
exports.isImportSpecifier = isImportSpecifier;
|
|
10
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
10
11
|
function getFirstImportFromSource(context, source) {
|
|
11
|
-
return
|
|
12
|
+
return (0, _contextCompat.getSourceCode)(context).ast.body.filter(isImportDeclaration).find(function (node) {
|
|
12
13
|
return node.source.value === source;
|
|
13
14
|
});
|
|
14
15
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getAncestors, getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
1
2
|
import { getImportSources, isCompiled } from '@atlaskit/eslint-utils/is-supported-import';
|
|
2
3
|
import { createLintRule } from '../utils/create-rule';
|
|
3
4
|
const isIdentifierReferenced = (hasImportSpecifier, node, references) => references.some(reference => {
|
|
@@ -58,8 +59,8 @@ export const rule = createLintRule({
|
|
|
58
59
|
'CallExpression Identifier': node => {
|
|
59
60
|
const {
|
|
60
61
|
references
|
|
61
|
-
} =
|
|
62
|
-
const ancestors =
|
|
62
|
+
} = getScope(context, node);
|
|
63
|
+
const ancestors = getAncestors(context, node);
|
|
63
64
|
|
|
64
65
|
// Check if ancestor node is a call expression to Compiled
|
|
65
66
|
if (ancestors.some(ancestor => ancestor.type === 'CallExpression' && ancestor.callee && isCompiled(ancestor.callee, references, importSources))) {
|
|
@@ -73,8 +74,8 @@ export const rule = createLintRule({
|
|
|
73
74
|
'TaggedTemplateExpression Identifier': node => {
|
|
74
75
|
const {
|
|
75
76
|
references
|
|
76
|
-
} =
|
|
77
|
-
const ancestors =
|
|
77
|
+
} = getScope(context, node);
|
|
78
|
+
const ancestors = getAncestors(context, node);
|
|
78
79
|
|
|
79
80
|
// Check if ancestor node is a tagged template expression to Compiled
|
|
80
81
|
if (ancestors.some(ancestor => ancestor.type === 'TaggedTemplateExpression' && ancestor.tag && isCompiled(ancestor.tag, references, importSources))) {
|