@atlaskit/eslint-plugin-design-system 13.8.0 → 13.9.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 +8 -0
- package/README.md +1 -0
- package/dist/cjs/presets/all-flat.codegen.js +2 -1
- package/dist/cjs/presets/all.codegen.js +2 -1
- package/dist/cjs/presets/recommended-flat.codegen.js +2 -1
- package/dist/cjs/presets/recommended.codegen.js +2 -1
- package/dist/cjs/rules/index.codegen.js +3 -1
- package/dist/cjs/rules/no-html-select/index.js +40 -0
- package/dist/cjs/rules/no-html-select/node-types/index.js +19 -0
- package/dist/cjs/rules/no-html-select/node-types/jsx-element/index.js +27 -0
- package/dist/cjs/rules/no-html-select/node-types/styled-component/index.js +42 -0
- package/dist/cjs/rules/no-html-select/node-types/supported.js +66 -0
- package/dist/es2019/presets/all-flat.codegen.js +2 -1
- package/dist/es2019/presets/all.codegen.js +2 -1
- package/dist/es2019/presets/recommended-flat.codegen.js +2 -1
- package/dist/es2019/presets/recommended.codegen.js +2 -1
- package/dist/es2019/rules/index.codegen.js +3 -1
- package/dist/es2019/rules/no-html-select/index.js +34 -0
- package/dist/es2019/rules/no-html-select/node-types/index.js +2 -0
- package/dist/es2019/rules/no-html-select/node-types/jsx-element/index.js +19 -0
- package/dist/es2019/rules/no-html-select/node-types/styled-component/index.js +37 -0
- package/dist/es2019/rules/no-html-select/node-types/supported.js +56 -0
- package/dist/esm/presets/all-flat.codegen.js +2 -1
- package/dist/esm/presets/all.codegen.js +2 -1
- package/dist/esm/presets/recommended-flat.codegen.js +2 -1
- package/dist/esm/presets/recommended.codegen.js +2 -1
- package/dist/esm/rules/index.codegen.js +3 -1
- package/dist/esm/rules/no-html-select/index.js +34 -0
- package/dist/esm/rules/no-html-select/node-types/index.js +2 -0
- package/dist/esm/rules/no-html-select/node-types/jsx-element/index.js +18 -0
- package/dist/esm/rules/no-html-select/node-types/styled-component/index.js +36 -0
- package/dist/esm/rules/no-html-select/node-types/supported.js +57 -0
- package/dist/types/index.codegen.d.ts +9 -0
- package/dist/types/presets/all-flat.codegen.d.ts +1 -0
- package/dist/types/presets/all.codegen.d.ts +1 -0
- package/dist/types/presets/recommended-flat.codegen.d.ts +1 -0
- package/dist/types/presets/recommended.codegen.d.ts +1 -0
- package/dist/types/rules/index.codegen.d.ts +1 -0
- package/dist/types/rules/no-html-select/index.d.ts +3 -0
- package/dist/types/rules/no-html-select/node-types/index.d.ts +2 -0
- package/dist/types/rules/no-html-select/node-types/jsx-element/index.d.ts +8 -0
- package/dist/types/rules/no-html-select/node-types/styled-component/index.d.ts +8 -0
- package/dist/types/rules/no-html-select/node-types/supported.d.ts +7 -0
- package/dist/types-ts4.5/index.codegen.d.ts +9 -0
- package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +1 -0
- package/dist/types-ts4.5/presets/all.codegen.d.ts +1 -0
- package/dist/types-ts4.5/presets/recommended-flat.codegen.d.ts +1 -0
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +1 -0
- package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
- package/dist/types-ts4.5/rules/no-html-select/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/no-html-select/node-types/index.d.ts +2 -0
- package/dist/types-ts4.5/rules/no-html-select/node-types/jsx-element/index.d.ts +8 -0
- package/dist/types-ts4.5/rules/no-html-select/node-types/styled-component/index.d.ts +8 -0
- package/dist/types-ts4.5/rules/no-html-select/node-types/supported.d.ts +7 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 13.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#145662](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/145662)
|
|
8
|
+
[`acf5f6979c85f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/acf5f6979c85f) -
|
|
9
|
+
Add rule to encourage use of the DS select component over native HTML selects.
|
|
10
|
+
|
|
3
11
|
## 13.8.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -71,6 +71,7 @@ module.exports = {
|
|
|
71
71
|
| <a href="./src/rules/no-html-checkbox/README.md">no-html-checkbox</a> | Discourage direct usage of HTML checkbox elements in favor of the Atlassian Design System checkbox component. | Yes | | Yes |
|
|
72
72
|
| <a href="./src/rules/no-html-image/README.md">no-html-image</a> | Discourage direct usage of HTML image elements in favor of the Atlassian Design System image component. | Yes | | Yes |
|
|
73
73
|
| <a href="./src/rules/no-html-range/README.md">no-html-range</a> | Discourage direct usage of HTML range elements in favor of the Atlassian Design System range component. | Yes | | Yes |
|
|
74
|
+
| <a href="./src/rules/no-html-select/README.md">no-html-select</a> | Discourage direct usage of HTML select elements in favor of the Atlassian Design System select component. | Yes | | Yes |
|
|
74
75
|
| <a href="./src/rules/no-invalid-css-map/README.md">no-invalid-css-map</a> | Checks the validity of a CSS map created through cssMap. This is intended to be used alongside TypeScript's type-checking. | Yes | | |
|
|
75
76
|
| <a href="./src/rules/no-keyframes-tagged-template-expression/README.md">no-keyframes-tagged-template-expression</a> | Disallows any `keyframe` tagged template expressions that originate from Emotion, Styled Components or Compiled | | Yes | |
|
|
76
77
|
| <a href="./src/rules/no-legacy-icons/README.md">no-legacy-icons</a> | Enforces no legacy icons are used. | | Yes | Yes |
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
9
|
-
* @codegen <<SignedSource::
|
|
9
|
+
* @codegen <<SignedSource::f202c585a3745f4765e0515889577a22>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -32,6 +32,7 @@ var _default = exports.default = {
|
|
|
32
32
|
'@atlaskit/design-system/no-html-checkbox': 'warn',
|
|
33
33
|
'@atlaskit/design-system/no-html-image': 'warn',
|
|
34
34
|
'@atlaskit/design-system/no-html-range': 'warn',
|
|
35
|
+
'@atlaskit/design-system/no-html-select': 'warn',
|
|
35
36
|
'@atlaskit/design-system/no-invalid-css-map': ['error', {
|
|
36
37
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
37
38
|
}],
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
9
|
-
* @codegen <<SignedSource::
|
|
9
|
+
* @codegen <<SignedSource::6b4a8032ac1f59781b9675b9cc053a55>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -31,6 +31,7 @@ var _default = exports.default = {
|
|
|
31
31
|
'@atlaskit/design-system/no-html-checkbox': 'warn',
|
|
32
32
|
'@atlaskit/design-system/no-html-image': 'warn',
|
|
33
33
|
'@atlaskit/design-system/no-html-range': 'warn',
|
|
34
|
+
'@atlaskit/design-system/no-html-select': 'warn',
|
|
34
35
|
'@atlaskit/design-system/no-invalid-css-map': ['error', {
|
|
35
36
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
36
37
|
}],
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
9
|
-
* @codegen <<SignedSource::
|
|
9
|
+
* @codegen <<SignedSource::88336f6c2f8c5d33f84730619006b49e>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -27,6 +27,7 @@ var _default = exports.default = {
|
|
|
27
27
|
'@atlaskit/design-system/no-html-checkbox': 'warn',
|
|
28
28
|
'@atlaskit/design-system/no-html-image': 'warn',
|
|
29
29
|
'@atlaskit/design-system/no-html-range': 'warn',
|
|
30
|
+
'@atlaskit/design-system/no-html-select': 'warn',
|
|
30
31
|
'@atlaskit/design-system/no-invalid-css-map': ['error', {
|
|
31
32
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
32
33
|
}],
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
9
|
-
* @codegen <<SignedSource::
|
|
9
|
+
* @codegen <<SignedSource::829b781e15e90c3a142273e2b153459f>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -26,6 +26,7 @@ var _default = exports.default = {
|
|
|
26
26
|
'@atlaskit/design-system/no-html-checkbox': 'warn',
|
|
27
27
|
'@atlaskit/design-system/no-html-image': 'warn',
|
|
28
28
|
'@atlaskit/design-system/no-html-range': 'warn',
|
|
29
|
+
'@atlaskit/design-system/no-html-select': 'warn',
|
|
29
30
|
'@atlaskit/design-system/no-invalid-css-map': ['error', {
|
|
30
31
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
31
32
|
}],
|
|
@@ -27,6 +27,7 @@ var _noHtmlButton = _interopRequireDefault(require("./no-html-button"));
|
|
|
27
27
|
var _noHtmlCheckbox = _interopRequireDefault(require("./no-html-checkbox"));
|
|
28
28
|
var _noHtmlImage = _interopRequireDefault(require("./no-html-image"));
|
|
29
29
|
var _noHtmlRange = _interopRequireDefault(require("./no-html-range"));
|
|
30
|
+
var _noHtmlSelect = _interopRequireDefault(require("./no-html-select"));
|
|
30
31
|
var _noInvalidCssMap = _interopRequireDefault(require("./no-invalid-css-map"));
|
|
31
32
|
var _noKeyframesTaggedTemplateExpression = _interopRequireDefault(require("./no-keyframes-tagged-template-expression"));
|
|
32
33
|
var _noLegacyIcons = _interopRequireDefault(require("./no-legacy-icons"));
|
|
@@ -61,7 +62,7 @@ var _useTokensTypography = _interopRequireDefault(require("./use-tokens-typograp
|
|
|
61
62
|
var _useVisuallyHidden = _interopRequireDefault(require("./use-visually-hidden"));
|
|
62
63
|
/**
|
|
63
64
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
64
|
-
* @codegen <<SignedSource::
|
|
65
|
+
* @codegen <<SignedSource::60d053061448c69290fba282ee307366>>
|
|
65
66
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
66
67
|
*/
|
|
67
68
|
|
|
@@ -88,6 +89,7 @@ var rules = exports.rules = {
|
|
|
88
89
|
'no-html-checkbox': _noHtmlCheckbox.default,
|
|
89
90
|
'no-html-image': _noHtmlImage.default,
|
|
90
91
|
'no-html-range': _noHtmlRange.default,
|
|
92
|
+
'no-html-select': _noHtmlSelect.default,
|
|
91
93
|
'no-invalid-css-map': _noInvalidCssMap.default,
|
|
92
94
|
'no-keyframes-tagged-template-expression': _noKeyframesTaggedTemplateExpression.default,
|
|
93
95
|
'no-legacy-icons': _noLegacyIcons.default,
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _createRule = require("../utils/create-rule");
|
|
8
|
+
var _nodeTypes = require("./node-types");
|
|
9
|
+
var rule = (0, _createRule.createLintRule)({
|
|
10
|
+
meta: {
|
|
11
|
+
name: 'no-html-select',
|
|
12
|
+
type: 'suggestion',
|
|
13
|
+
hasSuggestions: true,
|
|
14
|
+
docs: {
|
|
15
|
+
description: 'Discourage direct usage of HTML select elements in favor of the Atlassian Design System select component.',
|
|
16
|
+
recommended: true,
|
|
17
|
+
severity: 'warn'
|
|
18
|
+
},
|
|
19
|
+
messages: {
|
|
20
|
+
noHtmlSelect: "This <{{ name }}> should be replaced with the select component from the Atlassian Design System. ADS select components have event tracking, ensure accessible implementations, and provide access to ADS styling features like design tokens."
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
create: function create(context) {
|
|
24
|
+
return {
|
|
25
|
+
// transforms styled.<anchor>(...) usages
|
|
26
|
+
CallExpression: function CallExpression(node) {
|
|
27
|
+
_nodeTypes.StyledComponent.lint(node, {
|
|
28
|
+
context: context
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
// transforms <anchor css={...}> usages
|
|
32
|
+
JSXElement: function JSXElement(node) {
|
|
33
|
+
_nodeTypes.JSXElement.lint(node, {
|
|
34
|
+
context: context
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
var _default = exports.default = rule;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "JSXElement", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _jsxElement.JSXElement;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "StyledComponent", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _styledComponent.StyledComponent;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _styledComponent = require("./styled-component");
|
|
19
|
+
var _jsxElement = require("./jsx-element");
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.JSXElement = void 0;
|
|
8
|
+
var ast = _interopRequireWildcard(require("../../../../ast-nodes"));
|
|
9
|
+
var _supported = require("../supported");
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
|
+
var JSXElement = exports.JSXElement = {
|
|
13
|
+
lint: function lint(node, _ref) {
|
|
14
|
+
var context = _ref.context;
|
|
15
|
+
if (!(0, _supported.isSupportedForLint)(node)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
var nodeName = ast.JSXElement.getName(node);
|
|
19
|
+
context.report({
|
|
20
|
+
node: node.openingElement,
|
|
21
|
+
messageId: 'noHtmlSelect',
|
|
22
|
+
data: {
|
|
23
|
+
name: nodeName
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StyledComponent = void 0;
|
|
7
|
+
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
8
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
9
|
+
var _getJsxElementByName2 = require("../../../utils/get-jsx-element-by-name");
|
|
10
|
+
var _getStyledComponentCall = require("../../../utils/get-styled-component-call");
|
|
11
|
+
var _supported = require("../supported");
|
|
12
|
+
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
13
|
+
|
|
14
|
+
var StyledComponent = exports.StyledComponent = {
|
|
15
|
+
lint: function lint(node, _ref) {
|
|
16
|
+
var _getJsxElementByName;
|
|
17
|
+
var context = _ref.context;
|
|
18
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'CallExpression') || !(0, _eslintCodemodUtils.isNodeOfType)(node.callee, 'MemberExpression') || !(0, _eslintCodemodUtils.isNodeOfType)(node.callee.object, 'Identifier') || !(0, _eslintCodemodUtils.isNodeOfType)(node.callee.property, 'Identifier')) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
var styles = (0, _getStyledComponentCall.getStyledComponentCall)(node);
|
|
22
|
+
var elementName = node.callee.property.name;
|
|
23
|
+
if (!styles || !(0, _eslintCodemodUtils.isNodeOfType)(styles.id, 'Identifier')) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
var jsxElement = (_getJsxElementByName = (0, _getJsxElementByName2.getJsxElementByName)(styles.id.name, (0, _contextCompat.getScope)(context, node))) === null || _getJsxElementByName === void 0 ? void 0 : _getJsxElementByName.parent;
|
|
27
|
+
if (!jsxElement) {
|
|
28
|
+
// If there's no JSX element, we can't determine if it's being used as an select or not
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (jsxElement && !(0, _supported.isSupportedForLint)(jsxElement, elementName)) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
context.report({
|
|
35
|
+
node: styles,
|
|
36
|
+
messageId: 'noHtmlSelect',
|
|
37
|
+
data: {
|
|
38
|
+
name: node.callee.property.name
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.isSupportedForLint = isSupportedForLint;
|
|
8
|
+
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
9
|
+
var ast = _interopRequireWildcard(require("../../../ast-nodes"));
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
|
+
var supportedElements = [{
|
|
13
|
+
name: 'select'
|
|
14
|
+
}];
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Determines if the given JSX element is a supported element to lint with this rule.
|
|
18
|
+
*/
|
|
19
|
+
function isSupportedForLint(jsxNode, elementName) {
|
|
20
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(jsxNode, 'JSXElement')) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Allow passing in the element name because the jsxNode doesn't
|
|
25
|
+
// represent the element name with styled components
|
|
26
|
+
var elName = elementName || ast.JSXElement.getName(jsxNode);
|
|
27
|
+
if (!elName) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Only check native HTML elements, not components
|
|
32
|
+
if (elName[0] !== elName[0].toLowerCase()) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
var supportedElement = supportedElements.find(function (_ref) {
|
|
36
|
+
var name = _ref.name;
|
|
37
|
+
return name === elName;
|
|
38
|
+
});
|
|
39
|
+
if (!supportedElement) {
|
|
40
|
+
supportedElement = supportedElements.find(function (_ref2) {
|
|
41
|
+
var name = _ref2.name;
|
|
42
|
+
return name === '*';
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (!supportedElement) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Check if the element has any attributes that are not supported
|
|
50
|
+
var attributes = ast.JSXElement.getAttributes(jsxNode);
|
|
51
|
+
if (supportedElement.attributes && !supportedElement.attributes.every(function (_ref3) {
|
|
52
|
+
var name = _ref3.name,
|
|
53
|
+
values = _ref3.values;
|
|
54
|
+
return attributes.some(function (attribute) {
|
|
55
|
+
if (attribute.type === 'JSXSpreadAttribute') {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
var isMatchingName = attribute.name.name === name;
|
|
59
|
+
var isMatchingValues = values && attribute.value && attribute.value.type === 'Literal' && typeof attribute.value.value === 'string' && (values === null || values === void 0 ? void 0 : values.includes(attribute.value.value));
|
|
60
|
+
return isMatchingName && isMatchingValues;
|
|
61
|
+
});
|
|
62
|
+
})) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::f202c585a3745f4765e0515889577a22>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -27,6 +27,7 @@ export default {
|
|
|
27
27
|
'@atlaskit/design-system/no-html-checkbox': 'warn',
|
|
28
28
|
'@atlaskit/design-system/no-html-image': 'warn',
|
|
29
29
|
'@atlaskit/design-system/no-html-range': 'warn',
|
|
30
|
+
'@atlaskit/design-system/no-html-select': 'warn',
|
|
30
31
|
'@atlaskit/design-system/no-invalid-css-map': ['error', {
|
|
31
32
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
32
33
|
}],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::6b4a8032ac1f59781b9675b9cc053a55>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -26,6 +26,7 @@ export default {
|
|
|
26
26
|
'@atlaskit/design-system/no-html-checkbox': 'warn',
|
|
27
27
|
'@atlaskit/design-system/no-html-image': 'warn',
|
|
28
28
|
'@atlaskit/design-system/no-html-range': 'warn',
|
|
29
|
+
'@atlaskit/design-system/no-html-select': 'warn',
|
|
29
30
|
'@atlaskit/design-system/no-invalid-css-map': ['error', {
|
|
30
31
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
31
32
|
}],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::88336f6c2f8c5d33f84730619006b49e>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -22,6 +22,7 @@ export default {
|
|
|
22
22
|
'@atlaskit/design-system/no-html-checkbox': 'warn',
|
|
23
23
|
'@atlaskit/design-system/no-html-image': 'warn',
|
|
24
24
|
'@atlaskit/design-system/no-html-range': 'warn',
|
|
25
|
+
'@atlaskit/design-system/no-html-select': 'warn',
|
|
25
26
|
'@atlaskit/design-system/no-invalid-css-map': ['error', {
|
|
26
27
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
27
28
|
}],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::829b781e15e90c3a142273e2b153459f>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -21,6 +21,7 @@ export default {
|
|
|
21
21
|
'@atlaskit/design-system/no-html-checkbox': 'warn',
|
|
22
22
|
'@atlaskit/design-system/no-html-image': 'warn',
|
|
23
23
|
'@atlaskit/design-system/no-html-range': 'warn',
|
|
24
|
+
'@atlaskit/design-system/no-html-select': 'warn',
|
|
24
25
|
'@atlaskit/design-system/no-invalid-css-map': ['error', {
|
|
25
26
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
26
27
|
}],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::60d053061448c69290fba282ee307366>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
import consistentCssPropUsage from './consistent-css-prop-usage';
|
|
@@ -25,6 +25,7 @@ import noHtmlButton from './no-html-button';
|
|
|
25
25
|
import noHtmlCheckbox from './no-html-checkbox';
|
|
26
26
|
import noHtmlImage from './no-html-image';
|
|
27
27
|
import noHtmlRange from './no-html-range';
|
|
28
|
+
import noHtmlSelect from './no-html-select';
|
|
28
29
|
import noInvalidCssMap from './no-invalid-css-map';
|
|
29
30
|
import noKeyframesTaggedTemplateExpression from './no-keyframes-tagged-template-expression';
|
|
30
31
|
import noLegacyIcons from './no-legacy-icons';
|
|
@@ -80,6 +81,7 @@ export const rules = {
|
|
|
80
81
|
'no-html-checkbox': noHtmlCheckbox,
|
|
81
82
|
'no-html-image': noHtmlImage,
|
|
82
83
|
'no-html-range': noHtmlRange,
|
|
84
|
+
'no-html-select': noHtmlSelect,
|
|
83
85
|
'no-invalid-css-map': noInvalidCssMap,
|
|
84
86
|
'no-keyframes-tagged-template-expression': noKeyframesTaggedTemplateExpression,
|
|
85
87
|
'no-legacy-icons': noLegacyIcons,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createLintRule } from '../utils/create-rule';
|
|
2
|
+
import { JSXElement, StyledComponent } from './node-types';
|
|
3
|
+
const rule = createLintRule({
|
|
4
|
+
meta: {
|
|
5
|
+
name: 'no-html-select',
|
|
6
|
+
type: 'suggestion',
|
|
7
|
+
hasSuggestions: true,
|
|
8
|
+
docs: {
|
|
9
|
+
description: 'Discourage direct usage of HTML select elements in favor of the Atlassian Design System select component.',
|
|
10
|
+
recommended: true,
|
|
11
|
+
severity: 'warn'
|
|
12
|
+
},
|
|
13
|
+
messages: {
|
|
14
|
+
noHtmlSelect: `This <{{ name }}> should be replaced with the select component from the Atlassian Design System. ADS select components have event tracking, ensure accessible implementations, and provide access to ADS styling features like design tokens.`
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
create(context) {
|
|
18
|
+
return {
|
|
19
|
+
// transforms styled.<anchor>(...) usages
|
|
20
|
+
CallExpression(node) {
|
|
21
|
+
StyledComponent.lint(node, {
|
|
22
|
+
context
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
// transforms <anchor css={...}> usages
|
|
26
|
+
JSXElement(node) {
|
|
27
|
+
JSXElement.lint(node, {
|
|
28
|
+
context
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
export default rule;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as ast from '../../../../ast-nodes';
|
|
2
|
+
import { isSupportedForLint } from '../supported';
|
|
3
|
+
export const JSXElement = {
|
|
4
|
+
lint(node, {
|
|
5
|
+
context
|
|
6
|
+
}) {
|
|
7
|
+
if (!isSupportedForLint(node)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const nodeName = ast.JSXElement.getName(node);
|
|
11
|
+
context.report({
|
|
12
|
+
node: node.openingElement,
|
|
13
|
+
messageId: 'noHtmlSelect',
|
|
14
|
+
data: {
|
|
15
|
+
name: nodeName
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
2
|
+
|
|
3
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
+
import { getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
5
|
+
import { getJsxElementByName } from '../../../utils/get-jsx-element-by-name';
|
|
6
|
+
import { getStyledComponentCall } from '../../../utils/get-styled-component-call';
|
|
7
|
+
import { isSupportedForLint } from '../supported';
|
|
8
|
+
export const StyledComponent = {
|
|
9
|
+
lint(node, {
|
|
10
|
+
context
|
|
11
|
+
}) {
|
|
12
|
+
var _getJsxElementByName;
|
|
13
|
+
if (!isNodeOfType(node, 'CallExpression') || !isNodeOfType(node.callee, 'MemberExpression') || !isNodeOfType(node.callee.object, 'Identifier') || !isNodeOfType(node.callee.property, 'Identifier')) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const styles = getStyledComponentCall(node);
|
|
17
|
+
const elementName = node.callee.property.name;
|
|
18
|
+
if (!styles || !isNodeOfType(styles.id, 'Identifier')) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const jsxElement = (_getJsxElementByName = getJsxElementByName(styles.id.name, getScope(context, node))) === null || _getJsxElementByName === void 0 ? void 0 : _getJsxElementByName.parent;
|
|
22
|
+
if (!jsxElement) {
|
|
23
|
+
// If there's no JSX element, we can't determine if it's being used as an select or not
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (jsxElement && !isSupportedForLint(jsxElement, elementName)) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
context.report({
|
|
30
|
+
node: styles,
|
|
31
|
+
messageId: 'noHtmlSelect',
|
|
32
|
+
data: {
|
|
33
|
+
name: node.callee.property.name
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
+
import * as ast from '../../../ast-nodes';
|
|
3
|
+
const supportedElements = [{
|
|
4
|
+
name: 'select'
|
|
5
|
+
}];
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Determines if the given JSX element is a supported element to lint with this rule.
|
|
9
|
+
*/
|
|
10
|
+
export function isSupportedForLint(jsxNode, elementName) {
|
|
11
|
+
if (!isNodeOfType(jsxNode, 'JSXElement')) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Allow passing in the element name because the jsxNode doesn't
|
|
16
|
+
// represent the element name with styled components
|
|
17
|
+
const elName = elementName || ast.JSXElement.getName(jsxNode);
|
|
18
|
+
if (!elName) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Only check native HTML elements, not components
|
|
23
|
+
if (elName[0] !== elName[0].toLowerCase()) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
let supportedElement = supportedElements.find(({
|
|
27
|
+
name
|
|
28
|
+
}) => name === elName);
|
|
29
|
+
if (!supportedElement) {
|
|
30
|
+
supportedElement = supportedElements.find(({
|
|
31
|
+
name
|
|
32
|
+
}) => name === '*');
|
|
33
|
+
}
|
|
34
|
+
if (!supportedElement) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Check if the element has any attributes that are not supported
|
|
39
|
+
const attributes = ast.JSXElement.getAttributes(jsxNode);
|
|
40
|
+
if (supportedElement.attributes && !supportedElement.attributes.every(({
|
|
41
|
+
name,
|
|
42
|
+
values
|
|
43
|
+
}) => {
|
|
44
|
+
return attributes.some(attribute => {
|
|
45
|
+
if (attribute.type === 'JSXSpreadAttribute') {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
const isMatchingName = attribute.name.name === name;
|
|
49
|
+
const isMatchingValues = values && attribute.value && attribute.value.type === 'Literal' && typeof attribute.value.value === 'string' && (values === null || values === void 0 ? void 0 : values.includes(attribute.value.value));
|
|
50
|
+
return isMatchingName && isMatchingValues;
|
|
51
|
+
});
|
|
52
|
+
})) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::f202c585a3745f4765e0515889577a22>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -27,6 +27,7 @@ export default {
|
|
|
27
27
|
'@atlaskit/design-system/no-html-checkbox': 'warn',
|
|
28
28
|
'@atlaskit/design-system/no-html-image': 'warn',
|
|
29
29
|
'@atlaskit/design-system/no-html-range': 'warn',
|
|
30
|
+
'@atlaskit/design-system/no-html-select': 'warn',
|
|
30
31
|
'@atlaskit/design-system/no-invalid-css-map': ['error', {
|
|
31
32
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
32
33
|
}],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::6b4a8032ac1f59781b9675b9cc053a55>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -26,6 +26,7 @@ export default {
|
|
|
26
26
|
'@atlaskit/design-system/no-html-checkbox': 'warn',
|
|
27
27
|
'@atlaskit/design-system/no-html-image': 'warn',
|
|
28
28
|
'@atlaskit/design-system/no-html-range': 'warn',
|
|
29
|
+
'@atlaskit/design-system/no-html-select': 'warn',
|
|
29
30
|
'@atlaskit/design-system/no-invalid-css-map': ['error', {
|
|
30
31
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
31
32
|
}],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::88336f6c2f8c5d33f84730619006b49e>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -22,6 +22,7 @@ export default {
|
|
|
22
22
|
'@atlaskit/design-system/no-html-checkbox': 'warn',
|
|
23
23
|
'@atlaskit/design-system/no-html-image': 'warn',
|
|
24
24
|
'@atlaskit/design-system/no-html-range': 'warn',
|
|
25
|
+
'@atlaskit/design-system/no-html-select': 'warn',
|
|
25
26
|
'@atlaskit/design-system/no-invalid-css-map': ['error', {
|
|
26
27
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
27
28
|
}],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::829b781e15e90c3a142273e2b153459f>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -21,6 +21,7 @@ export default {
|
|
|
21
21
|
'@atlaskit/design-system/no-html-checkbox': 'warn',
|
|
22
22
|
'@atlaskit/design-system/no-html-image': 'warn',
|
|
23
23
|
'@atlaskit/design-system/no-html-range': 'warn',
|
|
24
|
+
'@atlaskit/design-system/no-html-select': 'warn',
|
|
24
25
|
'@atlaskit/design-system/no-invalid-css-map': ['error', {
|
|
25
26
|
allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
|
|
26
27
|
}],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::60d053061448c69290fba282ee307366>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
import consistentCssPropUsage from './consistent-css-prop-usage';
|
|
@@ -25,6 +25,7 @@ import noHtmlButton from './no-html-button';
|
|
|
25
25
|
import noHtmlCheckbox from './no-html-checkbox';
|
|
26
26
|
import noHtmlImage from './no-html-image';
|
|
27
27
|
import noHtmlRange from './no-html-range';
|
|
28
|
+
import noHtmlSelect from './no-html-select';
|
|
28
29
|
import noInvalidCssMap from './no-invalid-css-map';
|
|
29
30
|
import noKeyframesTaggedTemplateExpression from './no-keyframes-tagged-template-expression';
|
|
30
31
|
import noLegacyIcons from './no-legacy-icons';
|
|
@@ -80,6 +81,7 @@ export var rules = {
|
|
|
80
81
|
'no-html-checkbox': noHtmlCheckbox,
|
|
81
82
|
'no-html-image': noHtmlImage,
|
|
82
83
|
'no-html-range': noHtmlRange,
|
|
84
|
+
'no-html-select': noHtmlSelect,
|
|
83
85
|
'no-invalid-css-map': noInvalidCssMap,
|
|
84
86
|
'no-keyframes-tagged-template-expression': noKeyframesTaggedTemplateExpression,
|
|
85
87
|
'no-legacy-icons': noLegacyIcons,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createLintRule } from '../utils/create-rule';
|
|
2
|
+
import { JSXElement as _JSXElement, StyledComponent } from './node-types';
|
|
3
|
+
var rule = createLintRule({
|
|
4
|
+
meta: {
|
|
5
|
+
name: 'no-html-select',
|
|
6
|
+
type: 'suggestion',
|
|
7
|
+
hasSuggestions: true,
|
|
8
|
+
docs: {
|
|
9
|
+
description: 'Discourage direct usage of HTML select elements in favor of the Atlassian Design System select component.',
|
|
10
|
+
recommended: true,
|
|
11
|
+
severity: 'warn'
|
|
12
|
+
},
|
|
13
|
+
messages: {
|
|
14
|
+
noHtmlSelect: "This <{{ name }}> should be replaced with the select component from the Atlassian Design System. ADS select components have event tracking, ensure accessible implementations, and provide access to ADS styling features like design tokens."
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
create: function create(context) {
|
|
18
|
+
return {
|
|
19
|
+
// transforms styled.<anchor>(...) usages
|
|
20
|
+
CallExpression: function CallExpression(node) {
|
|
21
|
+
StyledComponent.lint(node, {
|
|
22
|
+
context: context
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
// transforms <anchor css={...}> usages
|
|
26
|
+
JSXElement: function JSXElement(node) {
|
|
27
|
+
_JSXElement.lint(node, {
|
|
28
|
+
context: context
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
export default rule;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as ast from '../../../../ast-nodes';
|
|
2
|
+
import { isSupportedForLint } from '../supported';
|
|
3
|
+
export var JSXElement = {
|
|
4
|
+
lint: function lint(node, _ref) {
|
|
5
|
+
var context = _ref.context;
|
|
6
|
+
if (!isSupportedForLint(node)) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
var nodeName = ast.JSXElement.getName(node);
|
|
10
|
+
context.report({
|
|
11
|
+
node: node.openingElement,
|
|
12
|
+
messageId: 'noHtmlSelect',
|
|
13
|
+
data: {
|
|
14
|
+
name: nodeName
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
2
|
+
|
|
3
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
+
import { getScope } from '@atlaskit/eslint-utils/context-compat';
|
|
5
|
+
import { getJsxElementByName } from '../../../utils/get-jsx-element-by-name';
|
|
6
|
+
import { getStyledComponentCall } from '../../../utils/get-styled-component-call';
|
|
7
|
+
import { isSupportedForLint } from '../supported';
|
|
8
|
+
export var StyledComponent = {
|
|
9
|
+
lint: function lint(node, _ref) {
|
|
10
|
+
var _getJsxElementByName;
|
|
11
|
+
var context = _ref.context;
|
|
12
|
+
if (!isNodeOfType(node, 'CallExpression') || !isNodeOfType(node.callee, 'MemberExpression') || !isNodeOfType(node.callee.object, 'Identifier') || !isNodeOfType(node.callee.property, 'Identifier')) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
var styles = getStyledComponentCall(node);
|
|
16
|
+
var elementName = node.callee.property.name;
|
|
17
|
+
if (!styles || !isNodeOfType(styles.id, 'Identifier')) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
var jsxElement = (_getJsxElementByName = getJsxElementByName(styles.id.name, getScope(context, node))) === null || _getJsxElementByName === void 0 ? void 0 : _getJsxElementByName.parent;
|
|
21
|
+
if (!jsxElement) {
|
|
22
|
+
// If there's no JSX element, we can't determine if it's being used as an select or not
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (jsxElement && !isSupportedForLint(jsxElement, elementName)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
context.report({
|
|
29
|
+
node: styles,
|
|
30
|
+
messageId: 'noHtmlSelect',
|
|
31
|
+
data: {
|
|
32
|
+
name: node.callee.property.name
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
+
import * as ast from '../../../ast-nodes';
|
|
3
|
+
var supportedElements = [{
|
|
4
|
+
name: 'select'
|
|
5
|
+
}];
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Determines if the given JSX element is a supported element to lint with this rule.
|
|
9
|
+
*/
|
|
10
|
+
export function isSupportedForLint(jsxNode, elementName) {
|
|
11
|
+
if (!isNodeOfType(jsxNode, 'JSXElement')) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Allow passing in the element name because the jsxNode doesn't
|
|
16
|
+
// represent the element name with styled components
|
|
17
|
+
var elName = elementName || ast.JSXElement.getName(jsxNode);
|
|
18
|
+
if (!elName) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Only check native HTML elements, not components
|
|
23
|
+
if (elName[0] !== elName[0].toLowerCase()) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
var supportedElement = supportedElements.find(function (_ref) {
|
|
27
|
+
var name = _ref.name;
|
|
28
|
+
return name === elName;
|
|
29
|
+
});
|
|
30
|
+
if (!supportedElement) {
|
|
31
|
+
supportedElement = supportedElements.find(function (_ref2) {
|
|
32
|
+
var name = _ref2.name;
|
|
33
|
+
return name === '*';
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (!supportedElement) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Check if the element has any attributes that are not supported
|
|
41
|
+
var attributes = ast.JSXElement.getAttributes(jsxNode);
|
|
42
|
+
if (supportedElement.attributes && !supportedElement.attributes.every(function (_ref3) {
|
|
43
|
+
var name = _ref3.name,
|
|
44
|
+
values = _ref3.values;
|
|
45
|
+
return attributes.some(function (attribute) {
|
|
46
|
+
if (attribute.type === 'JSXSpreadAttribute') {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
var isMatchingName = attribute.name.name === name;
|
|
50
|
+
var isMatchingValues = values && attribute.value && attribute.value.type === 'Literal' && typeof attribute.value.value === 'string' && (values === null || values === void 0 ? void 0 : values.includes(attribute.value.value));
|
|
51
|
+
return isMatchingName && isMatchingValues;
|
|
52
|
+
});
|
|
53
|
+
})) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
@@ -37,6 +37,7 @@ export declare const plugin: {
|
|
|
37
37
|
'no-html-checkbox': import("eslint").Rule.RuleModule;
|
|
38
38
|
'no-html-image': import("eslint").Rule.RuleModule;
|
|
39
39
|
'no-html-range': import("eslint").Rule.RuleModule;
|
|
40
|
+
'no-html-select': import("eslint").Rule.RuleModule;
|
|
40
41
|
'no-invalid-css-map': import("eslint").Rule.RuleModule;
|
|
41
42
|
'no-keyframes-tagged-template-expression': import("eslint").Rule.RuleModule;
|
|
42
43
|
'no-legacy-icons': import("eslint").Rule.RuleModule;
|
|
@@ -93,6 +94,7 @@ export declare const plugin: {
|
|
|
93
94
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
94
95
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
95
96
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
97
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
96
98
|
'@atlaskit/design-system/no-invalid-css-map': ["error", {
|
|
97
99
|
allowedFunctionCalls: string[][];
|
|
98
100
|
}];
|
|
@@ -153,6 +155,7 @@ export declare const plugin: {
|
|
|
153
155
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
154
156
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
155
157
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
158
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
156
159
|
'@atlaskit/design-system/no-invalid-css-map': ["error", {
|
|
157
160
|
allowedFunctionCalls: string[][];
|
|
158
161
|
}];
|
|
@@ -206,6 +209,7 @@ export declare const plugin: {
|
|
|
206
209
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
207
210
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
208
211
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
212
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
209
213
|
'@atlaskit/design-system/no-invalid-css-map': ["error", {
|
|
210
214
|
allowedFunctionCalls: string[][];
|
|
211
215
|
}];
|
|
@@ -250,6 +254,7 @@ export declare const plugin: {
|
|
|
250
254
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
251
255
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
252
256
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
257
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
253
258
|
'@atlaskit/design-system/no-invalid-css-map': ["error", {
|
|
254
259
|
allowedFunctionCalls: string[][];
|
|
255
260
|
}];
|
|
@@ -300,6 +305,7 @@ declare const configs: {
|
|
|
300
305
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
301
306
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
302
307
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
308
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
303
309
|
'@atlaskit/design-system/no-invalid-css-map': ["error", {
|
|
304
310
|
allowedFunctionCalls: string[][];
|
|
305
311
|
}];
|
|
@@ -360,6 +366,7 @@ declare const configs: {
|
|
|
360
366
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
361
367
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
362
368
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
369
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
363
370
|
'@atlaskit/design-system/no-invalid-css-map': ["error", {
|
|
364
371
|
allowedFunctionCalls: string[][];
|
|
365
372
|
}];
|
|
@@ -413,6 +420,7 @@ declare const configs: {
|
|
|
413
420
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
414
421
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
415
422
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
423
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
416
424
|
'@atlaskit/design-system/no-invalid-css-map': ["error", {
|
|
417
425
|
allowedFunctionCalls: string[][];
|
|
418
426
|
}];
|
|
@@ -457,6 +465,7 @@ declare const configs: {
|
|
|
457
465
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
458
466
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
459
467
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
468
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
460
469
|
'@atlaskit/design-system/no-invalid-css-map': ["error", {
|
|
461
470
|
allowedFunctionCalls: string[][];
|
|
462
471
|
}];
|
|
@@ -20,6 +20,7 @@ declare const _default: {
|
|
|
20
20
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
21
21
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
22
22
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
23
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
23
24
|
'@atlaskit/design-system/no-invalid-css-map': ["error", {
|
|
24
25
|
allowedFunctionCalls: string[][];
|
|
25
26
|
}];
|
|
@@ -20,6 +20,7 @@ declare const _default: {
|
|
|
20
20
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
21
21
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
22
22
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
23
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
23
24
|
'@atlaskit/design-system/no-invalid-css-map': ["error", {
|
|
24
25
|
allowedFunctionCalls: string[][];
|
|
25
26
|
}];
|
|
@@ -15,6 +15,7 @@ declare const _default: {
|
|
|
15
15
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
16
16
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
17
17
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
18
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
18
19
|
'@atlaskit/design-system/no-invalid-css-map': ["error", {
|
|
19
20
|
allowedFunctionCalls: string[][];
|
|
20
21
|
}];
|
|
@@ -15,6 +15,7 @@ declare const _default: {
|
|
|
15
15
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
16
16
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
17
17
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
18
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
18
19
|
'@atlaskit/design-system/no-invalid-css-map': ["error", {
|
|
19
20
|
allowedFunctionCalls: string[][];
|
|
20
21
|
}];
|
|
@@ -21,6 +21,7 @@ export declare const rules: {
|
|
|
21
21
|
'no-html-checkbox': import("eslint").Rule.RuleModule;
|
|
22
22
|
'no-html-image': import("eslint").Rule.RuleModule;
|
|
23
23
|
'no-html-range': import("eslint").Rule.RuleModule;
|
|
24
|
+
'no-html-select': import("eslint").Rule.RuleModule;
|
|
24
25
|
'no-invalid-css-map': import("eslint").Rule.RuleModule;
|
|
25
26
|
'no-keyframes-tagged-template-expression': import("eslint").Rule.RuleModule;
|
|
26
27
|
'no-legacy-icons': import("eslint").Rule.RuleModule;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type EslintNode } from 'eslint-codemod-utils';
|
|
2
|
+
/**
|
|
3
|
+
* Determines if the given JSX element is a supported element to lint with this rule.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isSupportedForLint(jsxNode: EslintNode, elementName?: string): jsxNode is Extract<EslintNode, {
|
|
6
|
+
type: 'JSXElement';
|
|
7
|
+
}>;
|
|
@@ -37,6 +37,7 @@ export declare const plugin: {
|
|
|
37
37
|
'no-html-checkbox': import("eslint").Rule.RuleModule;
|
|
38
38
|
'no-html-image': import("eslint").Rule.RuleModule;
|
|
39
39
|
'no-html-range': import("eslint").Rule.RuleModule;
|
|
40
|
+
'no-html-select': import("eslint").Rule.RuleModule;
|
|
40
41
|
'no-invalid-css-map': import("eslint").Rule.RuleModule;
|
|
41
42
|
'no-keyframes-tagged-template-expression': import("eslint").Rule.RuleModule;
|
|
42
43
|
'no-legacy-icons': import("eslint").Rule.RuleModule;
|
|
@@ -93,6 +94,7 @@ export declare const plugin: {
|
|
|
93
94
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
94
95
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
95
96
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
97
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
96
98
|
'@atlaskit/design-system/no-invalid-css-map': [
|
|
97
99
|
"error",
|
|
98
100
|
{
|
|
@@ -156,6 +158,7 @@ export declare const plugin: {
|
|
|
156
158
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
157
159
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
158
160
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
161
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
159
162
|
'@atlaskit/design-system/no-invalid-css-map': [
|
|
160
163
|
"error",
|
|
161
164
|
{
|
|
@@ -212,6 +215,7 @@ export declare const plugin: {
|
|
|
212
215
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
213
216
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
214
217
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
218
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
215
219
|
'@atlaskit/design-system/no-invalid-css-map': [
|
|
216
220
|
"error",
|
|
217
221
|
{
|
|
@@ -259,6 +263,7 @@ export declare const plugin: {
|
|
|
259
263
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
260
264
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
261
265
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
266
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
262
267
|
'@atlaskit/design-system/no-invalid-css-map': [
|
|
263
268
|
"error",
|
|
264
269
|
{
|
|
@@ -312,6 +317,7 @@ declare const configs: {
|
|
|
312
317
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
313
318
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
314
319
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
320
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
315
321
|
'@atlaskit/design-system/no-invalid-css-map': [
|
|
316
322
|
"error",
|
|
317
323
|
{
|
|
@@ -375,6 +381,7 @@ declare const configs: {
|
|
|
375
381
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
376
382
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
377
383
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
384
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
378
385
|
'@atlaskit/design-system/no-invalid-css-map': [
|
|
379
386
|
"error",
|
|
380
387
|
{
|
|
@@ -431,6 +438,7 @@ declare const configs: {
|
|
|
431
438
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
432
439
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
433
440
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
441
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
434
442
|
'@atlaskit/design-system/no-invalid-css-map': [
|
|
435
443
|
"error",
|
|
436
444
|
{
|
|
@@ -478,6 +486,7 @@ declare const configs: {
|
|
|
478
486
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
479
487
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
480
488
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
489
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
481
490
|
'@atlaskit/design-system/no-invalid-css-map': [
|
|
482
491
|
"error",
|
|
483
492
|
{
|
|
@@ -20,6 +20,7 @@ declare const _default: {
|
|
|
20
20
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
21
21
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
22
22
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
23
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
23
24
|
'@atlaskit/design-system/no-invalid-css-map': [
|
|
24
25
|
"error",
|
|
25
26
|
{
|
|
@@ -20,6 +20,7 @@ declare const _default: {
|
|
|
20
20
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
21
21
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
22
22
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
23
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
23
24
|
'@atlaskit/design-system/no-invalid-css-map': [
|
|
24
25
|
"error",
|
|
25
26
|
{
|
|
@@ -15,6 +15,7 @@ declare const _default: {
|
|
|
15
15
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
16
16
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
17
17
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
18
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
18
19
|
'@atlaskit/design-system/no-invalid-css-map': [
|
|
19
20
|
"error",
|
|
20
21
|
{
|
|
@@ -15,6 +15,7 @@ declare const _default: {
|
|
|
15
15
|
'@atlaskit/design-system/no-html-checkbox': "warn";
|
|
16
16
|
'@atlaskit/design-system/no-html-image': "warn";
|
|
17
17
|
'@atlaskit/design-system/no-html-range': "warn";
|
|
18
|
+
'@atlaskit/design-system/no-html-select': "warn";
|
|
18
19
|
'@atlaskit/design-system/no-invalid-css-map': [
|
|
19
20
|
"error",
|
|
20
21
|
{
|
|
@@ -21,6 +21,7 @@ export declare const rules: {
|
|
|
21
21
|
'no-html-checkbox': import("eslint").Rule.RuleModule;
|
|
22
22
|
'no-html-image': import("eslint").Rule.RuleModule;
|
|
23
23
|
'no-html-range': import("eslint").Rule.RuleModule;
|
|
24
|
+
'no-html-select': import("eslint").Rule.RuleModule;
|
|
24
25
|
'no-invalid-css-map': import("eslint").Rule.RuleModule;
|
|
25
26
|
'no-keyframes-tagged-template-expression': import("eslint").Rule.RuleModule;
|
|
26
27
|
'no-legacy-icons': import("eslint").Rule.RuleModule;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type EslintNode } from 'eslint-codemod-utils';
|
|
2
|
+
/**
|
|
3
|
+
* Determines if the given JSX element is a supported element to lint with this rule.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isSupportedForLint(jsxNode: EslintNode, elementName?: string): jsxNode is Extract<EslintNode, {
|
|
6
|
+
type: 'JSXElement';
|
|
7
|
+
}>;
|
package/package.json
CHANGED