@atlaskit/eslint-plugin-design-system 8.29.1 → 8.30.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 +6 -0
- package/README.md +1 -0
- package/constellation/index/usage.mdx +1 -0
- package/constellation/use-primitives-text/usage.mdx +21 -0
- package/dist/cjs/ast-nodes/jsx-element.js +33 -2
- package/dist/cjs/presets/all.codegen.js +2 -1
- package/dist/cjs/rules/index.codegen.js +3 -1
- package/dist/cjs/rules/use-primitives/transformers/emotion-css/index.js +1 -2
- package/dist/cjs/rules/use-primitives-text/config/index.js +15 -0
- package/dist/cjs/rules/use-primitives-text/index.js +57 -0
- package/dist/cjs/rules/use-primitives-text/transformers/common.js +43 -0
- package/dist/cjs/rules/use-primitives-text/transformers/emphasis-elements.js +82 -0
- package/dist/cjs/rules/use-primitives-text/transformers/index.js +33 -0
- package/dist/cjs/rules/use-primitives-text/transformers/paragraph-elements.js +196 -0
- package/dist/cjs/rules/use-primitives-text/transformers/span-elements.js +87 -0
- package/dist/cjs/rules/use-primitives-text/transformers/strong-elements.js +82 -0
- package/dist/es2019/ast-nodes/jsx-element.js +33 -2
- package/dist/es2019/presets/all.codegen.js +2 -1
- package/dist/es2019/rules/index.codegen.js +3 -1
- package/dist/es2019/rules/use-primitives/transformers/emotion-css/index.js +1 -2
- package/dist/es2019/rules/use-primitives-text/config/index.js +9 -0
- package/dist/es2019/rules/use-primitives-text/index.js +51 -0
- package/dist/es2019/rules/use-primitives-text/transformers/common.js +33 -0
- package/dist/es2019/rules/use-primitives-text/transformers/emphasis-elements.js +72 -0
- package/dist/es2019/rules/use-primitives-text/transformers/index.js +4 -0
- package/dist/es2019/rules/use-primitives-text/transformers/paragraph-elements.js +187 -0
- package/dist/es2019/rules/use-primitives-text/transformers/span-elements.js +77 -0
- package/dist/es2019/rules/use-primitives-text/transformers/strong-elements.js +72 -0
- package/dist/esm/ast-nodes/jsx-element.js +33 -2
- package/dist/esm/presets/all.codegen.js +2 -1
- package/dist/esm/rules/index.codegen.js +3 -1
- package/dist/esm/rules/use-primitives/transformers/emotion-css/index.js +1 -2
- package/dist/esm/rules/use-primitives-text/config/index.js +9 -0
- package/dist/esm/rules/use-primitives-text/index.js +51 -0
- package/dist/esm/rules/use-primitives-text/transformers/common.js +33 -0
- package/dist/esm/rules/use-primitives-text/transformers/emphasis-elements.js +72 -0
- package/dist/esm/rules/use-primitives-text/transformers/index.js +4 -0
- package/dist/esm/rules/use-primitives-text/transformers/paragraph-elements.js +186 -0
- package/dist/esm/rules/use-primitives-text/transformers/span-elements.js +77 -0
- package/dist/esm/rules/use-primitives-text/transformers/strong-elements.js +72 -0
- package/dist/types/ast-nodes/jsx-element.d.ts +5 -2
- 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/use-primitives-text/config/index.d.ts +6 -0
- package/dist/types/rules/use-primitives-text/index.d.ts +3 -0
- package/dist/types/rules/use-primitives-text/transformers/common.d.ts +5 -0
- package/dist/types/rules/use-primitives-text/transformers/emphasis-elements.d.ts +16 -0
- package/dist/types/rules/use-primitives-text/transformers/index.d.ts +4 -0
- package/dist/types/rules/use-primitives-text/transformers/paragraph-elements.d.ts +32 -0
- package/dist/types/rules/use-primitives-text/transformers/span-elements.d.ts +16 -0
- package/dist/types/rules/use-primitives-text/transformers/strong-elements.d.ts +16 -0
- package/dist/types-ts4.5/ast-nodes/jsx-element.d.ts +5 -2
- 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/use-primitives-text/config/index.d.ts +6 -0
- package/dist/types-ts4.5/rules/use-primitives-text/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/use-primitives-text/transformers/common.d.ts +5 -0
- package/dist/types-ts4.5/rules/use-primitives-text/transformers/emphasis-elements.d.ts +16 -0
- package/dist/types-ts4.5/rules/use-primitives-text/transformers/index.d.ts +4 -0
- package/dist/types-ts4.5/rules/use-primitives-text/transformers/paragraph-elements.d.ts +32 -0
- package/dist/types-ts4.5/rules/use-primitives-text/transformers/span-elements.d.ts +16 -0
- package/dist/types-ts4.5/rules/use-primitives-text/transformers/strong-elements.d.ts +16 -0
- package/package.json +1 -1
- package/dist/cjs/rules/use-primitives/transformers/emotion-css/contains-only-supported-attrs.js +0 -27
- package/dist/es2019/rules/use-primitives/transformers/emotion-css/contains-only-supported-attrs.js +0 -19
- package/dist/esm/rules/use-primitives/transformers/emotion-css/contains-only-supported-attrs.js +0 -19
- package/dist/types/rules/use-primitives/transformers/emotion-css/contains-only-supported-attrs.d.ts +0 -7
- package/dist/types-ts4.5/rules/use-primitives/transformers/emotion-css/contains-only-supported-attrs.d.ts +0 -7
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
3
|
+
|
|
4
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
5
|
+
import * as ast from '../../../ast-nodes';
|
|
6
|
+
import { upsertImportDeclaration } from '../../use-primitives/transformers/emotion-css/upsert-import-declaration';
|
|
7
|
+
import { allowedAttrs, hasTextChildrenOnly, updateTestIdAttributeFix } from './common';
|
|
8
|
+
export var SpanElements = {
|
|
9
|
+
lint: function lint(node, _ref) {
|
|
10
|
+
var context = _ref.context,
|
|
11
|
+
config = _ref.config;
|
|
12
|
+
if (!isNodeOfType(node, 'JSXElement')) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Check whether all criteria needed to make a transformation are met
|
|
17
|
+
if (!SpanElements._check(node, {
|
|
18
|
+
context: context,
|
|
19
|
+
config: config
|
|
20
|
+
})) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
context.report({
|
|
24
|
+
node: node.openingElement,
|
|
25
|
+
messageId: 'preferPrimitivesText',
|
|
26
|
+
suggest: [{
|
|
27
|
+
desc: "Convert to Text",
|
|
28
|
+
fix: SpanElements._fix(node, {
|
|
29
|
+
context: context
|
|
30
|
+
})
|
|
31
|
+
}]
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
_check: function _check(node, _ref2) {
|
|
35
|
+
var context = _ref2.context,
|
|
36
|
+
config = _ref2.config;
|
|
37
|
+
if (!config.patterns.includes('span-elements')) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
var elementName = ast.JSXElement.getName(node);
|
|
41
|
+
if (elementName !== 'span') {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Element has no unallowed props
|
|
46
|
+
if (!ast.JSXElement.hasAllowedAttrsOnly(node, allowedAttrs)) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Only allow elements with strings as children
|
|
51
|
+
if (!hasTextChildrenOnly(node)) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
var importDeclaration = ast.Root.findImportsByModule(context.getSourceCode().ast.body, '@atlaskit/primitives');
|
|
55
|
+
|
|
56
|
+
// If there is more than one `@atlaskit/primitives` import, then it becomes difficult to determine which import to transform
|
|
57
|
+
if (importDeclaration.length > 1) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
},
|
|
62
|
+
_fix: function _fix(node, _ref3) {
|
|
63
|
+
var context = _ref3.context;
|
|
64
|
+
return function (fixer) {
|
|
65
|
+
var importFix = upsertImportDeclaration({
|
|
66
|
+
module: '@atlaskit/primitives',
|
|
67
|
+
specifiers: ['Text']
|
|
68
|
+
}, context, fixer);
|
|
69
|
+
var elementNameFixes = ast.JSXElement.updateName(node, 'Text', fixer);
|
|
70
|
+
var variantAttributeFix = ast.JSXElement.addAttribute(node, 'variant', 'ui', fixer);
|
|
71
|
+
var testAttributeFix = updateTestIdAttributeFix(node, fixer);
|
|
72
|
+
return [importFix].concat(_toConsumableArray(elementNameFixes), [variantAttributeFix, testAttributeFix]).filter(function (fix) {
|
|
73
|
+
return Boolean(fix);
|
|
74
|
+
}); // Some of the transformers can return arrays with undefined, so filter them out
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
3
|
+
|
|
4
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
5
|
+
import * as ast from '../../../ast-nodes';
|
|
6
|
+
import { upsertImportDeclaration } from '../../use-primitives/transformers/emotion-css/upsert-import-declaration';
|
|
7
|
+
import { allowedAttrs, updateTestIdAttributeFix } from './common';
|
|
8
|
+
export var StrongElements = {
|
|
9
|
+
lint: function lint(node, _ref) {
|
|
10
|
+
var context = _ref.context,
|
|
11
|
+
config = _ref.config;
|
|
12
|
+
if (!isNodeOfType(node, 'JSXElement')) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Check whether all criteria needed to make a transformation are met
|
|
17
|
+
if (!StrongElements._check(node, {
|
|
18
|
+
context: context,
|
|
19
|
+
config: config
|
|
20
|
+
})) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
context.report({
|
|
24
|
+
node: node.openingElement,
|
|
25
|
+
messageId: 'preferPrimitivesText',
|
|
26
|
+
suggest: [{
|
|
27
|
+
desc: "Convert to Text",
|
|
28
|
+
fix: StrongElements._fix(node, {
|
|
29
|
+
context: context
|
|
30
|
+
})
|
|
31
|
+
}]
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
_check: function _check(node, _ref2) {
|
|
35
|
+
var context = _ref2.context,
|
|
36
|
+
config = _ref2.config;
|
|
37
|
+
if (!config.patterns.includes('strong-elements')) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
var elementName = ast.JSXElement.getName(node);
|
|
41
|
+
if (elementName !== 'strong') {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Element has no unallowed props
|
|
46
|
+
if (!ast.JSXElement.hasAllowedAttrsOnly(node, allowedAttrs)) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// If there is more than one `@atlaskit/primitives` import, then it becomes difficult to determine which import to transform
|
|
51
|
+
var importDeclaration = ast.Root.findImportsByModule(context.getSourceCode().ast.body, '@atlaskit/primitives');
|
|
52
|
+
if (importDeclaration.length > 1) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
return true;
|
|
56
|
+
},
|
|
57
|
+
_fix: function _fix(node, _ref3) {
|
|
58
|
+
var context = _ref3.context;
|
|
59
|
+
return function (fixer) {
|
|
60
|
+
var importFix = upsertImportDeclaration({
|
|
61
|
+
module: '@atlaskit/primitives',
|
|
62
|
+
specifiers: ['Text']
|
|
63
|
+
}, context, fixer);
|
|
64
|
+
var elementNameFixes = ast.JSXElement.updateName(node, 'Text', fixer);
|
|
65
|
+
var asAttributeFix = ast.JSXElement.addAttribute(node, 'as', 'strong', fixer);
|
|
66
|
+
var testAttributeFix = updateTestIdAttributeFix(node, fixer);
|
|
67
|
+
return [importFix].concat(_toConsumableArray(elementNameFixes), [asAttributeFix, testAttributeFix]).filter(function (fix) {
|
|
68
|
+
return Boolean(fix);
|
|
69
|
+
}); // Some of the transformers can return arrays with undefined, so filter them out
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
};
|
|
@@ -7,8 +7,8 @@ export declare const JSXElementHelper: {
|
|
|
7
7
|
* `<MyComponents.Component></MyComponents.Component>` - `MyComponents` is a namespace (JSXNamespacedName)
|
|
8
8
|
* `<MyComponents.Component></MyComponents.Component>` - `MyComponents` is an object (JSXMemberExpression)
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
* e.g.
|
|
10
|
+
* getting the name of a JSXMemberExpression is difficult, because object can contain objects, which is recursively defined in the AST.
|
|
11
|
+
* e.g. Getting the name of `<MyComponents.PresentationLayer.LeftSideBar.Header />` would require `getName` to recursively resolve all parts of the name.
|
|
12
12
|
* `getName` does not currently have this functionality. Add it if you need it.
|
|
13
13
|
*/
|
|
14
14
|
getName(node: JSXElement): string;
|
|
@@ -17,5 +17,8 @@ export declare const JSXElementHelper: {
|
|
|
17
17
|
getAttributes(node: JSXElement): (JSXAttribute | JSXSpreadAttribute)[];
|
|
18
18
|
getAttributeByName(node: JSXElement, name: string): JSXAttribute | undefined;
|
|
19
19
|
containsSpreadAttributes(node: JSXElement): boolean;
|
|
20
|
+
addAttribute(node: JSXElement, name: string, value: string, fixer: Rule.RuleFixer): Rule.Fix;
|
|
21
|
+
getChildren(node: JSXElement): JSXElement['children'];
|
|
22
|
+
hasAllowedAttrsOnly(node: JSXElement, allowedProps: string[]): boolean;
|
|
20
23
|
};
|
|
21
24
|
export { JSXElementHelper as JSXElement };
|
|
@@ -31,6 +31,7 @@ export declare const configs: {
|
|
|
31
31
|
'@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
|
|
32
32
|
'@atlaskit/design-system/use-href-in-link-item': string;
|
|
33
33
|
'@atlaskit/design-system/use-primitives': string;
|
|
34
|
+
'@atlaskit/design-system/use-primitives-text': string;
|
|
34
35
|
'@atlaskit/design-system/use-visually-hidden': string;
|
|
35
36
|
};
|
|
36
37
|
};
|
|
@@ -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::98174f9eecc3be9d3a54506bcf2994ef>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -34,6 +34,7 @@ declare const _default: {
|
|
|
34
34
|
'@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
|
|
35
35
|
'@atlaskit/design-system/use-href-in-link-item': string;
|
|
36
36
|
'@atlaskit/design-system/use-primitives': string;
|
|
37
|
+
'@atlaskit/design-system/use-primitives-text': string;
|
|
37
38
|
'@atlaskit/design-system/use-visually-hidden': string;
|
|
38
39
|
};
|
|
39
40
|
};
|
|
@@ -31,6 +31,7 @@ declare const _default: {
|
|
|
31
31
|
'use-heading-level-in-spotlight-card': import("eslint").Rule.RuleModule;
|
|
32
32
|
'use-href-in-link-item': import("eslint").Rule.RuleModule;
|
|
33
33
|
'use-primitives': import("eslint").Rule.RuleModule;
|
|
34
|
+
'use-primitives-text': import("eslint").Rule.RuleModule;
|
|
34
35
|
'use-visually-hidden': import("eslint").Rule.RuleModule;
|
|
35
36
|
};
|
|
36
37
|
export default _default;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
+
export declare function updateTestIdAttributeFix(node: JSXElement, fixer: Rule.RuleFixer): Rule.Fix | undefined;
|
|
4
|
+
export declare const allowedAttrs: string[];
|
|
5
|
+
export declare function hasTextChildrenOnly(node: JSXElement): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
+
import { RuleConfig } from '../config';
|
|
4
|
+
interface MetaData {
|
|
5
|
+
context: Rule.RuleContext;
|
|
6
|
+
config: RuleConfig;
|
|
7
|
+
}
|
|
8
|
+
type FixFunction = (fixer: Rule.RuleFixer) => Rule.Fix[];
|
|
9
|
+
export declare const EmphasisElements: {
|
|
10
|
+
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
11
|
+
_check(node: JSXElement, { context, config }: MetaData): boolean;
|
|
12
|
+
_fix(node: JSXElement, { context }: {
|
|
13
|
+
context: Rule.RuleContext;
|
|
14
|
+
}): FixFunction;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
+
import { RuleConfig } from '../config';
|
|
4
|
+
type MetaData = {
|
|
5
|
+
context: Rule.RuleContext;
|
|
6
|
+
config: RuleConfig;
|
|
7
|
+
};
|
|
8
|
+
type CheckResult = {
|
|
9
|
+
success: boolean;
|
|
10
|
+
refs: {
|
|
11
|
+
siblings: JSXElement['children'];
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
type FixFunction = (fixer: Rule.RuleFixer) => Rule.Fix[];
|
|
15
|
+
export declare const ParagraphElements: {
|
|
16
|
+
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
17
|
+
_check(node: JSXElement & {
|
|
18
|
+
parent: Rule.Node;
|
|
19
|
+
}, { context, config }: MetaData): CheckResult;
|
|
20
|
+
_fixSingle(node: JSXElement & {
|
|
21
|
+
parent: Rule.Node;
|
|
22
|
+
}, { context }: {
|
|
23
|
+
context: Rule.RuleContext;
|
|
24
|
+
}): FixFunction;
|
|
25
|
+
_fixMultiple(node: JSXElement & {
|
|
26
|
+
parent: Rule.Node;
|
|
27
|
+
}, { context, refs }: {
|
|
28
|
+
context: Rule.RuleContext;
|
|
29
|
+
refs: CheckResult['refs'];
|
|
30
|
+
}): FixFunction;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
+
import { RuleConfig } from '../config';
|
|
4
|
+
interface MetaData {
|
|
5
|
+
context: Rule.RuleContext;
|
|
6
|
+
config: RuleConfig;
|
|
7
|
+
}
|
|
8
|
+
type FixFunction = (fixer: Rule.RuleFixer) => Rule.Fix[];
|
|
9
|
+
export declare const SpanElements: {
|
|
10
|
+
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
11
|
+
_check(node: JSXElement, { context, config }: MetaData): boolean;
|
|
12
|
+
_fix(node: JSXElement, { context }: {
|
|
13
|
+
context: Rule.RuleContext;
|
|
14
|
+
}): FixFunction;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
+
import { RuleConfig } from '../config';
|
|
4
|
+
interface MetaData {
|
|
5
|
+
context: Rule.RuleContext;
|
|
6
|
+
config: RuleConfig;
|
|
7
|
+
}
|
|
8
|
+
type FixFunction = (fixer: Rule.RuleFixer) => Rule.Fix[];
|
|
9
|
+
export declare const StrongElements: {
|
|
10
|
+
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
11
|
+
_check(node: JSXElement, { context, config }: MetaData): boolean;
|
|
12
|
+
_fix(node: JSXElement, { context }: {
|
|
13
|
+
context: Rule.RuleContext;
|
|
14
|
+
}): FixFunction;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -7,8 +7,8 @@ export declare const JSXElementHelper: {
|
|
|
7
7
|
* `<MyComponents.Component></MyComponents.Component>` - `MyComponents` is a namespace (JSXNamespacedName)
|
|
8
8
|
* `<MyComponents.Component></MyComponents.Component>` - `MyComponents` is an object (JSXMemberExpression)
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
* e.g.
|
|
10
|
+
* getting the name of a JSXMemberExpression is difficult, because object can contain objects, which is recursively defined in the AST.
|
|
11
|
+
* e.g. Getting the name of `<MyComponents.PresentationLayer.LeftSideBar.Header />` would require `getName` to recursively resolve all parts of the name.
|
|
12
12
|
* `getName` does not currently have this functionality. Add it if you need it.
|
|
13
13
|
*/
|
|
14
14
|
getName(node: JSXElement): string;
|
|
@@ -17,5 +17,8 @@ export declare const JSXElementHelper: {
|
|
|
17
17
|
getAttributes(node: JSXElement): (JSXAttribute | JSXSpreadAttribute)[];
|
|
18
18
|
getAttributeByName(node: JSXElement, name: string): JSXAttribute | undefined;
|
|
19
19
|
containsSpreadAttributes(node: JSXElement): boolean;
|
|
20
|
+
addAttribute(node: JSXElement, name: string, value: string, fixer: Rule.RuleFixer): Rule.Fix;
|
|
21
|
+
getChildren(node: JSXElement): JSXElement['children'];
|
|
22
|
+
hasAllowedAttrsOnly(node: JSXElement, allowedProps: string[]): boolean;
|
|
20
23
|
};
|
|
21
24
|
export { JSXElementHelper as JSXElement };
|
|
@@ -31,6 +31,7 @@ export declare const configs: {
|
|
|
31
31
|
'@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
|
|
32
32
|
'@atlaskit/design-system/use-href-in-link-item': string;
|
|
33
33
|
'@atlaskit/design-system/use-primitives': string;
|
|
34
|
+
'@atlaskit/design-system/use-primitives-text': string;
|
|
34
35
|
'@atlaskit/design-system/use-visually-hidden': string;
|
|
35
36
|
};
|
|
36
37
|
};
|
|
@@ -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::98174f9eecc3be9d3a54506bcf2994ef>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -34,6 +34,7 @@ declare const _default: {
|
|
|
34
34
|
'@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
|
|
35
35
|
'@atlaskit/design-system/use-href-in-link-item': string;
|
|
36
36
|
'@atlaskit/design-system/use-primitives': string;
|
|
37
|
+
'@atlaskit/design-system/use-primitives-text': string;
|
|
37
38
|
'@atlaskit/design-system/use-visually-hidden': string;
|
|
38
39
|
};
|
|
39
40
|
};
|
|
@@ -35,6 +35,7 @@ declare const _default: {
|
|
|
35
35
|
'use-heading-level-in-spotlight-card': import("eslint").Rule.RuleModule;
|
|
36
36
|
'use-href-in-link-item': import("eslint").Rule.RuleModule;
|
|
37
37
|
'use-primitives': import("eslint").Rule.RuleModule;
|
|
38
|
+
'use-primitives-text': import("eslint").Rule.RuleModule;
|
|
38
39
|
'use-visually-hidden': import("eslint").Rule.RuleModule;
|
|
39
40
|
};
|
|
40
41
|
export default _default;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
+
export declare function updateTestIdAttributeFix(node: JSXElement, fixer: Rule.RuleFixer): Rule.Fix | undefined;
|
|
4
|
+
export declare const allowedAttrs: string[];
|
|
5
|
+
export declare function hasTextChildrenOnly(node: JSXElement): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
+
import { RuleConfig } from '../config';
|
|
4
|
+
interface MetaData {
|
|
5
|
+
context: Rule.RuleContext;
|
|
6
|
+
config: RuleConfig;
|
|
7
|
+
}
|
|
8
|
+
type FixFunction = (fixer: Rule.RuleFixer) => Rule.Fix[];
|
|
9
|
+
export declare const EmphasisElements: {
|
|
10
|
+
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
11
|
+
_check(node: JSXElement, { context, config }: MetaData): boolean;
|
|
12
|
+
_fix(node: JSXElement, { context }: {
|
|
13
|
+
context: Rule.RuleContext;
|
|
14
|
+
}): FixFunction;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
+
import { RuleConfig } from '../config';
|
|
4
|
+
type MetaData = {
|
|
5
|
+
context: Rule.RuleContext;
|
|
6
|
+
config: RuleConfig;
|
|
7
|
+
};
|
|
8
|
+
type CheckResult = {
|
|
9
|
+
success: boolean;
|
|
10
|
+
refs: {
|
|
11
|
+
siblings: JSXElement['children'];
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
type FixFunction = (fixer: Rule.RuleFixer) => Rule.Fix[];
|
|
15
|
+
export declare const ParagraphElements: {
|
|
16
|
+
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
17
|
+
_check(node: JSXElement & {
|
|
18
|
+
parent: Rule.Node;
|
|
19
|
+
}, { context, config }: MetaData): CheckResult;
|
|
20
|
+
_fixSingle(node: JSXElement & {
|
|
21
|
+
parent: Rule.Node;
|
|
22
|
+
}, { context }: {
|
|
23
|
+
context: Rule.RuleContext;
|
|
24
|
+
}): FixFunction;
|
|
25
|
+
_fixMultiple(node: JSXElement & {
|
|
26
|
+
parent: Rule.Node;
|
|
27
|
+
}, { context, refs }: {
|
|
28
|
+
context: Rule.RuleContext;
|
|
29
|
+
refs: CheckResult['refs'];
|
|
30
|
+
}): FixFunction;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
+
import { RuleConfig } from '../config';
|
|
4
|
+
interface MetaData {
|
|
5
|
+
context: Rule.RuleContext;
|
|
6
|
+
config: RuleConfig;
|
|
7
|
+
}
|
|
8
|
+
type FixFunction = (fixer: Rule.RuleFixer) => Rule.Fix[];
|
|
9
|
+
export declare const SpanElements: {
|
|
10
|
+
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
11
|
+
_check(node: JSXElement, { context, config }: MetaData): boolean;
|
|
12
|
+
_fix(node: JSXElement, { context }: {
|
|
13
|
+
context: Rule.RuleContext;
|
|
14
|
+
}): FixFunction;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
+
import { RuleConfig } from '../config';
|
|
4
|
+
interface MetaData {
|
|
5
|
+
context: Rule.RuleContext;
|
|
6
|
+
config: RuleConfig;
|
|
7
|
+
}
|
|
8
|
+
type FixFunction = (fixer: Rule.RuleFixer) => Rule.Fix[];
|
|
9
|
+
export declare const StrongElements: {
|
|
10
|
+
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
11
|
+
_check(node: JSXElement, { context, config }: MetaData): boolean;
|
|
12
|
+
_fix(node: JSXElement, { context }: {
|
|
13
|
+
context: Rule.RuleContext;
|
|
14
|
+
}): FixFunction;
|
|
15
|
+
};
|
|
16
|
+
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.30.0",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"registry": "https://registry.npmjs.org/"
|
package/dist/cjs/rules/use-primitives/transformers/emotion-css/contains-only-supported-attrs.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.containsOnlySupportedAttrs = void 0;
|
|
8
|
-
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
9
|
-
var ast = _interopRequireWildcard(require("../../../../ast-nodes"));
|
|
10
|
-
var supported = _interopRequireWildcard(require("./supported"));
|
|
11
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
-
/**
|
|
14
|
-
* Check that every attribute in the JSXElement is something we support.
|
|
15
|
-
* We do this via a whitelist in `this.attributes`. The result is we exclude
|
|
16
|
-
* dangerous attrs like `id` and `style`.
|
|
17
|
-
*/
|
|
18
|
-
var containsOnlySupportedAttrs = exports.containsOnlySupportedAttrs = function containsOnlySupportedAttrs(node) {
|
|
19
|
-
var attrs = ast.JSXElement.getAttributes(node);
|
|
20
|
-
return attrs.every(function (attr) {
|
|
21
|
-
if (!(0, _eslintCodemodUtils.isNodeOfType)(attr, 'JSXAttribute')) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
var name = ast.JSXAttribute.getName(attr);
|
|
25
|
-
return supported.attributes.includes(name);
|
|
26
|
-
});
|
|
27
|
-
};
|
package/dist/es2019/rules/use-primitives/transformers/emotion-css/contains-only-supported-attrs.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
-
import * as ast from '../../../../ast-nodes';
|
|
3
|
-
import * as supported from './supported';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Check that every attribute in the JSXElement is something we support.
|
|
7
|
-
* We do this via a whitelist in `this.attributes`. The result is we exclude
|
|
8
|
-
* dangerous attrs like `id` and `style`.
|
|
9
|
-
*/
|
|
10
|
-
export const containsOnlySupportedAttrs = node => {
|
|
11
|
-
const attrs = ast.JSXElement.getAttributes(node);
|
|
12
|
-
return attrs.every(attr => {
|
|
13
|
-
if (!isNodeOfType(attr, 'JSXAttribute')) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
const name = ast.JSXAttribute.getName(attr);
|
|
17
|
-
return supported.attributes.includes(name);
|
|
18
|
-
});
|
|
19
|
-
};
|
package/dist/esm/rules/use-primitives/transformers/emotion-css/contains-only-supported-attrs.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
-
import * as ast from '../../../../ast-nodes';
|
|
3
|
-
import * as supported from './supported';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Check that every attribute in the JSXElement is something we support.
|
|
7
|
-
* We do this via a whitelist in `this.attributes`. The result is we exclude
|
|
8
|
-
* dangerous attrs like `id` and `style`.
|
|
9
|
-
*/
|
|
10
|
-
export var containsOnlySupportedAttrs = function containsOnlySupportedAttrs(node) {
|
|
11
|
-
var attrs = ast.JSXElement.getAttributes(node);
|
|
12
|
-
return attrs.every(function (attr) {
|
|
13
|
-
if (!isNodeOfType(attr, 'JSXAttribute')) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
var name = ast.JSXAttribute.getName(attr);
|
|
17
|
-
return supported.attributes.includes(name);
|
|
18
|
-
});
|
|
19
|
-
};
|
package/dist/types/rules/use-primitives/transformers/emotion-css/contains-only-supported-attrs.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { JSXElement } from 'eslint-codemod-utils';
|
|
2
|
-
/**
|
|
3
|
-
* Check that every attribute in the JSXElement is something we support.
|
|
4
|
-
* We do this via a whitelist in `this.attributes`. The result is we exclude
|
|
5
|
-
* dangerous attrs like `id` and `style`.
|
|
6
|
-
*/
|
|
7
|
-
export declare const containsOnlySupportedAttrs: (node: JSXElement) => boolean;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { JSXElement } from 'eslint-codemod-utils';
|
|
2
|
-
/**
|
|
3
|
-
* Check that every attribute in the JSXElement is something we support.
|
|
4
|
-
* We do this via a whitelist in `this.attributes`. The result is we exclude
|
|
5
|
-
* dangerous attrs like `id` and `style`.
|
|
6
|
-
*/
|
|
7
|
-
export declare const containsOnlySupportedAttrs: (node: JSXElement) => boolean;
|