@atlaskit/eslint-plugin-design-system 10.9.0 → 10.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +1 -0
- package/dist/cjs/presets/all.codegen.js +2 -1
- package/dist/cjs/rules/ensure-design-token-usage/index.js +199 -227
- package/dist/cjs/rules/index.codegen.js +3 -1
- package/dist/cjs/rules/no-custom-icons/checks/has-prop.js +12 -0
- package/dist/cjs/rules/no-custom-icons/checks/is-from-import-source.js +42 -0
- package/dist/cjs/rules/no-custom-icons/checks/is-imported-jsx-element.js +10 -0
- package/dist/cjs/rules/no-custom-icons/index.js +67 -0
- package/dist/cjs/rules/no-legacy-icons/checks.js +63 -67
- package/dist/cjs/rules/no-legacy-icons/helpers.js +29 -24
- package/dist/cjs/rules/no-legacy-icons/index.js +15 -88
- package/dist/cjs/rules/use-tokens-typography/index.js +4 -8
- package/dist/cjs/rules/utils/error-boundary.js +58 -11
- package/dist/es2019/presets/all.codegen.js +2 -1
- package/dist/es2019/rules/ensure-design-token-usage/index.js +16 -30
- package/dist/es2019/rules/index.codegen.js +3 -1
- package/dist/es2019/rules/no-custom-icons/checks/has-prop.js +4 -0
- package/dist/es2019/rules/no-custom-icons/checks/is-from-import-source.js +23 -0
- package/dist/es2019/rules/no-custom-icons/checks/is-imported-jsx-element.js +4 -0
- package/dist/es2019/rules/no-custom-icons/index.js +61 -0
- package/dist/es2019/rules/no-legacy-icons/checks.js +20 -33
- package/dist/es2019/rules/no-legacy-icons/helpers.js +24 -21
- package/dist/es2019/rules/no-legacy-icons/index.js +15 -70
- package/dist/es2019/rules/use-tokens-typography/index.js +3 -7
- package/dist/es2019/rules/utils/error-boundary.js +55 -11
- package/dist/esm/presets/all.codegen.js +2 -1
- package/dist/esm/rules/ensure-design-token-usage/index.js +199 -227
- package/dist/esm/rules/index.codegen.js +3 -1
- package/dist/esm/rules/no-custom-icons/checks/has-prop.js +6 -0
- package/dist/esm/rules/no-custom-icons/checks/is-from-import-source.js +36 -0
- package/dist/esm/rules/no-custom-icons/checks/is-imported-jsx-element.js +4 -0
- package/dist/esm/rules/no-custom-icons/index.js +61 -0
- package/dist/esm/rules/no-legacy-icons/checks.js +64 -68
- package/dist/esm/rules/no-legacy-icons/helpers.js +28 -23
- package/dist/esm/rules/no-legacy-icons/index.js +15 -88
- package/dist/esm/rules/use-tokens-typography/index.js +4 -8
- package/dist/esm/rules/utils/error-boundary.js +56 -10
- package/dist/types/index.codegen.d.ts +1 -0
- package/dist/types/presets/all.codegen.d.ts +2 -1
- package/dist/types/rules/index.codegen.d.ts +1 -0
- package/dist/types/rules/no-custom-icons/checks/has-prop.d.ts +2 -0
- package/dist/types/rules/no-custom-icons/checks/is-from-import-source.d.ts +8 -0
- package/dist/types/rules/no-custom-icons/checks/is-imported-jsx-element.d.ts +8 -0
- package/dist/types/rules/no-custom-icons/index.d.ts +3 -0
- package/dist/types/rules/no-legacy-icons/helpers.d.ts +3 -13
- package/dist/types/rules/no-legacy-icons/index.d.ts +1 -2
- package/dist/types/rules/utils/error-boundary.d.ts +8 -5
- package/dist/types-ts4.5/index.codegen.d.ts +1 -0
- package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
- package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
- package/dist/types-ts4.5/rules/no-custom-icons/checks/has-prop.d.ts +2 -0
- package/dist/types-ts4.5/rules/no-custom-icons/checks/is-from-import-source.d.ts +8 -0
- package/dist/types-ts4.5/rules/no-custom-icons/checks/is-imported-jsx-element.d.ts +8 -0
- package/dist/types-ts4.5/rules/no-custom-icons/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/no-legacy-icons/helpers.d.ts +3 -13
- package/dist/types-ts4.5/rules/no-legacy-icons/index.d.ts +1 -2
- package/dist/types-ts4.5/rules/utils/error-boundary.d.ts +8 -5
- package/package.json +2 -2
- package/constellation/consistent-css-prop-usage/usage.mdx +0 -210
- package/constellation/ensure-design-token-usage/usage.mdx +0 -77
- package/constellation/ensure-design-token-usage-preview/usage.mdx +0 -6
- package/constellation/icon-label/usage.mdx +0 -41
- package/constellation/index/props.mdx +0 -30
- package/constellation/index/usage.mdx +0 -56
- package/constellation/no-banned-imports/usage.mdx +0 -19
- package/constellation/no-css-tagged-template-expression/usage.mdx +0 -71
- package/constellation/no-deprecated-apis/usage.mdx +0 -82
- package/constellation/no-deprecated-design-token-usage/usage.mdx +0 -30
- package/constellation/no-deprecated-imports/usage.mdx +0 -66
- package/constellation/no-direct-use-of-web-platform-drag-and-drop/usage.mdx +0 -149
- package/constellation/no-empty-styled-expression/usage.mdx +0 -82
- package/constellation/no-exported-css/usage.mdx +0 -55
- package/constellation/no-exported-keyframes/usage.mdx +0 -55
- package/constellation/no-html-anchor/usage.mdx +0 -46
- package/constellation/no-html-button/usage.mdx +0 -52
- package/constellation/no-invalid-css-map/usage.mdx +0 -210
- package/constellation/no-keyframes-tagged-template-expression/usage.mdx +0 -80
- package/constellation/no-legacy-icons/usage.mdx +0 -42
- package/constellation/no-margin/usage.mdx +0 -21
- package/constellation/no-nested-styles/usage.mdx +0 -47
- package/constellation/no-physical-properties/usage.mdx +0 -53
- package/constellation/no-styled-tagged-template-expression/usage.mdx +0 -135
- package/constellation/no-unsafe-design-token-usage/usage.mdx +0 -50
- package/constellation/no-unsafe-style-overrides/usage.mdx +0 -52
- package/constellation/no-unsupported-drag-and-drop-libraries/usage.mdx +0 -23
- package/constellation/prefer-primitives/usage.mdx +0 -32
- package/constellation/use-button-group-label/usage.mdx +0 -60
- package/constellation/use-drawer-label/usage.mdx +0 -55
- package/constellation/use-heading/usage.mdx +0 -31
- package/constellation/use-heading-level-in-spotlight-card/usage.mdx +0 -21
- package/constellation/use-href-in-link-item/usage.mdx +0 -19
- package/constellation/use-latest-xcss-syntax/usage.mdx +0 -33
- package/constellation/use-latest-xcss-syntax-typography/usage.mdx +0 -34
- package/constellation/use-menu-section-title/usage.mdx +0 -55
- package/constellation/use-popup-label/usage.mdx +0 -56
- package/constellation/use-primitives/usage.mdx +0 -78
- package/constellation/use-primitives-text/usage.mdx +0 -35
- package/constellation/use-tokens-space/usage.mdx +0 -34
- package/constellation/use-tokens-typography/usage.mdx +0 -55
- package/constellation/use-visually-hidden/usage.mdx +0 -35
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { type JSXElement, type JSXIdentifier, type JSXOpeningElement } from 'eslint-codemod-utils';
|
|
3
|
+
export type ImportedJSXElement = JSXElement & Rule.NodeParentExtension & {
|
|
4
|
+
openingElement: JSXOpeningElement & {
|
|
5
|
+
name: JSXIdentifier;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare function isImportedJSXElement(node: Rule.Node): node is ImportedJSXElement;
|
|
@@ -33,12 +33,6 @@ export declare const getMigrationMapObject: (iconPackage: string) => {
|
|
|
33
33
|
library: string;
|
|
34
34
|
} | undefined;
|
|
35
35
|
} | null;
|
|
36
|
-
/**
|
|
37
|
-
* Returns the key of a legacy icon
|
|
38
|
-
* @param iconPackage The name of the legacy icon package
|
|
39
|
-
* @returns The unique identifier for the icon (the part after "@atlaskit/icon/glyph")
|
|
40
|
-
*/
|
|
41
|
-
export declare const getIconKey: (iconPackage: string) => string;
|
|
42
36
|
/**
|
|
43
37
|
* Checks if a new icon can be auto-migrated based on guidance from the migration map
|
|
44
38
|
*/
|
|
@@ -46,7 +40,7 @@ export declare const canAutoMigrateNewIconBasedOnSize: (guidance?: string) => bo
|
|
|
46
40
|
/**
|
|
47
41
|
* Creates the written guidance for migrating a legacy icon to a new icon
|
|
48
42
|
*/
|
|
49
|
-
export declare const createGuidance: (iconPackage: string, size?: Size) => string;
|
|
43
|
+
export declare const createGuidance: (iconPackage: string, insideNewButton?: boolean, size?: Size) => string;
|
|
50
44
|
/**
|
|
51
45
|
* Checks if the color can be migrated
|
|
52
46
|
* @param color String representing the color to check
|
|
@@ -61,16 +55,12 @@ export declare const findUNSAFEProp: (iconAttr: JSXAttribute, button: JSXOpening
|
|
|
61
55
|
UNSAFE_propName: "UNSAFE_iconAfter_size" | "UNSAFE_iconBefore_size" | "UNSAFE_size" | null;
|
|
62
56
|
};
|
|
63
57
|
export declare const createCantMigrateUnsafeProp: (node: Node, propName: string, value: string, packageName: string, iconName: string, errors: errorsListManual) => void;
|
|
64
|
-
export declare const createCantFindSuitableReplacementError: (node: Node, importSource: string, iconName: string, errors: errorsListManual) => void;
|
|
58
|
+
export declare const createCantFindSuitableReplacementError: (node: Node, importSource: string, iconName: string, errors: errorsListManual, sizeIssue?: boolean) => void;
|
|
65
59
|
export declare const createCantMigrateFunctionUnknownError: (node: Node, importSource: string, iconName: string, errors: errorsListManual) => void;
|
|
66
60
|
export declare const createCantMigrateColorError: (node: Node, colorValue: string, errors: errorsListManual, importSource: string, iconName: string) => void;
|
|
67
61
|
export declare const createCantMigrateSpreadPropsError: (node: Node, missingProps: string[], errors: errorsListManual, importSource: string, iconName: string) => void;
|
|
68
62
|
export declare const createCantMigrateSizeUnknown: (node: Node, errors: errorsListManual, importSource: string, iconName: string) => void;
|
|
69
|
-
export declare const createAutoMigrationError: (node: Node, importSource: string, iconName: string,
|
|
70
|
-
name: string;
|
|
71
|
-
type: string;
|
|
72
|
-
library: string;
|
|
73
|
-
}, oldIconName: string, errors: errorsListAuto) => void;
|
|
63
|
+
export declare const createAutoMigrationError: (node: Node, importSource: string, iconName: string, errors: errorsListAuto) => void;
|
|
74
64
|
export declare const getLiteralStringValue: (value: any) => string | undefined;
|
|
75
65
|
export declare const createHelpers: (context: Rule.RuleContext) => {
|
|
76
66
|
/**
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
type
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
type SingleRuleListener = Rule.RuleListener[keyof Rule.RuleListener] & ((...args: any[]) => void);
|
|
3
|
+
type ErrorBoundaryConfig = undefined | boolean | {
|
|
2
4
|
failSilently?: boolean;
|
|
3
|
-
|
|
5
|
+
} | {
|
|
6
|
+
config: {
|
|
7
|
+
failSilently?: boolean;
|
|
8
|
+
};
|
|
4
9
|
};
|
|
5
10
|
/**
|
|
6
11
|
* ESLint rules should NEVER throw exceptions, because that breaks the VSCode ESLint server
|
|
@@ -9,7 +14,5 @@ type RuleConfig = {
|
|
|
9
14
|
* It also breaks CI, which was the reason this error boundary was added. It's a final
|
|
10
15
|
* catch all.
|
|
11
16
|
*/
|
|
12
|
-
export declare
|
|
13
|
-
config: RuleConfig;
|
|
14
|
-
}) => void;
|
|
17
|
+
export declare function errorBoundary<R extends SingleRuleListener | Rule.RuleListener>(ruleOrRules: R, config?: ErrorBoundaryConfig): R;
|
|
15
18
|
export {};
|
|
@@ -9,6 +9,7 @@ export declare const configs: {
|
|
|
9
9
|
'@atlaskit/design-system/icon-label': string;
|
|
10
10
|
'@atlaskit/design-system/no-banned-imports': string;
|
|
11
11
|
'@atlaskit/design-system/no-css-tagged-template-expression': string;
|
|
12
|
+
'@atlaskit/design-system/no-custom-icons': string;
|
|
12
13
|
'@atlaskit/design-system/no-deprecated-apis': string;
|
|
13
14
|
'@atlaskit/design-system/no-deprecated-design-token-usage': string;
|
|
14
15
|
'@atlaskit/design-system/no-deprecated-imports': string;
|
|
@@ -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::ab43b6e1a867d07b9a27eae78d48834a>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -12,6 +12,7 @@ declare const _default: {
|
|
|
12
12
|
'@atlaskit/design-system/icon-label': string;
|
|
13
13
|
'@atlaskit/design-system/no-banned-imports': string;
|
|
14
14
|
'@atlaskit/design-system/no-css-tagged-template-expression': string;
|
|
15
|
+
'@atlaskit/design-system/no-custom-icons': string;
|
|
15
16
|
'@atlaskit/design-system/no-deprecated-apis': string;
|
|
16
17
|
'@atlaskit/design-system/no-deprecated-design-token-usage': string;
|
|
17
18
|
'@atlaskit/design-system/no-deprecated-imports': string;
|
|
@@ -5,6 +5,7 @@ declare const _default: {
|
|
|
5
5
|
'icon-label': import("eslint").Rule.RuleModule;
|
|
6
6
|
'no-banned-imports': import("eslint").Rule.RuleModule;
|
|
7
7
|
'no-css-tagged-template-expression': import("eslint").Rule.RuleModule;
|
|
8
|
+
'no-custom-icons': import("eslint").Rule.RuleModule;
|
|
8
9
|
'no-deprecated-apis': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<string, [
|
|
9
10
|
{
|
|
10
11
|
deprecatedConfig: import("./utils/types").DeprecatedConfig;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import type { ImportDeclaration } from 'eslint-codemod-utils';
|
|
3
|
+
import { type ImportedJSXElement } from './is-imported-jsx-element';
|
|
4
|
+
export declare function createIsFromImportSourceFor(...importSources: (string | RegExp)[]): {
|
|
5
|
+
(node: Rule.Node): node is ImportedJSXElement;
|
|
6
|
+
importDeclarationHook(node: ImportDeclaration): void;
|
|
7
|
+
getImportSource(node: Rule.Node): string;
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { type JSXElement, type JSXIdentifier, type JSXOpeningElement } from 'eslint-codemod-utils';
|
|
3
|
+
export type ImportedJSXElement = JSXElement & Rule.NodeParentExtension & {
|
|
4
|
+
openingElement: JSXOpeningElement & {
|
|
5
|
+
name: JSXIdentifier;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare function isImportedJSXElement(node: Rule.Node): node is ImportedJSXElement;
|
|
@@ -33,12 +33,6 @@ export declare const getMigrationMapObject: (iconPackage: string) => {
|
|
|
33
33
|
library: string;
|
|
34
34
|
} | undefined;
|
|
35
35
|
} | null;
|
|
36
|
-
/**
|
|
37
|
-
* Returns the key of a legacy icon
|
|
38
|
-
* @param iconPackage The name of the legacy icon package
|
|
39
|
-
* @returns The unique identifier for the icon (the part after "@atlaskit/icon/glyph")
|
|
40
|
-
*/
|
|
41
|
-
export declare const getIconKey: (iconPackage: string) => string;
|
|
42
36
|
/**
|
|
43
37
|
* Checks if a new icon can be auto-migrated based on guidance from the migration map
|
|
44
38
|
*/
|
|
@@ -46,7 +40,7 @@ export declare const canAutoMigrateNewIconBasedOnSize: (guidance?: string) => bo
|
|
|
46
40
|
/**
|
|
47
41
|
* Creates the written guidance for migrating a legacy icon to a new icon
|
|
48
42
|
*/
|
|
49
|
-
export declare const createGuidance: (iconPackage: string, size?: Size) => string;
|
|
43
|
+
export declare const createGuidance: (iconPackage: string, insideNewButton?: boolean, size?: Size) => string;
|
|
50
44
|
/**
|
|
51
45
|
* Checks if the color can be migrated
|
|
52
46
|
* @param color String representing the color to check
|
|
@@ -61,16 +55,12 @@ export declare const findUNSAFEProp: (iconAttr: JSXAttribute, button: JSXOpening
|
|
|
61
55
|
UNSAFE_propName: "UNSAFE_iconAfter_size" | "UNSAFE_iconBefore_size" | "UNSAFE_size" | null;
|
|
62
56
|
};
|
|
63
57
|
export declare const createCantMigrateUnsafeProp: (node: Node, propName: string, value: string, packageName: string, iconName: string, errors: errorsListManual) => void;
|
|
64
|
-
export declare const createCantFindSuitableReplacementError: (node: Node, importSource: string, iconName: string, errors: errorsListManual) => void;
|
|
58
|
+
export declare const createCantFindSuitableReplacementError: (node: Node, importSource: string, iconName: string, errors: errorsListManual, sizeIssue?: boolean) => void;
|
|
65
59
|
export declare const createCantMigrateFunctionUnknownError: (node: Node, importSource: string, iconName: string, errors: errorsListManual) => void;
|
|
66
60
|
export declare const createCantMigrateColorError: (node: Node, colorValue: string, errors: errorsListManual, importSource: string, iconName: string) => void;
|
|
67
61
|
export declare const createCantMigrateSpreadPropsError: (node: Node, missingProps: string[], errors: errorsListManual, importSource: string, iconName: string) => void;
|
|
68
62
|
export declare const createCantMigrateSizeUnknown: (node: Node, errors: errorsListManual, importSource: string, iconName: string) => void;
|
|
69
|
-
export declare const createAutoMigrationError: (node: Node, importSource: string, iconName: string,
|
|
70
|
-
name: string;
|
|
71
|
-
type: string;
|
|
72
|
-
library: string;
|
|
73
|
-
}, oldIconName: string, errors: errorsListAuto) => void;
|
|
63
|
+
export declare const createAutoMigrationError: (node: Node, importSource: string, iconName: string, errors: errorsListAuto) => void;
|
|
74
64
|
export declare const getLiteralStringValue: (value: any) => string | undefined;
|
|
75
65
|
export declare const createHelpers: (context: Rule.RuleContext) => {
|
|
76
66
|
/**
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
type
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
type SingleRuleListener = Rule.RuleListener[keyof Rule.RuleListener] & ((...args: any[]) => void);
|
|
3
|
+
type ErrorBoundaryConfig = undefined | boolean | {
|
|
2
4
|
failSilently?: boolean;
|
|
3
|
-
|
|
5
|
+
} | {
|
|
6
|
+
config: {
|
|
7
|
+
failSilently?: boolean;
|
|
8
|
+
};
|
|
4
9
|
};
|
|
5
10
|
/**
|
|
6
11
|
* ESLint rules should NEVER throw exceptions, because that breaks the VSCode ESLint server
|
|
@@ -9,7 +14,5 @@ type RuleConfig = {
|
|
|
9
14
|
* It also breaks CI, which was the reason this error boundary was added. It's a final
|
|
10
15
|
* catch all.
|
|
11
16
|
*/
|
|
12
|
-
export declare
|
|
13
|
-
config: RuleConfig;
|
|
14
|
-
}) => void;
|
|
17
|
+
export declare function errorBoundary<R extends SingleRuleListener | Rule.RuleListener>(ruleOrRules: R, config?: ErrorBoundaryConfig): R;
|
|
15
18
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/eslint-plugin-design-system",
|
|
3
3
|
"description": "The essential plugin for use with the Atlassian Design System.",
|
|
4
|
-
"version": "10.
|
|
4
|
+
"version": "10.10.1",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"publishConfig": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"jscodeshift": "^0.13.0",
|
|
68
68
|
"outdent": "^0.5.0",
|
|
69
69
|
"react": "^16.8.0",
|
|
70
|
-
"ts-jest": "
|
|
70
|
+
"ts-jest": "29.1.2",
|
|
71
71
|
"ts-node": "^10.9.1",
|
|
72
72
|
"tsconfig-paths": "^4.2.0",
|
|
73
73
|
"typescript": "~5.4.2"
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
# consistent-css-prop-usage
|
|
2
|
-
|
|
3
|
-
Ensures consistency with css prop usage.
|
|
4
|
-
|
|
5
|
-
## Rationale
|
|
6
|
-
|
|
7
|
-
Every product should be defining styles in the same way, using the same tools, enforced by the same
|
|
8
|
-
linting rules, which we can then all evolve and scale together.
|
|
9
|
-
|
|
10
|
-
## How the rule works
|
|
11
|
-
|
|
12
|
-
This rule checks for the following cases:
|
|
13
|
-
|
|
14
|
-
- Styles should not be defined inline; it should instead be in a standalone variable.
|
|
15
|
-
- The exception for this is style composition (e.g. `<div css={[baseStyles, moreStyles]} />`),
|
|
16
|
-
which is a way to combine styles from two variables.
|
|
17
|
-
- Styles must be wrapped in a `css` function call.
|
|
18
|
-
- Styles must be defined in the same file as their usage, and not be imported.
|
|
19
|
-
- Styles should not contain spread operators (e.g. `css({ ...spreadStyles })`).
|
|
20
|
-
- Styles must all be defined at the top of the file, or at the bottom of the file.
|
|
21
|
-
|
|
22
|
-
This rule also has an autofixer that enforces and fixes the code (where practical) to meet the above
|
|
23
|
-
requirements.
|
|
24
|
-
|
|
25
|
-
All the above can also work for custom `css` functions, such as `xcss`
|
|
26
|
-
(https://atlassian.design/components/primitives/xcss/).
|
|
27
|
-
|
|
28
|
-
This rule has several options - see below.
|
|
29
|
-
|
|
30
|
-
## Examples
|
|
31
|
-
|
|
32
|
-
### Incorrect
|
|
33
|
-
|
|
34
|
-
**Calling a css/xcss function or direct objects inside the JSX attribute.**
|
|
35
|
-
|
|
36
|
-
```js
|
|
37
|
-
function Button({ children }) {
|
|
38
|
-
return <div css={css({...})}>{children}</div>;
|
|
39
|
-
^^^^^^^ css function call used inline (performance issue)
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
**Inserting a non css-function based object identifier into a css JSX attribute.**
|
|
44
|
-
|
|
45
|
-
```js
|
|
46
|
-
const container = {
|
|
47
|
-
^^^^^^^^^ should be a css function call
|
|
48
|
-
zIndex: 10,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
function Button({ children }) {
|
|
52
|
-
return <button css={container}>{children}</button>;
|
|
53
|
-
}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
**Importing styles from another file.**
|
|
57
|
-
|
|
58
|
-
```js
|
|
59
|
-
import { container } from './styles';
|
|
60
|
-
^^^^^^^^^ styles should be local, not shared
|
|
61
|
-
|
|
62
|
-
function Button({ children }) {
|
|
63
|
-
return <button css={container}>{children}</button>;
|
|
64
|
-
}
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
**Nesting styles with objects instead of arrays.**
|
|
68
|
-
|
|
69
|
-
```js
|
|
70
|
-
const baseContainerStyles = css({
|
|
71
|
-
zIndex: 5,
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const containerStyles = css({
|
|
75
|
-
...baseContainerStyles,
|
|
76
|
-
^^^^^^^^^^^^^^^^^^^^^^ compose styles by providing an array to the css call instead (see example below)
|
|
77
|
-
zIndex: 7,
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
function Button({ children }) {
|
|
81
|
-
return <button css={containerStyles}>{children}</button>;
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### Correct
|
|
86
|
-
|
|
87
|
-
**Using the css() function to create a style object and passing it as a variable into the css={...}
|
|
88
|
-
JSX attribute.**
|
|
89
|
-
|
|
90
|
-
With the following options turned on:
|
|
91
|
-
|
|
92
|
-
- cssFunctions = ['css']
|
|
93
|
-
- stylesPlacement = 'top'
|
|
94
|
-
|
|
95
|
-
```js
|
|
96
|
-
const containerStyles = css({
|
|
97
|
-
zIndex: 1,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
function Button({ children }) {
|
|
101
|
-
return <button css={containerStyles}>{children}</button>;
|
|
102
|
-
}
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
**Technically correct usage of the cssMap function.**
|
|
106
|
-
|
|
107
|
-
With the following options turned on:
|
|
108
|
-
|
|
109
|
-
- cssFunctions = ['css']
|
|
110
|
-
- stylesPlacement = 'top'
|
|
111
|
-
|
|
112
|
-
```js
|
|
113
|
-
const borderStyles = cssMap({
|
|
114
|
-
'solid': '1px solid';
|
|
115
|
-
'none': '0px';
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
function Button({ children }) {
|
|
119
|
-
return <button css={borderStyles[solid]}>{children}</button>;
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
**Create composite styles with arrays, not objects.**
|
|
124
|
-
|
|
125
|
-
With the following options turned on:
|
|
126
|
-
|
|
127
|
-
- cssFunctions = ['css']
|
|
128
|
-
- stylesPlacement = 'bottom'
|
|
129
|
-
|
|
130
|
-
```js
|
|
131
|
-
function Button({ children }) {
|
|
132
|
-
return <button css={[baseContainerStyles, containerStyles]}>{children}</button>;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const baseContainerStyles = css({
|
|
136
|
-
zIndex: 5,
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
const containerStyles = css({
|
|
140
|
-
zIndex: 7,
|
|
141
|
-
});
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
**Ternaries can be used inline**
|
|
145
|
-
|
|
146
|
-
```js
|
|
147
|
-
const baseStyles = css({ color: token('color.text.primary') });
|
|
148
|
-
const disabledStyles = css({ color: token('color.text.disabled') });
|
|
149
|
-
|
|
150
|
-
<div css={props.disabled ? disabledStyles : baseStyles}></div>;
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
## Options
|
|
154
|
-
|
|
155
|
-
This rule comes with options to support different repository configurations.
|
|
156
|
-
|
|
157
|
-
### cssFunctions
|
|
158
|
-
|
|
159
|
-
An array of function names the linting rule should target. Defaults to `['css', 'xcss']`. The
|
|
160
|
-
functionality of `cssMap` will be linted regardless of the configuration of `cssFunctions`, as it
|
|
161
|
-
can be used with either attribute.
|
|
162
|
-
|
|
163
|
-
### stylesPlacement
|
|
164
|
-
|
|
165
|
-
Either `top` or `bottom`.
|
|
166
|
-
|
|
167
|
-
The rule prevents inline styles from being created. This option defines what the error message
|
|
168
|
-
should say: "(...) styles at the top (...)" or "(...) styles at the bottom (...)". Defaults to
|
|
169
|
-
`top`.
|
|
170
|
-
|
|
171
|
-
### cssImportSource
|
|
172
|
-
|
|
173
|
-
When auto-fixing the contents of the `css` attribute, this rule will wrap CSS styles in a `css(...)`
|
|
174
|
-
function call or ``css`...` `` template expression, and it will add an import declaration for the
|
|
175
|
-
`css` function. `cssImportSource` is a string that determines what package `css` should be imported
|
|
176
|
-
from.
|
|
177
|
-
|
|
178
|
-
This is `@compiled/react` by default.
|
|
179
|
-
|
|
180
|
-
### xcssImportSource
|
|
181
|
-
|
|
182
|
-
When auto-fixing the contents of the `xcss` attribute, this rule will wrap XCSS styles in a
|
|
183
|
-
`xcss(...)` function call, and it will add an import declaration for the `xcss` function.
|
|
184
|
-
`xcssImportSource` is a string that determines what package `xcss` should be imported from.
|
|
185
|
-
|
|
186
|
-
This is `@atlaskit/primitives` by default.
|
|
187
|
-
|
|
188
|
-
### excludeReactComponents
|
|
189
|
-
|
|
190
|
-
Whether to exclude `css` attributes of React components from being affected by this ESLint rule. We
|
|
191
|
-
assume that an element is a React component if its name starts with a capital letter, e.g.
|
|
192
|
-
`<Button />`.
|
|
193
|
-
|
|
194
|
-
This is `false` by default.
|
|
195
|
-
|
|
196
|
-
### shouldAlwaysCheckXcss
|
|
197
|
-
|
|
198
|
-
Overrides `excludeReactComponents` specifically for the `xcss` prop.
|
|
199
|
-
|
|
200
|
-
This means that even if `excludeReactComponents` is `true`, you can still lint the `xcss` prop by
|
|
201
|
-
setting `shouldAlwaysCheckXcss` to `true`.
|
|
202
|
-
|
|
203
|
-
This is `false` by default.
|
|
204
|
-
|
|
205
|
-
### autoFix
|
|
206
|
-
|
|
207
|
-
When set to `true`, this rule will turn on the autofixer. Set this to `false` if you do not want the
|
|
208
|
-
autofixers to run.
|
|
209
|
-
|
|
210
|
-
This is `true` by default.
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
# ensure-design-token-usage
|
|
2
|
-
|
|
3
|
-
Using design tokens results in a harmonious experience for end users whilst providing theming and
|
|
4
|
-
consistency. All experiences must use color tokens otherwise when switching between themes,
|
|
5
|
-
unexpected incidents can occur where not all of the UI is themed. Space, and shape tokens are
|
|
6
|
-
strongly recommended to further align our experiences and make future changes easier.
|
|
7
|
-
|
|
8
|
-
## Examples
|
|
9
|
-
|
|
10
|
-
Using anything other than design tokens such as hardcoded values or legacy theme colors will be
|
|
11
|
-
considered violations.
|
|
12
|
-
|
|
13
|
-
### Incorrect
|
|
14
|
-
|
|
15
|
-
```js
|
|
16
|
-
import { e100 } from '@atlaskit/theme/elevation';
|
|
17
|
-
import { B100 } from '@atlaskit/theme/colors';
|
|
18
|
-
|
|
19
|
-
css({ color: 'red' });
|
|
20
|
-
^^^
|
|
21
|
-
css({ boxShadow: '0px 1px 1px #161A1D32' });
|
|
22
|
-
^^^^^^^^^
|
|
23
|
-
css`${e100};`;
|
|
24
|
-
^^^^
|
|
25
|
-
css({ color: B100 });
|
|
26
|
-
^^^^
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### Correct
|
|
30
|
-
|
|
31
|
-
```js
|
|
32
|
-
import { token } from '@atlaskit/tokens';
|
|
33
|
-
|
|
34
|
-
css({ color: token('color.text.danger') });
|
|
35
|
-
|
|
36
|
-
css({ boxShadow: token('elevation.shadow.card') });
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### Incorrect
|
|
40
|
-
|
|
41
|
-
```js
|
|
42
|
-
css({ padding: '16px' });
|
|
43
|
-
^^^
|
|
44
|
-
css({ margin: gridSize() });
|
|
45
|
-
^^^^^^^^^^
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Correct
|
|
49
|
-
|
|
50
|
-
```js
|
|
51
|
-
import { token } from '@atlaskit/tokens';
|
|
52
|
-
|
|
53
|
-
css({ padding: token('space.100') });
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## Options
|
|
57
|
-
|
|
58
|
-
This rule comes with options to aid in migrating to design tokens.
|
|
59
|
-
|
|
60
|
-
### domains
|
|
61
|
-
|
|
62
|
-
An array specifiying which token domains to lint against (`color`, `spacing`, `shape`). Defaults to
|
|
63
|
-
[`'color'`] if not provided.
|
|
64
|
-
|
|
65
|
-
### applyImport
|
|
66
|
-
|
|
67
|
-
When `true`, the rule when automatically add imports to the `@atlaskit/tokens` package where tokens
|
|
68
|
-
are auto-fixed. Defaults to `true` if not provided.
|
|
69
|
-
|
|
70
|
-
### shouldEnforceFallbacks
|
|
71
|
-
|
|
72
|
-
When `true` the rule will add in stub fallbacks when choosing a suggestion in your IDE. Defaults to
|
|
73
|
-
`false` if not provided.
|
|
74
|
-
|
|
75
|
-
### exceptions
|
|
76
|
-
|
|
77
|
-
An array specifying strings to ingore when linting.
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# icon-label
|
|
2
|
-
|
|
3
|
-
Icon labels are used to describe what the icon is so the visually impaired can be described what the
|
|
4
|
-
UI element is. There are cases where icons should have labels as well as cases where they shouldn't
|
|
5
|
-
be labelled.
|
|
6
|
-
|
|
7
|
-
## Examples
|
|
8
|
-
|
|
9
|
-
This rule will find violations for when an icon label is or isn't needed when composed with other
|
|
10
|
-
Design System components.
|
|
11
|
-
|
|
12
|
-
### Incorrect
|
|
13
|
-
|
|
14
|
-
```js
|
|
15
|
-
import ActivityIcon from '@atlaskit/icon/glyph/activity'
|
|
16
|
-
|
|
17
|
-
<ActivityIcon>
|
|
18
|
-
^^^^^^^^^^^^^^ missing `label` prop
|
|
19
|
-
|
|
20
|
-
<Button iconLeft={<ActivityIcon label="">} />
|
|
21
|
-
^^^^^ label should be defined
|
|
22
|
-
|
|
23
|
-
<ButtonItem iconBefore={<ActivityIcon label="">}>
|
|
24
|
-
^^^^^ label should not be defined
|
|
25
|
-
My activity
|
|
26
|
-
</ButtonItem>
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### Correct
|
|
30
|
-
|
|
31
|
-
```js
|
|
32
|
-
import ActivityIcon from '@atlaskit/icon/glyph/activity'
|
|
33
|
-
|
|
34
|
-
<ActivityIcon label="Activity">
|
|
35
|
-
|
|
36
|
-
<Button iconLeft={<ActivityIcon label="Activity">} />
|
|
37
|
-
|
|
38
|
-
<ButtonItem iconBefore={<ActivityIcon label="">}>
|
|
39
|
-
My activity
|
|
40
|
-
</ButtonItem>
|
|
41
|
-
```
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
Use the recommended config to get reasonable defaults recommended by the Atlassian Design System:
|
|
2
|
-
|
|
3
|
-
```diff
|
|
4
|
-
module.exports = {
|
|
5
|
-
extends: [
|
|
6
|
-
+ 'plugin:@atlaskit/design-system/recommended',
|
|
7
|
-
],
|
|
8
|
-
};
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
We don't recommended maintaining your own configuration. If you do not use our config you will need
|
|
12
|
-
to specify individual rules and configuration. Add the plugin to your `.eslintrc.js` file.
|
|
13
|
-
|
|
14
|
-
```diff
|
|
15
|
-
module.exports = {
|
|
16
|
-
plugins: [
|
|
17
|
-
+ '@atlaskit/design-system',
|
|
18
|
-
],
|
|
19
|
-
};
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
Enable the rules that you would like to use.
|
|
23
|
-
|
|
24
|
-
```diff
|
|
25
|
-
module.exports = {
|
|
26
|
-
rules: [
|
|
27
|
-
+ '@atlaskit/design-system/no-deprecated-apis': 'error',
|
|
28
|
-
],
|
|
29
|
-
};
|
|
30
|
-
```
|