@atlaskit/eslint-plugin-design-system 8.19.0 → 8.19.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/dist/cjs/rules/use-primitives/config/index.js +15 -0
- package/dist/cjs/rules/use-primitives/index.js +9 -9
- package/dist/es2019/rules/use-primitives/config/index.js +9 -0
- package/dist/es2019/rules/use-primitives/index.js +9 -8
- package/dist/esm/rules/use-primitives/config/index.js +9 -0
- package/dist/esm/rules/use-primitives/index.js +9 -8
- package/dist/types/rules/use-primitives/config/index.d.ts +4 -0
- package/dist/types-ts4.5/rules/use-primitives/config/index.d.ts +4 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 8.19.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#65221](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/65221) [`a2ba22904ca0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a2ba22904ca0) - Allow for @atlaskit/design-system/use-primitives lint rule to take a configuration object.
|
|
8
|
+
|
|
3
9
|
## 8.19.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getConfig = void 0;
|
|
7
|
+
var defaults = {
|
|
8
|
+
patterns: ['div-object-css']
|
|
9
|
+
};
|
|
10
|
+
var getConfig = exports.getConfig = function getConfig(overrides) {
|
|
11
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
12
|
+
// start with an empty object, then merge in the defaults, then merge in overrides.
|
|
13
|
+
// The empty object is returned, as well as modified in place
|
|
14
|
+
return Object.assign({}, defaults, overrides);
|
|
15
|
+
};
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = void 0;
|
|
8
7
|
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
9
|
-
var _assign = _interopRequireDefault(require("lodash/assign"));
|
|
10
8
|
var _createRule = require("../utils/create-rule");
|
|
9
|
+
var _config = require("./config");
|
|
11
10
|
var _transformers = require("./transformers");
|
|
12
11
|
var _utils = require("./utils");
|
|
13
12
|
var boxDocsUrl = 'https://atlassian.design/components/primitives/box';
|
|
14
|
-
var defaultConfig = {
|
|
15
|
-
preview: false
|
|
16
|
-
};
|
|
17
13
|
var rule = (0, _createRule.createLintRule)({
|
|
18
14
|
meta: {
|
|
19
15
|
name: 'use-primitives',
|
|
@@ -30,11 +26,11 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
30
26
|
}
|
|
31
27
|
},
|
|
32
28
|
create: function create(context) {
|
|
33
|
-
var
|
|
29
|
+
var config = (0, _config.getConfig)(context.options[0]);
|
|
34
30
|
return {
|
|
35
31
|
// transforms styled.<html>(...) usages
|
|
36
32
|
CallExpression: function CallExpression(node) {
|
|
37
|
-
if (!
|
|
33
|
+
if (!config.patterns.includes('compiled-styled-object')) {
|
|
38
34
|
return;
|
|
39
35
|
}
|
|
40
36
|
if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'CallExpression')) {
|
|
@@ -64,6 +60,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
64
60
|
},
|
|
65
61
|
// transforms <div css={...}> usages
|
|
66
62
|
JSXOpeningElement: function JSXOpeningElement(node) {
|
|
63
|
+
var config = (0, _config.getConfig)(context.options[0]);
|
|
67
64
|
if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXOpeningElement')) {
|
|
68
65
|
return;
|
|
69
66
|
}
|
|
@@ -73,7 +70,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
73
70
|
if (!(0, _eslintCodemodUtils.isNodeOfType)(node.parent, 'JSXElement')) {
|
|
74
71
|
return;
|
|
75
72
|
}
|
|
76
|
-
var suggestBox = shouldSuggestBox(node.parent, context);
|
|
73
|
+
var suggestBox = shouldSuggestBox(node.parent, context, config);
|
|
77
74
|
if (suggestBox) {
|
|
78
75
|
context.report({
|
|
79
76
|
node: node,
|
|
@@ -91,7 +88,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
91
88
|
};
|
|
92
89
|
}
|
|
93
90
|
});
|
|
94
|
-
var shouldSuggestBox = function shouldSuggestBox(node, context
|
|
91
|
+
var shouldSuggestBox = function shouldSuggestBox(node, context, config
|
|
95
92
|
// scope: Scope.Scope,
|
|
96
93
|
) {
|
|
97
94
|
if (!node) {
|
|
@@ -138,6 +135,9 @@ var shouldSuggestBox = function shouldSuggestBox(node, context
|
|
|
138
135
|
if (!cssVariableValue || !(0, _utils.isFunctionNamed)(cssVariableValue, 'css')) {
|
|
139
136
|
return false;
|
|
140
137
|
}
|
|
138
|
+
if (!config.patterns.includes('div-object-css')) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
141
|
return (0, _utils.isValidCssPropertiesToTransform)(cssVariableValue.node.init);
|
|
142
142
|
};
|
|
143
143
|
var _default = exports.default = rule;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const defaults = {
|
|
2
|
+
patterns: ['div-object-css']
|
|
3
|
+
};
|
|
4
|
+
export const getConfig = overrides => {
|
|
5
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
6
|
+
// start with an empty object, then merge in the defaults, then merge in overrides.
|
|
7
|
+
// The empty object is returned, as well as modified in place
|
|
8
|
+
return Object.assign({}, defaults, overrides);
|
|
9
|
+
};
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { getIdentifierInParentScope, isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
-
import assign from 'lodash/assign';
|
|
3
2
|
import { createLintRule } from '../utils/create-rule';
|
|
3
|
+
import { getConfig } from './config';
|
|
4
4
|
import { jsxElementToBoxTransformer, styledComponentToPrimitive } from './transformers';
|
|
5
5
|
import { containsOnlySupportedAttrs, findValidJsxUsageToTransform, findValidStyledComponentCall, getAttributeValueIdentifier, getJSXAttributeByName, getVariableDefinitionValue, getVariableUsagesCount, isFunctionNamed, isValidCssPropertiesToTransform, isValidTagName } from './utils';
|
|
6
6
|
const boxDocsUrl = 'https://atlassian.design/components/primitives/box';
|
|
7
|
-
const defaultConfig = {
|
|
8
|
-
preview: false
|
|
9
|
-
};
|
|
10
7
|
const rule = createLintRule({
|
|
11
8
|
meta: {
|
|
12
9
|
name: 'use-primitives',
|
|
@@ -23,11 +20,11 @@ const rule = createLintRule({
|
|
|
23
20
|
}
|
|
24
21
|
},
|
|
25
22
|
create(context) {
|
|
26
|
-
const
|
|
23
|
+
const config = getConfig(context.options[0]);
|
|
27
24
|
return {
|
|
28
25
|
// transforms styled.<html>(...) usages
|
|
29
26
|
CallExpression(node) {
|
|
30
|
-
if (!
|
|
27
|
+
if (!config.patterns.includes('compiled-styled-object')) {
|
|
31
28
|
return;
|
|
32
29
|
}
|
|
33
30
|
if (!isNodeOfType(node, 'CallExpression')) {
|
|
@@ -57,6 +54,7 @@ const rule = createLintRule({
|
|
|
57
54
|
},
|
|
58
55
|
// transforms <div css={...}> usages
|
|
59
56
|
JSXOpeningElement(node) {
|
|
57
|
+
const config = getConfig(context.options[0]);
|
|
60
58
|
if (!isNodeOfType(node, 'JSXOpeningElement')) {
|
|
61
59
|
return;
|
|
62
60
|
}
|
|
@@ -66,7 +64,7 @@ const rule = createLintRule({
|
|
|
66
64
|
if (!isNodeOfType(node.parent, 'JSXElement')) {
|
|
67
65
|
return;
|
|
68
66
|
}
|
|
69
|
-
const suggestBox = shouldSuggestBox(node.parent, context);
|
|
67
|
+
const suggestBox = shouldSuggestBox(node.parent, context, config);
|
|
70
68
|
if (suggestBox) {
|
|
71
69
|
context.report({
|
|
72
70
|
node: node,
|
|
@@ -84,7 +82,7 @@ const rule = createLintRule({
|
|
|
84
82
|
};
|
|
85
83
|
}
|
|
86
84
|
});
|
|
87
|
-
const shouldSuggestBox = (node, context
|
|
85
|
+
const shouldSuggestBox = (node, context, config
|
|
88
86
|
// scope: Scope.Scope,
|
|
89
87
|
) => {
|
|
90
88
|
if (!node) {
|
|
@@ -131,6 +129,9 @@ const shouldSuggestBox = (node, context
|
|
|
131
129
|
if (!cssVariableValue || !isFunctionNamed(cssVariableValue, 'css')) {
|
|
132
130
|
return false;
|
|
133
131
|
}
|
|
132
|
+
if (!config.patterns.includes('div-object-css')) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
134
135
|
return isValidCssPropertiesToTransform(cssVariableValue.node.init);
|
|
135
136
|
};
|
|
136
137
|
export default rule;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var defaults = {
|
|
2
|
+
patterns: ['div-object-css']
|
|
3
|
+
};
|
|
4
|
+
export var getConfig = function getConfig(overrides) {
|
|
5
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
6
|
+
// start with an empty object, then merge in the defaults, then merge in overrides.
|
|
7
|
+
// The empty object is returned, as well as modified in place
|
|
8
|
+
return Object.assign({}, defaults, overrides);
|
|
9
|
+
};
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { getIdentifierInParentScope, isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
-
import assign from 'lodash/assign';
|
|
3
2
|
import { createLintRule } from '../utils/create-rule';
|
|
3
|
+
import { getConfig } from './config';
|
|
4
4
|
import { jsxElementToBoxTransformer, styledComponentToPrimitive } from './transformers';
|
|
5
5
|
import { containsOnlySupportedAttrs, findValidJsxUsageToTransform, findValidStyledComponentCall, getAttributeValueIdentifier, getJSXAttributeByName, getVariableDefinitionValue, getVariableUsagesCount, isFunctionNamed, isValidCssPropertiesToTransform, isValidTagName } from './utils';
|
|
6
6
|
var boxDocsUrl = 'https://atlassian.design/components/primitives/box';
|
|
7
|
-
var defaultConfig = {
|
|
8
|
-
preview: false
|
|
9
|
-
};
|
|
10
7
|
var rule = createLintRule({
|
|
11
8
|
meta: {
|
|
12
9
|
name: 'use-primitives',
|
|
@@ -23,11 +20,11 @@ var rule = createLintRule({
|
|
|
23
20
|
}
|
|
24
21
|
},
|
|
25
22
|
create: function create(context) {
|
|
26
|
-
var
|
|
23
|
+
var config = getConfig(context.options[0]);
|
|
27
24
|
return {
|
|
28
25
|
// transforms styled.<html>(...) usages
|
|
29
26
|
CallExpression: function CallExpression(node) {
|
|
30
|
-
if (!
|
|
27
|
+
if (!config.patterns.includes('compiled-styled-object')) {
|
|
31
28
|
return;
|
|
32
29
|
}
|
|
33
30
|
if (!isNodeOfType(node, 'CallExpression')) {
|
|
@@ -57,6 +54,7 @@ var rule = createLintRule({
|
|
|
57
54
|
},
|
|
58
55
|
// transforms <div css={...}> usages
|
|
59
56
|
JSXOpeningElement: function JSXOpeningElement(node) {
|
|
57
|
+
var config = getConfig(context.options[0]);
|
|
60
58
|
if (!isNodeOfType(node, 'JSXOpeningElement')) {
|
|
61
59
|
return;
|
|
62
60
|
}
|
|
@@ -66,7 +64,7 @@ var rule = createLintRule({
|
|
|
66
64
|
if (!isNodeOfType(node.parent, 'JSXElement')) {
|
|
67
65
|
return;
|
|
68
66
|
}
|
|
69
|
-
var suggestBox = shouldSuggestBox(node.parent, context);
|
|
67
|
+
var suggestBox = shouldSuggestBox(node.parent, context, config);
|
|
70
68
|
if (suggestBox) {
|
|
71
69
|
context.report({
|
|
72
70
|
node: node,
|
|
@@ -84,7 +82,7 @@ var rule = createLintRule({
|
|
|
84
82
|
};
|
|
85
83
|
}
|
|
86
84
|
});
|
|
87
|
-
var shouldSuggestBox = function shouldSuggestBox(node, context
|
|
85
|
+
var shouldSuggestBox = function shouldSuggestBox(node, context, config
|
|
88
86
|
// scope: Scope.Scope,
|
|
89
87
|
) {
|
|
90
88
|
if (!node) {
|
|
@@ -131,6 +129,9 @@ var shouldSuggestBox = function shouldSuggestBox(node, context
|
|
|
131
129
|
if (!cssVariableValue || !isFunctionNamed(cssVariableValue, 'css')) {
|
|
132
130
|
return false;
|
|
133
131
|
}
|
|
132
|
+
if (!config.patterns.includes('div-object-css')) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
134
135
|
return isValidCssPropertiesToTransform(cssVariableValue.node.init);
|
|
135
136
|
};
|
|
136
137
|
export default rule;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export interface RuleConfig {
|
|
2
|
+
patterns: ('div-object-css' | 'compiled-styled-object' | 'compiled-template-literal' | 'div-object-css-with-tokens' | 'div-object-css-with-multiple-vals')[];
|
|
3
|
+
}
|
|
4
|
+
export declare const getConfig: (overrides: Partial<RuleConfig>) => Required<RuleConfig>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export interface RuleConfig {
|
|
2
|
+
patterns: ('div-object-css' | 'compiled-styled-object' | 'compiled-template-literal' | 'div-object-css-with-tokens' | 'div-object-css-with-multiple-vals')[];
|
|
3
|
+
}
|
|
4
|
+
export declare const getConfig: (overrides: Partial<RuleConfig>) => Required<RuleConfig>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/eslint-plugin-design-system",
|
|
3
3
|
"description": "The essential plugin for use with the Atlassian Design System.",
|
|
4
|
-
"version": "8.19.
|
|
4
|
+
"version": "8.19.1",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"registry": "https://registry.npmjs.org/"
|