@atlaskit/eslint-plugin-ui-styling-standard 1.1.0 → 1.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 +19 -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
|
@@ -2,6 +2,7 @@ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol
|
|
|
2
2
|
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; } }
|
|
3
3
|
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; }
|
|
4
4
|
import esquery from 'esquery';
|
|
5
|
+
import { getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
5
6
|
import { hasStyleObjectArguments } from '@atlaskit/eslint-utils/is-supported-import';
|
|
6
7
|
import { importSources } from '@atlaskit/eslint-utils/schema';
|
|
7
8
|
import { createLintRuleWithTypedConfig } from '../utils/create-rule-with-typed-config';
|
|
@@ -28,8 +29,8 @@ export var rule = createLintRuleWithTypedConfig({
|
|
|
28
29
|
var importSources = _ref.importSources;
|
|
29
30
|
return {
|
|
30
31
|
CallExpression: function CallExpression(node) {
|
|
31
|
-
var
|
|
32
|
-
references =
|
|
32
|
+
var _getScope = getScope(context, node),
|
|
33
|
+
references = _getScope.references;
|
|
33
34
|
if (!hasStyleObjectArguments(node.callee, references, importSources)) {
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
@@ -8,6 +8,7 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
8
8
|
import esquery from 'esquery';
|
|
9
9
|
import estraverse from 'estraverse';
|
|
10
10
|
import { getAllowedDynamicKeys, getAllowedFunctionCalls, isAllowListedVariable } from '@atlaskit/eslint-utils/allowed-function-calls';
|
|
11
|
+
import { getScope, getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
11
12
|
import { findVariable } from '@atlaskit/eslint-utils/find-variable';
|
|
12
13
|
import { getImportSources, hasStyleObjectArguments, isCxFunction } from '@atlaskit/eslint-utils/is-supported-import';
|
|
13
14
|
import { createLintRule } from '../utils/create-rule';
|
|
@@ -54,7 +55,7 @@ var schema = [{
|
|
|
54
55
|
var isIdentifierImported = function isIdentifierImported(identifier, context, functionAllowList, keysAllowList) {
|
|
55
56
|
var variable = findVariable({
|
|
56
57
|
identifier: identifier,
|
|
57
|
-
sourceCode:
|
|
58
|
+
sourceCode: getSourceCode(context)
|
|
58
59
|
});
|
|
59
60
|
if (!variable) {
|
|
60
61
|
return false;
|
|
@@ -154,19 +155,19 @@ export var rule = createLintRule({
|
|
|
154
155
|
if (callExpression.callee !== identifier) {
|
|
155
156
|
return false;
|
|
156
157
|
}
|
|
157
|
-
return isCxFunction(identifier,
|
|
158
|
+
return isCxFunction(identifier, getScope(context, identifier).references, importSources);
|
|
158
159
|
};
|
|
159
160
|
return {
|
|
160
161
|
// Checking css/cssMap/keyframes/styled/xcss calls
|
|
161
162
|
CallExpression: function CallExpression(node) {
|
|
162
|
-
var
|
|
163
|
-
references =
|
|
163
|
+
var _getScope = getScope(context, node),
|
|
164
|
+
references = _getScope.references;
|
|
164
165
|
if (!hasStyleObjectArguments(node.callee, references, importSources)) {
|
|
165
166
|
return;
|
|
166
167
|
}
|
|
167
168
|
node.arguments.forEach(checkForIdentifiers);
|
|
168
169
|
},
|
|
169
|
-
'JSXAttribute[name.name=/^(style|css|xcss)$/]': function
|
|
170
|
+
'JSXAttribute[name.name=/^(style|css|xcss)$/]': function JSXAttributeNameName_StyleCssXcss$_(jsxAttribute) {
|
|
170
171
|
if (jsxAttribute.type !== 'JSXAttribute') {
|
|
171
172
|
return;
|
|
172
173
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _toArray from "@babel/runtime/helpers/toArray";
|
|
2
2
|
import cssSelectorParser, { isNesting, isPseudo } from 'postcss-selector-parser';
|
|
3
|
-
import {
|
|
3
|
+
import { getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
4
4
|
import { importSources } from '@atlaskit/eslint-utils/schema';
|
|
5
|
+
import { walkStyleProperties } from '@atlaskit/eslint-utils/walk-style-properties';
|
|
5
6
|
import { createLintRuleWithTypedConfig } from '../utils/create-rule-with-typed-config';
|
|
6
7
|
var getCssSelector = function getCssSelector(key) {
|
|
7
8
|
if (key.type === 'Literal' && typeof key.value === 'string') {
|
|
@@ -53,8 +54,8 @@ export var rule = createLintRuleWithTypedConfig({
|
|
|
53
54
|
var importSources = _ref.importSources;
|
|
54
55
|
return {
|
|
55
56
|
CallExpression: function CallExpression(node) {
|
|
56
|
-
var
|
|
57
|
-
references =
|
|
57
|
+
var _getScope = getScope(context, node),
|
|
58
|
+
references = _getScope.references;
|
|
58
59
|
walkStyleProperties(node, references, importSources, function (_ref2) {
|
|
59
60
|
var key = _ref2.key,
|
|
60
61
|
value = _ref2.value;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getAncestors, getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
2
|
+
import { getImportSources, isStyled } from '@atlaskit/eslint-utils/is-supported-import';
|
|
2
3
|
import { createLintRule } from '../utils/create-rule';
|
|
3
4
|
export var rule = createLintRule({
|
|
4
5
|
meta: {
|
|
@@ -16,7 +17,7 @@ export var rule = createLintRule({
|
|
|
16
17
|
create: function create(context) {
|
|
17
18
|
return {
|
|
18
19
|
CallExpression: function CallExpression(node) {
|
|
19
|
-
var references =
|
|
20
|
+
var references = getScope(context, node).references;
|
|
20
21
|
var importSources = getImportSources(context);
|
|
21
22
|
if (isStyled(node, references, importSources)) {
|
|
22
23
|
context.report({
|
|
@@ -26,10 +27,10 @@ export var rule = createLintRule({
|
|
|
26
27
|
}
|
|
27
28
|
},
|
|
28
29
|
MemberExpression: function MemberExpression(node) {
|
|
29
|
-
var references =
|
|
30
|
+
var references = getScope(context, node).references;
|
|
30
31
|
var importSources = getImportSources(context);
|
|
31
32
|
if (node.object.type === 'Identifier' && isStyled(node.object, references, importSources)) {
|
|
32
|
-
var parent =
|
|
33
|
+
var parent = getAncestors(context, node).at(-1);
|
|
33
34
|
if (parent && (parent.type === 'CallExpression' || parent.type === 'MemberExpression')) {
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import cssSelectorParser from 'postcss-selector-parser';
|
|
2
|
+
import { getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
2
3
|
import { isXcss } from '@atlaskit/eslint-utils/is-supported-import';
|
|
3
4
|
import { importSources } from '@atlaskit/eslint-utils/schema';
|
|
4
5
|
import { walkStyleProperties } from '@atlaskit/eslint-utils/walk-style-properties';
|
|
@@ -78,8 +79,8 @@ var rule = createLintRuleWithTypedConfig({
|
|
|
78
79
|
});
|
|
79
80
|
},
|
|
80
81
|
CallExpression: function CallExpression(node) {
|
|
81
|
-
var
|
|
82
|
-
references =
|
|
82
|
+
var _getScope = getScope(context, node),
|
|
83
|
+
references = _getScope.references;
|
|
83
84
|
var isXcssCall = isXcss(node, references, config.importSources);
|
|
84
85
|
walkStyleProperties(node, references, config.importSources, function (_ref) {
|
|
85
86
|
var key = _ref.key,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
2
3
|
export function getRangeFromNode(_ref) {
|
|
3
4
|
var node = _ref.node,
|
|
4
5
|
sourceNode = _ref.sourceNode;
|
|
@@ -26,7 +27,7 @@ export function getSourceLocationFromRange(context, _ref2) {
|
|
|
26
27
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
27
28
|
start = _ref3[0],
|
|
28
29
|
end = _ref3[1];
|
|
29
|
-
var sourceCode =
|
|
30
|
+
var sourceCode = getSourceCode(context);
|
|
30
31
|
return {
|
|
31
32
|
start: sourceCode.getLocFromIndex(start),
|
|
32
33
|
end: sourceCode.getLocFromIndex(end)
|
|
@@ -5,11 +5,12 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
5
5
|
* This is because the API is likely to change and should not be considered stable.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
8
9
|
export function walkCssMap(_ref) {
|
|
9
10
|
var context = _ref.context,
|
|
10
11
|
importSources = _ref.importSources,
|
|
11
12
|
visitor = _ref.visitor;
|
|
12
|
-
var program =
|
|
13
|
+
var program = getSourceCode(context).ast;
|
|
13
14
|
var importDeclaration = program.body.find(function (node) {
|
|
14
15
|
return node.type === 'ImportDeclaration' && importSources.includes(node.source.value);
|
|
15
16
|
});
|
|
@@ -19,9 +20,9 @@ export function walkCssMap(_ref) {
|
|
|
19
20
|
if (!specifier) {
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
variable =
|
|
23
|
+
var _getSourceCode$scopeM = getSourceCode(context).scopeManager.getDeclaredVariables(specifier),
|
|
24
|
+
_getSourceCode$scopeM2 = _slicedToArray(_getSourceCode$scopeM, 1),
|
|
25
|
+
variable = _getSourceCode$scopeM2[0];
|
|
25
26
|
if (!variable) {
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @atlassian/tangerine/import/entry-points */
|
|
2
2
|
|
|
3
|
+
import { getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
3
4
|
import { getImportSources, isCss, isCssMap, isKeyframes, isStyled, isXcss } from '@atlaskit/eslint-utils/is-supported-import';
|
|
4
5
|
import { createLintRule } from '../utils/create-rule';
|
|
5
6
|
import { messages } from './messages';
|
|
@@ -61,8 +62,8 @@ export var rule = createLintRule({
|
|
|
61
62
|
var importSources = getImportSources(context);
|
|
62
63
|
return {
|
|
63
64
|
CallExpression: function CallExpression(node) {
|
|
64
|
-
var
|
|
65
|
-
references =
|
|
65
|
+
var _getScope = getScope(context, node),
|
|
66
|
+
references = _getScope.references;
|
|
66
67
|
if (!isCss(node.callee, references, importSources) && !isStyled(node.callee, references, importSources) && !isKeyframes(node.callee, references, importSources) && !isCssMap(node.callee, references, importSources) && !isXcss(node.callee, references, importSources)) {
|
|
67
68
|
return;
|
|
68
69
|
}
|
|
@@ -2,10 +2,11 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import { identifier, importDeclaration, importSpecifier, literal } from 'eslint-codemod-utils';
|
|
5
|
+
import { getAllComments } from '@atlaskit/eslint-utils/context-compat';
|
|
5
6
|
import { findVariable } from '@atlaskit/eslint-utils/find-variable';
|
|
6
7
|
import { createLintRule } from '../utils/create-rule';
|
|
7
|
-
import { getFirstImportFromSource, isImportDefaultSpecifier, isImportNamespaceSpecifier, isImportSpecifier } from './utils';
|
|
8
8
|
import { isSafeStyled, isSafeUsage } from './is-safe';
|
|
9
|
+
import { getFirstImportFromSource, isImportDefaultSpecifier, isImportNamespaceSpecifier, isImportSpecifier } from './utils';
|
|
9
10
|
var SUPPORTED_EMOTION_IMPORTS = new Set(['css', 'keyframes', 'ClassNames', 'jsx']);
|
|
10
11
|
var SUPPORTED_IMPORT_MAP = {
|
|
11
12
|
'@emotion/core': SUPPORTED_EMOTION_IMPORTS,
|
|
@@ -56,7 +57,7 @@ export var rule = createLintRule({
|
|
|
56
57
|
var config = readConfig(context);
|
|
57
58
|
return {
|
|
58
59
|
Program: function Program() {
|
|
59
|
-
var pragma =
|
|
60
|
+
var pragma = getAllComments(context).find(function (n) {
|
|
60
61
|
return n.value.includes('@jsxImportSource @emotion/react');
|
|
61
62
|
});
|
|
62
63
|
if (!pragma) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { closestOfType } from 'eslint-codemod-utils';
|
|
2
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
2
3
|
import { findVariable } from '@atlaskit/eslint-utils/find-variable';
|
|
3
4
|
export function isSafeUsage(_ref) {
|
|
4
5
|
var context = _ref.context,
|
|
@@ -11,14 +12,14 @@ export function isSafeUsage(_ref) {
|
|
|
11
12
|
if (importName === 'css') {
|
|
12
13
|
var css = findVariable({
|
|
13
14
|
identifier: specifier.local,
|
|
14
|
-
sourceCode:
|
|
15
|
+
sourceCode: getSourceCode(context)
|
|
15
16
|
});
|
|
16
17
|
return css !== null && isSafeCss(css);
|
|
17
18
|
}
|
|
18
19
|
if (importName === 'keyframes') {
|
|
19
20
|
var keyframes = findVariable({
|
|
20
21
|
identifier: specifier.local,
|
|
21
|
-
sourceCode:
|
|
22
|
+
sourceCode: getSourceCode(context)
|
|
22
23
|
});
|
|
23
24
|
return keyframes !== null && isSafeKeyframes(keyframes);
|
|
24
25
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
1
2
|
export function getFirstImportFromSource(context, source) {
|
|
2
|
-
return
|
|
3
|
+
return getSourceCode(context).ast.body.filter(isImportDeclaration).find(function (node) {
|
|
3
4
|
return node.source.value === source;
|
|
4
5
|
});
|
|
5
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/eslint-plugin-ui-styling-standard",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"author": "Atlassian Pty Ltd",
|
|
5
5
|
"description": "The eslint plugin to enforce and educate on Atlassian's UI Styling Standard",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"./package.json": "./package.json"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@atlaskit/eslint-plugin-design-system": "^
|
|
44
|
-
"@atlaskit/eslint-utils": "^1.
|
|
43
|
+
"@atlaskit/eslint-plugin-design-system": "^12.1.0",
|
|
44
|
+
"@atlaskit/eslint-utils": "^1.9.0",
|
|
45
45
|
"@babel/runtime": "^7.0.0",
|
|
46
46
|
"@typescript-eslint/utils": "^7.1.0",
|
|
47
47
|
"ajv": "^6.12.6",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@af/formatting": "*",
|
|
58
|
-
"@atlaskit/ds-lib": "^3.
|
|
58
|
+
"@atlaskit/ds-lib": "^3.5.0",
|
|
59
59
|
"@atlassian/codegen": "*",
|
|
60
60
|
"@atlassian/ts-loader": "*",
|
|
61
61
|
"@eslint/eslintrc": "^3.0.2",
|