@atlaskit/eslint-plugin-design-system 13.32.0 → 13.33.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 +7 -0
- package/README.md +76 -75
- 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/use-simple-field/index.js +138 -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/use-simple-field/index.js +124 -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/use-simple-field/index.js +132 -0
- package/dist/types/presets/all-flat.codegen.d.ts +1 -1
- package/dist/types/presets/all.codegen.d.ts +1 -1
- package/dist/types/presets/recommended-flat.codegen.d.ts +1 -1
- package/dist/types/presets/recommended.codegen.d.ts +1 -1
- package/dist/types/rules/index.codegen.d.ts +1 -1
- package/dist/types/rules/use-simple-field/index.d.ts +4 -0
- package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +1 -1
- package/dist/types-ts4.5/presets/all.codegen.d.ts +1 -1
- package/dist/types-ts4.5/presets/recommended-flat.codegen.d.ts +1 -1
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +1 -1
- package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -1
- package/dist/types-ts4.5/rules/use-simple-field/index.d.ts +4 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 13.33.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`dfd88c3eda55b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/dfd88c3eda55b) -
|
|
8
|
+
Add rule to enforce simplified fields in form implementations.
|
|
9
|
+
|
|
3
10
|
## 13.32.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -47,80 +47,81 @@ module.exports = {
|
|
|
47
47
|
<!-- START_RULE_TABLE_CODEGEN -->
|
|
48
48
|
<!-- @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen -->
|
|
49
49
|
|
|
50
|
-
| Rule
|
|
51
|
-
|
|
|
52
|
-
| <a href="./src/rules/consistent-css-prop-usage/README.md">consistent-css-prop-usage</a> | Ensures consistency with `css` and `xcss` prop usages | Yes | Yes | |
|
|
53
|
-
| <a href="./src/rules/enforce-inline-styles-in-select/README.md">enforce-inline-styles-in-select</a> | Disallow unsupported CSS selectors in styles prop for @atlaskit/select and require inline styles only | | | |
|
|
54
|
-
| <a href="./src/rules/ensure-design-token-usage/README.md">ensure-design-token-usage</a> | Enforces usage of design tokens rather than hard-coded values. | Yes | Yes | Yes |
|
|
55
|
-
| <a href="./src/rules/ensure-design-token-usage-preview/README.md">ensure-design-token-usage/preview</a> | Enforces usage of pre-release design tokens rather than hard-coded values. | | Yes | Yes |
|
|
56
|
-
| <a href="./src/rules/ensure-icon-color/README.md">ensure-icon-color</a> | Enforces that upcoming icon components have a color prop set, to enable a migration of the default value. | | | |
|
|
57
|
-
| <a href="./src/rules/ensure-proper-xcss-usage/README.md">ensure-proper-xcss-usage</a> | Enforces proper xcss usage: migrate from xcss() to cssMap() and use cssMap objects with specific keys. | | | |
|
|
58
|
-
| <a href="./src/rules/icon-label/README.md">icon-label</a> | Enforces accessible usage of icon labels when composed with Atlassian Design System components. | Yes | Yes | |
|
|
59
|
-
| <a href="./src/rules/lozenge-badge-tag-labelling-system-migration/README.md">lozenge-badge-tag-labelling-system-migration</a> | Helps migrate Lozenge isBold prop, Badge appearance values, and SimpleTag/RemovableTag components as part of the Labelling System Phase 1 migration. | | Yes | |
|
|
60
|
-
| <a href="./src/rules/no-banned-imports/README.md">no-banned-imports</a> | Disallow importing banned modules. | Yes | | |
|
|
61
|
-
| <a href="./src/rules/no-boolean-autofocus-on-modal-dialog/README.md">no-boolean-autofocus-on-modal-dialog</a> | Encourages makers to not use boolean values for `autoFocus` on Atlassian Design System's modal dialog component. | Yes | | |
|
|
62
|
-
| <a href="./src/rules/no-css-tagged-template-expression/README.md">no-css-tagged-template-expression</a> | Disallows any `css` tagged template expressions that originate from Emotion, Styled Components or Compiled | | Yes | |
|
|
63
|
-
| <a href="./src/rules/no-custom-icons/README.md">no-custom-icons</a> | Enforces custom glyph icons are used. | | | |
|
|
64
|
-
| <a href="./src/rules/no-dark-theme-vr-tests/README.md">no-dark-theme-vr-tests</a> | Disallow using dark colorScheme in VR tests. | | Yes | |
|
|
65
|
-
| <a href="./src/rules/no-deprecated-apis/README.md">no-deprecated-apis</a> | Disallow using deprecated APIs. | Yes | | |
|
|
66
|
-
| <a href="./src/rules/no-deprecated-design-token-usage/README.md">no-deprecated-design-token-usage</a> | Disallow using deprecated design tokens. | Yes | Yes | |
|
|
67
|
-
| <a href="./src/rules/no-deprecated-imports/README.md">no-deprecated-imports</a> | Disallow importing deprecated modules. | Yes | Yes | Yes |
|
|
68
|
-
| <a href="./src/rules/no-direct-use-of-web-platform-drag-and-drop/README.md">no-direct-use-of-web-platform-drag-and-drop</a> | Disallow using direct use of native drag and drop (please use Pragmatic drag and drop) | Yes | | |
|
|
69
|
-
| <a href="./src/rules/no-emotion-primitives/README.md">no-emotion-primitives</a> | Ensures usage of Compiled Primitives import instead of Emotion entrypoint. | | Yes | |
|
|
70
|
-
| <a href="./src/rules/no-empty-styled-expression/README.md">no-empty-styled-expression</a> | Forbids any styled expression to be used when passing empty arguments to styled.div() (or other JSX elements). | | | |
|
|
71
|
-
| <a href="./src/rules/no-exported-css/README.md">no-exported-css</a> | Forbid exporting `css` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable. | | | |
|
|
72
|
-
| <a href="./src/rules/no-exported-keyframes/README.md">no-exported-keyframes</a> | Forbid exporting `keyframes` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable. | | | |
|
|
73
|
-
| <a href="./src/rules/no-html-anchor/README.md">no-html-anchor</a> | Discourage direct usage of HTML anchor elements in favor of Atlassian Design System link components. | Yes | | Yes |
|
|
74
|
-
| <a href="./src/rules/no-html-button/README.md">no-html-button</a> | Discourage direct usage of HTML button elements in favor of Atlassian Design System button components. | Yes | | |
|
|
75
|
-
| <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 |
|
|
76
|
-
| <a href="./src/rules/no-html-code/README.md">no-html-code</a> | Discourage direct usage of HTML code elements in favor of the Atlassian Design System code component. | Yes | | Yes |
|
|
77
|
-
| <a href="./src/rules/no-html-heading/README.md">no-html-heading</a> | Discourage direct usage of HTML heading elements in favor of Atlassian Design System heading components. | Yes | | Yes |
|
|
78
|
-
| <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 |
|
|
79
|
-
| <a href="./src/rules/no-html-radio/README.md">no-html-radio</a> | Discourage direct usage of HTML radio elements in favor of the Atlassian Design System radio component. | Yes | | Yes |
|
|
80
|
-
| <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 |
|
|
81
|
-
| <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 |
|
|
82
|
-
| <a href="./src/rules/no-html-text-input/README.md">no-html-text-input</a> | Discourage direct usage of HTML text input elements in favor of the Atlassian Design System textfield component. | Yes | | Yes |
|
|
83
|
-
| <a href="./src/rules/no-html-textarea/README.md">no-html-textarea</a> | Discourage direct usage of HTML textarea elements in favor of the Atlassian Design System textarea component. | Yes | | Yes |
|
|
84
|
-
| <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 | | |
|
|
85
|
-
| <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 | |
|
|
86
|
-
| <a href="./src/rules/no-legacy-icons/README.md">no-legacy-icons</a> | Enforces no legacy icons are used. | | Yes | Yes |
|
|
87
|
-
| <a href="./src/rules/no-margin/README.md">no-margin</a> | Disallow using the margin CSS property. | | | |
|
|
88
|
-
| <a href="./src/rules/no-nested-styles/README.md">no-nested-styles</a> | Disallows use of nested styles in `css` functions. | Yes | | |
|
|
89
|
-
| <a href="./src/rules/no-physical-properties/README.md">no-physical-properties</a> | Disallow physical properties and values in `css` and `cssMap` function calls. | | Yes | |
|
|
90
|
-
| <a href="./src/rules/no-placeholder/README.md">no-placeholder</a> | Placeholders should not be used. If information should be given to the user about the proper type or formatting of a value, this should be included using a helper message that is associated to the input instead. | Yes | | |
|
|
91
|
-
| <a href="./src/rules/no-separator-with-list-elements/README.md">no-separator-with-list-elements</a> | Warn when the `separator` prop is used with `as="li"`, `as="ol"`, or `as="dl"` in the Inline component. | Yes | | |
|
|
92
|
-
| <a href="./src/rules/no-styled-tagged-template-expression/README.md">no-styled-tagged-template-expression</a> | Disallows any `styled` tagged template expressions that originate from Emotion, Styled Components or Compiled | | Yes | |
|
|
93
|
-
| <a href="./src/rules/no-to-match-snapshot/README.md">no-to-match-snapshot</a> | Disallow using toMatchSnapshot() in favor of toMatchInlineSnapshot(). See https://hello.atlassian.net/wiki/spaces/DST/pages/6105892000/DSTRFC-038+-+Removal+of+.toMatchSnapshot for rationale. | | | |
|
|
94
|
-
| <a href="./src/rules/no-unsafe-design-token-usage/README.md">no-unsafe-design-token-usage</a> | Enforces design token usage is statically and locally analyzable. | Yes | Yes | |
|
|
95
|
-
| <a href="./src/rules/no-unsafe-inline-snapshot/README.md">no-unsafe-inline-snapshot</a> | Enforce guardrails on toMatchInlineSnapshot usage: snapshots must not exceed 100 lines and must not contain internal implementation details like className or style attributes. | | | |
|
|
96
|
-
| <a href="./src/rules/no-unsafe-style-overrides/README.md">no-unsafe-style-overrides</a> | Discourage usage of unsafe style overrides used against the Atlassian Design System. | Yes | | |
|
|
97
|
-
| <a href="./src/rules/no-unsupported-drag-and-drop-libraries/README.md">no-unsupported-drag-and-drop-libraries</a> | Disallow importing unsupported drag and drop modules. | Yes | | |
|
|
98
|
-
| <a href="./src/rules/no-unused-css-map/README.md">no-unused-css-map</a> | Detects unused styles in cssMap objects to help keep code clean. | Yes | | |
|
|
99
|
-
| <a href="./src/rules/prefer-primitives/README.md">prefer-primitives</a> | Increase awareness of primitive components via code hints. Strictly used for education purposes and discoverability. To enforce usage please refer to the `use-primitives` rule. | | | |
|
|
100
|
-
| <a href="./src/rules/use-button-group-label/README.md">use-button-group-label</a> | Ensures button groups are described to assistive technology by a direct label or by another element. | Yes | | Yes |
|
|
101
|
-
| <a href="./src/rules/use-character-counter-field/README.md">use-character-counter-field</a> | Suggests using CharacterCounterField or CharacterCounter when Textfield or Textarea components have maxLength or minLength props. | Yes | | |
|
|
102
|
-
| <a href="./src/rules/use-correct-field/README.md">use-correct-field</a> | Ensure makers use appropriate field component for their respective form elements. | Yes | Yes | Yes |
|
|
103
|
-
| <a href="./src/rules/use-cx-function-in-xcss/README.md">use-cx-function-in-xcss</a> | Enforces cx function use to combine styles in xcss. | Yes | Yes | Yes |
|
|
104
|
-
| <a href="./src/rules/use-datetime-picker-calendar-button/README.md">use-datetime-picker-calendar-button</a> | Encourages makers to use calendar button in Atlassian Design System's date picker and datetime picker components. | Yes | Yes | Yes |
|
|
105
|
-
| <a href="./src/rules/use-drawer-label/README.md">use-drawer-label</a> | Encourages to provide accessible name for Atlassian Design System Drawer component. | Yes | | Yes |
|
|
106
|
-
| <a href="./src/rules/use-field-message-wrapper/README.md">use-field-message-wrapper</a> | Encourage use of message wrapper component when using form message components. | Yes | | Yes |
|
|
107
|
-
| <a href="./src/rules/use-heading/README.md">use-heading</a> | Encourage the usage of heading components. | Yes | Yes | Yes |
|
|
108
|
-
| <a href="./src/rules/use-heading-level-in-spotlight-card/README.md">use-heading-level-in-spotlight-card</a> | Inform developers of eventual requirement of `headingLevel` prop in `SpotlightCard` component. The heading level should be the appropriate level according to the surrounding context. | Yes | Yes | |
|
|
109
|
-
| <a href="./src/rules/use-href-in-link-item/README.md">use-href-in-link-item</a> | Inform developers of eventual requirement of `href` prop in `LinkItem` component. Elements with a `link` role require an `href` attribute for users to properly navigate, particularly those using assistive technologies. If no valid `href` is required for your use case, consider using a `ButtonItem` instead. | Yes | Yes | Yes |
|
|
110
|
-
| <a href="./src/rules/use-latest-xcss-syntax/README.md">use-latest-xcss-syntax</a> | Enforces usage of space design tokens rather than hard-coded values in xcss. | Yes | Yes | |
|
|
111
|
-
| <a href="./src/rules/use-latest-xcss-syntax-typography/README.md">use-latest-xcss-syntax-typography</a> | Prohibits use of unsafe styling properties in xcss. Please use Text/Heading primitives instead. | Yes | Yes | |
|
|
112
|
-
| <a href="./src/rules/use-menu-section-title/README.md">use-menu-section-title</a> | Encourages makers to provide accessible title for Atlassian Design System Menu Section component. | Yes | | Yes |
|
|
113
|
-
| <a href="./src/rules/use-modal-dialog-close-button/README.md">use-modal-dialog-close-button</a> | Encourages makers to use close button in Atlassian Design System's modal dialog component. | Yes | Yes | Yes |
|
|
114
|
-
| <a href="./src/rules/use-onboarding-spotlight-label/README.md">use-onboarding-spotlight-label</a> | Ensures onboarding spotlight dialogs are described to assistive technology by a direct label or by another element. | Yes | | Yes |
|
|
115
|
-
| <a href="./src/rules/use-popup-label/README.md">use-popup-label</a> | Encourages to provide accessible name for Atlassian Design System Popup component. | Yes | | Yes |
|
|
116
|
-
| <a href="./src/rules/use-primitives/README.md">use-primitives</a> | Encourage the usage of primitives components. | | Yes | Yes |
|
|
117
|
-
| <a href="./src/rules/use-primitives-text/README.md">use-primitives-text</a> | Encourage the usage of text components. | Yes | Yes | Yes |
|
|
118
|
-
| <a href="./src/rules/use-should-render-to-parent/README.md">use-should-render-to-parent</a> | Encourages makers to use the `shouldRenderToParent` where possible in Atlassian Design System `Popup` and `DropdownMenu` components. | Yes | | Yes |
|
|
119
|
-
| <a href="./src/rules/use-
|
|
120
|
-
| <a href="./src/rules/use-
|
|
121
|
-
| <a href="./src/rules/use-
|
|
122
|
-
| <a href="./src/rules/use-tokens-
|
|
123
|
-
| <a href="./src/rules/use-tokens-
|
|
124
|
-
| <a href="./src/rules/use-
|
|
50
|
+
| Rule | Description | Recommended | Fixable | Suggestions |
|
|
51
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | ------- | ----------- |
|
|
52
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/consistent-css-prop-usage/README.md">consistent-css-prop-usage</a> | Ensures consistency with `css` and `xcss` prop usages | Yes | Yes | |
|
|
53
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/enforce-inline-styles-in-select/README.md">enforce-inline-styles-in-select</a> | Disallow unsupported CSS selectors in styles prop for @atlaskit/select and require inline styles only | | | |
|
|
54
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/ensure-design-token-usage/README.md">ensure-design-token-usage</a> | Enforces usage of design tokens rather than hard-coded values. | Yes | Yes | Yes |
|
|
55
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/ensure-design-token-usage-preview/README.md">ensure-design-token-usage/preview</a> | Enforces usage of pre-release design tokens rather than hard-coded values. | | Yes | Yes |
|
|
56
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/ensure-icon-color/README.md">ensure-icon-color</a> | Enforces that upcoming icon components have a color prop set, to enable a migration of the default value. | | | |
|
|
57
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/ensure-proper-xcss-usage/README.md">ensure-proper-xcss-usage</a> | Enforces proper xcss usage: migrate from xcss() to cssMap() and use cssMap objects with specific keys. | | | |
|
|
58
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/icon-label/README.md">icon-label</a> | Enforces accessible usage of icon labels when composed with Atlassian Design System components. | Yes | Yes | |
|
|
59
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/lozenge-badge-tag-labelling-system-migration/README.md">lozenge-badge-tag-labelling-system-migration</a> | Helps migrate Lozenge isBold prop, Badge appearance values, and SimpleTag/RemovableTag components as part of the Labelling System Phase 1 migration. | | Yes | |
|
|
60
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-banned-imports/README.md">no-banned-imports</a> | Disallow importing banned modules. | Yes | | |
|
|
61
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-boolean-autofocus-on-modal-dialog/README.md">no-boolean-autofocus-on-modal-dialog</a> | Encourages makers to not use boolean values for `autoFocus` on Atlassian Design System's modal dialog component. | Yes | | |
|
|
62
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-css-tagged-template-expression/README.md">no-css-tagged-template-expression</a> | Disallows any `css` tagged template expressions that originate from Emotion, Styled Components or Compiled | | Yes | |
|
|
63
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-custom-icons/README.md">no-custom-icons</a> | Enforces custom glyph icons are used. | | | |
|
|
64
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-dark-theme-vr-tests/README.md">no-dark-theme-vr-tests</a> | Disallow using dark colorScheme in VR tests. | | Yes | |
|
|
65
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-deprecated-apis/README.md">no-deprecated-apis</a> | Disallow using deprecated APIs. | Yes | | |
|
|
66
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-deprecated-design-token-usage/README.md">no-deprecated-design-token-usage</a> | Disallow using deprecated design tokens. | Yes | Yes | |
|
|
67
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-deprecated-imports/README.md">no-deprecated-imports</a> | Disallow importing deprecated modules. | Yes | Yes | Yes |
|
|
68
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-direct-use-of-web-platform-drag-and-drop/README.md">no-direct-use-of-web-platform-drag-and-drop</a> | Disallow using direct use of native drag and drop (please use Pragmatic drag and drop) | Yes | | |
|
|
69
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-emotion-primitives/README.md">no-emotion-primitives</a> | Ensures usage of Compiled Primitives import instead of Emotion entrypoint. | | Yes | |
|
|
70
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-empty-styled-expression/README.md">no-empty-styled-expression</a> | Forbids any styled expression to be used when passing empty arguments to styled.div() (or other JSX elements). | | | |
|
|
71
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-exported-css/README.md">no-exported-css</a> | Forbid exporting `css` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable. | | | |
|
|
72
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-exported-keyframes/README.md">no-exported-keyframes</a> | Forbid exporting `keyframes` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable. | | | |
|
|
73
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-html-anchor/README.md">no-html-anchor</a> | Discourage direct usage of HTML anchor elements in favor of Atlassian Design System link components. | Yes | | Yes |
|
|
74
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-html-button/README.md">no-html-button</a> | Discourage direct usage of HTML button elements in favor of Atlassian Design System button components. | Yes | | |
|
|
75
|
+
| <a href="./packages/design-system/eslint-plugin/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 |
|
|
76
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-html-code/README.md">no-html-code</a> | Discourage direct usage of HTML code elements in favor of the Atlassian Design System code component. | Yes | | Yes |
|
|
77
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-html-heading/README.md">no-html-heading</a> | Discourage direct usage of HTML heading elements in favor of Atlassian Design System heading components. | Yes | | Yes |
|
|
78
|
+
| <a href="./packages/design-system/eslint-plugin/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 |
|
|
79
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-html-radio/README.md">no-html-radio</a> | Discourage direct usage of HTML radio elements in favor of the Atlassian Design System radio component. | Yes | | Yes |
|
|
80
|
+
| <a href="./packages/design-system/eslint-plugin/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 |
|
|
81
|
+
| <a href="./packages/design-system/eslint-plugin/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 |
|
|
82
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-html-text-input/README.md">no-html-text-input</a> | Discourage direct usage of HTML text input elements in favor of the Atlassian Design System textfield component. | Yes | | Yes |
|
|
83
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-html-textarea/README.md">no-html-textarea</a> | Discourage direct usage of HTML textarea elements in favor of the Atlassian Design System textarea component. | Yes | | Yes |
|
|
84
|
+
| <a href="./packages/design-system/eslint-plugin/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 | | |
|
|
85
|
+
| <a href="./packages/design-system/eslint-plugin/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 | |
|
|
86
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-legacy-icons/README.md">no-legacy-icons</a> | Enforces no legacy icons are used. | | Yes | Yes |
|
|
87
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-margin/README.md">no-margin</a> | Disallow using the margin CSS property. | | | |
|
|
88
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-nested-styles/README.md">no-nested-styles</a> | Disallows use of nested styles in `css` functions. | Yes | | |
|
|
89
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-physical-properties/README.md">no-physical-properties</a> | Disallow physical properties and values in `css` and `cssMap` function calls. | | Yes | |
|
|
90
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-placeholder/README.md">no-placeholder</a> | Placeholders should not be used. If information should be given to the user about the proper type or formatting of a value, this should be included using a helper message that is associated to the input instead. | Yes | | |
|
|
91
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-separator-with-list-elements/README.md">no-separator-with-list-elements</a> | Warn when the `separator` prop is used with `as="li"`, `as="ol"`, or `as="dl"` in the Inline component. | Yes | | |
|
|
92
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-styled-tagged-template-expression/README.md">no-styled-tagged-template-expression</a> | Disallows any `styled` tagged template expressions that originate from Emotion, Styled Components or Compiled | | Yes | |
|
|
93
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-to-match-snapshot/README.md">no-to-match-snapshot</a> | Disallow using toMatchSnapshot() in favor of toMatchInlineSnapshot(). See https://hello.atlassian.net/wiki/spaces/DST/pages/6105892000/DSTRFC-038+-+Removal+of+.toMatchSnapshot for rationale. | | | |
|
|
94
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-unsafe-design-token-usage/README.md">no-unsafe-design-token-usage</a> | Enforces design token usage is statically and locally analyzable. | Yes | Yes | |
|
|
95
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-unsafe-inline-snapshot/README.md">no-unsafe-inline-snapshot</a> | Enforce guardrails on toMatchInlineSnapshot usage: snapshots must not exceed 100 lines and must not contain internal implementation details like className or style attributes. | | | |
|
|
96
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-unsafe-style-overrides/README.md">no-unsafe-style-overrides</a> | Discourage usage of unsafe style overrides used against the Atlassian Design System. | Yes | | |
|
|
97
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-unsupported-drag-and-drop-libraries/README.md">no-unsupported-drag-and-drop-libraries</a> | Disallow importing unsupported drag and drop modules. | Yes | | |
|
|
98
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-unused-css-map/README.md">no-unused-css-map</a> | Detects unused styles in cssMap objects to help keep code clean. | Yes | | |
|
|
99
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/prefer-primitives/README.md">prefer-primitives</a> | Increase awareness of primitive components via code hints. Strictly used for education purposes and discoverability. To enforce usage please refer to the `use-primitives` rule. | | | |
|
|
100
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-button-group-label/README.md">use-button-group-label</a> | Ensures button groups are described to assistive technology by a direct label or by another element. | Yes | | Yes |
|
|
101
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-character-counter-field/README.md">use-character-counter-field</a> | Suggests using CharacterCounterField or CharacterCounter when Textfield or Textarea components have maxLength or minLength props. | Yes | | |
|
|
102
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-correct-field/README.md">use-correct-field</a> | Ensure makers use appropriate field component for their respective form elements. | Yes | Yes | Yes |
|
|
103
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-cx-function-in-xcss/README.md">use-cx-function-in-xcss</a> | Enforces cx function use to combine styles in xcss. | Yes | Yes | Yes |
|
|
104
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-datetime-picker-calendar-button/README.md">use-datetime-picker-calendar-button</a> | Encourages makers to use calendar button in Atlassian Design System's date picker and datetime picker components. | Yes | Yes | Yes |
|
|
105
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-drawer-label/README.md">use-drawer-label</a> | Encourages to provide accessible name for Atlassian Design System Drawer component. | Yes | | Yes |
|
|
106
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-field-message-wrapper/README.md">use-field-message-wrapper</a> | Encourage use of message wrapper component when using form message components. | Yes | | Yes |
|
|
107
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-heading/README.md">use-heading</a> | Encourage the usage of heading components. | Yes | Yes | Yes |
|
|
108
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-heading-level-in-spotlight-card/README.md">use-heading-level-in-spotlight-card</a> | Inform developers of eventual requirement of `headingLevel` prop in `SpotlightCard` component. The heading level should be the appropriate level according to the surrounding context. | Yes | Yes | |
|
|
109
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-href-in-link-item/README.md">use-href-in-link-item</a> | Inform developers of eventual requirement of `href` prop in `LinkItem` component. Elements with a `link` role require an `href` attribute for users to properly navigate, particularly those using assistive technologies. If no valid `href` is required for your use case, consider using a `ButtonItem` instead. | Yes | Yes | Yes |
|
|
110
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-latest-xcss-syntax/README.md">use-latest-xcss-syntax</a> | Enforces usage of space design tokens rather than hard-coded values in xcss. | Yes | Yes | |
|
|
111
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-latest-xcss-syntax-typography/README.md">use-latest-xcss-syntax-typography</a> | Prohibits use of unsafe styling properties in xcss. Please use Text/Heading primitives instead. | Yes | Yes | |
|
|
112
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-menu-section-title/README.md">use-menu-section-title</a> | Encourages makers to provide accessible title for Atlassian Design System Menu Section component. | Yes | | Yes |
|
|
113
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-modal-dialog-close-button/README.md">use-modal-dialog-close-button</a> | Encourages makers to use close button in Atlassian Design System's modal dialog component. | Yes | Yes | Yes |
|
|
114
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-onboarding-spotlight-label/README.md">use-onboarding-spotlight-label</a> | Ensures onboarding spotlight dialogs are described to assistive technology by a direct label or by another element. | Yes | | Yes |
|
|
115
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-popup-label/README.md">use-popup-label</a> | Encourages to provide accessible name for Atlassian Design System Popup component. | Yes | | Yes |
|
|
116
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-primitives/README.md">use-primitives</a> | Encourage the usage of primitives components. | | Yes | Yes |
|
|
117
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-primitives-text/README.md">use-primitives-text</a> | Encourage the usage of text components. | Yes | Yes | Yes |
|
|
118
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-should-render-to-parent/README.md">use-should-render-to-parent</a> | Encourages makers to use the `shouldRenderToParent` where possible in Atlassian Design System `Popup` and `DropdownMenu` components. | Yes | | Yes |
|
|
119
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-simple-field/README.md">use-simple-field</a> | Encourage use of simple field for better developer experience and accessibility. | Yes | | Yes |
|
|
120
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-spotlight-package/README.md">use-spotlight-package</a> | Discourage the use of @atlaskit/onboarding in favor of @atlaskit/spotlight. | | Yes | Yes |
|
|
121
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-tag-group-label/README.md">use-tag-group-label</a> | Ensures tag groups are described to assistive technology by a direct label or by another element. | Yes | | Yes |
|
|
122
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-tokens-shape/README.md">use-tokens-shape</a> | Enforces usage of shape design tokens rather than hard-coded values. | | Yes | Yes |
|
|
123
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-tokens-space/README.md">use-tokens-space</a> | Enforces usage of space design tokens rather than hard-coded values. | | Yes | Yes |
|
|
124
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-tokens-typography/README.md">use-tokens-typography</a> | Enforces usage of design tokens for typography properties rather than hard-coded values. | Yes | Yes | Yes |
|
|
125
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/use-visually-hidden/README.md">use-visually-hidden</a> | Enforce usage of the visually hidden component. | Yes | Yes | |
|
|
125
126
|
|
|
126
127
|
<!-- END_RULE_TABLE_CODEGEN -->
|
|
@@ -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::05e8a8ff80cb4a88a89ccd31570686f6>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -80,6 +80,7 @@ var rules = {
|
|
|
80
80
|
'@atlaskit/design-system/use-primitives': 'warn',
|
|
81
81
|
'@atlaskit/design-system/use-primitives-text': 'warn',
|
|
82
82
|
'@atlaskit/design-system/use-should-render-to-parent': 'warn',
|
|
83
|
+
'@atlaskit/design-system/use-simple-field': 'warn',
|
|
83
84
|
'@atlaskit/design-system/use-spotlight-package': 'warn',
|
|
84
85
|
'@atlaskit/design-system/use-tag-group-label': 'warn',
|
|
85
86
|
'@atlaskit/design-system/use-tokens-shape': 'error',
|
|
@@ -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::f2a8bbab8acdaf84ca6e295124378517>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -79,6 +79,7 @@ var rules = {
|
|
|
79
79
|
'@atlaskit/design-system/use-primitives': 'warn',
|
|
80
80
|
'@atlaskit/design-system/use-primitives-text': 'warn',
|
|
81
81
|
'@atlaskit/design-system/use-should-render-to-parent': 'warn',
|
|
82
|
+
'@atlaskit/design-system/use-simple-field': 'warn',
|
|
82
83
|
'@atlaskit/design-system/use-spotlight-package': 'warn',
|
|
83
84
|
'@atlaskit/design-system/use-tag-group-label': 'warn',
|
|
84
85
|
'@atlaskit/design-system/use-tokens-shape': 'error',
|
|
@@ -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::2ca5e0a897270a5cfe3e234d7948ed0f>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -62,6 +62,7 @@ var rules = {
|
|
|
62
62
|
'@atlaskit/design-system/use-popup-label': 'warn',
|
|
63
63
|
'@atlaskit/design-system/use-primitives-text': 'warn',
|
|
64
64
|
'@atlaskit/design-system/use-should-render-to-parent': 'warn',
|
|
65
|
+
'@atlaskit/design-system/use-simple-field': 'warn',
|
|
65
66
|
'@atlaskit/design-system/use-tag-group-label': 'warn',
|
|
66
67
|
'@atlaskit/design-system/use-tokens-typography': 'warn',
|
|
67
68
|
'@atlaskit/design-system/use-visually-hidden': 'error'
|
|
@@ -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::aee2986e6e48e70acef7dfa4ba53747d>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -61,6 +61,7 @@ var rules = {
|
|
|
61
61
|
'@atlaskit/design-system/use-popup-label': 'warn',
|
|
62
62
|
'@atlaskit/design-system/use-primitives-text': 'warn',
|
|
63
63
|
'@atlaskit/design-system/use-should-render-to-parent': 'warn',
|
|
64
|
+
'@atlaskit/design-system/use-simple-field': 'warn',
|
|
64
65
|
'@atlaskit/design-system/use-tag-group-label': 'warn',
|
|
65
66
|
'@atlaskit/design-system/use-tokens-typography': 'warn',
|
|
66
67
|
'@atlaskit/design-system/use-visually-hidden': 'error'
|
|
@@ -72,6 +72,7 @@ var _usePopupLabel = _interopRequireDefault(require("./use-popup-label"));
|
|
|
72
72
|
var _usePrimitives = _interopRequireDefault(require("./use-primitives"));
|
|
73
73
|
var _usePrimitivesText = _interopRequireDefault(require("./use-primitives-text"));
|
|
74
74
|
var _useShouldRenderToParent = _interopRequireDefault(require("./use-should-render-to-parent"));
|
|
75
|
+
var _useSimpleField = _interopRequireDefault(require("./use-simple-field"));
|
|
75
76
|
var _useSpotlightPackage = _interopRequireDefault(require("./use-spotlight-package"));
|
|
76
77
|
var _useTagGroupLabel = _interopRequireDefault(require("./use-tag-group-label"));
|
|
77
78
|
var _useTokensShape = _interopRequireDefault(require("./use-tokens-shape"));
|
|
@@ -80,7 +81,7 @@ var _useTokensTypography = _interopRequireDefault(require("./use-tokens-typograp
|
|
|
80
81
|
var _useVisuallyHidden = _interopRequireDefault(require("./use-visually-hidden"));
|
|
81
82
|
/**
|
|
82
83
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
83
|
-
* @codegen <<SignedSource::
|
|
84
|
+
* @codegen <<SignedSource::030718cab57dce4d3b39031485e53af4>>
|
|
84
85
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
85
86
|
*/
|
|
86
87
|
|
|
@@ -152,6 +153,7 @@ var rules = exports.rules = {
|
|
|
152
153
|
'use-primitives': _usePrimitives.default,
|
|
153
154
|
'use-primitives-text': _usePrimitivesText.default,
|
|
154
155
|
'use-should-render-to-parent': _useShouldRenderToParent.default,
|
|
156
|
+
'use-simple-field': _useSimpleField.default,
|
|
155
157
|
'use-spotlight-package': _useSpotlightPackage.default,
|
|
156
158
|
'use-tag-group-label': _useTagGroupLabel.default,
|
|
157
159
|
'use-tokens-shape': _useTokensShape.default,
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.convertField = void 0;
|
|
7
|
+
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
8
|
+
var _createRule = require("../utils/create-rule");
|
|
9
|
+
var FORM_PACKAGE = '@atlaskit/form';
|
|
10
|
+
var MESSAGE_COMPONENTS = ['ErrorMessage', 'HelperMessage', 'ValidMessage'];
|
|
11
|
+
var convertField = exports.convertField = 'Convert field to simple field';
|
|
12
|
+
var rule = (0, _createRule.createLintRule)({
|
|
13
|
+
meta: {
|
|
14
|
+
name: 'use-simple-field',
|
|
15
|
+
type: 'suggestion',
|
|
16
|
+
hasSuggestions: true,
|
|
17
|
+
docs: {
|
|
18
|
+
description: 'Encourage use of simple field for better developer experience and accessibility.',
|
|
19
|
+
recommended: true,
|
|
20
|
+
severity: 'warn'
|
|
21
|
+
},
|
|
22
|
+
messages: {
|
|
23
|
+
useSimpleField: 'The simplified field implementation can be used here.'
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
create: function create(context) {
|
|
27
|
+
var fieldImport;
|
|
28
|
+
var messageImports = [];
|
|
29
|
+
return {
|
|
30
|
+
ImportDeclaration: function ImportDeclaration(node) {
|
|
31
|
+
var source = node.source.value;
|
|
32
|
+
|
|
33
|
+
// Ignore anomalies
|
|
34
|
+
if (typeof source !== 'string') {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (!node.specifiers.length) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// If it's not from our package, ignore.
|
|
42
|
+
if (source !== FORM_PACKAGE) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
var namedImportSpecifiers = node.specifiers.filter(function (spec) {
|
|
46
|
+
return (0, _eslintCodemodUtils.isNodeOfType)(spec, 'ImportSpecifier');
|
|
47
|
+
});
|
|
48
|
+
namedImportSpecifiers.forEach(function (spec) {
|
|
49
|
+
if (spec.type === 'ImportSpecifier' && 'name' in spec.imported) {
|
|
50
|
+
var name = spec.imported.name;
|
|
51
|
+
var local = spec.local;
|
|
52
|
+
if (MESSAGE_COMPONENTS.includes(name)) {
|
|
53
|
+
messageImports.push(local);
|
|
54
|
+
} else if (name === 'Field') {
|
|
55
|
+
fieldImport = local.name;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
JSXElement: function JSXElement(node) {
|
|
61
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXElement')) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(node.openingElement.name, 'JSXIdentifier')) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// if no field import exists, skip
|
|
69
|
+
if (!fieldImport) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// if component is not field, skip
|
|
74
|
+
if (node.openingElement.name.name !== fieldImport) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// if message imports exist, skip because we can't really dig around
|
|
79
|
+
// inside the field to see if they exist because of memory constraints
|
|
80
|
+
if (messageImports.length > 0) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// if component exists as a prop, skip because it's already simple
|
|
85
|
+
var attributes = node.openingElement.attributes;
|
|
86
|
+
var componentAttr = attributes.find(function (attr) {
|
|
87
|
+
return (0, _eslintCodemodUtils.isNodeOfType)(attr, 'JSXAttribute') && (0, _eslintCodemodUtils.isNodeOfType)(attr.name, 'JSXIdentifier') && attr.name.name === 'component';
|
|
88
|
+
});
|
|
89
|
+
if (componentAttr) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// if children is not a render prop, skip
|
|
94
|
+
var renderProps = node.children.find(function (child) {
|
|
95
|
+
return (0, _eslintCodemodUtils.isNodeOfType)(child, 'JSXExpressionContainer');
|
|
96
|
+
});
|
|
97
|
+
if (!renderProps) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
var renderPropExpression = renderProps.expression;
|
|
101
|
+
// If not an arrow func, ignore
|
|
102
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(renderPropExpression, 'ArrowFunctionExpression')) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
var renderPropParams = renderPropExpression.params;
|
|
106
|
+
// if it is not an object pattern, skip
|
|
107
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(renderPropParams[0], 'ObjectPattern')) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
// if component uses more than just fieldProps in render props, skip
|
|
111
|
+
var renderPropArgProperties = renderPropParams[0].properties;
|
|
112
|
+
var fieldPropsProp = renderPropArgProperties.find(function (property) {
|
|
113
|
+
return (0, _eslintCodemodUtils.isNodeOfType)(property, 'Property') && (0, _eslintCodemodUtils.isNodeOfType)(property.key, 'Identifier') && property.key.name === 'fieldProps';
|
|
114
|
+
});
|
|
115
|
+
if (renderPropArgProperties.length > 1 || !fieldPropsProp) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
var lastProp = attributes.slice(-1)[0] || node.openingElement.name;
|
|
119
|
+
var sourceCode = context.sourceCode;
|
|
120
|
+
var renderPropsText = sourceCode.getText(renderProps);
|
|
121
|
+
context.report({
|
|
122
|
+
node: node,
|
|
123
|
+
messageId: 'useSimpleField',
|
|
124
|
+
suggest: [{
|
|
125
|
+
desc: convertField,
|
|
126
|
+
fix: function fix(fixer) {
|
|
127
|
+
var fixes = [];
|
|
128
|
+
fixes.push(fixer.insertTextAfter(lastProp, " component=".concat(renderPropsText, " ")));
|
|
129
|
+
fixes.push(fixer.remove(renderProps));
|
|
130
|
+
return fixes;
|
|
131
|
+
}
|
|
132
|
+
}]
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
var _default = exports.default = rule;
|
|
@@ -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::05e8a8ff80cb4a88a89ccd31570686f6>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -74,6 +74,7 @@ const rules = {
|
|
|
74
74
|
'@atlaskit/design-system/use-primitives': 'warn',
|
|
75
75
|
'@atlaskit/design-system/use-primitives-text': 'warn',
|
|
76
76
|
'@atlaskit/design-system/use-should-render-to-parent': 'warn',
|
|
77
|
+
'@atlaskit/design-system/use-simple-field': 'warn',
|
|
77
78
|
'@atlaskit/design-system/use-spotlight-package': 'warn',
|
|
78
79
|
'@atlaskit/design-system/use-tag-group-label': 'warn',
|
|
79
80
|
'@atlaskit/design-system/use-tokens-shape': 'error',
|
|
@@ -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::f2a8bbab8acdaf84ca6e295124378517>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -73,6 +73,7 @@ const rules = {
|
|
|
73
73
|
'@atlaskit/design-system/use-primitives': 'warn',
|
|
74
74
|
'@atlaskit/design-system/use-primitives-text': 'warn',
|
|
75
75
|
'@atlaskit/design-system/use-should-render-to-parent': 'warn',
|
|
76
|
+
'@atlaskit/design-system/use-simple-field': 'warn',
|
|
76
77
|
'@atlaskit/design-system/use-spotlight-package': 'warn',
|
|
77
78
|
'@atlaskit/design-system/use-tag-group-label': 'warn',
|
|
78
79
|
'@atlaskit/design-system/use-tokens-shape': 'error',
|
|
@@ -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::2ca5e0a897270a5cfe3e234d7948ed0f>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -56,6 +56,7 @@ const rules = {
|
|
|
56
56
|
'@atlaskit/design-system/use-popup-label': 'warn',
|
|
57
57
|
'@atlaskit/design-system/use-primitives-text': 'warn',
|
|
58
58
|
'@atlaskit/design-system/use-should-render-to-parent': 'warn',
|
|
59
|
+
'@atlaskit/design-system/use-simple-field': 'warn',
|
|
59
60
|
'@atlaskit/design-system/use-tag-group-label': 'warn',
|
|
60
61
|
'@atlaskit/design-system/use-tokens-typography': 'warn',
|
|
61
62
|
'@atlaskit/design-system/use-visually-hidden': 'error'
|
|
@@ -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::aee2986e6e48e70acef7dfa4ba53747d>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -55,6 +55,7 @@ const rules = {
|
|
|
55
55
|
'@atlaskit/design-system/use-popup-label': 'warn',
|
|
56
56
|
'@atlaskit/design-system/use-primitives-text': 'warn',
|
|
57
57
|
'@atlaskit/design-system/use-should-render-to-parent': 'warn',
|
|
58
|
+
'@atlaskit/design-system/use-simple-field': 'warn',
|
|
58
59
|
'@atlaskit/design-system/use-tag-group-label': 'warn',
|
|
59
60
|
'@atlaskit/design-system/use-tokens-typography': 'warn',
|
|
60
61
|
'@atlaskit/design-system/use-visually-hidden': 'error'
|
|
@@ -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::030718cab57dce4d3b39031485e53af4>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -71,6 +71,7 @@ import usePopupLabel from './use-popup-label';
|
|
|
71
71
|
import usePrimitives from './use-primitives';
|
|
72
72
|
import usePrimitivesText from './use-primitives-text';
|
|
73
73
|
import useShouldRenderToParent from './use-should-render-to-parent';
|
|
74
|
+
import useSimpleField from './use-simple-field';
|
|
74
75
|
import useSpotlightPackage from './use-spotlight-package';
|
|
75
76
|
import useTagGroupLabel from './use-tag-group-label';
|
|
76
77
|
import useTokensShape from './use-tokens-shape';
|
|
@@ -145,6 +146,7 @@ export const rules = {
|
|
|
145
146
|
'use-primitives': usePrimitives,
|
|
146
147
|
'use-primitives-text': usePrimitivesText,
|
|
147
148
|
'use-should-render-to-parent': useShouldRenderToParent,
|
|
149
|
+
'use-simple-field': useSimpleField,
|
|
148
150
|
'use-spotlight-package': useSpotlightPackage,
|
|
149
151
|
'use-tag-group-label': useTagGroupLabel,
|
|
150
152
|
'use-tokens-shape': useTokensShape,
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
+
import { createLintRule } from '../utils/create-rule';
|
|
3
|
+
const FORM_PACKAGE = '@atlaskit/form';
|
|
4
|
+
const MESSAGE_COMPONENTS = ['ErrorMessage', 'HelperMessage', 'ValidMessage'];
|
|
5
|
+
export const convertField = 'Convert field to simple field';
|
|
6
|
+
const rule = createLintRule({
|
|
7
|
+
meta: {
|
|
8
|
+
name: 'use-simple-field',
|
|
9
|
+
type: 'suggestion',
|
|
10
|
+
hasSuggestions: true,
|
|
11
|
+
docs: {
|
|
12
|
+
description: 'Encourage use of simple field for better developer experience and accessibility.',
|
|
13
|
+
recommended: true,
|
|
14
|
+
severity: 'warn'
|
|
15
|
+
},
|
|
16
|
+
messages: {
|
|
17
|
+
useSimpleField: 'The simplified field implementation can be used here.'
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
create(context) {
|
|
21
|
+
let fieldImport;
|
|
22
|
+
let messageImports = [];
|
|
23
|
+
return {
|
|
24
|
+
ImportDeclaration(node) {
|
|
25
|
+
const source = node.source.value;
|
|
26
|
+
|
|
27
|
+
// Ignore anomalies
|
|
28
|
+
if (typeof source !== 'string') {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (!node.specifiers.length) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// If it's not from our package, ignore.
|
|
36
|
+
if (source !== FORM_PACKAGE) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const namedImportSpecifiers = node.specifiers.filter(spec => isNodeOfType(spec, 'ImportSpecifier'));
|
|
40
|
+
namedImportSpecifiers.forEach(spec => {
|
|
41
|
+
if (spec.type === 'ImportSpecifier' && 'name' in spec.imported) {
|
|
42
|
+
const name = spec.imported.name;
|
|
43
|
+
const local = spec.local;
|
|
44
|
+
if (MESSAGE_COMPONENTS.includes(name)) {
|
|
45
|
+
messageImports.push(local);
|
|
46
|
+
} else if (name === 'Field') {
|
|
47
|
+
fieldImport = local.name;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
JSXElement(node) {
|
|
53
|
+
if (!isNodeOfType(node, 'JSXElement')) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (!isNodeOfType(node.openingElement.name, 'JSXIdentifier')) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// if no field import exists, skip
|
|
61
|
+
if (!fieldImport) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// if component is not field, skip
|
|
66
|
+
if (node.openingElement.name.name !== fieldImport) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// if message imports exist, skip because we can't really dig around
|
|
71
|
+
// inside the field to see if they exist because of memory constraints
|
|
72
|
+
if (messageImports.length > 0) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// if component exists as a prop, skip because it's already simple
|
|
77
|
+
const attributes = node.openingElement.attributes;
|
|
78
|
+
const componentAttr = attributes.find(attr => isNodeOfType(attr, 'JSXAttribute') && isNodeOfType(attr.name, 'JSXIdentifier') && attr.name.name === 'component');
|
|
79
|
+
if (componentAttr) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// if children is not a render prop, skip
|
|
84
|
+
const renderProps = node.children.find(child => isNodeOfType(child, 'JSXExpressionContainer'));
|
|
85
|
+
if (!renderProps) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const renderPropExpression = renderProps.expression;
|
|
89
|
+
// If not an arrow func, ignore
|
|
90
|
+
if (!isNodeOfType(renderPropExpression, 'ArrowFunctionExpression')) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const renderPropParams = renderPropExpression.params;
|
|
94
|
+
// if it is not an object pattern, skip
|
|
95
|
+
if (!isNodeOfType(renderPropParams[0], 'ObjectPattern')) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
// if component uses more than just fieldProps in render props, skip
|
|
99
|
+
const renderPropArgProperties = renderPropParams[0].properties;
|
|
100
|
+
const fieldPropsProp = renderPropArgProperties.find(property => isNodeOfType(property, 'Property') && isNodeOfType(property.key, 'Identifier') && property.key.name === 'fieldProps');
|
|
101
|
+
if (renderPropArgProperties.length > 1 || !fieldPropsProp) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const lastProp = attributes.slice(-1)[0] || node.openingElement.name;
|
|
105
|
+
const sourceCode = context.sourceCode;
|
|
106
|
+
const renderPropsText = sourceCode.getText(renderProps);
|
|
107
|
+
context.report({
|
|
108
|
+
node: node,
|
|
109
|
+
messageId: 'useSimpleField',
|
|
110
|
+
suggest: [{
|
|
111
|
+
desc: convertField,
|
|
112
|
+
fix: fixer => {
|
|
113
|
+
const fixes = [];
|
|
114
|
+
fixes.push(fixer.insertTextAfter(lastProp, ` component=${renderPropsText} `));
|
|
115
|
+
fixes.push(fixer.remove(renderProps));
|
|
116
|
+
return fixes;
|
|
117
|
+
}
|
|
118
|
+
}]
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
export default rule;
|
|
@@ -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::05e8a8ff80cb4a88a89ccd31570686f6>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -74,6 +74,7 @@ var rules = {
|
|
|
74
74
|
'@atlaskit/design-system/use-primitives': 'warn',
|
|
75
75
|
'@atlaskit/design-system/use-primitives-text': 'warn',
|
|
76
76
|
'@atlaskit/design-system/use-should-render-to-parent': 'warn',
|
|
77
|
+
'@atlaskit/design-system/use-simple-field': 'warn',
|
|
77
78
|
'@atlaskit/design-system/use-spotlight-package': 'warn',
|
|
78
79
|
'@atlaskit/design-system/use-tag-group-label': 'warn',
|
|
79
80
|
'@atlaskit/design-system/use-tokens-shape': 'error',
|
|
@@ -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::f2a8bbab8acdaf84ca6e295124378517>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -73,6 +73,7 @@ var rules = {
|
|
|
73
73
|
'@atlaskit/design-system/use-primitives': 'warn',
|
|
74
74
|
'@atlaskit/design-system/use-primitives-text': 'warn',
|
|
75
75
|
'@atlaskit/design-system/use-should-render-to-parent': 'warn',
|
|
76
|
+
'@atlaskit/design-system/use-simple-field': 'warn',
|
|
76
77
|
'@atlaskit/design-system/use-spotlight-package': 'warn',
|
|
77
78
|
'@atlaskit/design-system/use-tag-group-label': 'warn',
|
|
78
79
|
'@atlaskit/design-system/use-tokens-shape': 'error',
|
|
@@ -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::2ca5e0a897270a5cfe3e234d7948ed0f>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -56,6 +56,7 @@ var rules = {
|
|
|
56
56
|
'@atlaskit/design-system/use-popup-label': 'warn',
|
|
57
57
|
'@atlaskit/design-system/use-primitives-text': 'warn',
|
|
58
58
|
'@atlaskit/design-system/use-should-render-to-parent': 'warn',
|
|
59
|
+
'@atlaskit/design-system/use-simple-field': 'warn',
|
|
59
60
|
'@atlaskit/design-system/use-tag-group-label': 'warn',
|
|
60
61
|
'@atlaskit/design-system/use-tokens-typography': 'warn',
|
|
61
62
|
'@atlaskit/design-system/use-visually-hidden': 'error'
|
|
@@ -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::aee2986e6e48e70acef7dfa4ba53747d>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -55,6 +55,7 @@ var rules = {
|
|
|
55
55
|
'@atlaskit/design-system/use-popup-label': 'warn',
|
|
56
56
|
'@atlaskit/design-system/use-primitives-text': 'warn',
|
|
57
57
|
'@atlaskit/design-system/use-should-render-to-parent': 'warn',
|
|
58
|
+
'@atlaskit/design-system/use-simple-field': 'warn',
|
|
58
59
|
'@atlaskit/design-system/use-tag-group-label': 'warn',
|
|
59
60
|
'@atlaskit/design-system/use-tokens-typography': 'warn',
|
|
60
61
|
'@atlaskit/design-system/use-visually-hidden': 'error'
|
|
@@ -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::030718cab57dce4d3b39031485e53af4>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -71,6 +71,7 @@ import usePopupLabel from './use-popup-label';
|
|
|
71
71
|
import usePrimitives from './use-primitives';
|
|
72
72
|
import usePrimitivesText from './use-primitives-text';
|
|
73
73
|
import useShouldRenderToParent from './use-should-render-to-parent';
|
|
74
|
+
import useSimpleField from './use-simple-field';
|
|
74
75
|
import useSpotlightPackage from './use-spotlight-package';
|
|
75
76
|
import useTagGroupLabel from './use-tag-group-label';
|
|
76
77
|
import useTokensShape from './use-tokens-shape';
|
|
@@ -145,6 +146,7 @@ export var rules = {
|
|
|
145
146
|
'use-primitives': usePrimitives,
|
|
146
147
|
'use-primitives-text': usePrimitivesText,
|
|
147
148
|
'use-should-render-to-parent': useShouldRenderToParent,
|
|
149
|
+
'use-simple-field': useSimpleField,
|
|
148
150
|
'use-spotlight-package': useSpotlightPackage,
|
|
149
151
|
'use-tag-group-label': useTagGroupLabel,
|
|
150
152
|
'use-tokens-shape': useTokensShape,
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
+
import { createLintRule } from '../utils/create-rule';
|
|
3
|
+
var FORM_PACKAGE = '@atlaskit/form';
|
|
4
|
+
var MESSAGE_COMPONENTS = ['ErrorMessage', 'HelperMessage', 'ValidMessage'];
|
|
5
|
+
export var convertField = 'Convert field to simple field';
|
|
6
|
+
var rule = createLintRule({
|
|
7
|
+
meta: {
|
|
8
|
+
name: 'use-simple-field',
|
|
9
|
+
type: 'suggestion',
|
|
10
|
+
hasSuggestions: true,
|
|
11
|
+
docs: {
|
|
12
|
+
description: 'Encourage use of simple field for better developer experience and accessibility.',
|
|
13
|
+
recommended: true,
|
|
14
|
+
severity: 'warn'
|
|
15
|
+
},
|
|
16
|
+
messages: {
|
|
17
|
+
useSimpleField: 'The simplified field implementation can be used here.'
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
create: function create(context) {
|
|
21
|
+
var fieldImport;
|
|
22
|
+
var messageImports = [];
|
|
23
|
+
return {
|
|
24
|
+
ImportDeclaration: function ImportDeclaration(node) {
|
|
25
|
+
var source = node.source.value;
|
|
26
|
+
|
|
27
|
+
// Ignore anomalies
|
|
28
|
+
if (typeof source !== 'string') {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (!node.specifiers.length) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// If it's not from our package, ignore.
|
|
36
|
+
if (source !== FORM_PACKAGE) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
var namedImportSpecifiers = node.specifiers.filter(function (spec) {
|
|
40
|
+
return isNodeOfType(spec, 'ImportSpecifier');
|
|
41
|
+
});
|
|
42
|
+
namedImportSpecifiers.forEach(function (spec) {
|
|
43
|
+
if (spec.type === 'ImportSpecifier' && 'name' in spec.imported) {
|
|
44
|
+
var name = spec.imported.name;
|
|
45
|
+
var local = spec.local;
|
|
46
|
+
if (MESSAGE_COMPONENTS.includes(name)) {
|
|
47
|
+
messageImports.push(local);
|
|
48
|
+
} else if (name === 'Field') {
|
|
49
|
+
fieldImport = local.name;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
JSXElement: function JSXElement(node) {
|
|
55
|
+
if (!isNodeOfType(node, 'JSXElement')) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (!isNodeOfType(node.openingElement.name, 'JSXIdentifier')) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// if no field import exists, skip
|
|
63
|
+
if (!fieldImport) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// if component is not field, skip
|
|
68
|
+
if (node.openingElement.name.name !== fieldImport) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// if message imports exist, skip because we can't really dig around
|
|
73
|
+
// inside the field to see if they exist because of memory constraints
|
|
74
|
+
if (messageImports.length > 0) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// if component exists as a prop, skip because it's already simple
|
|
79
|
+
var attributes = node.openingElement.attributes;
|
|
80
|
+
var componentAttr = attributes.find(function (attr) {
|
|
81
|
+
return isNodeOfType(attr, 'JSXAttribute') && isNodeOfType(attr.name, 'JSXIdentifier') && attr.name.name === 'component';
|
|
82
|
+
});
|
|
83
|
+
if (componentAttr) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// if children is not a render prop, skip
|
|
88
|
+
var renderProps = node.children.find(function (child) {
|
|
89
|
+
return isNodeOfType(child, 'JSXExpressionContainer');
|
|
90
|
+
});
|
|
91
|
+
if (!renderProps) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
var renderPropExpression = renderProps.expression;
|
|
95
|
+
// If not an arrow func, ignore
|
|
96
|
+
if (!isNodeOfType(renderPropExpression, 'ArrowFunctionExpression')) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
var renderPropParams = renderPropExpression.params;
|
|
100
|
+
// if it is not an object pattern, skip
|
|
101
|
+
if (!isNodeOfType(renderPropParams[0], 'ObjectPattern')) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
// if component uses more than just fieldProps in render props, skip
|
|
105
|
+
var renderPropArgProperties = renderPropParams[0].properties;
|
|
106
|
+
var fieldPropsProp = renderPropArgProperties.find(function (property) {
|
|
107
|
+
return isNodeOfType(property, 'Property') && isNodeOfType(property.key, 'Identifier') && property.key.name === 'fieldProps';
|
|
108
|
+
});
|
|
109
|
+
if (renderPropArgProperties.length > 1 || !fieldPropsProp) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
var lastProp = attributes.slice(-1)[0] || node.openingElement.name;
|
|
113
|
+
var sourceCode = context.sourceCode;
|
|
114
|
+
var renderPropsText = sourceCode.getText(renderProps);
|
|
115
|
+
context.report({
|
|
116
|
+
node: node,
|
|
117
|
+
messageId: 'useSimpleField',
|
|
118
|
+
suggest: [{
|
|
119
|
+
desc: convertField,
|
|
120
|
+
fix: function fix(fixer) {
|
|
121
|
+
var fixes = [];
|
|
122
|
+
fixes.push(fixer.insertTextAfter(lastProp, " component=".concat(renderPropsText, " ")));
|
|
123
|
+
fixes.push(fixer.remove(renderProps));
|
|
124
|
+
return fixes;
|
|
125
|
+
}
|
|
126
|
+
}]
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
export default rule;
|
|
@@ -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::05e8a8ff80cb4a88a89ccd31570686f6>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
import type { Linter } from 'eslint';
|
|
@@ -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::f2a8bbab8acdaf84ca6e295124378517>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
import type { ESLint } from 'eslint';
|
|
@@ -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::2ca5e0a897270a5cfe3e234d7948ed0f>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
import type { Linter } from 'eslint';
|
|
@@ -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::aee2986e6e48e70acef7dfa4ba53747d>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
import type { ESLint } from 'eslint';
|
|
@@ -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::030718cab57dce4d3b39031485e53af4>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
import type { Rule } from 'eslint';
|
|
@@ -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::05e8a8ff80cb4a88a89ccd31570686f6>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
import type { Linter } from 'eslint';
|
|
@@ -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::f2a8bbab8acdaf84ca6e295124378517>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
import type { ESLint } from 'eslint';
|
|
@@ -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::2ca5e0a897270a5cfe3e234d7948ed0f>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
import type { Linter } from 'eslint';
|
|
@@ -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::aee2986e6e48e70acef7dfa4ba53747d>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
import type { ESLint } from 'eslint';
|
|
@@ -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::030718cab57dce4d3b39031485e53af4>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
import type { Rule } from 'eslint';
|
package/package.json
CHANGED