@atlaskit/eslint-plugin-design-system 8.25.2 → 8.27.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 +42 -0
- package/README.md +4 -0
- package/constellation/index/usage.mdx +402 -6
- package/dist/cjs/presets/all.codegen.js +5 -1
- package/dist/cjs/presets/recommended.codegen.js +5 -1
- package/dist/cjs/rules/consistent-css-prop-usage/index.js +254 -32
- package/dist/cjs/rules/index.codegen.js +9 -1
- package/dist/cjs/rules/no-empty-styled-expression/index.js +75 -0
- package/dist/cjs/rules/no-exported-css/index.js +37 -0
- package/dist/cjs/rules/no-exported-keyframes/index.js +37 -0
- package/dist/cjs/rules/no-invalid-css-map/index.js +102 -0
- package/dist/cjs/rules/no-invalid-css-map/utils.js +193 -0
- package/dist/cjs/rules/utils/create-no-exported-rule/check-if-supported-export.js +158 -0
- package/dist/cjs/rules/utils/create-no-exported-rule/is-styled-component.js +80 -0
- package/dist/cjs/rules/utils/create-no-exported-rule/main.js +66 -0
- package/dist/cjs/rules/utils/get-first-supported-import.js +28 -0
- package/dist/cjs/rules/utils/is-supported-import.js +53 -16
- package/dist/es2019/presets/all.codegen.js +5 -1
- package/dist/es2019/presets/recommended.codegen.js +5 -1
- package/dist/es2019/rules/consistent-css-prop-usage/index.js +251 -33
- package/dist/es2019/rules/index.codegen.js +9 -1
- package/dist/es2019/rules/no-empty-styled-expression/index.js +65 -0
- package/dist/es2019/rules/no-exported-css/index.js +31 -0
- package/dist/es2019/rules/no-exported-keyframes/index.js +31 -0
- package/dist/es2019/rules/no-invalid-css-map/index.js +95 -0
- package/dist/es2019/rules/no-invalid-css-map/utils.js +134 -0
- package/dist/es2019/rules/utils/create-no-exported-rule/check-if-supported-export.js +142 -0
- package/dist/es2019/rules/utils/create-no-exported-rule/is-styled-component.js +70 -0
- package/dist/es2019/rules/utils/create-no-exported-rule/main.js +59 -0
- package/dist/es2019/rules/utils/get-first-supported-import.js +22 -0
- package/dist/es2019/rules/utils/is-supported-import.js +50 -15
- package/dist/esm/presets/all.codegen.js +5 -1
- package/dist/esm/presets/recommended.codegen.js +5 -1
- package/dist/esm/rules/consistent-css-prop-usage/index.js +255 -33
- package/dist/esm/rules/index.codegen.js +9 -1
- package/dist/esm/rules/no-empty-styled-expression/index.js +68 -0
- package/dist/esm/rules/no-exported-css/index.js +31 -0
- package/dist/esm/rules/no-exported-keyframes/index.js +31 -0
- package/dist/esm/rules/no-invalid-css-map/index.js +96 -0
- package/dist/esm/rules/no-invalid-css-map/utils.js +186 -0
- package/dist/esm/rules/utils/create-no-exported-rule/check-if-supported-export.js +151 -0
- package/dist/esm/rules/utils/create-no-exported-rule/is-styled-component.js +74 -0
- package/dist/esm/rules/utils/create-no-exported-rule/main.js +60 -0
- package/dist/esm/rules/utils/get-first-supported-import.js +22 -0
- package/dist/esm/rules/utils/is-supported-import.js +51 -15
- package/dist/types/index.codegen.d.ts +8 -0
- package/dist/types/presets/all.codegen.d.ts +5 -1
- package/dist/types/presets/recommended.codegen.d.ts +5 -1
- package/dist/types/rules/consistent-css-prop-usage/types.d.ts +7 -2
- package/dist/types/rules/index.codegen.d.ts +4 -0
- package/dist/types/rules/no-empty-styled-expression/index.d.ts +3 -0
- package/dist/types/rules/no-exported-css/index.d.ts +3 -0
- package/dist/types/rules/no-exported-keyframes/index.d.ts +3 -0
- package/dist/types/rules/no-invalid-css-map/index.d.ts +3 -0
- package/dist/types/rules/no-invalid-css-map/utils.d.ts +14 -0
- package/dist/types/rules/use-primitives/utils/update-jsx-attribute-by-name.d.ts +1 -1
- package/dist/types/rules/utils/create-no-exported-rule/check-if-supported-export.d.ts +15 -0
- package/dist/types/rules/utils/create-no-exported-rule/is-styled-component.d.ts +14 -0
- package/dist/types/rules/utils/create-no-exported-rule/main.d.ts +19 -0
- package/dist/types/rules/utils/create-rule.d.ts +1 -1
- package/dist/types/rules/utils/get-first-supported-import.d.ts +17 -0
- package/dist/types/rules/utils/is-supported-import.d.ts +26 -8
- package/dist/types-ts4.5/index.codegen.d.ts +8 -0
- package/dist/types-ts4.5/presets/all.codegen.d.ts +5 -1
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +5 -1
- package/dist/types-ts4.5/rules/consistent-css-prop-usage/types.d.ts +7 -2
- package/dist/types-ts4.5/rules/index.codegen.d.ts +4 -0
- package/dist/types-ts4.5/rules/no-empty-styled-expression/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/no-exported-css/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/no-exported-keyframes/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/no-invalid-css-map/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/no-invalid-css-map/utils.d.ts +14 -0
- package/dist/types-ts4.5/rules/use-primitives/utils/update-jsx-attribute-by-name.d.ts +1 -1
- package/dist/types-ts4.5/rules/utils/create-no-exported-rule/check-if-supported-export.d.ts +15 -0
- package/dist/types-ts4.5/rules/utils/create-no-exported-rule/is-styled-component.d.ts +14 -0
- package/dist/types-ts4.5/rules/utils/create-no-exported-rule/main.d.ts +19 -0
- package/dist/types-ts4.5/rules/utils/create-rule.d.ts +1 -1
- package/dist/types-ts4.5/rules/utils/get-first-supported-import.d.ts +17 -0
- package/dist/types-ts4.5/rules/utils/is-supported-import.d.ts +26 -8
- package/package.json +3 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
3
|
|
|
3
4
|
export var CSS_IN_JS_IMPORTS = {
|
|
@@ -5,34 +6,68 @@ export var CSS_IN_JS_IMPORTS = {
|
|
|
5
6
|
emotionReact: '@emotion/react',
|
|
6
7
|
emotionCore: '@emotion/core',
|
|
7
8
|
styledComponents: 'styled-components',
|
|
8
|
-
atlaskitCss: '@atlaskit/css'
|
|
9
|
+
atlaskitCss: '@atlaskit/css',
|
|
10
|
+
atlaskitPrimitives: '@atlaskit/primitives'
|
|
9
11
|
};
|
|
10
12
|
|
|
11
|
-
//
|
|
13
|
+
// A CSS-in-JS library an import of a valid css, cx, cssMap, etc.
|
|
12
14
|
// function might originate from, e.g. @compiled/react, @emotion/core.
|
|
15
|
+
// All ESLint rules originating from `@compiled/eslint-plugin` should apply to these libraries.
|
|
16
|
+
export var DEFAULT_IMPORT_SOURCES = [CSS_IN_JS_IMPORTS.compiled, CSS_IN_JS_IMPORTS.atlaskitCss];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Given the ESLint rule context, extract and parse the value of the importSources rule option.
|
|
20
|
+
* The importSources option is used to define additional libraries for which an ESLint rule
|
|
21
|
+
* should apply to.
|
|
22
|
+
*
|
|
23
|
+
* Note that `@compiled/react` and `@atlaskit/css` are always included in importSources, regardless
|
|
24
|
+
* of what importSources is configured to by the user.
|
|
25
|
+
*
|
|
26
|
+
* @param context The rule context.
|
|
27
|
+
* @returns An array of strings representing what CSS-in-JS packages that should be checked, based
|
|
28
|
+
* on the rule options configuration.
|
|
29
|
+
*/
|
|
30
|
+
export var getImportSources = function getImportSources(context) {
|
|
31
|
+
var options = context.options;
|
|
32
|
+
if (!options.length) {
|
|
33
|
+
return DEFAULT_IMPORT_SOURCES;
|
|
34
|
+
}
|
|
35
|
+
if (options[0].importSources && Array.isArray(options[0].importSources)) {
|
|
36
|
+
return [].concat(DEFAULT_IMPORT_SOURCES, _toConsumableArray(options[0].importSources));
|
|
37
|
+
}
|
|
38
|
+
return DEFAULT_IMPORT_SOURCES;
|
|
39
|
+
};
|
|
13
40
|
var isSupportedImportWrapper = function isSupportedImportWrapper(functionName) {
|
|
14
|
-
// This will need to be extended to support default imports once we start
|
|
15
|
-
// checking cases like `import css from '@emotion/css'`
|
|
16
41
|
var checkDefinitionHasImport = function checkDefinitionHasImport(def, importSources) {
|
|
17
|
-
|
|
18
|
-
|
|
42
|
+
if (def.type !== 'ImportBinding') {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
if (!def.parent || !importSources.includes(def.parent.source.value)) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return (
|
|
49
|
+
// import { functionName } from 'import-source';
|
|
50
|
+
def.node.type === 'ImportSpecifier' && def.node.imported.name === functionName ||
|
|
51
|
+
// import functionName from 'import-source';
|
|
52
|
+
def.node.type === 'ImportDefaultSpecifier' && def.node.local.name === functionName
|
|
53
|
+
);
|
|
19
54
|
};
|
|
20
55
|
|
|
21
56
|
/**
|
|
22
57
|
* Checks whether:
|
|
23
58
|
*
|
|
24
|
-
* 1.
|
|
59
|
+
* 1. A function name `nodeToCheck` matches the name of the function we
|
|
25
60
|
* want to check for (e.g. `cx`, `css`, `cssMap`, or `keyframes`), and
|
|
26
|
-
* 2.
|
|
61
|
+
* 2. Whether `nodeToCheck` originates from one of the libraries listed
|
|
27
62
|
* in `importSources`.
|
|
28
63
|
*
|
|
29
|
-
* @param nodeToCheck
|
|
30
|
-
* @param referencesInScope
|
|
64
|
+
* @param nodeToCheck The function callee we are checking (e.g. The `css` in `css()`).
|
|
65
|
+
* @param referencesInScope List of references that are in scope. We'll use this
|
|
31
66
|
* to check where the function callee is imported from.
|
|
32
|
-
* @param importSources
|
|
33
|
-
* comes from
|
|
67
|
+
* @param importSources List of libraries that we want to ensure `nodeToCheck`
|
|
68
|
+
* comes from.
|
|
34
69
|
*
|
|
35
|
-
* @returns
|
|
70
|
+
* @returns Whether the above conditions are true.
|
|
36
71
|
*/
|
|
37
72
|
var isSupportedImport = function isSupportedImport(nodeToCheck, referencesInScope, importSources) {
|
|
38
73
|
return nodeToCheck.type === 'Identifier' && referencesInScope.some(function (reference) {
|
|
@@ -50,5 +85,6 @@ var isSupportedImportWrapper = function isSupportedImportWrapper(functionName) {
|
|
|
50
85
|
//
|
|
51
86
|
export var isCss = isSupportedImportWrapper('css');
|
|
52
87
|
export var isCxFunction = isSupportedImportWrapper('cx');
|
|
53
|
-
|
|
54
|
-
|
|
88
|
+
export var isCssMap = isSupportedImportWrapper('cssMap');
|
|
89
|
+
export var isKeyframes = isSupportedImportWrapper('keyframes');
|
|
90
|
+
export var isStyled = isSupportedImportWrapper('styled');
|
|
@@ -13,6 +13,10 @@ export declare const configs: {
|
|
|
13
13
|
'@atlaskit/design-system/no-deprecated-apis': string;
|
|
14
14
|
'@atlaskit/design-system/no-deprecated-design-token-usage': string;
|
|
15
15
|
'@atlaskit/design-system/no-deprecated-imports': string;
|
|
16
|
+
'@atlaskit/design-system/no-empty-styled-expression': string;
|
|
17
|
+
'@atlaskit/design-system/no-exported-css': string;
|
|
18
|
+
'@atlaskit/design-system/no-exported-keyframes': string;
|
|
19
|
+
'@atlaskit/design-system/no-invalid-css-map': string;
|
|
16
20
|
'@atlaskit/design-system/no-margin': string;
|
|
17
21
|
'@atlaskit/design-system/no-nested-styles': string;
|
|
18
22
|
'@atlaskit/design-system/no-physical-properties': string;
|
|
@@ -39,6 +43,10 @@ export declare const configs: {
|
|
|
39
43
|
'@atlaskit/design-system/no-deprecated-apis': string;
|
|
40
44
|
'@atlaskit/design-system/no-deprecated-design-token-usage': string;
|
|
41
45
|
'@atlaskit/design-system/no-deprecated-imports': string;
|
|
46
|
+
'@atlaskit/design-system/no-empty-styled-expression': string;
|
|
47
|
+
'@atlaskit/design-system/no-exported-css': string;
|
|
48
|
+
'@atlaskit/design-system/no-exported-keyframes': string;
|
|
49
|
+
'@atlaskit/design-system/no-invalid-css-map': string;
|
|
42
50
|
'@atlaskit/design-system/no-nested-styles': string;
|
|
43
51
|
'@atlaskit/design-system/no-unsafe-design-token-usage': string;
|
|
44
52
|
'@atlaskit/design-system/no-unsafe-style-overrides': 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::914085544778f4543f43e3e30d0982e0>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -16,6 +16,10 @@ declare const _default: {
|
|
|
16
16
|
'@atlaskit/design-system/no-deprecated-apis': string;
|
|
17
17
|
'@atlaskit/design-system/no-deprecated-design-token-usage': string;
|
|
18
18
|
'@atlaskit/design-system/no-deprecated-imports': string;
|
|
19
|
+
'@atlaskit/design-system/no-empty-styled-expression': string;
|
|
20
|
+
'@atlaskit/design-system/no-exported-css': string;
|
|
21
|
+
'@atlaskit/design-system/no-exported-keyframes': string;
|
|
22
|
+
'@atlaskit/design-system/no-invalid-css-map': string;
|
|
19
23
|
'@atlaskit/design-system/no-margin': string;
|
|
20
24
|
'@atlaskit/design-system/no-nested-styles': string;
|
|
21
25
|
'@atlaskit/design-system/no-physical-properties': 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::577269c832952ce359cde6a50f26f4e0>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -14,6 +14,10 @@ declare const _default: {
|
|
|
14
14
|
'@atlaskit/design-system/no-deprecated-apis': string;
|
|
15
15
|
'@atlaskit/design-system/no-deprecated-design-token-usage': string;
|
|
16
16
|
'@atlaskit/design-system/no-deprecated-imports': string;
|
|
17
|
+
'@atlaskit/design-system/no-empty-styled-expression': string;
|
|
18
|
+
'@atlaskit/design-system/no-exported-css': string;
|
|
19
|
+
'@atlaskit/design-system/no-exported-keyframes': string;
|
|
20
|
+
'@atlaskit/design-system/no-invalid-css-map': string;
|
|
17
21
|
'@atlaskit/design-system/no-nested-styles': string;
|
|
18
22
|
'@atlaskit/design-system/no-unsafe-design-token-usage': string;
|
|
19
23
|
'@atlaskit/design-system/no-unsafe-style-overrides': string;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import type { ImportSource } from '../utils/is-supported-import';
|
|
1
2
|
export type RuleConfig = {
|
|
2
|
-
cssFunctions
|
|
3
|
-
stylesPlacement
|
|
3
|
+
cssFunctions: string[];
|
|
4
|
+
stylesPlacement: 'top' | 'bottom';
|
|
5
|
+
cssImportSource: ImportSource;
|
|
6
|
+
xcssImportSource: ImportSource;
|
|
7
|
+
excludeReactComponents: boolean;
|
|
8
|
+
fixNamesOnly: boolean;
|
|
4
9
|
};
|
|
@@ -13,6 +13,10 @@ declare const _default: {
|
|
|
13
13
|
'no-deprecated-imports': import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<string, [{
|
|
14
14
|
deprecatedConfig: import("./utils/types").DeprecatedConfig;
|
|
15
15
|
}], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>;
|
|
16
|
+
'no-empty-styled-expression': import("eslint").Rule.RuleModule;
|
|
17
|
+
'no-exported-css': import("eslint").Rule.RuleModule;
|
|
18
|
+
'no-exported-keyframes': import("eslint").Rule.RuleModule;
|
|
19
|
+
'no-invalid-css-map': import("eslint").Rule.RuleModule;
|
|
16
20
|
'no-margin': import("eslint").Rule.RuleModule;
|
|
17
21
|
'no-nested-styles': import("eslint").Rule.RuleModule;
|
|
18
22
|
'no-physical-properties': import("eslint").Rule.RuleModule;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import type { CallExpression, ObjectExpression } from 'estree';
|
|
3
|
+
export declare const getCssMapObject: (node: CallExpression) => ObjectExpression | undefined;
|
|
4
|
+
export declare class CssMapObjectChecker {
|
|
5
|
+
private readonly allowedFunctionCalls;
|
|
6
|
+
private readonly cssMapObject;
|
|
7
|
+
private readonly report;
|
|
8
|
+
private readonly references;
|
|
9
|
+
constructor(cssMapObject: ObjectExpression, context: Rule.RuleContext);
|
|
10
|
+
private isNotWhitelistedFunction;
|
|
11
|
+
private checkCssMapObjectValue;
|
|
12
|
+
private checkCssMapObject;
|
|
13
|
+
run(): void;
|
|
14
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
-
export declare const updateJSXAttributeByName: (oldName: string, newName: string, node: JSXElement, fixer: Rule.RuleFixer) => never[]
|
|
3
|
+
export declare const updateJSXAttributeByName: (oldName: string, newName: string, node: JSXElement, fixer: Rule.RuleFixer) => Rule.Fix | never[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Rule, Scope as ScopeNamespace } from 'eslint';
|
|
2
|
+
import { ImportSource } from '../is-supported-import';
|
|
3
|
+
type Node = Rule.Node;
|
|
4
|
+
type RuleContext = Rule.RuleContext;
|
|
5
|
+
type Scope = ScopeNamespace.Scope;
|
|
6
|
+
type Yes = {
|
|
7
|
+
isExport: true;
|
|
8
|
+
node: Node;
|
|
9
|
+
};
|
|
10
|
+
type No = {
|
|
11
|
+
isExport: false;
|
|
12
|
+
};
|
|
13
|
+
type IsSupportedExport = Yes | No;
|
|
14
|
+
export declare const checkIfSupportedExport: (context: RuleContext, node: Node, importSources: ImportSource[], scope?: Scope) => IsSupportedExport;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import type { ImportSource } from '../is-supported-import';
|
|
3
|
+
type Node = Rule.Node;
|
|
4
|
+
type RuleContext = Rule.RuleContext;
|
|
5
|
+
/**
|
|
6
|
+
* Returns whether the node is a usage of the `styled` API in the libraries we support.
|
|
7
|
+
*
|
|
8
|
+
* @param nodes Nodes to check.
|
|
9
|
+
* @param context Rule context.
|
|
10
|
+
* @param importSources A list of libraries we support.
|
|
11
|
+
* @returns Whether the node is a usage of the `styled` API.
|
|
12
|
+
*/
|
|
13
|
+
export declare const isStyledComponent: (nodes: Node[], context: RuleContext, importSources: ImportSource[]) => boolean;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { type SupportedNameChecker } from '../is-supported-import';
|
|
3
|
+
type RuleModule = Rule.RuleModule;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new ESLint rule for banning exporting certain function calls, e.g.
|
|
6
|
+
* `css` and `keyframes`.
|
|
7
|
+
*
|
|
8
|
+
* Copied from the `utils/create-no-exported-rule/` folder in @compiled/eslint-plugin.
|
|
9
|
+
*
|
|
10
|
+
* Requires an importSources option defined on the rule, which is used to define additional
|
|
11
|
+
* packages which should be checked as part of this rule.
|
|
12
|
+
*
|
|
13
|
+
* @param isUsage A function that checks whether the current node matches the desired
|
|
14
|
+
* function call to check.
|
|
15
|
+
* @param messageId The ESLint error message to use for lint violations.
|
|
16
|
+
* @returns An eslint rule.
|
|
17
|
+
*/
|
|
18
|
+
export declare const createNoExportedRule: (isUsage: SupportedNameChecker, messageId: string) => RuleModule['create'];
|
|
19
|
+
export {};
|
|
@@ -30,7 +30,7 @@ export interface LintRuleMeta extends Omit<Rule.RuleMetaData, 'docs'> {
|
|
|
30
30
|
*/
|
|
31
31
|
description: string;
|
|
32
32
|
/**
|
|
33
|
-
* Specifies the URL at which the full documentation can be accessed
|
|
33
|
+
* Specifies the URL at which the full documentation can be accessed.
|
|
34
34
|
*/
|
|
35
35
|
url?: string | undefined;
|
|
36
36
|
/**
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { ImportDeclaration } from 'eslint-codemod-utils';
|
|
3
|
+
import { ImportSource } from './is-supported-import';
|
|
4
|
+
type RuleContext = Rule.RuleContext;
|
|
5
|
+
/**
|
|
6
|
+
* Get the first import declaration in the file that matches any of the packages
|
|
7
|
+
* in `importSources`.
|
|
8
|
+
*
|
|
9
|
+
* @param context Rule context.
|
|
10
|
+
* @param importSources The packages to check import statements for. If importSources
|
|
11
|
+
* contains more than one package, the first import statement
|
|
12
|
+
* detected in the file that matches any of the packages will be
|
|
13
|
+
* returned.
|
|
14
|
+
* @returns The first import declaration found in the file.
|
|
15
|
+
*/
|
|
16
|
+
export declare const getFirstSupportedImport: (context: RuleContext, importSources: ImportSource[]) => ImportDeclaration | undefined;
|
|
17
|
+
export {};
|
|
@@ -1,16 +1,34 @@
|
|
|
1
|
-
import type { Scope } from 'eslint';
|
|
1
|
+
import type { Rule, Scope } from 'eslint';
|
|
2
2
|
import type { CallExpression } from 'estree';
|
|
3
3
|
type Callee = CallExpression['callee'];
|
|
4
4
|
type Reference = Scope.Reference;
|
|
5
5
|
export declare const CSS_IN_JS_IMPORTS: {
|
|
6
|
-
compiled:
|
|
7
|
-
emotionReact:
|
|
8
|
-
emotionCore:
|
|
9
|
-
styledComponents:
|
|
10
|
-
atlaskitCss:
|
|
6
|
+
readonly compiled: "@compiled/react";
|
|
7
|
+
readonly emotionReact: "@emotion/react";
|
|
8
|
+
readonly emotionCore: "@emotion/core";
|
|
9
|
+
readonly styledComponents: "styled-components";
|
|
10
|
+
readonly atlaskitCss: "@atlaskit/css";
|
|
11
|
+
readonly atlaskitPrimitives: "@atlaskit/primitives";
|
|
11
12
|
};
|
|
12
|
-
type
|
|
13
|
-
export type SupportedNameChecker = (nodeToCheck: Callee, referencesInScope: Reference[], importSources:
|
|
13
|
+
export type ImportSource = string;
|
|
14
|
+
export type SupportedNameChecker = (nodeToCheck: Callee, referencesInScope: Reference[], importSources: ImportSource[]) => boolean;
|
|
15
|
+
export declare const DEFAULT_IMPORT_SOURCES: ImportSource[];
|
|
16
|
+
/**
|
|
17
|
+
* Given the ESLint rule context, extract and parse the value of the importSources rule option.
|
|
18
|
+
* The importSources option is used to define additional libraries for which an ESLint rule
|
|
19
|
+
* should apply to.
|
|
20
|
+
*
|
|
21
|
+
* Note that `@compiled/react` and `@atlaskit/css` are always included in importSources, regardless
|
|
22
|
+
* of what importSources is configured to by the user.
|
|
23
|
+
*
|
|
24
|
+
* @param context The rule context.
|
|
25
|
+
* @returns An array of strings representing what CSS-in-JS packages that should be checked, based
|
|
26
|
+
* on the rule options configuration.
|
|
27
|
+
*/
|
|
28
|
+
export declare const getImportSources: (context: Rule.RuleContext) => ImportSource[];
|
|
14
29
|
export declare const isCss: SupportedNameChecker;
|
|
15
30
|
export declare const isCxFunction: SupportedNameChecker;
|
|
31
|
+
export declare const isCssMap: SupportedNameChecker;
|
|
32
|
+
export declare const isKeyframes: SupportedNameChecker;
|
|
33
|
+
export declare const isStyled: SupportedNameChecker;
|
|
16
34
|
export {};
|
|
@@ -13,6 +13,10 @@ export declare const configs: {
|
|
|
13
13
|
'@atlaskit/design-system/no-deprecated-apis': string;
|
|
14
14
|
'@atlaskit/design-system/no-deprecated-design-token-usage': string;
|
|
15
15
|
'@atlaskit/design-system/no-deprecated-imports': string;
|
|
16
|
+
'@atlaskit/design-system/no-empty-styled-expression': string;
|
|
17
|
+
'@atlaskit/design-system/no-exported-css': string;
|
|
18
|
+
'@atlaskit/design-system/no-exported-keyframes': string;
|
|
19
|
+
'@atlaskit/design-system/no-invalid-css-map': string;
|
|
16
20
|
'@atlaskit/design-system/no-margin': string;
|
|
17
21
|
'@atlaskit/design-system/no-nested-styles': string;
|
|
18
22
|
'@atlaskit/design-system/no-physical-properties': string;
|
|
@@ -39,6 +43,10 @@ export declare const configs: {
|
|
|
39
43
|
'@atlaskit/design-system/no-deprecated-apis': string;
|
|
40
44
|
'@atlaskit/design-system/no-deprecated-design-token-usage': string;
|
|
41
45
|
'@atlaskit/design-system/no-deprecated-imports': string;
|
|
46
|
+
'@atlaskit/design-system/no-empty-styled-expression': string;
|
|
47
|
+
'@atlaskit/design-system/no-exported-css': string;
|
|
48
|
+
'@atlaskit/design-system/no-exported-keyframes': string;
|
|
49
|
+
'@atlaskit/design-system/no-invalid-css-map': string;
|
|
42
50
|
'@atlaskit/design-system/no-nested-styles': string;
|
|
43
51
|
'@atlaskit/design-system/no-unsafe-design-token-usage': string;
|
|
44
52
|
'@atlaskit/design-system/no-unsafe-style-overrides': 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::914085544778f4543f43e3e30d0982e0>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -16,6 +16,10 @@ declare const _default: {
|
|
|
16
16
|
'@atlaskit/design-system/no-deprecated-apis': string;
|
|
17
17
|
'@atlaskit/design-system/no-deprecated-design-token-usage': string;
|
|
18
18
|
'@atlaskit/design-system/no-deprecated-imports': string;
|
|
19
|
+
'@atlaskit/design-system/no-empty-styled-expression': string;
|
|
20
|
+
'@atlaskit/design-system/no-exported-css': string;
|
|
21
|
+
'@atlaskit/design-system/no-exported-keyframes': string;
|
|
22
|
+
'@atlaskit/design-system/no-invalid-css-map': string;
|
|
19
23
|
'@atlaskit/design-system/no-margin': string;
|
|
20
24
|
'@atlaskit/design-system/no-nested-styles': string;
|
|
21
25
|
'@atlaskit/design-system/no-physical-properties': 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::577269c832952ce359cde6a50f26f4e0>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -14,6 +14,10 @@ declare const _default: {
|
|
|
14
14
|
'@atlaskit/design-system/no-deprecated-apis': string;
|
|
15
15
|
'@atlaskit/design-system/no-deprecated-design-token-usage': string;
|
|
16
16
|
'@atlaskit/design-system/no-deprecated-imports': string;
|
|
17
|
+
'@atlaskit/design-system/no-empty-styled-expression': string;
|
|
18
|
+
'@atlaskit/design-system/no-exported-css': string;
|
|
19
|
+
'@atlaskit/design-system/no-exported-keyframes': string;
|
|
20
|
+
'@atlaskit/design-system/no-invalid-css-map': string;
|
|
17
21
|
'@atlaskit/design-system/no-nested-styles': string;
|
|
18
22
|
'@atlaskit/design-system/no-unsafe-design-token-usage': string;
|
|
19
23
|
'@atlaskit/design-system/no-unsafe-style-overrides': string;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import type { ImportSource } from '../utils/is-supported-import';
|
|
1
2
|
export type RuleConfig = {
|
|
2
|
-
cssFunctions
|
|
3
|
-
stylesPlacement
|
|
3
|
+
cssFunctions: string[];
|
|
4
|
+
stylesPlacement: 'top' | 'bottom';
|
|
5
|
+
cssImportSource: ImportSource;
|
|
6
|
+
xcssImportSource: ImportSource;
|
|
7
|
+
excludeReactComponents: boolean;
|
|
8
|
+
fixNamesOnly: boolean;
|
|
4
9
|
};
|
|
@@ -17,6 +17,10 @@ declare const _default: {
|
|
|
17
17
|
deprecatedConfig: import("./utils/types").DeprecatedConfig;
|
|
18
18
|
}
|
|
19
19
|
], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>;
|
|
20
|
+
'no-empty-styled-expression': import("eslint").Rule.RuleModule;
|
|
21
|
+
'no-exported-css': import("eslint").Rule.RuleModule;
|
|
22
|
+
'no-exported-keyframes': import("eslint").Rule.RuleModule;
|
|
23
|
+
'no-invalid-css-map': import("eslint").Rule.RuleModule;
|
|
20
24
|
'no-margin': import("eslint").Rule.RuleModule;
|
|
21
25
|
'no-nested-styles': import("eslint").Rule.RuleModule;
|
|
22
26
|
'no-physical-properties': import("eslint").Rule.RuleModule;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import type { CallExpression, ObjectExpression } from 'estree';
|
|
3
|
+
export declare const getCssMapObject: (node: CallExpression) => ObjectExpression | undefined;
|
|
4
|
+
export declare class CssMapObjectChecker {
|
|
5
|
+
private readonly allowedFunctionCalls;
|
|
6
|
+
private readonly cssMapObject;
|
|
7
|
+
private readonly report;
|
|
8
|
+
private readonly references;
|
|
9
|
+
constructor(cssMapObject: ObjectExpression, context: Rule.RuleContext);
|
|
10
|
+
private isNotWhitelistedFunction;
|
|
11
|
+
private checkCssMapObjectValue;
|
|
12
|
+
private checkCssMapObject;
|
|
13
|
+
run(): void;
|
|
14
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
-
export declare const updateJSXAttributeByName: (oldName: string, newName: string, node: JSXElement, fixer: Rule.RuleFixer) => never[]
|
|
3
|
+
export declare const updateJSXAttributeByName: (oldName: string, newName: string, node: JSXElement, fixer: Rule.RuleFixer) => Rule.Fix | never[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Rule, Scope as ScopeNamespace } from 'eslint';
|
|
2
|
+
import { ImportSource } from '../is-supported-import';
|
|
3
|
+
type Node = Rule.Node;
|
|
4
|
+
type RuleContext = Rule.RuleContext;
|
|
5
|
+
type Scope = ScopeNamespace.Scope;
|
|
6
|
+
type Yes = {
|
|
7
|
+
isExport: true;
|
|
8
|
+
node: Node;
|
|
9
|
+
};
|
|
10
|
+
type No = {
|
|
11
|
+
isExport: false;
|
|
12
|
+
};
|
|
13
|
+
type IsSupportedExport = Yes | No;
|
|
14
|
+
export declare const checkIfSupportedExport: (context: RuleContext, node: Node, importSources: ImportSource[], scope?: Scope) => IsSupportedExport;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import type { ImportSource } from '../is-supported-import';
|
|
3
|
+
type Node = Rule.Node;
|
|
4
|
+
type RuleContext = Rule.RuleContext;
|
|
5
|
+
/**
|
|
6
|
+
* Returns whether the node is a usage of the `styled` API in the libraries we support.
|
|
7
|
+
*
|
|
8
|
+
* @param nodes Nodes to check.
|
|
9
|
+
* @param context Rule context.
|
|
10
|
+
* @param importSources A list of libraries we support.
|
|
11
|
+
* @returns Whether the node is a usage of the `styled` API.
|
|
12
|
+
*/
|
|
13
|
+
export declare const isStyledComponent: (nodes: Node[], context: RuleContext, importSources: ImportSource[]) => boolean;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { type SupportedNameChecker } from '../is-supported-import';
|
|
3
|
+
type RuleModule = Rule.RuleModule;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new ESLint rule for banning exporting certain function calls, e.g.
|
|
6
|
+
* `css` and `keyframes`.
|
|
7
|
+
*
|
|
8
|
+
* Copied from the `utils/create-no-exported-rule/` folder in @compiled/eslint-plugin.
|
|
9
|
+
*
|
|
10
|
+
* Requires an importSources option defined on the rule, which is used to define additional
|
|
11
|
+
* packages which should be checked as part of this rule.
|
|
12
|
+
*
|
|
13
|
+
* @param isUsage A function that checks whether the current node matches the desired
|
|
14
|
+
* function call to check.
|
|
15
|
+
* @param messageId The ESLint error message to use for lint violations.
|
|
16
|
+
* @returns An eslint rule.
|
|
17
|
+
*/
|
|
18
|
+
export declare const createNoExportedRule: (isUsage: SupportedNameChecker, messageId: string) => RuleModule['create'];
|
|
19
|
+
export {};
|
|
@@ -30,7 +30,7 @@ export interface LintRuleMeta extends Omit<Rule.RuleMetaData, 'docs'> {
|
|
|
30
30
|
*/
|
|
31
31
|
description: string;
|
|
32
32
|
/**
|
|
33
|
-
* Specifies the URL at which the full documentation can be accessed
|
|
33
|
+
* Specifies the URL at which the full documentation can be accessed.
|
|
34
34
|
*/
|
|
35
35
|
url?: string | undefined;
|
|
36
36
|
/**
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { ImportDeclaration } from 'eslint-codemod-utils';
|
|
3
|
+
import { ImportSource } from './is-supported-import';
|
|
4
|
+
type RuleContext = Rule.RuleContext;
|
|
5
|
+
/**
|
|
6
|
+
* Get the first import declaration in the file that matches any of the packages
|
|
7
|
+
* in `importSources`.
|
|
8
|
+
*
|
|
9
|
+
* @param context Rule context.
|
|
10
|
+
* @param importSources The packages to check import statements for. If importSources
|
|
11
|
+
* contains more than one package, the first import statement
|
|
12
|
+
* detected in the file that matches any of the packages will be
|
|
13
|
+
* returned.
|
|
14
|
+
* @returns The first import declaration found in the file.
|
|
15
|
+
*/
|
|
16
|
+
export declare const getFirstSupportedImport: (context: RuleContext, importSources: ImportSource[]) => ImportDeclaration | undefined;
|
|
17
|
+
export {};
|
|
@@ -1,16 +1,34 @@
|
|
|
1
|
-
import type { Scope } from 'eslint';
|
|
1
|
+
import type { Rule, Scope } from 'eslint';
|
|
2
2
|
import type { CallExpression } from 'estree';
|
|
3
3
|
type Callee = CallExpression['callee'];
|
|
4
4
|
type Reference = Scope.Reference;
|
|
5
5
|
export declare const CSS_IN_JS_IMPORTS: {
|
|
6
|
-
compiled:
|
|
7
|
-
emotionReact:
|
|
8
|
-
emotionCore:
|
|
9
|
-
styledComponents:
|
|
10
|
-
atlaskitCss:
|
|
6
|
+
readonly compiled: "@compiled/react";
|
|
7
|
+
readonly emotionReact: "@emotion/react";
|
|
8
|
+
readonly emotionCore: "@emotion/core";
|
|
9
|
+
readonly styledComponents: "styled-components";
|
|
10
|
+
readonly atlaskitCss: "@atlaskit/css";
|
|
11
|
+
readonly atlaskitPrimitives: "@atlaskit/primitives";
|
|
11
12
|
};
|
|
12
|
-
type
|
|
13
|
-
export type SupportedNameChecker = (nodeToCheck: Callee, referencesInScope: Reference[], importSources:
|
|
13
|
+
export type ImportSource = string;
|
|
14
|
+
export type SupportedNameChecker = (nodeToCheck: Callee, referencesInScope: Reference[], importSources: ImportSource[]) => boolean;
|
|
15
|
+
export declare const DEFAULT_IMPORT_SOURCES: ImportSource[];
|
|
16
|
+
/**
|
|
17
|
+
* Given the ESLint rule context, extract and parse the value of the importSources rule option.
|
|
18
|
+
* The importSources option is used to define additional libraries for which an ESLint rule
|
|
19
|
+
* should apply to.
|
|
20
|
+
*
|
|
21
|
+
* Note that `@compiled/react` and `@atlaskit/css` are always included in importSources, regardless
|
|
22
|
+
* of what importSources is configured to by the user.
|
|
23
|
+
*
|
|
24
|
+
* @param context The rule context.
|
|
25
|
+
* @returns An array of strings representing what CSS-in-JS packages that should be checked, based
|
|
26
|
+
* on the rule options configuration.
|
|
27
|
+
*/
|
|
28
|
+
export declare const getImportSources: (context: Rule.RuleContext) => ImportSource[];
|
|
14
29
|
export declare const isCss: SupportedNameChecker;
|
|
15
30
|
export declare const isCxFunction: SupportedNameChecker;
|
|
31
|
+
export declare const isCssMap: SupportedNameChecker;
|
|
32
|
+
export declare const isKeyframes: SupportedNameChecker;
|
|
33
|
+
export declare const isStyled: SupportedNameChecker;
|
|
16
34
|
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": "8.
|
|
4
|
+
"version": "8.27.0",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"@typescript-eslint/utils": "^5.48.1",
|
|
42
42
|
"ajv": "^6.12.6",
|
|
43
43
|
"eslint-codemod-utils": "^1.8.6",
|
|
44
|
+
"estraverse": "^5.3.0",
|
|
44
45
|
"lodash": "^4.17.21",
|
|
45
46
|
"semver": "^7.5.2"
|
|
46
47
|
},
|
|
@@ -53,6 +54,7 @@
|
|
|
53
54
|
"@emotion/react": "^11.7.1",
|
|
54
55
|
"@emotion/styled": "^11.0.0",
|
|
55
56
|
"@types/eslint": "^8.4.5",
|
|
57
|
+
"@types/estraverse": "^5.1.7",
|
|
56
58
|
"eslint": "^7.7.0",
|
|
57
59
|
"jscodeshift": "^0.13.0",
|
|
58
60
|
"outdent": "^0.5.0",
|