@atlaskit/eslint-plugin-platform 2.2.1 → 2.4.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 +22 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/rules/compiled/expand-border-shorthand/index.js +4 -4
- package/dist/cjs/rules/compiled/expand-spacing-shorthand/index.js +18 -17
- package/dist/cjs/rules/ensure-test-runner-arguments/index.js +1 -1
- package/dist/cjs/rules/ensure-test-runner-nested-count/index.js +1 -1
- package/dist/cjs/rules/feature-gating/inline-usage/index.js +7 -4
- package/dist/cjs/rules/feature-gating/no-alias/index.js +1 -1
- package/dist/cjs/rules/feature-gating/no-preconditioning/index.js +4 -4
- package/dist/cjs/rules/feature-gating/use-recommended-utils/index.js +2 -2
- package/dist/cjs/rules/no-duplicate-dependencies/index.js +2 -2
- package/dist/cjs/rules/no-invalid-feature-flag-usage/index.js +6 -6
- package/dist/cjs/rules/no-invalid-storybook-decorator-usage/index.js +1 -1
- package/dist/cjs/rules/no-pre-post-installs/index.js +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/rules/compiled/expand-spacing-shorthand/index.js +16 -15
- package/dist/es2019/rules/feature-gating/inline-usage/index.js +3 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/rules/compiled/expand-border-shorthand/index.js +4 -4
- package/dist/esm/rules/compiled/expand-spacing-shorthand/index.js +18 -17
- package/dist/esm/rules/ensure-test-runner-arguments/index.js +1 -1
- package/dist/esm/rules/ensure-test-runner-nested-count/index.js +1 -1
- package/dist/esm/rules/feature-gating/inline-usage/index.js +7 -4
- package/dist/esm/rules/feature-gating/no-alias/index.js +1 -1
- package/dist/esm/rules/feature-gating/no-preconditioning/index.js +4 -4
- package/dist/esm/rules/feature-gating/use-recommended-utils/index.js +2 -2
- package/dist/esm/rules/no-duplicate-dependencies/index.js +2 -2
- package/dist/esm/rules/no-invalid-feature-flag-usage/index.js +6 -6
- package/dist/esm/rules/no-invalid-storybook-decorator-usage/index.js +1 -1
- package/dist/esm/rules/no-pre-post-installs/index.js +1 -1
- package/dist/types/index.d.ts +8 -8
- package/dist/types-ts4.5/index.d.ts +8 -8
- package/package.json +2 -2
- package/src/index.tsx +1 -1
- package/src/rules/compiled/expand-spacing-shorthand/__tests__/rule.test.ts +22 -20
- package/src/rules/compiled/expand-spacing-shorthand/index.ts +36 -22
- package/src/rules/feature-gating/README.md +1 -1
- package/src/rules/feature-gating/inline-usage/index.tsx +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-platform
|
|
2
2
|
|
|
3
|
+
## 2.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#113173](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/113173)
|
|
8
|
+
[`46aad36c62f2f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/46aad36c62f2f) -
|
|
9
|
+
Cuts a new changeset to land ESLint v9 changes to NPM fully (shipped internally Feb 5th:
|
|
10
|
+
https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/109855)
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 2.3.0
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- [#108485](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/108485)
|
|
21
|
+
[`0c642edaebbbb`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0c642edaebbbb) -
|
|
22
|
+
AFB-822 Modifying expand-spacing-shorthand ESLint rule to not throw error for non-token
|
|
23
|
+
expressions in template strings
|
|
24
|
+
|
|
3
25
|
## 2.2.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -74,7 +74,7 @@ var commonConfig = {
|
|
|
74
74
|
// Compiled: rules that are not included via `@compiled/recommended
|
|
75
75
|
'@atlaskit/platform/expand-border-shorthand': 'error',
|
|
76
76
|
'@atlaskit/platform/expand-background-shorthand': 'error',
|
|
77
|
-
'@atlaskit/platform/expand-spacing-shorthand': '
|
|
77
|
+
'@atlaskit/platform/expand-spacing-shorthand': 'error',
|
|
78
78
|
'@compiled/jsx-pragma': ['error', {
|
|
79
79
|
importSources: ['@atlaskit/css'],
|
|
80
80
|
onlyRunIfImportingCompiled: true,
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.expandBorderShorthand = exports.default = void 0;
|
|
7
7
|
var EXCLUDED_VALUES = ['0', 'none', 'unset', 'none !important'];
|
|
8
|
-
var
|
|
8
|
+
var _findCallExpression = function findCallExpression(node) {
|
|
9
9
|
var parent = node.parent;
|
|
10
10
|
if (!parent) {
|
|
11
11
|
return null;
|
|
@@ -13,7 +13,7 @@ var findCallExpression = function findCallExpression(node) {
|
|
|
13
13
|
if (parent.type === 'CallExpression') {
|
|
14
14
|
return parent;
|
|
15
15
|
}
|
|
16
|
-
return
|
|
16
|
+
return _findCallExpression(parent);
|
|
17
17
|
};
|
|
18
18
|
var separateBorderProperties = function separateBorderProperties(borderString, property, context) {
|
|
19
19
|
if (EXCLUDED_VALUES.includes(borderString)) {
|
|
@@ -58,11 +58,11 @@ var expandBorderShorthand = exports.expandBorderShorthand = {
|
|
|
58
58
|
create: function create(context) {
|
|
59
59
|
var importDeclaration;
|
|
60
60
|
return {
|
|
61
|
-
'ImportDeclaration[source.value="@compiled/react"], ImportDeclaration[source.value="@atlaskit/css"]': function
|
|
61
|
+
'ImportDeclaration[source.value="@compiled/react"], ImportDeclaration[source.value="@atlaskit/css"]': function ImportDeclarationSourceValueCompiled_react_ImportDeclarationSourceValueAtlaskit_css(node) {
|
|
62
62
|
importDeclaration = node;
|
|
63
63
|
},
|
|
64
64
|
'Property[key.name="border"]': function PropertyKeyNameBorder(node) {
|
|
65
|
-
var callExpression =
|
|
65
|
+
var callExpression = _findCallExpression(node);
|
|
66
66
|
if (!callExpression) {
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
@@ -48,15 +48,23 @@ var parseTemplateLiteral = function parseTemplateLiteral(templateLiteral, contex
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
* Checks if the parsed property values are valid
|
|
52
|
-
* 1.
|
|
53
|
-
* 2.
|
|
54
|
-
* 3.
|
|
51
|
+
* Checks if the parsed property values are valid; values that we shouldn't handle with the fixer:
|
|
52
|
+
* 1. At least one expression in TemplateLiteral is not a token expression
|
|
53
|
+
* 2. Do not contain a token
|
|
54
|
+
* 3. Have length that are not in the range [1, 4] for different spacing directions
|
|
55
|
+
* - No more than 4 to exclude additional values such as `!important`
|
|
56
|
+
* 4. Includes `calc(...)`
|
|
55
57
|
* Then, the rule will return with no error
|
|
56
58
|
* @param propertyValues property values parsed as list of strings
|
|
57
59
|
* @returns boolean
|
|
58
60
|
*/
|
|
59
|
-
var isPropertyValueExempted = function isPropertyValueExempted(propertyValues) {
|
|
61
|
+
var isPropertyValueExempted = function isPropertyValueExempted(templateLiteral, propertyValues) {
|
|
62
|
+
var expressions = templateLiteral.expressions;
|
|
63
|
+
if (!expressions.every(function (expr) {
|
|
64
|
+
return expr.type === 'CallExpression' && isTokenCallExpression(expr);
|
|
65
|
+
})) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
60
68
|
if (!propertyValues.some(function (str) {
|
|
61
69
|
return str.includes('token(');
|
|
62
70
|
})) {
|
|
@@ -74,21 +82,14 @@ var isPropertyValueExempted = function isPropertyValueExempted(propertyValues) {
|
|
|
74
82
|
};
|
|
75
83
|
|
|
76
84
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* 2. Property values must have a format which includes -> e.g. 2, '2(rem|em|px)', auto, initial, inherit, token(...)
|
|
85
|
+
* Checks if the parsed property values are invalid (i.e. rule violation thrown) and autofix required. Cases are when
|
|
86
|
+
* property values must have a format which includes -> e.g. 2, '2(rem|em|px)', auto, initial, inherit, token(...)
|
|
80
87
|
* The rule will return with error and provide a fix
|
|
81
88
|
* @param templateLiteral TemplateLiteral AST Node
|
|
82
89
|
* @param propertyValues property values parsed as list of strings
|
|
83
90
|
* @returns boolean
|
|
84
91
|
*/
|
|
85
|
-
var isPropertyValuesInvalidFix = function isPropertyValuesInvalidFix(
|
|
86
|
-
var expressions = templateLiteral.expressions;
|
|
87
|
-
if (!expressions.every(function (expr) {
|
|
88
|
-
return expr.type === 'CallExpression' && isTokenCallExpression(expr);
|
|
89
|
-
})) {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
+
var isPropertyValuesInvalidFix = function isPropertyValuesInvalidFix(propertyValues) {
|
|
92
93
|
var _iterator = _createForOfIteratorHelper(propertyValues),
|
|
93
94
|
_step;
|
|
94
95
|
try {
|
|
@@ -182,11 +183,11 @@ var executeExpandSpacingRule = function executeExpandSpacingRule(context, node,
|
|
|
182
183
|
}
|
|
183
184
|
if (node.value.type === 'TemplateLiteral') {
|
|
184
185
|
var propertyValues = parseTemplateLiteral(node.value, context);
|
|
185
|
-
if (isPropertyValueExempted(propertyValues)) {
|
|
186
|
+
if (isPropertyValueExempted(node.value, propertyValues)) {
|
|
186
187
|
// Valid, so no error should be thrown
|
|
187
188
|
return;
|
|
188
189
|
}
|
|
189
|
-
if (isPropertyValuesInvalidFix(
|
|
190
|
+
if (isPropertyValuesInvalidFix(propertyValues)) {
|
|
190
191
|
// Invalid, so error should be thrown and fix provided
|
|
191
192
|
context.report({
|
|
192
193
|
node: node,
|
|
@@ -25,7 +25,7 @@ var rule = {
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
create: function create(context) {
|
|
28
|
-
return (0, _defineProperty2.default)({}, "CallExpression[callee.name=/".concat(TEST_RUNNER_IDENTIFIER, "/]"), function
|
|
28
|
+
return (0, _defineProperty2.default)({}, "CallExpression[callee.name=/".concat(TEST_RUNNER_IDENTIFIER, "/]"), function CallExpressionCalleeName__(node) {
|
|
29
29
|
if (node.type === 'CallExpression') {
|
|
30
30
|
var _node$parent, _node$parent2;
|
|
31
31
|
var args = node.arguments;
|
|
@@ -49,7 +49,7 @@ var rule = {
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
create: function create(context) {
|
|
52
|
-
return (0, _defineProperty2.default)({}, "Program > * > CallExpression[callee.name=/".concat(TEST_RUNNER_IDENTIFIER, "/], CallExpression[callee.name=/describe/] > * > * > * > CallExpression[callee.name=/").concat(TEST_RUNNER_IDENTIFIER, "/]"), function
|
|
52
|
+
return (0, _defineProperty2.default)({}, "Program > * > CallExpression[callee.name=/".concat(TEST_RUNNER_IDENTIFIER, "/], CallExpression[callee.name=/describe/] > * > * > * > CallExpression[callee.name=/").concat(TEST_RUNNER_IDENTIFIER, "/]"), function Program____CallExpressionCalleeName___CallExpressionCalleeName_describe_________CallExpressionCalleeName__(node) {
|
|
53
53
|
if (node.type === 'CallExpression') {
|
|
54
54
|
// Calculate the depth of nested test runners, counting from the most outside
|
|
55
55
|
var depth = getDepthOfNestedRunner(node);
|
|
@@ -9,15 +9,15 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
9
9
|
var _utils = require("../utils");
|
|
10
10
|
var FUNCTION_NAMES = new Set(['ff', 'fg', 'expVal', 'expValEquals', 'UNSAFE_noExposureExp']);
|
|
11
11
|
var STATSIG_ONLY_FUNCTION_NAMES = new Set(['fg', 'expVal', 'expValEquals', 'UNSAFE_noExposureExp']);
|
|
12
|
-
var
|
|
13
|
-
return node.type === 'VariableDeclaration' || node.type === 'FunctionDeclaration' ? node :
|
|
12
|
+
var _findDefinitionDeclaration = function findDefinitionDeclaration(node) {
|
|
13
|
+
return node.type === 'VariableDeclaration' || node.type === 'FunctionDeclaration' ? node : _findDefinitionDeclaration(node.parent);
|
|
14
14
|
};
|
|
15
15
|
var validateCallExpression = function validateCallExpression(node, context) {
|
|
16
16
|
var targetedFunctionsSwitch = context.options[0] === 'ssOnly' ? STATSIG_ONLY_FUNCTION_NAMES : FUNCTION_NAMES;
|
|
17
17
|
var callee = node.callee;
|
|
18
18
|
var shouldWarn = callee.type === 'Identifier' && targetedFunctionsSwitch.has(callee.name) && (0, _utils.isAPIimport)(callee.name, context, node);
|
|
19
19
|
if (shouldWarn) {
|
|
20
|
-
var defDeclaration =
|
|
20
|
+
var defDeclaration = _findDefinitionDeclaration(node.parent);
|
|
21
21
|
context.report({
|
|
22
22
|
messageId: 'inlineUsage',
|
|
23
23
|
node: defDeclaration.parent.type === 'ExportNamedDeclaration' ? defDeclaration.parent : defDeclaration
|
|
@@ -74,13 +74,16 @@ var rule = {
|
|
|
74
74
|
description: 'Ensure feature flags/gates and experiments are inlined so that they can be statically analyzable.',
|
|
75
75
|
url: 'https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/browse/platform/packages/platform/eslint-plugin/src/rules/inline-usage/README.md'
|
|
76
76
|
},
|
|
77
|
+
schema: [{
|
|
78
|
+
enum: ['ssOnly']
|
|
79
|
+
}],
|
|
77
80
|
messages: {
|
|
78
81
|
inlineUsage: 'Do not export or wrap feature flags/gates and experiments usages. Inline calls at the callsite to ensure it is statically analyzable.'
|
|
79
82
|
}
|
|
80
83
|
},
|
|
81
84
|
create: function create(context) {
|
|
82
85
|
return {
|
|
83
|
-
'VariableDeclaration[declarations.length=1] > VariableDeclarator[id.type="Identifier"]:matches([init.type="ArrowFunctionExpression"], [init.type="FunctionExpression"]) > *.init': function
|
|
86
|
+
'VariableDeclaration[declarations.length=1] > VariableDeclarator[id.type="Identifier"]:matches([init.type="ArrowFunctionExpression"], [init.type="FunctionExpression"]) > *.init': function VariableDeclarationDeclarationsLength1__VariableDeclaratorIdTypeIdentifierMatchesInitTypeArrowFunctionExpression_InitTypeFunctionExpression__Init(_ref2) {
|
|
84
87
|
var body = _ref2.body;
|
|
85
88
|
validateFunctionBody(body, context);
|
|
86
89
|
},
|
|
@@ -46,7 +46,7 @@ var rule = {
|
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
},
|
|
49
|
-
'VariableDeclaration[kind="const"] > VariableDeclarator[id.type="Identifier"][init.type="Identifier"]': function
|
|
49
|
+
'VariableDeclaration[kind="const"] > VariableDeclarator[id.type="Identifier"][init.type="Identifier"]': function VariableDeclarationKindConst__VariableDeclaratorIdTypeIdentifierInitTypeIdentifier(node) {
|
|
50
50
|
if (!node.init || node.init.type !== 'Identifier') {
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
@@ -11,10 +11,10 @@ var isAndExpression = function isAndExpression(node) {
|
|
|
11
11
|
var isExpUsage = function isExpUsage(calleeName) {
|
|
12
12
|
return calleeName === 'expVal' || calleeName === 'expValEquals';
|
|
13
13
|
};
|
|
14
|
-
var
|
|
14
|
+
var _getGateType = function getGateType(node, context) {
|
|
15
15
|
var type = node.type;
|
|
16
16
|
if (type === 'BinaryExpression') {
|
|
17
|
-
return
|
|
17
|
+
return _getGateType(node.left, context) || _getGateType(node.right, context);
|
|
18
18
|
}
|
|
19
19
|
if (node.type === 'CallExpression') {
|
|
20
20
|
var callee = node.callee;
|
|
@@ -29,9 +29,9 @@ var getPreconditionStatus = function getPreconditionStatus(logicalExpression, co
|
|
|
29
29
|
var _ref = logicalExpression,
|
|
30
30
|
left = _ref.left;
|
|
31
31
|
// If left side is a nested AND expression then the left side node is on the nested's right
|
|
32
|
-
var leftGateType =
|
|
32
|
+
var leftGateType = _getGateType(isAndExpression(left) ? left.right : left, context);
|
|
33
33
|
if (leftGateType) {
|
|
34
|
-
var rightGateType =
|
|
34
|
+
var rightGateType = _getGateType(logicalExpression.right, context);
|
|
35
35
|
// Check this scenario: fg('gate') && isAdmin
|
|
36
36
|
if (!rightGateType) {
|
|
37
37
|
return 'early-exposure';
|
|
@@ -20,7 +20,7 @@ var rule = {
|
|
|
20
20
|
},
|
|
21
21
|
create: function create(context) {
|
|
22
22
|
return {
|
|
23
|
-
'CallExpression > MemberExpression:matches([property.name="checkGate"])': function
|
|
23
|
+
'CallExpression > MemberExpression:matches([property.name="checkGate"])': function CallExpression__MemberExpressionMatchesPropertyNameCheckGate(node) {
|
|
24
24
|
if (node.object.type === 'Identifier' && (0, _utils.isIdentifierImportedFrom)(node.object.name, BANNED_IMPORTS_SET, context, node)) {
|
|
25
25
|
context.report({
|
|
26
26
|
messageId: 'useRecommended',
|
|
@@ -33,7 +33,7 @@ var rule = {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
|
-
'CallExpression > MemberExpression:matches([property.name="getExperimentValue"])': function
|
|
36
|
+
'CallExpression > MemberExpression:matches([property.name="getExperimentValue"])': function CallExpression__MemberExpressionMatchesPropertyNameGetExperimentValue(node) {
|
|
37
37
|
if (node.object.type === 'Identifier' && (0, _utils.isIdentifierImportedFrom)(node.object.name, BANNED_IMPORTS_SET, context, node)) {
|
|
38
38
|
context.report({
|
|
39
39
|
messageId: 'notSupported',
|
|
@@ -27,11 +27,11 @@ var rule = {
|
|
|
27
27
|
var dependencies = new Map();
|
|
28
28
|
var devDependencies = new Map();
|
|
29
29
|
return {
|
|
30
|
-
'ObjectExpression Property[key.value=dependencies] Property': function
|
|
30
|
+
'ObjectExpression Property[key.value=dependencies] Property': function ObjectExpression_PropertyKeyValueDependencies_Property(node) {
|
|
31
31
|
// @ts-expect-error
|
|
32
32
|
dependencies.set(node.key.value, node.key);
|
|
33
33
|
},
|
|
34
|
-
'ObjectExpression Property[key.value=devDependencies] Property': function
|
|
34
|
+
'ObjectExpression Property[key.value=devDependencies] Property': function ObjectExpression_PropertyKeyValueDevDependencies_Property(node) {
|
|
35
35
|
// @ts-expect-error
|
|
36
36
|
devDependencies.set(node.key.value, node.key);
|
|
37
37
|
},
|
|
@@ -9,12 +9,12 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
10
10
|
|
|
11
11
|
var FF_GETTER_BOOLEAN_IDENTIFIER = 'getBooleanFF';
|
|
12
|
-
var
|
|
12
|
+
var _isOnlyOneFlagCheckInExpression = function __isOnlyOneFlagCheckInExpression(root, ignoredNode) {
|
|
13
13
|
switch (root.type) {
|
|
14
14
|
case 'IfStatement':
|
|
15
|
-
return
|
|
15
|
+
return _isOnlyOneFlagCheckInExpression(root.test, ignoredNode);
|
|
16
16
|
case 'UnaryExpression':
|
|
17
|
-
return
|
|
17
|
+
return _isOnlyOneFlagCheckInExpression(root.argument, ignoredNode);
|
|
18
18
|
case 'CallExpression':
|
|
19
19
|
if (root === ignoredNode) {
|
|
20
20
|
return true;
|
|
@@ -26,7 +26,7 @@ var __isOnlyOneFlagCheckInExpression = function __isOnlyOneFlagCheckInExpression
|
|
|
26
26
|
return root.name !== FF_GETTER_BOOLEAN_IDENTIFIER;
|
|
27
27
|
case 'BinaryExpression':
|
|
28
28
|
case 'LogicalExpression':
|
|
29
|
-
return
|
|
29
|
+
return _isOnlyOneFlagCheckInExpression(root.left, ignoredNode) && _isOnlyOneFlagCheckInExpression(root.right, ignoredNode);
|
|
30
30
|
default:
|
|
31
31
|
return true;
|
|
32
32
|
}
|
|
@@ -38,7 +38,7 @@ var isOnlyOneFlagCheckInExpression = function isOnlyOneFlagCheckInExpression(nod
|
|
|
38
38
|
while (root.type.endsWith('Expression')) {
|
|
39
39
|
root = root.parent;
|
|
40
40
|
}
|
|
41
|
-
return
|
|
41
|
+
return _isOnlyOneFlagCheckInExpression(root, node);
|
|
42
42
|
};
|
|
43
43
|
var rule = {
|
|
44
44
|
meta: {
|
|
@@ -55,7 +55,7 @@ var rule = {
|
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
create: function create(context) {
|
|
58
|
-
return (0, _defineProperty2.default)({}, "CallExpression[callee.name=/".concat(FF_GETTER_BOOLEAN_IDENTIFIER, "/]"), function
|
|
58
|
+
return (0, _defineProperty2.default)({}, "CallExpression[callee.name=/".concat(FF_GETTER_BOOLEAN_IDENTIFIER, "/]"), function CallExpressionCalleeName__(node) {
|
|
59
59
|
var _node$parent2;
|
|
60
60
|
// to make typescript happy
|
|
61
61
|
if (node.type === 'CallExpression') {
|
|
@@ -21,7 +21,7 @@ var rule = {
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
create: function create(context) {
|
|
24
|
-
return (0, _defineProperty2.default)({}, "CallExpression[callee.name=/".concat(STORYBOOK_DECORATOR_IDENTIFIER, "/]"), function
|
|
24
|
+
return (0, _defineProperty2.default)({}, "CallExpression[callee.name=/".concat(STORYBOOK_DECORATOR_IDENTIFIER, "/]"), function CallExpressionCalleeName__(node) {
|
|
25
25
|
// to make typescript happy
|
|
26
26
|
if (node.type === 'CallExpression') {
|
|
27
27
|
var args = node.arguments;
|
|
@@ -20,7 +20,7 @@ var rule = {
|
|
|
20
20
|
},
|
|
21
21
|
create: function create(context) {
|
|
22
22
|
return {
|
|
23
|
-
'ObjectExpression Property[key.value=scripts] Property[key.value=/^(pre|post)install$/]': function
|
|
23
|
+
'ObjectExpression Property[key.value=scripts] Property[key.value=/^(pre|post)install$/]': function ObjectExpression_PropertyKeyValueScripts_PropertyKeyValue_PrePostInstall$_(node) {
|
|
24
24
|
if (!context.getFilename().endsWith('/package.json')) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
package/dist/es2019/index.js
CHANGED
|
@@ -65,7 +65,7 @@ const commonConfig = {
|
|
|
65
65
|
// Compiled: rules that are not included via `@compiled/recommended
|
|
66
66
|
'@atlaskit/platform/expand-border-shorthand': 'error',
|
|
67
67
|
'@atlaskit/platform/expand-background-shorthand': 'error',
|
|
68
|
-
'@atlaskit/platform/expand-spacing-shorthand': '
|
|
68
|
+
'@atlaskit/platform/expand-spacing-shorthand': 'error',
|
|
69
69
|
'@compiled/jsx-pragma': ['error', {
|
|
70
70
|
importSources: ['@atlaskit/css'],
|
|
71
71
|
onlyRunIfImportingCompiled: true,
|
|
@@ -37,15 +37,21 @@ const parseTemplateLiteral = (templateLiteral, context) => {
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* Checks if the parsed property values are valid
|
|
41
|
-
* 1.
|
|
42
|
-
* 2.
|
|
43
|
-
* 3.
|
|
40
|
+
* Checks if the parsed property values are valid; values that we shouldn't handle with the fixer:
|
|
41
|
+
* 1. At least one expression in TemplateLiteral is not a token expression
|
|
42
|
+
* 2. Do not contain a token
|
|
43
|
+
* 3. Have length that are not in the range [1, 4] for different spacing directions
|
|
44
|
+
* - No more than 4 to exclude additional values such as `!important`
|
|
45
|
+
* 4. Includes `calc(...)`
|
|
44
46
|
* Then, the rule will return with no error
|
|
45
47
|
* @param propertyValues property values parsed as list of strings
|
|
46
48
|
* @returns boolean
|
|
47
49
|
*/
|
|
48
|
-
const isPropertyValueExempted = propertyValues => {
|
|
50
|
+
const isPropertyValueExempted = (templateLiteral, propertyValues) => {
|
|
51
|
+
const expressions = templateLiteral.expressions;
|
|
52
|
+
if (!expressions.every(expr => expr.type === 'CallExpression' && isTokenCallExpression(expr))) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
49
55
|
if (!propertyValues.some(str => str.includes('token('))) {
|
|
50
56
|
return true;
|
|
51
57
|
}
|
|
@@ -59,19 +65,14 @@ const isPropertyValueExempted = propertyValues => {
|
|
|
59
65
|
};
|
|
60
66
|
|
|
61
67
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* 2. Property values must have a format which includes -> e.g. 2, '2(rem|em|px)', auto, initial, inherit, token(...)
|
|
68
|
+
* Checks if the parsed property values are invalid (i.e. rule violation thrown) and autofix required. Cases are when
|
|
69
|
+
* property values must have a format which includes -> e.g. 2, '2(rem|em|px)', auto, initial, inherit, token(...)
|
|
65
70
|
* The rule will return with error and provide a fix
|
|
66
71
|
* @param templateLiteral TemplateLiteral AST Node
|
|
67
72
|
* @param propertyValues property values parsed as list of strings
|
|
68
73
|
* @returns boolean
|
|
69
74
|
*/
|
|
70
|
-
const isPropertyValuesInvalidFix =
|
|
71
|
-
const expressions = templateLiteral.expressions;
|
|
72
|
-
if (!expressions.every(expr => expr.type === 'CallExpression' && isTokenCallExpression(expr))) {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
+
const isPropertyValuesInvalidFix = propertyValues => {
|
|
75
76
|
for (const propValue of propertyValues) {
|
|
76
77
|
if (propValue === '0') {
|
|
77
78
|
continue;
|
|
@@ -139,11 +140,11 @@ const executeExpandSpacingRule = (context, node, propertyShorthand) => {
|
|
|
139
140
|
}
|
|
140
141
|
if (node.value.type === 'TemplateLiteral') {
|
|
141
142
|
const propertyValues = parseTemplateLiteral(node.value, context);
|
|
142
|
-
if (isPropertyValueExempted(propertyValues)) {
|
|
143
|
+
if (isPropertyValueExempted(node.value, propertyValues)) {
|
|
143
144
|
// Valid, so no error should be thrown
|
|
144
145
|
return;
|
|
145
146
|
}
|
|
146
|
-
if (isPropertyValuesInvalidFix(
|
|
147
|
+
if (isPropertyValuesInvalidFix(propertyValues)) {
|
|
147
148
|
// Invalid, so error should be thrown and fix provided
|
|
148
149
|
context.report({
|
|
149
150
|
node,
|
|
@@ -68,6 +68,9 @@ const rule = {
|
|
|
68
68
|
description: 'Ensure feature flags/gates and experiments are inlined so that they can be statically analyzable.',
|
|
69
69
|
url: 'https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/browse/platform/packages/platform/eslint-plugin/src/rules/inline-usage/README.md'
|
|
70
70
|
},
|
|
71
|
+
schema: [{
|
|
72
|
+
enum: ['ssOnly']
|
|
73
|
+
}],
|
|
71
74
|
messages: {
|
|
72
75
|
inlineUsage: 'Do not export or wrap feature flags/gates and experiments usages. Inline calls at the callsite to ensure it is statically analyzable.'
|
|
73
76
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -68,7 +68,7 @@ var commonConfig = {
|
|
|
68
68
|
// Compiled: rules that are not included via `@compiled/recommended
|
|
69
69
|
'@atlaskit/platform/expand-border-shorthand': 'error',
|
|
70
70
|
'@atlaskit/platform/expand-background-shorthand': 'error',
|
|
71
|
-
'@atlaskit/platform/expand-spacing-shorthand': '
|
|
71
|
+
'@atlaskit/platform/expand-spacing-shorthand': 'error',
|
|
72
72
|
'@compiled/jsx-pragma': ['error', {
|
|
73
73
|
importSources: ['@atlaskit/css'],
|
|
74
74
|
onlyRunIfImportingCompiled: true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var EXCLUDED_VALUES = ['0', 'none', 'unset', 'none !important'];
|
|
2
|
-
var
|
|
2
|
+
var _findCallExpression = function findCallExpression(node) {
|
|
3
3
|
var parent = node.parent;
|
|
4
4
|
if (!parent) {
|
|
5
5
|
return null;
|
|
@@ -7,7 +7,7 @@ var findCallExpression = function findCallExpression(node) {
|
|
|
7
7
|
if (parent.type === 'CallExpression') {
|
|
8
8
|
return parent;
|
|
9
9
|
}
|
|
10
|
-
return
|
|
10
|
+
return _findCallExpression(parent);
|
|
11
11
|
};
|
|
12
12
|
var separateBorderProperties = function separateBorderProperties(borderString, property, context) {
|
|
13
13
|
if (EXCLUDED_VALUES.includes(borderString)) {
|
|
@@ -52,11 +52,11 @@ export var expandBorderShorthand = {
|
|
|
52
52
|
create: function create(context) {
|
|
53
53
|
var importDeclaration;
|
|
54
54
|
return {
|
|
55
|
-
'ImportDeclaration[source.value="@compiled/react"], ImportDeclaration[source.value="@atlaskit/css"]': function
|
|
55
|
+
'ImportDeclaration[source.value="@compiled/react"], ImportDeclaration[source.value="@atlaskit/css"]': function ImportDeclarationSourceValueCompiled_react_ImportDeclarationSourceValueAtlaskit_css(node) {
|
|
56
56
|
importDeclaration = node;
|
|
57
57
|
},
|
|
58
58
|
'Property[key.name="border"]': function PropertyKeyNameBorder(node) {
|
|
59
|
-
var callExpression =
|
|
59
|
+
var callExpression = _findCallExpression(node);
|
|
60
60
|
if (!callExpression) {
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
@@ -41,15 +41,23 @@ var parseTemplateLiteral = function parseTemplateLiteral(templateLiteral, contex
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* Checks if the parsed property values are valid
|
|
45
|
-
* 1.
|
|
46
|
-
* 2.
|
|
47
|
-
* 3.
|
|
44
|
+
* Checks if the parsed property values are valid; values that we shouldn't handle with the fixer:
|
|
45
|
+
* 1. At least one expression in TemplateLiteral is not a token expression
|
|
46
|
+
* 2. Do not contain a token
|
|
47
|
+
* 3. Have length that are not in the range [1, 4] for different spacing directions
|
|
48
|
+
* - No more than 4 to exclude additional values such as `!important`
|
|
49
|
+
* 4. Includes `calc(...)`
|
|
48
50
|
* Then, the rule will return with no error
|
|
49
51
|
* @param propertyValues property values parsed as list of strings
|
|
50
52
|
* @returns boolean
|
|
51
53
|
*/
|
|
52
|
-
var isPropertyValueExempted = function isPropertyValueExempted(propertyValues) {
|
|
54
|
+
var isPropertyValueExempted = function isPropertyValueExempted(templateLiteral, propertyValues) {
|
|
55
|
+
var expressions = templateLiteral.expressions;
|
|
56
|
+
if (!expressions.every(function (expr) {
|
|
57
|
+
return expr.type === 'CallExpression' && isTokenCallExpression(expr);
|
|
58
|
+
})) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
53
61
|
if (!propertyValues.some(function (str) {
|
|
54
62
|
return str.includes('token(');
|
|
55
63
|
})) {
|
|
@@ -67,21 +75,14 @@ var isPropertyValueExempted = function isPropertyValueExempted(propertyValues) {
|
|
|
67
75
|
};
|
|
68
76
|
|
|
69
77
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* 2. Property values must have a format which includes -> e.g. 2, '2(rem|em|px)', auto, initial, inherit, token(...)
|
|
78
|
+
* Checks if the parsed property values are invalid (i.e. rule violation thrown) and autofix required. Cases are when
|
|
79
|
+
* property values must have a format which includes -> e.g. 2, '2(rem|em|px)', auto, initial, inherit, token(...)
|
|
73
80
|
* The rule will return with error and provide a fix
|
|
74
81
|
* @param templateLiteral TemplateLiteral AST Node
|
|
75
82
|
* @param propertyValues property values parsed as list of strings
|
|
76
83
|
* @returns boolean
|
|
77
84
|
*/
|
|
78
|
-
var isPropertyValuesInvalidFix = function isPropertyValuesInvalidFix(
|
|
79
|
-
var expressions = templateLiteral.expressions;
|
|
80
|
-
if (!expressions.every(function (expr) {
|
|
81
|
-
return expr.type === 'CallExpression' && isTokenCallExpression(expr);
|
|
82
|
-
})) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
+
var isPropertyValuesInvalidFix = function isPropertyValuesInvalidFix(propertyValues) {
|
|
85
86
|
var _iterator = _createForOfIteratorHelper(propertyValues),
|
|
86
87
|
_step;
|
|
87
88
|
try {
|
|
@@ -175,11 +176,11 @@ var executeExpandSpacingRule = function executeExpandSpacingRule(context, node,
|
|
|
175
176
|
}
|
|
176
177
|
if (node.value.type === 'TemplateLiteral') {
|
|
177
178
|
var propertyValues = parseTemplateLiteral(node.value, context);
|
|
178
|
-
if (isPropertyValueExempted(propertyValues)) {
|
|
179
|
+
if (isPropertyValueExempted(node.value, propertyValues)) {
|
|
179
180
|
// Valid, so no error should be thrown
|
|
180
181
|
return;
|
|
181
182
|
}
|
|
182
|
-
if (isPropertyValuesInvalidFix(
|
|
183
|
+
if (isPropertyValuesInvalidFix(propertyValues)) {
|
|
183
184
|
// Invalid, so error should be thrown and fix provided
|
|
184
185
|
context.report({
|
|
185
186
|
node: node,
|
|
@@ -18,7 +18,7 @@ var rule = {
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
create: function create(context) {
|
|
21
|
-
return _defineProperty({}, "CallExpression[callee.name=/".concat(TEST_RUNNER_IDENTIFIER, "/]"), function
|
|
21
|
+
return _defineProperty({}, "CallExpression[callee.name=/".concat(TEST_RUNNER_IDENTIFIER, "/]"), function CallExpressionCalleeName__(node) {
|
|
22
22
|
if (node.type === 'CallExpression') {
|
|
23
23
|
var _node$parent, _node$parent2;
|
|
24
24
|
var args = node.arguments;
|
|
@@ -42,7 +42,7 @@ var rule = {
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
create: function create(context) {
|
|
45
|
-
return _defineProperty({}, "Program > * > CallExpression[callee.name=/".concat(TEST_RUNNER_IDENTIFIER, "/], CallExpression[callee.name=/describe/] > * > * > * > CallExpression[callee.name=/").concat(TEST_RUNNER_IDENTIFIER, "/]"), function
|
|
45
|
+
return _defineProperty({}, "Program > * > CallExpression[callee.name=/".concat(TEST_RUNNER_IDENTIFIER, "/], CallExpression[callee.name=/describe/] > * > * > * > CallExpression[callee.name=/").concat(TEST_RUNNER_IDENTIFIER, "/]"), function Program____CallExpressionCalleeName___CallExpressionCalleeName_describe_________CallExpressionCalleeName__(node) {
|
|
46
46
|
if (node.type === 'CallExpression') {
|
|
47
47
|
// Calculate the depth of nested test runners, counting from the most outside
|
|
48
48
|
var depth = getDepthOfNestedRunner(node);
|
|
@@ -2,15 +2,15 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
2
2
|
import { isAPIimport } from '../utils';
|
|
3
3
|
var FUNCTION_NAMES = new Set(['ff', 'fg', 'expVal', 'expValEquals', 'UNSAFE_noExposureExp']);
|
|
4
4
|
var STATSIG_ONLY_FUNCTION_NAMES = new Set(['fg', 'expVal', 'expValEquals', 'UNSAFE_noExposureExp']);
|
|
5
|
-
var
|
|
6
|
-
return node.type === 'VariableDeclaration' || node.type === 'FunctionDeclaration' ? node :
|
|
5
|
+
var _findDefinitionDeclaration = function findDefinitionDeclaration(node) {
|
|
6
|
+
return node.type === 'VariableDeclaration' || node.type === 'FunctionDeclaration' ? node : _findDefinitionDeclaration(node.parent);
|
|
7
7
|
};
|
|
8
8
|
var validateCallExpression = function validateCallExpression(node, context) {
|
|
9
9
|
var targetedFunctionsSwitch = context.options[0] === 'ssOnly' ? STATSIG_ONLY_FUNCTION_NAMES : FUNCTION_NAMES;
|
|
10
10
|
var callee = node.callee;
|
|
11
11
|
var shouldWarn = callee.type === 'Identifier' && targetedFunctionsSwitch.has(callee.name) && isAPIimport(callee.name, context, node);
|
|
12
12
|
if (shouldWarn) {
|
|
13
|
-
var defDeclaration =
|
|
13
|
+
var defDeclaration = _findDefinitionDeclaration(node.parent);
|
|
14
14
|
context.report({
|
|
15
15
|
messageId: 'inlineUsage',
|
|
16
16
|
node: defDeclaration.parent.type === 'ExportNamedDeclaration' ? defDeclaration.parent : defDeclaration
|
|
@@ -67,13 +67,16 @@ var rule = {
|
|
|
67
67
|
description: 'Ensure feature flags/gates and experiments are inlined so that they can be statically analyzable.',
|
|
68
68
|
url: 'https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/browse/platform/packages/platform/eslint-plugin/src/rules/inline-usage/README.md'
|
|
69
69
|
},
|
|
70
|
+
schema: [{
|
|
71
|
+
enum: ['ssOnly']
|
|
72
|
+
}],
|
|
70
73
|
messages: {
|
|
71
74
|
inlineUsage: 'Do not export or wrap feature flags/gates and experiments usages. Inline calls at the callsite to ensure it is statically analyzable.'
|
|
72
75
|
}
|
|
73
76
|
},
|
|
74
77
|
create: function create(context) {
|
|
75
78
|
return {
|
|
76
|
-
'VariableDeclaration[declarations.length=1] > VariableDeclarator[id.type="Identifier"]:matches([init.type="ArrowFunctionExpression"], [init.type="FunctionExpression"]) > *.init': function
|
|
79
|
+
'VariableDeclaration[declarations.length=1] > VariableDeclarator[id.type="Identifier"]:matches([init.type="ArrowFunctionExpression"], [init.type="FunctionExpression"]) > *.init': function VariableDeclarationDeclarationsLength1__VariableDeclaratorIdTypeIdentifierMatchesInitTypeArrowFunctionExpression_InitTypeFunctionExpression__Init(_ref2) {
|
|
77
80
|
var body = _ref2.body;
|
|
78
81
|
validateFunctionBody(body, context);
|
|
79
82
|
},
|
|
@@ -39,7 +39,7 @@ var rule = {
|
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
},
|
|
42
|
-
'VariableDeclaration[kind="const"] > VariableDeclarator[id.type="Identifier"][init.type="Identifier"]': function
|
|
42
|
+
'VariableDeclaration[kind="const"] > VariableDeclarator[id.type="Identifier"][init.type="Identifier"]': function VariableDeclarationKindConst__VariableDeclaratorIdTypeIdentifierInitTypeIdentifier(node) {
|
|
43
43
|
if (!node.init || node.init.type !== 'Identifier') {
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
@@ -5,10 +5,10 @@ var isAndExpression = function isAndExpression(node) {
|
|
|
5
5
|
var isExpUsage = function isExpUsage(calleeName) {
|
|
6
6
|
return calleeName === 'expVal' || calleeName === 'expValEquals';
|
|
7
7
|
};
|
|
8
|
-
var
|
|
8
|
+
var _getGateType = function getGateType(node, context) {
|
|
9
9
|
var type = node.type;
|
|
10
10
|
if (type === 'BinaryExpression') {
|
|
11
|
-
return
|
|
11
|
+
return _getGateType(node.left, context) || _getGateType(node.right, context);
|
|
12
12
|
}
|
|
13
13
|
if (node.type === 'CallExpression') {
|
|
14
14
|
var callee = node.callee;
|
|
@@ -23,9 +23,9 @@ var getPreconditionStatus = function getPreconditionStatus(logicalExpression, co
|
|
|
23
23
|
var _ref = logicalExpression,
|
|
24
24
|
left = _ref.left;
|
|
25
25
|
// If left side is a nested AND expression then the left side node is on the nested's right
|
|
26
|
-
var leftGateType =
|
|
26
|
+
var leftGateType = _getGateType(isAndExpression(left) ? left.right : left, context);
|
|
27
27
|
if (leftGateType) {
|
|
28
|
-
var rightGateType =
|
|
28
|
+
var rightGateType = _getGateType(logicalExpression.right, context);
|
|
29
29
|
// Check this scenario: fg('gate') && isAdmin
|
|
30
30
|
if (!rightGateType) {
|
|
31
31
|
return 'early-exposure';
|
|
@@ -14,7 +14,7 @@ var rule = {
|
|
|
14
14
|
},
|
|
15
15
|
create: function create(context) {
|
|
16
16
|
return {
|
|
17
|
-
'CallExpression > MemberExpression:matches([property.name="checkGate"])': function
|
|
17
|
+
'CallExpression > MemberExpression:matches([property.name="checkGate"])': function CallExpression__MemberExpressionMatchesPropertyNameCheckGate(node) {
|
|
18
18
|
if (node.object.type === 'Identifier' && isIdentifierImportedFrom(node.object.name, BANNED_IMPORTS_SET, context, node)) {
|
|
19
19
|
context.report({
|
|
20
20
|
messageId: 'useRecommended',
|
|
@@ -27,7 +27,7 @@ var rule = {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
-
'CallExpression > MemberExpression:matches([property.name="getExperimentValue"])': function
|
|
30
|
+
'CallExpression > MemberExpression:matches([property.name="getExperimentValue"])': function CallExpression__MemberExpressionMatchesPropertyNameGetExperimentValue(node) {
|
|
31
31
|
if (node.object.type === 'Identifier' && isIdentifierImportedFrom(node.object.name, BANNED_IMPORTS_SET, context, node)) {
|
|
32
32
|
context.report({
|
|
33
33
|
messageId: 'notSupported',
|
|
@@ -20,11 +20,11 @@ var rule = {
|
|
|
20
20
|
var dependencies = new Map();
|
|
21
21
|
var devDependencies = new Map();
|
|
22
22
|
return {
|
|
23
|
-
'ObjectExpression Property[key.value=dependencies] Property': function
|
|
23
|
+
'ObjectExpression Property[key.value=dependencies] Property': function ObjectExpression_PropertyKeyValueDependencies_Property(node) {
|
|
24
24
|
// @ts-expect-error
|
|
25
25
|
dependencies.set(node.key.value, node.key);
|
|
26
26
|
},
|
|
27
|
-
'ObjectExpression Property[key.value=devDependencies] Property': function
|
|
27
|
+
'ObjectExpression Property[key.value=devDependencies] Property': function ObjectExpression_PropertyKeyValueDevDependencies_Property(node) {
|
|
28
28
|
// @ts-expect-error
|
|
29
29
|
devDependencies.set(node.key.value, node.key);
|
|
30
30
|
},
|
|
@@ -2,12 +2,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
3
|
|
|
4
4
|
var FF_GETTER_BOOLEAN_IDENTIFIER = 'getBooleanFF';
|
|
5
|
-
var
|
|
5
|
+
var _isOnlyOneFlagCheckInExpression = function __isOnlyOneFlagCheckInExpression(root, ignoredNode) {
|
|
6
6
|
switch (root.type) {
|
|
7
7
|
case 'IfStatement':
|
|
8
|
-
return
|
|
8
|
+
return _isOnlyOneFlagCheckInExpression(root.test, ignoredNode);
|
|
9
9
|
case 'UnaryExpression':
|
|
10
|
-
return
|
|
10
|
+
return _isOnlyOneFlagCheckInExpression(root.argument, ignoredNode);
|
|
11
11
|
case 'CallExpression':
|
|
12
12
|
if (root === ignoredNode) {
|
|
13
13
|
return true;
|
|
@@ -19,7 +19,7 @@ var __isOnlyOneFlagCheckInExpression = function __isOnlyOneFlagCheckInExpression
|
|
|
19
19
|
return root.name !== FF_GETTER_BOOLEAN_IDENTIFIER;
|
|
20
20
|
case 'BinaryExpression':
|
|
21
21
|
case 'LogicalExpression':
|
|
22
|
-
return
|
|
22
|
+
return _isOnlyOneFlagCheckInExpression(root.left, ignoredNode) && _isOnlyOneFlagCheckInExpression(root.right, ignoredNode);
|
|
23
23
|
default:
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
@@ -31,7 +31,7 @@ var isOnlyOneFlagCheckInExpression = function isOnlyOneFlagCheckInExpression(nod
|
|
|
31
31
|
while (root.type.endsWith('Expression')) {
|
|
32
32
|
root = root.parent;
|
|
33
33
|
}
|
|
34
|
-
return
|
|
34
|
+
return _isOnlyOneFlagCheckInExpression(root, node);
|
|
35
35
|
};
|
|
36
36
|
var rule = {
|
|
37
37
|
meta: {
|
|
@@ -48,7 +48,7 @@ var rule = {
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
create: function create(context) {
|
|
51
|
-
return _defineProperty({}, "CallExpression[callee.name=/".concat(FF_GETTER_BOOLEAN_IDENTIFIER, "/]"), function
|
|
51
|
+
return _defineProperty({}, "CallExpression[callee.name=/".concat(FF_GETTER_BOOLEAN_IDENTIFIER, "/]"), function CallExpressionCalleeName__(node) {
|
|
52
52
|
var _node$parent2;
|
|
53
53
|
// to make typescript happy
|
|
54
54
|
if (node.type === 'CallExpression') {
|
|
@@ -14,7 +14,7 @@ var rule = {
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
create: function create(context) {
|
|
17
|
-
return _defineProperty({}, "CallExpression[callee.name=/".concat(STORYBOOK_DECORATOR_IDENTIFIER, "/]"), function
|
|
17
|
+
return _defineProperty({}, "CallExpression[callee.name=/".concat(STORYBOOK_DECORATOR_IDENTIFIER, "/]"), function CallExpressionCalleeName__(node) {
|
|
18
18
|
// to make typescript happy
|
|
19
19
|
if (node.type === 'CallExpression') {
|
|
20
20
|
var args = node.arguments;
|
|
@@ -14,7 +14,7 @@ var rule = {
|
|
|
14
14
|
},
|
|
15
15
|
create: function create(context) {
|
|
16
16
|
return {
|
|
17
|
-
'ObjectExpression Property[key.value=scripts] Property[key.value=/^(pre|post)install$/]': function
|
|
17
|
+
'ObjectExpression Property[key.value=scripts] Property[key.value=/^(pre|post)install$/]': function ObjectExpression_PropertyKeyValueScripts_PropertyKeyValue_PrePostInstall$_(node) {
|
|
18
18
|
if (!context.getFilename().endsWith('/package.json')) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -82,7 +82,7 @@ declare const plugin: {
|
|
|
82
82
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
83
83
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
84
84
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
85
|
-
'@atlaskit/platform/expand-spacing-shorthand': "
|
|
85
|
+
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
86
86
|
'@compiled/jsx-pragma': ["error", {
|
|
87
87
|
importSources: string[];
|
|
88
88
|
onlyRunIfImportingCompiled: boolean;
|
|
@@ -114,7 +114,7 @@ declare const plugin: {
|
|
|
114
114
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
115
115
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
116
116
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
117
|
-
'@atlaskit/platform/expand-spacing-shorthand': "
|
|
117
|
+
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
118
118
|
'@compiled/jsx-pragma': ["error", {
|
|
119
119
|
importSources: string[];
|
|
120
120
|
onlyRunIfImportingCompiled: boolean;
|
|
@@ -133,7 +133,7 @@ declare const plugin: {
|
|
|
133
133
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
134
134
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
135
135
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
136
|
-
'@atlaskit/platform/expand-spacing-shorthand': "
|
|
136
|
+
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
137
137
|
'@compiled/jsx-pragma': ["error", {
|
|
138
138
|
importSources: string[];
|
|
139
139
|
onlyRunIfImportingCompiled: boolean;
|
|
@@ -155,7 +155,7 @@ declare const plugin: {
|
|
|
155
155
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
156
156
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
157
157
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
158
|
-
'@atlaskit/platform/expand-spacing-shorthand': "
|
|
158
|
+
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
159
159
|
'@compiled/jsx-pragma': ["error", {
|
|
160
160
|
importSources: string[];
|
|
161
161
|
onlyRunIfImportingCompiled: boolean;
|
|
@@ -191,7 +191,7 @@ declare const configs: {
|
|
|
191
191
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
192
192
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
193
193
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
194
|
-
'@atlaskit/platform/expand-spacing-shorthand': "
|
|
194
|
+
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
195
195
|
'@compiled/jsx-pragma': ["error", {
|
|
196
196
|
importSources: string[];
|
|
197
197
|
onlyRunIfImportingCompiled: boolean;
|
|
@@ -223,7 +223,7 @@ declare const configs: {
|
|
|
223
223
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
224
224
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
225
225
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
226
|
-
'@atlaskit/platform/expand-spacing-shorthand': "
|
|
226
|
+
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
227
227
|
'@compiled/jsx-pragma': ["error", {
|
|
228
228
|
importSources: string[];
|
|
229
229
|
onlyRunIfImportingCompiled: boolean;
|
|
@@ -242,7 +242,7 @@ declare const configs: {
|
|
|
242
242
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
243
243
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
244
244
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
245
|
-
'@atlaskit/platform/expand-spacing-shorthand': "
|
|
245
|
+
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
246
246
|
'@compiled/jsx-pragma': ["error", {
|
|
247
247
|
importSources: string[];
|
|
248
248
|
onlyRunIfImportingCompiled: boolean;
|
|
@@ -264,7 +264,7 @@ declare const configs: {
|
|
|
264
264
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
265
265
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
266
266
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
267
|
-
'@atlaskit/platform/expand-spacing-shorthand': "
|
|
267
|
+
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
268
268
|
'@compiled/jsx-pragma': ["error", {
|
|
269
269
|
importSources: string[];
|
|
270
270
|
onlyRunIfImportingCompiled: boolean;
|
|
@@ -85,7 +85,7 @@ declare const plugin: {
|
|
|
85
85
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
86
86
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
87
87
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
88
|
-
'@atlaskit/platform/expand-spacing-shorthand': "
|
|
88
|
+
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
89
89
|
'@compiled/jsx-pragma': [
|
|
90
90
|
"error",
|
|
91
91
|
{
|
|
@@ -123,7 +123,7 @@ declare const plugin: {
|
|
|
123
123
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
124
124
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
125
125
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
126
|
-
'@atlaskit/platform/expand-spacing-shorthand': "
|
|
126
|
+
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
127
127
|
'@compiled/jsx-pragma': [
|
|
128
128
|
"error",
|
|
129
129
|
{
|
|
@@ -145,7 +145,7 @@ declare const plugin: {
|
|
|
145
145
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
146
146
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
147
147
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
148
|
-
'@atlaskit/platform/expand-spacing-shorthand': "
|
|
148
|
+
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
149
149
|
'@compiled/jsx-pragma': [
|
|
150
150
|
"error",
|
|
151
151
|
{
|
|
@@ -170,7 +170,7 @@ declare const plugin: {
|
|
|
170
170
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
171
171
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
172
172
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
173
|
-
'@atlaskit/platform/expand-spacing-shorthand': "
|
|
173
|
+
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
174
174
|
'@compiled/jsx-pragma': [
|
|
175
175
|
"error",
|
|
176
176
|
{
|
|
@@ -212,7 +212,7 @@ declare const configs: {
|
|
|
212
212
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
213
213
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
214
214
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
215
|
-
'@atlaskit/platform/expand-spacing-shorthand': "
|
|
215
|
+
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
216
216
|
'@compiled/jsx-pragma': [
|
|
217
217
|
"error",
|
|
218
218
|
{
|
|
@@ -250,7 +250,7 @@ declare const configs: {
|
|
|
250
250
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
251
251
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
252
252
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
253
|
-
'@atlaskit/platform/expand-spacing-shorthand': "
|
|
253
|
+
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
254
254
|
'@compiled/jsx-pragma': [
|
|
255
255
|
"error",
|
|
256
256
|
{
|
|
@@ -272,7 +272,7 @@ declare const configs: {
|
|
|
272
272
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
273
273
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
274
274
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
275
|
-
'@atlaskit/platform/expand-spacing-shorthand': "
|
|
275
|
+
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
276
276
|
'@compiled/jsx-pragma': [
|
|
277
277
|
"error",
|
|
278
278
|
{
|
|
@@ -297,7 +297,7 @@ declare const configs: {
|
|
|
297
297
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
298
298
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
299
299
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
300
|
-
'@atlaskit/platform/expand-spacing-shorthand': "
|
|
300
|
+
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
301
301
|
'@compiled/jsx-pragma': [
|
|
302
302
|
"error",
|
|
303
303
|
{
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/eslint-plugin-platform",
|
|
3
3
|
"description": "The essential plugin for use with Atlassian frontend platform tools",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.4.0",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"atlassian": {
|
|
7
7
|
"team": "Build Infra",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
".": "./src/index.tsx"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/eslint-utils": "^1.
|
|
34
|
+
"@atlaskit/eslint-utils": "^1.10.0",
|
|
35
35
|
"@babel/runtime": "^7.0.0",
|
|
36
36
|
"@compiled/eslint-plugin": "^0.18.2",
|
|
37
37
|
"@manypkg/find-root": "^1.1.0",
|
package/src/index.tsx
CHANGED
|
@@ -73,7 +73,7 @@ const commonConfig = {
|
|
|
73
73
|
// Compiled: rules that are not included via `@compiled/recommended
|
|
74
74
|
'@atlaskit/platform/expand-border-shorthand': 'error',
|
|
75
75
|
'@atlaskit/platform/expand-background-shorthand': 'error',
|
|
76
|
-
'@atlaskit/platform/expand-spacing-shorthand': '
|
|
76
|
+
'@atlaskit/platform/expand-spacing-shorthand': 'error',
|
|
77
77
|
'@compiled/jsx-pragma': [
|
|
78
78
|
'error',
|
|
79
79
|
{
|
|
@@ -79,6 +79,28 @@ const validTestCases = (property: string) => {
|
|
|
79
79
|
});
|
|
80
80
|
`,
|
|
81
81
|
},
|
|
82
|
+
// Template literal containing expressions that is not token should only throw error with no autofix
|
|
83
|
+
{
|
|
84
|
+
name: `${property}: property value template string where it contains an expression that is not a token`,
|
|
85
|
+
code: outdent`
|
|
86
|
+
import {css} from '@compiled/react';
|
|
87
|
+
const styles = css({
|
|
88
|
+
${property}: \`\${token('space.100', '8px')} \${gridSize * 2}px\`,
|
|
89
|
+
});
|
|
90
|
+
const styles2 = css({
|
|
91
|
+
padding: \`\${DROPDOWN_HEADER_VERTICAL_PADDING} \${token('space.075','6px')}
|
|
92
|
+
\${DROPDOWN_HEADER_VERTICAL_PADDING} \${token('space.200', '16px')}\`,
|
|
93
|
+
});
|
|
94
|
+
const styles3 = css({
|
|
95
|
+
${property}: \`\${token('space.050', '4px')} \${token('space.150', '12px')} \${token('space.150', '12px')}
|
|
96
|
+
\${({ isSummaryView }: EditFormContentWrapperProps) =>
|
|
97
|
+
isSummaryView ? token('space.0', '0') : token('space.150', '12px')}\`,
|
|
98
|
+
});
|
|
99
|
+
const styles4 = css({
|
|
100
|
+
${property}: \`\${token('space.100', '8px')} -\${gridSize}px 0\`,
|
|
101
|
+
});
|
|
102
|
+
`,
|
|
103
|
+
},
|
|
82
104
|
];
|
|
83
105
|
};
|
|
84
106
|
|
|
@@ -252,26 +274,6 @@ const invalidTestCases = (property: string) => {
|
|
|
252
274
|
`,
|
|
253
275
|
errors: [{ messageId: 'expandSpacingShorthand' }],
|
|
254
276
|
},
|
|
255
|
-
// Template literal containing expressions that is not token should only throw error with no autofix
|
|
256
|
-
{
|
|
257
|
-
name: `${property}: property value template string where it contains an expression that is not a token`,
|
|
258
|
-
code: outdent`
|
|
259
|
-
import {css} from '@compiled/react';
|
|
260
|
-
const styles = css({
|
|
261
|
-
${property}: \`\${token('space.100', '8px')} \${gridSize * 2}px\`,
|
|
262
|
-
});
|
|
263
|
-
const styles2 = css({
|
|
264
|
-
padding: \`\${DROPDOWN_HEADER_VERTICAL_PADDING} \${token('space.075','6px')}
|
|
265
|
-
\${DROPDOWN_HEADER_VERTICAL_PADDING} \${token('space.200', '16px')}\`,
|
|
266
|
-
});
|
|
267
|
-
const styles3 = css({
|
|
268
|
-
${property}: \`\${token('space.050', '4px')} \${token('space.150', '12px')} \${token('space.150', '12px')}
|
|
269
|
-
\${({ isSummaryView }: EditFormContentWrapperProps) =>
|
|
270
|
-
isSummaryView ? token('space.0', '0') : token('space.150', '12px')}\`,
|
|
271
|
-
});
|
|
272
|
-
`,
|
|
273
|
-
errors: Array.from(Array(3), () => ({ messageId: 'expandSpacingShorthand' })),
|
|
274
|
-
},
|
|
275
277
|
// Strings that are not valid property values should not be autofixed (e.g. !important)
|
|
276
278
|
{
|
|
277
279
|
name: `${property}: Don't autofix if not able to handle all the string values, e.g !important`,
|
|
@@ -50,15 +50,21 @@ const parseTemplateLiteral = (templateLiteral: TemplateLiteral, context: Rule.Ru
|
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
* Checks if the parsed property values are valid
|
|
54
|
-
* 1.
|
|
55
|
-
* 2.
|
|
56
|
-
* 3.
|
|
53
|
+
* Checks if the parsed property values are valid; values that we shouldn't handle with the fixer:
|
|
54
|
+
* 1. At least one expression in TemplateLiteral is not a token expression
|
|
55
|
+
* 2. Do not contain a token
|
|
56
|
+
* 3. Have length that are not in the range [1, 4] for different spacing directions
|
|
57
|
+
* - No more than 4 to exclude additional values such as `!important`
|
|
58
|
+
* 4. Includes `calc(...)`
|
|
57
59
|
* Then, the rule will return with no error
|
|
58
60
|
* @param propertyValues property values parsed as list of strings
|
|
59
61
|
* @returns boolean
|
|
60
62
|
*/
|
|
61
|
-
const isPropertyValueExempted = (propertyValues: string[]) => {
|
|
63
|
+
const isPropertyValueExempted = (templateLiteral: TemplateLiteral, propertyValues: string[]) => {
|
|
64
|
+
const expressions = templateLiteral.expressions;
|
|
65
|
+
if (!expressions.every((expr) => expr.type === 'CallExpression' && isTokenCallExpression(expr))) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
62
68
|
if (!propertyValues.some((str) => str.includes('token('))) {
|
|
63
69
|
return true;
|
|
64
70
|
}
|
|
@@ -72,29 +78,31 @@ const isPropertyValueExempted = (propertyValues: string[]) => {
|
|
|
72
78
|
};
|
|
73
79
|
|
|
74
80
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* 2. Property values must have a format which includes -> e.g. 2, '2(rem|em|px)', auto, initial, inherit, token(...)
|
|
81
|
+
* Checks if the parsed property values are invalid (i.e. rule violation thrown) and autofix required. Cases are when
|
|
82
|
+
* property values must have a format which includes -> e.g. 2, '2(rem|em|px)', auto, initial, inherit, token(...)
|
|
78
83
|
* The rule will return with error and provide a fix
|
|
79
84
|
* @param templateLiteral TemplateLiteral AST Node
|
|
80
85
|
* @param propertyValues property values parsed as list of strings
|
|
81
86
|
* @returns boolean
|
|
82
87
|
*/
|
|
83
|
-
const isPropertyValuesInvalidFix = (
|
|
84
|
-
const expressions = templateLiteral.expressions;
|
|
85
|
-
if (!expressions.every((expr) => expr.type === 'CallExpression' && isTokenCallExpression(expr))) {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
|
|
88
|
+
const isPropertyValuesInvalidFix = (propertyValues: string[]) => {
|
|
89
89
|
for (const propValue of propertyValues) {
|
|
90
|
-
if (propValue === '0') {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (
|
|
90
|
+
if (propValue === '0') {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (['auto', 'initial', 'inherit'].includes(propValue.slice(1, -1))) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (/^token\(.*\)$/.test(propValue)) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (/^['"]\d+(\.\d+)?((rem)|(em)|(px))['"]$/.test(propValue)) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
94
102
|
return false;
|
|
95
103
|
}
|
|
96
104
|
return true;
|
|
97
|
-
}
|
|
105
|
+
};
|
|
98
106
|
|
|
99
107
|
// To fix spacing shorthands, given a list of spacing property values, expands the spacing property and adds autofix fixes
|
|
100
108
|
const expandSpacingProperties = ({
|
|
@@ -157,11 +165,11 @@ const executeExpandSpacingRule = (
|
|
|
157
165
|
}
|
|
158
166
|
if (node.value.type === 'TemplateLiteral') {
|
|
159
167
|
const propertyValues = parseTemplateLiteral(node.value, context);
|
|
160
|
-
if (isPropertyValueExempted(propertyValues)) {
|
|
168
|
+
if (isPropertyValueExempted(node.value, propertyValues)) {
|
|
161
169
|
// Valid, so no error should be thrown
|
|
162
170
|
return;
|
|
163
171
|
}
|
|
164
|
-
if (isPropertyValuesInvalidFix(
|
|
172
|
+
if (isPropertyValuesInvalidFix(propertyValues)) {
|
|
165
173
|
// Invalid, so error should be thrown and fix provided
|
|
166
174
|
context.report({
|
|
167
175
|
node,
|
|
@@ -170,7 +178,13 @@ const executeExpandSpacingRule = (
|
|
|
170
178
|
property: propertyShorthand,
|
|
171
179
|
},
|
|
172
180
|
fix(fixer) {
|
|
173
|
-
return expandSpacingProperties({
|
|
181
|
+
return expandSpacingProperties({
|
|
182
|
+
context,
|
|
183
|
+
node,
|
|
184
|
+
propertyValues,
|
|
185
|
+
fixer,
|
|
186
|
+
propertyShorthand,
|
|
187
|
+
});
|
|
174
188
|
},
|
|
175
189
|
});
|
|
176
190
|
} else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
### Notes
|
|
2
2
|
|
|
3
3
|
- feature-gating/\* rules are copied from
|
|
4
|
-
[eslint-plugin-jira/rules/ff](https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/browse/jira/
|
|
4
|
+
[eslint-plugin-jira/rules/ff](https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/browse/jira/dev-tooling/packages/eslint-plugin-jira/rules/ff)
|
|
5
5
|
with small variations as mentioned in this
|
|
6
6
|
[PR](https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/pull-requests/115546/overview)
|
|
7
7
|
- these rules could be a WIP since they are still targeting JFE libraries- see
|
|
@@ -109,6 +109,11 @@ const rule: Rule.RuleModule = {
|
|
|
109
109
|
'Ensure feature flags/gates and experiments are inlined so that they can be statically analyzable.',
|
|
110
110
|
url: 'https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/browse/platform/packages/platform/eslint-plugin/src/rules/inline-usage/README.md',
|
|
111
111
|
},
|
|
112
|
+
schema: [
|
|
113
|
+
{
|
|
114
|
+
enum: ['ssOnly'],
|
|
115
|
+
},
|
|
116
|
+
],
|
|
112
117
|
messages: {
|
|
113
118
|
inlineUsage:
|
|
114
119
|
'Do not export or wrap feature flags/gates and experiments usages. Inline calls at the callsite to ensure it is statically analyzable.',
|