@atlaskit/eslint-plugin-ui-styling-standard 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +18 -5
  3. package/build/tsconfig.json +2 -4
  4. package/constellation/consistent-css-prop-usage/usage.mdx +5 -0
  5. package/constellation/index/overview.mdx +219 -0
  6. package/constellation/index/props.mdx +33 -0
  7. package/constellation/local-cx-xcss/usage.mdx +37 -0
  8. package/constellation/no-css-tagged-template-expression/usage.mdx +5 -0
  9. package/constellation/no-empty-styled-expression/usage.mdx +5 -0
  10. package/constellation/no-exported-css/usage.mdx +5 -0
  11. package/constellation/no-exported-keyframes/usage.mdx +5 -0
  12. package/constellation/no-invalid-css-map/usage.mdx +5 -0
  13. package/constellation/no-js-xcss/usage.mdx +23 -0
  14. package/constellation/no-keyframes-tagged-template-expression/usage.mdx +5 -0
  15. package/constellation/no-styled-tagged-template-expression/usage.mdx +5 -0
  16. package/constellation/no-suppress-xcss/usage.mdx +25 -0
  17. package/dist/cjs/index.codegen.js +26 -0
  18. package/dist/cjs/index.js +12 -12
  19. package/dist/cjs/presets/all.codegen.js +37 -0
  20. package/dist/cjs/presets/recommended.codegen.js +37 -0
  21. package/dist/cjs/rules/external-rules.js +143 -0
  22. package/dist/cjs/rules/index.codegen.js +16 -0
  23. package/dist/cjs/rules/local-cx-xcss/index.js +51 -0
  24. package/dist/cjs/rules/utils/create-rule.js +43 -0
  25. package/dist/cjs/rules/utils/is-supported-import.js +98 -0
  26. package/dist/es2019/index.codegen.js +12 -0
  27. package/dist/es2019/index.js +1 -12
  28. package/dist/es2019/presets/all.codegen.js +31 -0
  29. package/dist/es2019/presets/recommended.codegen.js +31 -0
  30. package/dist/es2019/rules/external-rules.js +138 -0
  31. package/dist/es2019/rules/index.codegen.js +9 -0
  32. package/dist/es2019/rules/local-cx-xcss/index.js +45 -0
  33. package/dist/es2019/rules/utils/create-rule.js +33 -0
  34. package/dist/es2019/rules/utils/is-supported-import.js +87 -0
  35. package/dist/esm/index.codegen.js +12 -0
  36. package/dist/esm/index.js +1 -12
  37. package/dist/esm/presets/all.codegen.js +31 -0
  38. package/dist/esm/presets/recommended.codegen.js +31 -0
  39. package/dist/esm/rules/external-rules.js +138 -0
  40. package/dist/esm/rules/index.codegen.js +9 -0
  41. package/dist/esm/rules/local-cx-xcss/index.js +45 -0
  42. package/dist/esm/rules/utils/create-rule.js +35 -0
  43. package/dist/esm/rules/utils/is-supported-import.js +90 -0
  44. package/dist/types/index.codegen.d.ts +55 -0
  45. package/dist/types/index.d.ts +1 -0
  46. package/dist/types/presets/all.codegen.d.ts +32 -0
  47. package/dist/types/presets/recommended.codegen.d.ts +32 -0
  48. package/dist/types/rules/external-rules.d.ts +11 -0
  49. package/dist/types/rules/index.codegen.d.ts +4 -0
  50. package/dist/types/rules/local-cx-xcss/index.d.ts +3 -0
  51. package/dist/types/rules/utils/create-rule.d.ts +64 -0
  52. package/dist/types/rules/utils/is-supported-import.d.ts +34 -0
  53. package/dist/types-ts4.5/index.codegen.d.ts +55 -0
  54. package/dist/types-ts4.5/index.d.ts +1 -0
  55. package/dist/types-ts4.5/presets/all.codegen.d.ts +32 -0
  56. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +32 -0
  57. package/dist/types-ts4.5/rules/external-rules.d.ts +11 -0
  58. package/dist/types-ts4.5/rules/index.codegen.d.ts +4 -0
  59. package/dist/types-ts4.5/rules/local-cx-xcss/index.d.ts +3 -0
  60. package/dist/types-ts4.5/rules/utils/create-rule.d.ts +64 -0
  61. package/dist/types-ts4.5/rules/utils/is-supported-import.d.ts +34 -0
  62. package/package.json +21 -8
  63. package/scripts/codegen.tsx +439 -0
  64. package/src/index.codegen.tsx +14 -0
  65. package/src/index.tsx +1 -17
  66. package/src/presets/all.codegen.tsx +67 -0
  67. package/src/presets/recommended.codegen.tsx +67 -0
  68. package/src/rules/TEMPLATE.md +29 -0
  69. package/src/rules/__tests__/utils/_tester.tsx +40 -0
  70. package/src/rules/external-rules.tsx +175 -0
  71. package/src/rules/index.codegen.tsx +10 -0
  72. package/src/rules/local-cx-xcss/README.md +35 -0
  73. package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +102 -0
  74. package/src/rules/local-cx-xcss/index.tsx +69 -0
  75. package/src/rules/utils/create-rule.tsx +80 -0
  76. package/src/rules/utils/is-supported-import.tsx +130 -0
  77. package/tsconfig.app.json +5 -1
  78. package/tsconfig.dev.json +5 -1
  79. package/tsconfig.json +7 -6
  80. package/dist/types/src/index.d.ts +0 -12
  81. package/dist/types-ts4.5/src/index.d.ts +0 -12
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @atlaskit/eslint-plugin-ui-styling-standard
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#75600](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/75600) [`8875d9de2e5d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8875d9de2e5d) - Migrates the ESLint rule from `@atlaskit/design-system/local-cx-xcss` to `@atlaskit/ui-styling-standard/local-cx-xcss` and overhauls the codegen to enable better documentation and rule distribution.
8
+
9
+ ## 0.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#74981](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/74981) [`842300de03a1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/842300de03a1) - Add the following rules:
14
+
15
+ - `consistent-css-prop-usage`: Ensures consistency with `css` and `xcss` prop usages
16
+ - `no-empty-styled-expression`: Forbids any styled expression to be used when passing empty arguments to styled.div() (or other JSX elements).
17
+ - `no-exported-css`: Forbid exporting `css` function calls.
18
+ - `no-exported-keyframes`: Forbid exporting `keyframes` function calls.
19
+ - `no-invalid-css-map`: Checks the validity of a CSS map created through cssMap.
20
+
21
+ - [#72983](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/72983) [`878065bfc4c0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/878065bfc4c0) - Adds the following rules to the recommended preset:
22
+
23
+ - `@atlaskit/design-system/no-css-tagged-template-expression`
24
+ - `@atlaskit/design-system/no-keyframes-tagged-template-expression`
25
+ - `@atlaskit/design-system/no-styled-tagged-template-expression`
26
+
27
+ ### Patch Changes
28
+
29
+ - [#75152](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/75152) [`c16a175d372b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c16a175d372b) - Change 'error' to 'warn' to unbreak AFM platform
30
+
3
31
  ## 0.2.1
4
32
 
5
33
  ### Patch Changes
package/README.md CHANGED
@@ -8,8 +8,21 @@ Not intended for use outside the Atlassian frontend repository.
8
8
 
9
9
  ## Rules
10
10
 
11
- | Rule | Description | Recommended | Fixable | Suggestions |
12
- | --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | ------- | ----------- |
13
- | <a href="../eslint-plugin/src/rules/local-cx-xcss/README.md">local-cx-xcss</a> | Ensures the cx() function, which is part of the XCSS API, is only used within the xcss prop. This aids tracking what styles are applied to a jsx element. | Yes | | |
14
- | <a href="https://github.com/atlassian-labs/compiled/tree/master/packages/eslint-plugin/src/rules/no-suppress-xcss">no-suppress-xcss</a> | Disallows supressing type violations when using the xcss prop | Yes | | |
15
- | <a href="https://github.com/atlassian-labs/compiled/tree/master/packages/eslint-plugin/src/rules/no-js-xcss">no-js-xcss</a> | Disallows using xcss prop inside JavaScript files | Yes | | |
11
+ <!-- START_RULE_TABLE_CODEGEN -->
12
+ <!-- @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen -->
13
+
14
+ | Rule | Description | Recommended | Fixable | Suggestions |
15
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | ------- | ----------- |
16
+ | <a href="./src/rules/local-cx-xcss/README.md">local-cx-xcss</a> | Ensures the cx() function, which is part of the XCSS API, is only used within the xcss prop. This aids tracking what styles are applied to a jsx element. | Yes | | |
17
+ | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/consistent-css-prop-usage/usage">@atlaskit/design-system/consistent-css-prop-usage</a> | Ensures consistency with `css` and `xcss` prop usages | Yes | Yes | |
18
+ | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-css-tagged-template-expression/usage">@atlaskit/design-system/no-css-tagged-template-expression</a> | Disallows any `css` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
19
+ | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-keyframes-tagged-template-expression/usage">@atlaskit/design-system/no-keyframes-tagged-template-expression</a> | Disallows any `keyframe` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
20
+ | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-styled-tagged-template-expression/usage">@atlaskit/design-system/no-styled-tagged-template-expression</a> | Disallows any `styled` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
21
+ | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-suppress-xcss/usage">@compiled/no-suppress-xcss</a> | Disallows supressing type violations when using the xcss prop. | Yes | | |
22
+ | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-js-xcss/usage">@compiled/no-js-xcss</a> | Disallows using xcss prop inside JavaScript files. | Yes | | |
23
+ | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-empty-styled-expression/usage">@atlaskit/design-system/no-empty-styled-expression</a> | Forbids any styled expression to be used when passing empty arguments to styled.div() (or other JSX elements). | Yes | | |
24
+ | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-exported-css/usage">@atlaskit/design-system/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. | Yes | | |
25
+ | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-exported-keyframes/usage">@atlaskit/design-system/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. | Yes | | |
26
+ | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-invalid-css-map/usage">@atlaskit/design-system/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 | | |
27
+
28
+ <!-- END_RULE_TABLE_CODEGEN -->
@@ -2,11 +2,9 @@
2
2
  "extends": "../tsconfig",
3
3
  "compilerOptions": {
4
4
  "target": "es5",
5
- "outDir": "../dist",
6
- "rootDir": "../",
7
- "baseUrl": "../",
5
+ "lib": ["ES2021.String"],
8
6
  "paths": {}
9
- },
7
+ },
10
8
  "include": [
11
9
  "../src/**/*.ts",
12
10
  "../src/**/*.tsx"
@@ -0,0 +1,5 @@
1
+ # @atlaskit/design-system/consistent-css-prop-usage
2
+
3
+ Ensures consistency with `css` and `xcss` prop usages
4
+
5
+ This rule is maintained by another package and configured here, refer to https://atlassian.design/components/eslint-plugin-design-system/consistent-css-prop-usage/usage for more details
@@ -0,0 +1,219 @@
1
+ ## What is the "UI Styling Standard"?
2
+
3
+ The UI Styling Standard is a set of ESLint rules and principles to guide building web styling code
4
+ across Atlassian's frontend codebases and ecosystem.
5
+
6
+ ## Rules
7
+
8
+ <!-- START_RULE_TABLE_CODEGEN -->
9
+ <!-- @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen -->
10
+
11
+ | Rule | Description | Recommended | Fixable | Suggestions |
12
+ | --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | ------- | ----------- |
13
+ | <a href="local-cx-xcss/usage">local-cx-xcss</a> | Ensures the cx() function, which is part of the XCSS API, is only used within the xcss prop. This aids tracking what styles are applied to a jsx element. | Yes | | |
14
+ | <a href="consistent-css-prop-usage/usage">@atlaskit/design-system/consistent-css-prop-usage</a> | Ensures consistency with `css` and `xcss` prop usages | Yes | Yes | |
15
+ | <a href="no-css-tagged-template-expression/usage">@atlaskit/design-system/no-css-tagged-template-expression</a> | Disallows any `css` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
16
+ | <a href="no-keyframes-tagged-template-expression/usage">@atlaskit/design-system/no-keyframes-tagged-template-expression</a> | Disallows any `keyframe` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
17
+ | <a href="no-styled-tagged-template-expression/usage">@atlaskit/design-system/no-styled-tagged-template-expression</a> | Disallows any `styled` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
18
+ | <a href="no-suppress-xcss/usage">@compiled/no-suppress-xcss</a> | Disallows supressing type violations when using the xcss prop. | Yes | | |
19
+ | <a href="no-js-xcss/usage">@compiled/no-js-xcss</a> | Disallows using xcss prop inside JavaScript files. | Yes | | |
20
+ | <a href="no-empty-styled-expression/usage">@atlaskit/design-system/no-empty-styled-expression</a> | Forbids any styled expression to be used when passing empty arguments to styled.div() (or other JSX elements). | Yes | | |
21
+ | <a href="no-exported-css/usage">@atlaskit/design-system/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. | Yes | | |
22
+ | <a href="no-exported-keyframes/usage">@atlaskit/design-system/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. | Yes | | |
23
+ | <a href="no-invalid-css-map/usage">@atlaskit/design-system/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 | | |
24
+
25
+ <!-- END_RULE_TABLE_CODEGEN -->
26
+
27
+ ## Purpose of the UI Styling Standard
28
+
29
+ To enforce scoped encapsulation, type safety, and deterministic behavior in styling code that is
30
+ present in other programming languages. This is a stepping stone to large performance improvements,
31
+ reduced visual regressions, and enables testing and maintainability at scale.
32
+ This approach improves readability and developer productivity via automation with tooling, testing,
33
+ code migrations, and future advancements like generative AI.
34
+
35
+ ### Desired outcomes:
36
+
37
+ - We can make large visual changes and migrations safely and in a fraction of the time.
38
+ - To have the vast majority of styling code be deterministic, immutable, and bound to its scope, reducing unknown visual and UX regressions.
39
+ - To enable teams to write tooling quicker that's better and more performant to lint, test, and migrate UI code to improve current and future developer productivity and satisfaction.
40
+ - To enable large performance improvements for customers and developers with a zero-runtime styling solution.
41
+ - To reduce the amount of overall custom styling code written while supporting customization without without the need for hacks and technical debt.
42
+ - We aim to see a reduction of the “average styles per component”, reducing the effort to build and maintain UIs.
43
+
44
+ ## Basic Principles
45
+
46
+ We want the styling ecosystem (CSS, CSS-in-JS, and parts of JSX) at Atlassian and the wider ecosystem
47
+ we support to be as mature as the other code we write, such as TypeScript/JavaScript, Java, Go, etc.
48
+
49
+ ### Like other languages, styling code must be:
50
+
51
+ - type-safe
52
+ - static and locally analyzable
53
+ - reusable and composable
54
+ - restricted to an encapsulated scope
55
+ - deterministic—with styling known in isolation
56
+ - discoverable and readable without deep knowledge of the CSS spec
57
+
58
+ As the W3C CSS spec and wider industry grows, having our styling code meet these principles will mean we
59
+ can programatically evolve that a better future state.
60
+
61
+ ## How we'll achieve this
62
+
63
+ Within Atlassian, most frontend code will have this enforced over time through ESLint rules and engineering standardization.
64
+
65
+ Refer to the eslint rules for more details: _documentation coming soon_
66
+
67
+ ## Examples
68
+
69
+ Please refer to the eslint rules (_documentation coming soon_)
70
+
71
+ ### Incorrect code
72
+
73
+ 1. The use of `styled-components` and `@emotion/…` are being deprecated.
74
+ 2. Dynamic styles are heavily discouraged.
75
+ 3. Nested selectors as well as `props.className` and global styles are heavily discouraged.
76
+ 4. Do not import or export styles.
77
+ 5. Do not use the `styled.div` or `styled(Component)` syntaxes.
78
+ 6. Do not pass-through or spread props, be explicit to verbose.
79
+ 7. Don't use `!important`, `&& { … }`, or similar hacks.
80
+
81
+ ```tsx
82
+ import styled from 'styled-components';
83
+ import { css } from '@emotion/react';
84
+ import { mixin, innerWrapperStyles, disabledStyles } from './shared/styles';
85
+
86
+ const Wrapper = styled.div`
87
+ ${mixin}
88
+ && {
89
+ color: ${(props) => (props.disabled ? 'gray' : 'black')};
90
+ width: ${(props) => props.width || 100}px;
91
+ }
92
+ & > button {
93
+ color: ${(props) => (props.disabled ? 'gray' : 'blue')} !important;
94
+ }
95
+ `;
96
+
97
+ export const Component = ({
98
+ disabled,
99
+ width,
100
+ appearance = 'primary',
101
+ ...props,
102
+ }: {
103
+ disabled?: boolean;
104
+ width?: number;
105
+ appearance?: 'primary' | 'secondary';
106
+ }) => (
107
+ <Wrapper disabled={props.disabled}>
108
+ <div
109
+ css={[
110
+ innerWrapperStyles,
111
+ css({
112
+ ...(disabled
113
+ ? {
114
+ '& + [disabled]': {
115
+ ...disabledStyles,
116
+ opacity: props.disabled ? '70%' : '100%',
117
+ }
118
+ : undefined
119
+ ),
120
+ }),
121
+ ]}
122
+ {...props}
123
+ >
124
+ <button
125
+ disabled={props.disabled}
126
+ className={`btn btn-${props.appearance}`}
127
+ >
128
+ Click me
129
+ </button>
130
+ </div>
131
+ </Wrapper>
132
+ );
133
+ ```
134
+
135
+ ### Correct code
136
+
137
+ Every element should be clear in isolation how it's styled, using locally and statically available context so both humans and tooling can read this component in a performant and deterministic manner.
138
+
139
+ 1. Use `@compiled/…` wherever possible!
140
+ 2. Instead of dynamic styles:
141
+ 1. Use static `css()` calls everywhere.
142
+ 2. Compose styles together, turning styles on or off.
143
+ 3. When absoluteuly necessary, use `props.style` for dynamic styles.
144
+ 3. Instead of nested selectors or global styles:
145
+ 1. Style components directly.
146
+ 2. Treat everything as local scope, parents shouldn't interact with children wherever feasible.
147
+ 4. Instead of passing raw styles around:
148
+ 1. Write composable and reusable components which distribute styles with clear context.
149
+ 2. Co-locate styles in the same file for human readability and far better tooling feasibility and performance.
150
+ 5. Instead of `styled.…`, use `const styles = css({ … });` (hoisted and static) and `<div css={styles} />`.
151
+ 1. There will be a safe way to make bounded customizations on components through the use of `<Component xcss={css({ … })}>` in the future.
152
+ 6. Instead of `...props`, be explicit with the `aria-` or `data-` props you support, or have more complex spread handling. This is because `className`, `style`, and other things can be applied without any knowledge, resulting in regressions in the future.
153
+ 7. Instead of `!important`, `&& { … }`, or other specificity hacks, ensure your styles are correctly scoped to the component.
154
+
155
+ ```tsx
156
+ import { css } from '@compiled/react';
157
+ import { token } from '@atlaskit/tokens';
158
+
159
+ const wrapperStyles = css({
160
+ padding: token('space.200'), // eg. from mixin
161
+ font: token('font.body'), // eg. from mixin
162
+ color: token('color.text'),
163
+ });
164
+ const disabledWrapperStyles = css({
165
+ color: token('color.text.disabled'),
166
+ });
167
+ const innerWrapperStyles = css({
168
+ // eg. colocated `innerWrapperStyles` (alternatively could create a reusable `<InnerWrapper>`)
169
+ display: 'flex',
170
+ gap: token('space.100'),
171
+ flexDirection: 'column',
172
+ });
173
+ const buttonStyles = css({
174
+ appearance: 'none', // eg. from global styles
175
+ padding: `${token('space.100')} ${token('space.200')}`, // eg. from global styles
176
+ color: token('color.link'),
177
+ });
178
+ const disabledButtonStyles = css({
179
+ cursor: 'not-allowed', // eg. from disabledStyles
180
+ color: token('color.text.disabled'),
181
+ opacity: '70%',
182
+ });
183
+ const buttonAppearanceStyles = cssMap({
184
+ primary: { background: token('color.background.brand.subtlest') },
185
+ secondary: { background: token('color.background.success') },
186
+ });
187
+
188
+ export const Component = ({
189
+ disabled = false,
190
+ width = 100,
191
+ appearance = 'primary',
192
+ 'aria-label': ariaLabel,
193
+ }: {
194
+ disabled?: boolean;
195
+ width?: number;
196
+ appearance?: 'primary' | 'secondary';
197
+ 'aria-label'?: string;
198
+ }) => (
199
+ <div
200
+ css={[wrapperStyles, props.disabled && disabledWrapperStyles]}
201
+ style={{ width: `${props.width}px` }}
202
+ aria-label={ariaLabel}
203
+ >
204
+ <div css={innerWrapperStyles}>
205
+ {/* Typically, this `<button>` should be an Atlassian Design System `<Button>` */}
206
+ <button
207
+ disabled={props.disabled}
208
+ css={[
209
+ buttonStyles,
210
+ buttonAppearances[props.appearance],
211
+ props.disabled && disabledButtonStyles,
212
+ ]}
213
+ >
214
+ Click me
215
+ </button>
216
+ </div>
217
+ </div>
218
+ );
219
+ ```
@@ -0,0 +1,33 @@
1
+ You must use the recommended config to follow the styling standards at Atlassian,
2
+ which will ensure compatability and performance with the design system.
3
+
4
+ ```diff
5
+ module.exports = {
6
+ extends: [
7
+ + 'plugin:@atlaskit/ui-styling-standard/recommended',
8
+ ],
9
+ };
10
+ ```
11
+
12
+ We don't recommended maintaining your own configuration.
13
+ If you do not use our config you will need to specify individual rules and configuration.
14
+ Add the plugin to your `.eslintrc.js` file.
15
+
16
+ ```diff
17
+ module.exports = {
18
+ plugins: [
19
+ + '@atlaskit/ui-styling-standard',
20
+ ],
21
+ };
22
+ ```
23
+
24
+ Enable individual rules as that you're ready to adopt.
25
+
26
+ ```diff
27
+ module.exports = {
28
+ rules: [
29
+ + '@atlaskit/design-system/consistent-css-prop-usage': 'error',
30
+ + '@atlaskit/design-system/local-cx-xcss': 'error',
31
+ ],
32
+ };
33
+ ```
@@ -0,0 +1,37 @@
1
+ # local-cx-xcss
2
+
3
+ This rule ensures the `cx()` function is only used within the `xcss` prop. This aids tracking what styles are applied to a jsx element.
4
+
5
+ The `cx` function is checked only if it is imported from `@compiled/react` or `@atlaskit/css`.
6
+
7
+ Passing arguments to the `cx()` function is how you compose styles (combine more than one set of styles together) with XCSS. This is a workaround for the more conventional array syntax (e.g. [in Emotion](https://emotion.sh/docs/composition)) `<div xcss={[style1, style2]} />` not giving robust enough type checking.
8
+
9
+ ## Examples
10
+
11
+ ### Incorrect
12
+
13
+ ```js
14
+ import { cx, cssMap } from '@compiled/react';
15
+
16
+ const styles = cssMap({
17
+ text: { color: 'red' },
18
+ bg: { background: 'blue' },
19
+ });
20
+
21
+ const joinedStyles = cx(styles.text, styles.bg);
22
+
23
+ <Button xcss={joinedStyles} />;
24
+ ```
25
+
26
+ ### Correct
27
+
28
+ ```js
29
+ import { cx, cssMap } from '@compiled/react';
30
+
31
+ const styles = cssMap({
32
+ text: { color: 'red' },
33
+ bg: { background: 'blue' },
34
+ });
35
+
36
+ <Button xcss={cx(styles.text, styles.bg)} />;
37
+ ```
@@ -0,0 +1,5 @@
1
+ # @atlaskit/design-system/no-css-tagged-template-expression
2
+
3
+ Disallows any css tagged template expressions that originate from @emotion/react, @emotion/core, compiled/react or styled-components.
4
+
5
+ This rule is maintained by another package and configured here, refer to https://atlassian.design/components/eslint-plugin-design-system/no-css-tagged-template-expression/usage for more details
@@ -0,0 +1,5 @@
1
+ # @atlaskit/design-system/no-empty-styled-expression
2
+
3
+ Disallows/discourages passing empty arguments to any styled expression when using @compiled/react, as well as any other CSS-in-JS library defined through the importSources option.
4
+
5
+ This rule is maintained by another package and configured here, refer to https://atlassian.design/components/eslint-plugin-design-system/no-empty-styled-expression/usage for more details
@@ -0,0 +1,5 @@
1
+ # @atlaskit/design-system/no-exported-css
2
+
3
+ Disallows css export declarations that originate from @compiled/react and @atlaskit/css, as well as any other CSS-in-JS library defined through the importSources option.
4
+
5
+ This rule is maintained by another package and configured here, refer to https://atlassian.design/components/eslint-plugin-design-system/no-exported-css/usage for more details
@@ -0,0 +1,5 @@
1
+ # @atlaskit/design-system/no-exported-keyframes
2
+
3
+ Disallows keyframes export declarations that originate from @compiled/react, as well as any other CSS-in-JS library defined through the importSources option.
4
+
5
+ This rule is maintained by another package and configured here, refer to https://atlassian.design/components/eslint-plugin-design-system/no-exported-keyframes/usage for more details
@@ -0,0 +1,5 @@
1
+ # @atlaskit/design-system/no-invalid-css-map
2
+
3
+ Ensure that all usages of the cssMap API are valid, and enforces the format of the object that is passed to cssMap.
4
+
5
+ This rule is maintained by another package and configured here, refer to https://atlassian.design/components/eslint-plugin-design-system/no-invalid-css-map/usage for more details
@@ -0,0 +1,23 @@
1
+ # @compiled/no-js-xcss
2
+
3
+ Disallows using xcss prop inside JavaScript files.
4
+
5
+ Components that use xcss prop have explicitly declared what styles via the type system they should and should not accept, consumers must adhere to this API. Without TypeScript it's impossible to ensure this is met.
6
+
7
+ ## Incorrect
8
+
9
+ Do not use xcss in a JavaScript file as type safety is required to ensure compatability and support
10
+
11
+ ```js
12
+ // my-component.js
13
+ <Button xcss={{ fill: 'var(--ds-text)' }} />
14
+ ```
15
+
16
+ ## Correct
17
+
18
+ Using xcss in a TypeScript file is perfectly fine
19
+
20
+ ```tsx
21
+ // my-component.tsx
22
+ <Button xcss={{ color: 'var(--ds-text)' }} />
23
+ ```
@@ -0,0 +1,5 @@
1
+ # @atlaskit/design-system/no-keyframes-tagged-template-expression
2
+
3
+ Disallows any keyframes tagged template expressions that originate from @emotion/react, @emotion/core, compiled/react or styled-components.
4
+
5
+ This rule is maintained by another package and configured here, refer to https://atlassian.design/components/eslint-plugin-design-system/no-keyframes-tagged-template-expression/usage for more details
@@ -0,0 +1,5 @@
1
+ # @atlaskit/design-system/no-styled-tagged-template-expression
2
+
3
+ Disallows any styled tagged template expressions that originate from @emotion/react, @emotion/core, compiled/react or styled-components.
4
+
5
+ This rule is maintained by another package and configured here, refer to https://atlassian.design/components/eslint-plugin-design-system/no-styled-tagged-template-expression/usage for more details
@@ -0,0 +1,25 @@
1
+ # @compiled/no-suppress-xcss
2
+
3
+ Disallows supressing type violations when using the xcss prop. Supressing type violations will cause incidents and unexpected behaviour when code changes in the future.
4
+
5
+ Components that use xcss prop have explicitly declared what styles they should and should not accept, consumers must adhere to this API.
6
+
7
+ ## Incorrect
8
+
9
+ Do not suppress type violations; if the value doesn't match the type, fix the value or expect breaking changes in the future.
10
+
11
+ ```js
12
+ // @ts-expect-error
13
+ <Button xcss={{ fill: '#fff' }} />
14
+
15
+ // @ts-ignore
16
+ <Button xcss={{ fill: 'var(--ds-text)' }} />
17
+ ```
18
+
19
+ ## Correct
20
+
21
+ You should never have a type error.
22
+
23
+ ```js
24
+ <Button xcss={{ color: 'var(--ds-text)' }} />
25
+ ```
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.configs = void 0;
8
+ Object.defineProperty(exports, "rules", {
9
+ enumerable: true,
10
+ get: function get() {
11
+ return _index.default;
12
+ }
13
+ });
14
+ var _all = _interopRequireDefault(require("./presets/all.codegen"));
15
+ var _recommended = _interopRequireDefault(require("./presets/recommended.codegen"));
16
+ var _index = _interopRequireDefault(require("./rules/index.codegen"));
17
+ /**
18
+ * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
19
+ * @codegen <<SignedSource::3fd41935576c9346ca1f1e0c787a0a48>>
20
+ * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
21
+ */
22
+
23
+ var configs = exports.configs = {
24
+ all: _all.default,
25
+ recommended: _recommended.default
26
+ };
package/dist/cjs/index.js CHANGED
@@ -3,16 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.rules = exports.configs = void 0;
7
- var rules = exports.rules = {};
8
- var configs = exports.configs = {
9
- recommended: {
10
- plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
11
- rules: {
12
- '@atlaskit/design-system/consistent-css-prop-usage': 'error',
13
- '@atlaskit/design-system/local-cx-xcss': 'error',
14
- '@compiled/no-suppress-xcss': 'error',
15
- '@compiled/no-js-xcss': 'error'
16
- }
6
+ Object.defineProperty(exports, "configs", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _index.configs;
17
10
  }
18
- };
11
+ });
12
+ Object.defineProperty(exports, "rules", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _index.rules;
16
+ }
17
+ });
18
+ var _index = require("./index.codegen");
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /**
8
+ * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
9
+ * @codegen <<SignedSource::6b1418e07df6af9ad4cae4baf66739c1>>
10
+ * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
11
+ */
12
+ var _default = exports.default = {
13
+ plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
14
+ rules: {
15
+ '@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
16
+ '@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
17
+ excludeReactComponents: true
18
+ }],
19
+ '@atlaskit/design-system/no-css-tagged-template-expression': 'warn',
20
+ '@atlaskit/design-system/no-keyframes-tagged-template-expression': 'warn',
21
+ '@atlaskit/design-system/no-styled-tagged-template-expression': 'warn',
22
+ '@compiled/no-suppress-xcss': 'warn',
23
+ '@compiled/no-js-xcss': 'warn',
24
+ '@atlaskit/design-system/no-empty-styled-expression': ['warn', {
25
+ importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components']
26
+ }],
27
+ '@atlaskit/design-system/no-exported-css': ['warn', {
28
+ importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components']
29
+ }],
30
+ '@atlaskit/design-system/no-exported-keyframes': ['warn', {
31
+ importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components']
32
+ }],
33
+ '@atlaskit/design-system/no-invalid-css-map': ['warn', {
34
+ allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
35
+ }]
36
+ }
37
+ };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /**
8
+ * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
9
+ * @codegen <<SignedSource::6b1418e07df6af9ad4cae4baf66739c1>>
10
+ * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
11
+ */
12
+ var _default = exports.default = {
13
+ plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
14
+ rules: {
15
+ '@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
16
+ '@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
17
+ excludeReactComponents: true
18
+ }],
19
+ '@atlaskit/design-system/no-css-tagged-template-expression': 'warn',
20
+ '@atlaskit/design-system/no-keyframes-tagged-template-expression': 'warn',
21
+ '@atlaskit/design-system/no-styled-tagged-template-expression': 'warn',
22
+ '@compiled/no-suppress-xcss': 'warn',
23
+ '@compiled/no-js-xcss': 'warn',
24
+ '@atlaskit/design-system/no-empty-styled-expression': ['warn', {
25
+ importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components']
26
+ }],
27
+ '@atlaskit/design-system/no-exported-css': ['warn', {
28
+ importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components']
29
+ }],
30
+ '@atlaskit/design-system/no-exported-keyframes': ['warn', {
31
+ importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components']
32
+ }],
33
+ '@atlaskit/design-system/no-invalid-css-map': ['warn', {
34
+ allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
35
+ }]
36
+ }
37
+ };