@atlaskit/eslint-plugin-ui-styling-standard 0.18.1 → 0.18.2
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
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-ui-styling-standard
|
|
2
2
|
|
|
3
|
+
## 0.18.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#120040](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/120040)
|
|
8
|
+
[`5d9c0285bcb91`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5d9c0285bcb91) -
|
|
9
|
+
The `no-imported-style-values` rule will now allow using `cx()` inside the `xcss` prop.
|
|
10
|
+
|
|
3
11
|
## 0.18.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -5,12 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.rule = exports.default = void 0;
|
|
8
|
-
var _createRule = require("../utils/create-rule");
|
|
9
|
-
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
10
|
-
var _findVariable = require("@atlaskit/eslint-utils/find-variable");
|
|
11
|
-
var _allowedFunctionCalls = require("@atlaskit/eslint-utils/allowed-function-calls");
|
|
12
8
|
var _esquery = _interopRequireDefault(require("esquery"));
|
|
13
9
|
var _estraverse = _interopRequireDefault(require("estraverse"));
|
|
10
|
+
var _allowedFunctionCalls = require("@atlaskit/eslint-utils/allowed-function-calls");
|
|
11
|
+
var _findVariable = require("@atlaskit/eslint-utils/find-variable");
|
|
12
|
+
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
13
|
+
var _createRule = require("../utils/create-rule");
|
|
14
14
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
15
15
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
16
16
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
@@ -134,6 +134,31 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
134
134
|
_iterator.f();
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
|
+
var isValidCx = function isValidCx(jsxAttribute, identifier) {
|
|
138
|
+
/**
|
|
139
|
+
* We don't want to allow `cx` for `css` (or `style`)
|
|
140
|
+
*/
|
|
141
|
+
if (jsxAttribute.name.name !== 'xcss') {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Check we have the exact form of `xcss={cx(...)}` otherwise it isn't valid.
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
var jsxExpression = jsxAttribute.value;
|
|
150
|
+
if ((jsxExpression === null || jsxExpression === void 0 ? void 0 : jsxExpression.type) !== 'JSXExpressionContainer') {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
var callExpression = jsxExpression.expression;
|
|
154
|
+
if ((callExpression === null || callExpression === void 0 ? void 0 : callExpression.type) !== 'CallExpression') {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
if (callExpression.callee !== identifier) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
return (0, _isSupportedImport.isCxFunction)(identifier, context.getScope().references, importSources);
|
|
161
|
+
};
|
|
137
162
|
return {
|
|
138
163
|
// Checking css/cssMap/keyframes/styled/xcss calls
|
|
139
164
|
CallExpression: function CallExpression(node) {
|
|
@@ -144,7 +169,10 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
144
169
|
}
|
|
145
170
|
node.arguments.forEach(checkForIdentifiers);
|
|
146
171
|
},
|
|
147
|
-
'JSXAttribute[name.name=/^style|css$/]': function
|
|
172
|
+
'JSXAttribute[name.name=/^(style|css|xcss)$/]': function JSXAttributeNameNameStyleCssXcss$(jsxAttribute) {
|
|
173
|
+
if (jsxAttribute.type !== 'JSXAttribute') {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
148
176
|
_estraverse.default.traverse(jsxAttribute, {
|
|
149
177
|
fallback: function fallback(node) {
|
|
150
178
|
// estraverse does not know about nodes not in the ESTree standard.
|
|
@@ -174,6 +202,9 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
174
202
|
if (node.type !== 'Identifier') {
|
|
175
203
|
return;
|
|
176
204
|
}
|
|
205
|
+
if (isValidCx(jsxAttribute, node)) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
177
208
|
checkIdentifier(node, context, functionAllowList, keysAllowList);
|
|
178
209
|
}
|
|
179
210
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createLintRule } from '../utils/create-rule';
|
|
2
|
-
import { getImportSources, hasStyleObjectArguments } from '@atlaskit/eslint-utils/is-supported-import';
|
|
3
|
-
import { findVariable } from '@atlaskit/eslint-utils/find-variable';
|
|
4
|
-
import { getAllowedDynamicKeys, getAllowedFunctionCalls, isAllowListedVariable } from '@atlaskit/eslint-utils/allowed-function-calls';
|
|
5
1
|
import esquery from 'esquery';
|
|
6
2
|
import estraverse from 'estraverse';
|
|
3
|
+
import { getAllowedDynamicKeys, getAllowedFunctionCalls, isAllowListedVariable } from '@atlaskit/eslint-utils/allowed-function-calls';
|
|
4
|
+
import { findVariable } from '@atlaskit/eslint-utils/find-variable';
|
|
5
|
+
import { getImportSources, hasStyleObjectArguments, isCxFunction } from '@atlaskit/eslint-utils/is-supported-import';
|
|
6
|
+
import { createLintRule } from '../utils/create-rule';
|
|
7
7
|
const schema = [{
|
|
8
8
|
type: 'object',
|
|
9
9
|
properties: {
|
|
@@ -114,6 +114,31 @@ export const rule = createLintRule({
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
|
+
const isValidCx = (jsxAttribute, identifier) => {
|
|
118
|
+
/**
|
|
119
|
+
* We don't want to allow `cx` for `css` (or `style`)
|
|
120
|
+
*/
|
|
121
|
+
if (jsxAttribute.name.name !== 'xcss') {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Check we have the exact form of `xcss={cx(...)}` otherwise it isn't valid.
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
const jsxExpression = jsxAttribute.value;
|
|
130
|
+
if ((jsxExpression === null || jsxExpression === void 0 ? void 0 : jsxExpression.type) !== 'JSXExpressionContainer') {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
const callExpression = jsxExpression.expression;
|
|
134
|
+
if ((callExpression === null || callExpression === void 0 ? void 0 : callExpression.type) !== 'CallExpression') {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
if (callExpression.callee !== identifier) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
return isCxFunction(identifier, context.getScope().references, importSources);
|
|
141
|
+
};
|
|
117
142
|
return {
|
|
118
143
|
// Checking css/cssMap/keyframes/styled/xcss calls
|
|
119
144
|
CallExpression(node) {
|
|
@@ -125,7 +150,10 @@ export const rule = createLintRule({
|
|
|
125
150
|
}
|
|
126
151
|
node.arguments.forEach(checkForIdentifiers);
|
|
127
152
|
},
|
|
128
|
-
'JSXAttribute[name.name=/^style|css$/]'(jsxAttribute) {
|
|
153
|
+
'JSXAttribute[name.name=/^(style|css|xcss)$/]'(jsxAttribute) {
|
|
154
|
+
if (jsxAttribute.type !== 'JSXAttribute') {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
129
157
|
estraverse.traverse(jsxAttribute, {
|
|
130
158
|
fallback(node) {
|
|
131
159
|
// estraverse does not know about nodes not in the ESTree standard.
|
|
@@ -153,6 +181,9 @@ export const rule = createLintRule({
|
|
|
153
181
|
if (node.type !== 'Identifier') {
|
|
154
182
|
return;
|
|
155
183
|
}
|
|
184
|
+
if (isValidCx(jsxAttribute, node)) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
156
187
|
checkIdentifier(node, context, functionAllowList, keysAllowList);
|
|
157
188
|
}
|
|
158
189
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
2
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
3
3
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
4
|
-
import { createLintRule } from '../utils/create-rule';
|
|
5
|
-
import { getImportSources, hasStyleObjectArguments } from '@atlaskit/eslint-utils/is-supported-import';
|
|
6
|
-
import { findVariable } from '@atlaskit/eslint-utils/find-variable';
|
|
7
|
-
import { getAllowedDynamicKeys, getAllowedFunctionCalls, isAllowListedVariable } from '@atlaskit/eslint-utils/allowed-function-calls';
|
|
8
4
|
import esquery from 'esquery';
|
|
9
5
|
import estraverse from 'estraverse';
|
|
6
|
+
import { getAllowedDynamicKeys, getAllowedFunctionCalls, isAllowListedVariable } from '@atlaskit/eslint-utils/allowed-function-calls';
|
|
7
|
+
import { findVariable } from '@atlaskit/eslint-utils/find-variable';
|
|
8
|
+
import { getImportSources, hasStyleObjectArguments, isCxFunction } from '@atlaskit/eslint-utils/is-supported-import';
|
|
9
|
+
import { createLintRule } from '../utils/create-rule';
|
|
10
10
|
var schema = [{
|
|
11
11
|
type: 'object',
|
|
12
12
|
properties: {
|
|
@@ -127,6 +127,31 @@ export var rule = createLintRule({
|
|
|
127
127
|
_iterator.f();
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
|
+
var isValidCx = function isValidCx(jsxAttribute, identifier) {
|
|
131
|
+
/**
|
|
132
|
+
* We don't want to allow `cx` for `css` (or `style`)
|
|
133
|
+
*/
|
|
134
|
+
if (jsxAttribute.name.name !== 'xcss') {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Check we have the exact form of `xcss={cx(...)}` otherwise it isn't valid.
|
|
140
|
+
*/
|
|
141
|
+
|
|
142
|
+
var jsxExpression = jsxAttribute.value;
|
|
143
|
+
if ((jsxExpression === null || jsxExpression === void 0 ? void 0 : jsxExpression.type) !== 'JSXExpressionContainer') {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
var callExpression = jsxExpression.expression;
|
|
147
|
+
if ((callExpression === null || callExpression === void 0 ? void 0 : callExpression.type) !== 'CallExpression') {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
if (callExpression.callee !== identifier) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
return isCxFunction(identifier, context.getScope().references, importSources);
|
|
154
|
+
};
|
|
130
155
|
return {
|
|
131
156
|
// Checking css/cssMap/keyframes/styled/xcss calls
|
|
132
157
|
CallExpression: function CallExpression(node) {
|
|
@@ -137,7 +162,10 @@ export var rule = createLintRule({
|
|
|
137
162
|
}
|
|
138
163
|
node.arguments.forEach(checkForIdentifiers);
|
|
139
164
|
},
|
|
140
|
-
'JSXAttribute[name.name=/^style|css$/]': function
|
|
165
|
+
'JSXAttribute[name.name=/^(style|css|xcss)$/]': function JSXAttributeNameNameStyleCssXcss$(jsxAttribute) {
|
|
166
|
+
if (jsxAttribute.type !== 'JSXAttribute') {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
141
169
|
estraverse.traverse(jsxAttribute, {
|
|
142
170
|
fallback: function fallback(node) {
|
|
143
171
|
// estraverse does not know about nodes not in the ESTree standard.
|
|
@@ -167,6 +195,9 @@ export var rule = createLintRule({
|
|
|
167
195
|
if (node.type !== 'Identifier') {
|
|
168
196
|
return;
|
|
169
197
|
}
|
|
198
|
+
if (isValidCx(jsxAttribute, node)) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
170
201
|
checkIdentifier(node, context, functionAllowList, keysAllowList);
|
|
171
202
|
}
|
|
172
203
|
});
|
package/package.json
CHANGED