@atlaskit/eslint-plugin-design-system 9.2.5 → 9.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +1 -0
  3. package/constellation/index/usage.mdx +1 -0
  4. package/constellation/use-heading/usage.mdx +28 -0
  5. package/dist/cjs/ast-nodes/root.js +32 -0
  6. package/dist/cjs/presets/all.codegen.js +2 -1
  7. package/dist/cjs/rules/index.codegen.js +3 -1
  8. package/dist/cjs/rules/use-heading/config/index.js +15 -0
  9. package/dist/cjs/rules/use-heading/index.js +39 -0
  10. package/dist/cjs/rules/use-heading/transformers/common.js +19 -0
  11. package/dist/cjs/rules/use-heading/transformers/index.js +12 -0
  12. package/dist/cjs/rules/use-heading/transformers/native-elements.js +99 -0
  13. package/dist/cjs/rules/use-primitives/transformers/compiled-styled/index.js +1 -2
  14. package/dist/cjs/rules/use-primitives/transformers/emotion-css/index.js +1 -2
  15. package/dist/cjs/rules/use-primitives-text/transformers/emphasis-elements.js +1 -2
  16. package/dist/cjs/rules/use-primitives-text/transformers/paragraph-elements.js +2 -3
  17. package/dist/cjs/rules/use-primitives-text/transformers/span-elements.js +1 -2
  18. package/dist/cjs/rules/use-primitives-text/transformers/strong-elements.js +1 -2
  19. package/dist/cjs/rules/use-tokens-space/transformers/style-property/index.js +1 -2
  20. package/dist/cjs/rules/utils/create-rule.js +4 -7
  21. package/dist/es2019/ast-nodes/root.js +34 -0
  22. package/dist/es2019/presets/all.codegen.js +2 -1
  23. package/dist/es2019/rules/index.codegen.js +3 -1
  24. package/dist/es2019/rules/use-heading/config/index.js +9 -0
  25. package/dist/es2019/rules/use-heading/index.js +33 -0
  26. package/dist/es2019/rules/use-heading/transformers/common.js +9 -0
  27. package/dist/es2019/rules/use-heading/transformers/index.js +1 -0
  28. package/dist/es2019/rules/use-heading/transformers/native-elements.js +89 -0
  29. package/dist/es2019/rules/use-primitives/transformers/compiled-styled/index.js +1 -2
  30. package/dist/es2019/rules/use-primitives/transformers/emotion-css/index.js +1 -2
  31. package/dist/es2019/rules/use-primitives-text/transformers/emphasis-elements.js +1 -2
  32. package/dist/es2019/rules/use-primitives-text/transformers/paragraph-elements.js +2 -3
  33. package/dist/es2019/rules/use-primitives-text/transformers/span-elements.js +1 -2
  34. package/dist/es2019/rules/use-primitives-text/transformers/strong-elements.js +1 -2
  35. package/dist/es2019/rules/use-tokens-space/transformers/style-property/index.js +1 -2
  36. package/dist/es2019/rules/utils/create-rule.js +4 -6
  37. package/dist/esm/ast-nodes/root.js +32 -0
  38. package/dist/esm/presets/all.codegen.js +2 -1
  39. package/dist/esm/rules/index.codegen.js +3 -1
  40. package/dist/esm/rules/use-heading/config/index.js +9 -0
  41. package/dist/esm/rules/use-heading/index.js +33 -0
  42. package/dist/esm/rules/use-heading/transformers/common.js +9 -0
  43. package/dist/esm/rules/use-heading/transformers/index.js +1 -0
  44. package/dist/esm/rules/use-heading/transformers/native-elements.js +89 -0
  45. package/dist/esm/rules/use-primitives/transformers/compiled-styled/index.js +1 -2
  46. package/dist/esm/rules/use-primitives/transformers/emotion-css/index.js +1 -2
  47. package/dist/esm/rules/use-primitives-text/transformers/emphasis-elements.js +1 -2
  48. package/dist/esm/rules/use-primitives-text/transformers/paragraph-elements.js +2 -3
  49. package/dist/esm/rules/use-primitives-text/transformers/span-elements.js +1 -2
  50. package/dist/esm/rules/use-primitives-text/transformers/strong-elements.js +1 -2
  51. package/dist/esm/rules/use-tokens-space/transformers/style-property/index.js +1 -2
  52. package/dist/esm/rules/utils/create-rule.js +4 -6
  53. package/dist/types/ast-nodes/jsx-element.d.ts +2 -2
  54. package/dist/types/ast-nodes/root.d.ts +8 -0
  55. package/dist/types/index.codegen.d.ts +1 -0
  56. package/dist/types/presets/all.codegen.d.ts +2 -1
  57. package/dist/types/rules/ensure-design-token-usage/rule-meta.d.ts +1 -1
  58. package/dist/types/rules/index.codegen.d.ts +1 -0
  59. package/dist/types/rules/use-heading/config/index.d.ts +6 -0
  60. package/dist/types/rules/use-heading/index.d.ts +3 -0
  61. package/dist/types/rules/use-heading/transformers/common.d.ts +9 -0
  62. package/dist/types/rules/use-heading/transformers/index.d.ts +1 -0
  63. package/dist/types/rules/use-heading/transformers/native-elements.d.ts +18 -0
  64. package/dist/types/rules/utils/create-rule.d.ts +1 -37
  65. package/dist/types-ts4.5/ast-nodes/jsx-element.d.ts +2 -2
  66. package/dist/types-ts4.5/ast-nodes/root.d.ts +8 -0
  67. package/dist/types-ts4.5/index.codegen.d.ts +1 -0
  68. package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
  69. package/dist/types-ts4.5/rules/ensure-design-token-usage/rule-meta.d.ts +1 -1
  70. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
  71. package/dist/types-ts4.5/rules/use-heading/config/index.d.ts +6 -0
  72. package/dist/types-ts4.5/rules/use-heading/index.d.ts +3 -0
  73. package/dist/types-ts4.5/rules/use-heading/transformers/common.d.ts +9 -0
  74. package/dist/types-ts4.5/rules/use-heading/transformers/index.d.ts +1 -0
  75. package/dist/types-ts4.5/rules/use-heading/transformers/native-elements.d.ts +18 -0
  76. package/dist/types-ts4.5/rules/utils/create-rule.d.ts +1 -37
  77. package/package.json +2 -2
  78. package/dist/cjs/rules/use-primitives/transformers/compiled-styled/upsert-import-declaration.js +0 -37
  79. package/dist/cjs/rules/use-primitives/transformers/emotion-css/upsert-import-declaration.js +0 -37
  80. package/dist/cjs/rules/use-tokens-space/transformers/style-property/upsert-import-declaration.js +0 -37
  81. package/dist/es2019/rules/use-primitives/transformers/compiled-styled/upsert-import-declaration.js +0 -30
  82. package/dist/es2019/rules/use-primitives/transformers/emotion-css/upsert-import-declaration.js +0 -30
  83. package/dist/es2019/rules/use-tokens-space/transformers/style-property/upsert-import-declaration.js +0 -30
  84. package/dist/esm/rules/use-primitives/transformers/compiled-styled/upsert-import-declaration.js +0 -29
  85. package/dist/esm/rules/use-primitives/transformers/emotion-css/upsert-import-declaration.js +0 -29
  86. package/dist/esm/rules/use-tokens-space/transformers/style-property/upsert-import-declaration.js +0 -29
  87. package/dist/types/rules/use-primitives/transformers/compiled-styled/upsert-import-declaration.d.ts +0 -14
  88. package/dist/types/rules/use-primitives/transformers/emotion-css/upsert-import-declaration.d.ts +0 -14
  89. package/dist/types/rules/use-tokens-space/transformers/style-property/upsert-import-declaration.d.ts +0 -14
  90. package/dist/types-ts4.5/rules/use-primitives/transformers/compiled-styled/upsert-import-declaration.d.ts +0 -14
  91. package/dist/types-ts4.5/rules/use-primitives/transformers/emotion-css/upsert-import-declaration.d.ts +0 -14
  92. package/dist/types-ts4.5/rules/use-tokens-space/transformers/style-property/upsert-import-declaration.d.ts +0 -14
@@ -5,7 +5,6 @@ import * as ast from '../../../../ast-nodes';
5
5
  import { isStringOrNumber } from '../../utils';
6
6
  import { styleMap } from './style-map';
7
7
  import supported from './supported';
8
- import { upsertImportDeclaration } from './upsert-import-declaration';
9
8
  var messageId = 'noRawSpacingValues';
10
9
  export var StyleProperty = {
11
10
  lint: function lint(node, _ref) {
@@ -106,7 +105,7 @@ export var StyleProperty = {
106
105
  */
107
106
  _fix: function _fix(ref, context) {
108
107
  return function (fixer) {
109
- var importFix = upsertImportDeclaration({
108
+ var importFix = ast.Root.upsertNamedImportDeclaration({
110
109
  module: '@atlaskit/tokens',
111
110
  specifiers: ['token']
112
111
  }, context, fixer);
@@ -1,5 +1,5 @@
1
1
  import { ESLintUtils } from '@typescript-eslint/utils';
2
- // eslint-disable-next-line import/no-extraneous-dependencies
2
+ import { getCreateLintRule, getPathSafeName } from '@atlaskit/eslint-utils/create-rule';
3
3
 
4
4
  /**
5
5
  * We are moving to our own small abstraction to create a lint rule that we have the power
@@ -13,16 +13,14 @@ import { ESLintUtils } from '@typescript-eslint/utils';
13
13
  export var createRule = ESLintUtils.RuleCreator(function (name) {
14
14
  return getRuleUrl(name);
15
15
  });
16
+
16
17
  /**
17
18
  * Tiny wrapped over the ESLint rule module type that ensures
18
19
  * there is a docs link to our ESLint plugin documentation page,
19
20
  * as well as improving type support.
20
21
  */
21
- export var createLintRule = function createLintRule(rule) {
22
- rule.meta.docs.url = getRuleUrl(rule.meta.name);
23
- return rule;
24
- };
22
+ export var createLintRule = getCreateLintRule(getRuleUrl);
25
23
  function getRuleUrl(ruleName) {
26
- var name = ruleName.replace('/', '-'); // If it's a nested rule, ensure the url is clean and matches codegen/gatsby
24
+ var name = getPathSafeName(ruleName);
27
25
  return "https://atlassian.design/components/eslint-plugin-design-system/".concat(name, "/usage");
28
26
  }
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { JSXAttribute, JSXElement, JSXSpreadAttribute } from 'eslint-codemod-utils';
2
+ import { JSXAttribute, JSXElement, JSXFragment, JSXSpreadAttribute } from 'eslint-codemod-utils';
3
3
  export declare const JSXElementHelper: {
4
4
  /**
5
5
  * Names of JSXElements can be any of:
@@ -18,7 +18,7 @@ export declare const JSXElementHelper: {
18
18
  getAttributeByName(node: JSXElement, name: string): JSXAttribute | undefined;
19
19
  containsSpreadAttributes(node: JSXElement): boolean;
20
20
  addAttribute(node: JSXElement, name: string, value: string, fixer: Rule.RuleFixer): Rule.Fix;
21
- getChildren(node: JSXElement): JSXElement['children'];
21
+ getChildren(node: JSXElement | JSXFragment): JSXElement['children'];
22
22
  hasAllowedAttrsOnly(node: JSXElement, allowedProps: string[]): boolean;
23
23
  };
24
24
  export { JSXElementHelper as JSXElement };
@@ -15,5 +15,13 @@ export declare const Root: {
15
15
  module: string;
16
16
  specifiers: ImportData;
17
17
  }, fixer: Rule.RuleFixer): Rule.Fix;
18
+ upsertNamedImportDeclaration({ module, specifiers, }: {
19
+ module: string;
20
+ specifiers: string[];
21
+ }, context: Rule.RuleContext, fixer: Rule.RuleFixer): Rule.Fix | undefined;
22
+ upsertDefaultImportDeclaration({ module, localName, }: {
23
+ module: string;
24
+ localName: string;
25
+ }, context: Rule.RuleContext, fixer: Rule.RuleFixer): Rule.Fix | undefined;
18
26
  };
19
27
  export {};
@@ -28,6 +28,7 @@ export declare const configs: {
28
28
  '@atlaskit/design-system/prefer-primitives': string;
29
29
  '@atlaskit/design-system/use-button-group-label': string;
30
30
  '@atlaskit/design-system/use-drawer-label': string;
31
+ '@atlaskit/design-system/use-heading': string;
31
32
  '@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
32
33
  '@atlaskit/design-system/use-href-in-link-item': string;
33
34
  '@atlaskit/design-system/use-primitives': 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::d95217b658f807294de3c81123068bf1>>
3
+ * @codegen <<SignedSource::2e2cf6c0ecfe1b01f3eb24caa223f09e>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  declare const _default: {
@@ -31,6 +31,7 @@ declare const _default: {
31
31
  '@atlaskit/design-system/prefer-primitives': string;
32
32
  '@atlaskit/design-system/use-button-group-label': string;
33
33
  '@atlaskit/design-system/use-drawer-label': string;
34
+ '@atlaskit/design-system/use-heading': string;
34
35
  '@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
35
36
  '@atlaskit/design-system/use-href-in-link-item': string;
36
37
  '@atlaskit/design-system/use-primitives': string;
@@ -1,3 +1,3 @@
1
- import { LintRuleMeta } from '../utils/create-rule';
1
+ import type { LintRuleMeta } from '@atlaskit/eslint-utils/create-rule';
2
2
  declare const ruleMeta: LintRuleMeta;
3
3
  export default ruleMeta;
@@ -28,6 +28,7 @@ declare const _default: {
28
28
  'prefer-primitives': import("eslint").Rule.RuleModule;
29
29
  'use-button-group-label': import("eslint").Rule.RuleModule;
30
30
  'use-drawer-label': import("eslint").Rule.RuleModule;
31
+ 'use-heading': import("eslint").Rule.RuleModule;
31
32
  'use-heading-level-in-spotlight-card': import("eslint").Rule.RuleModule;
32
33
  'use-href-in-link-item': import("eslint").Rule.RuleModule;
33
34
  'use-primitives': import("eslint").Rule.RuleModule;
@@ -0,0 +1,6 @@
1
+ type Pattern = 'native-elements';
2
+ export interface RuleConfig {
3
+ patterns: Pattern[];
4
+ }
5
+ export declare const getConfig: (overrides: Partial<RuleConfig>) => Required<RuleConfig>;
6
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -0,0 +1,9 @@
1
+ import type { Rule } from 'eslint';
2
+ import { JSXElement } from 'eslint-codemod-utils';
3
+ import { RuleConfig } from '../config';
4
+ export type MetaData = {
5
+ context: Rule.RuleContext;
6
+ config: RuleConfig;
7
+ };
8
+ export declare function updateTestIdAttributeFix(node: JSXElement, fixer: Rule.RuleFixer): Rule.Fix | undefined;
9
+ export declare const allowedAttrs: string[];
@@ -0,0 +1 @@
1
+ export { NativeElements } from './native-elements';
@@ -0,0 +1,18 @@
1
+ import type { Rule } from 'eslint';
2
+ import { JSXElement, JSXIdentifier, JSXOpeningElement } from 'eslint-codemod-utils';
3
+ import { type MetaData } from './common';
4
+ type ValidTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
5
+ interface ValidHeadingElement extends JSXElement {
6
+ parent: Rule.Node;
7
+ openingElement: {
8
+ name: JSXIdentifier & {
9
+ name: ValidTags;
10
+ };
11
+ } & JSXOpeningElement;
12
+ }
13
+ export declare const NativeElements: {
14
+ lint(node: Rule.Node, { context, config }: MetaData): void;
15
+ _check(node: Rule.Node, { config }: MetaData): node is ValidHeadingElement;
16
+ _fix(node: ValidHeadingElement, { context }: MetaData): Rule.ReportFixer;
17
+ };
18
+ export {};
@@ -1,5 +1,4 @@
1
1
  import { ESLintUtils } from '@typescript-eslint/utils';
2
- import type { Rule } from 'eslint';
3
2
  /**
4
3
  * We are moving to our own small abstraction to create a lint rule that we have the power
5
4
  * to change and mold to our own needs.
@@ -10,44 +9,9 @@ import type { Rule } from 'eslint';
10
9
  * @deprecated
11
10
  */
12
11
  export declare const createRule: <TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends import("@typescript-eslint/utils/dist/ts-eslint").RuleListener = import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>({ name, meta, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<TOptions, TMessageIds, TRuleListener>>) => import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<TMessageIds, TOptions, TRuleListener>;
13
- export interface LintRule extends Omit<Rule.RuleModule, 'meta'> {
14
- /**
15
- * Including this for backwards compat moving from the typescript-eslint util.
16
- */
17
- name?: never;
18
- meta: LintRuleMeta;
19
- }
20
- export interface LintRuleMeta extends Omit<Rule.RuleMetaData, 'docs'> {
21
- /**
22
- * Name of the rule.
23
- * Must match the folder it is in exactly else build will throw.
24
- * Add an exception in codegen.tsx for nested rules.
25
- */
26
- name: string;
27
- docs: {
28
- /**
29
- * Short description of what this rule does.
30
- */
31
- description: string;
32
- /**
33
- * Specifies the URL at which the full documentation can be accessed.
34
- */
35
- url?: string | undefined;
36
- /**
37
- * If this rule should be in the recommended preset or not.
38
- * Set to `false` to exclude it from the recommended preset.
39
- */
40
- recommended: boolean;
41
- /**
42
- * The severity level to be applied to this rule.
43
- * When setting to `"error"` it will mean releasing a breaking change.
44
- */
45
- severity: 'error' | 'warn';
46
- };
47
- }
48
12
  /**
49
13
  * Tiny wrapped over the ESLint rule module type that ensures
50
14
  * there is a docs link to our ESLint plugin documentation page,
51
15
  * as well as improving type support.
52
16
  */
53
- export declare const createLintRule: (rule: LintRule) => Rule.RuleModule;
17
+ export declare const createLintRule: (rule: import("@atlaskit/eslint-utils/create-rule").LintRule) => import("eslint").Rule.RuleModule;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { JSXAttribute, JSXElement, JSXSpreadAttribute } from 'eslint-codemod-utils';
2
+ import { JSXAttribute, JSXElement, JSXFragment, JSXSpreadAttribute } from 'eslint-codemod-utils';
3
3
  export declare const JSXElementHelper: {
4
4
  /**
5
5
  * Names of JSXElements can be any of:
@@ -18,7 +18,7 @@ export declare const JSXElementHelper: {
18
18
  getAttributeByName(node: JSXElement, name: string): JSXAttribute | undefined;
19
19
  containsSpreadAttributes(node: JSXElement): boolean;
20
20
  addAttribute(node: JSXElement, name: string, value: string, fixer: Rule.RuleFixer): Rule.Fix;
21
- getChildren(node: JSXElement): JSXElement['children'];
21
+ getChildren(node: JSXElement | JSXFragment): JSXElement['children'];
22
22
  hasAllowedAttrsOnly(node: JSXElement, allowedProps: string[]): boolean;
23
23
  };
24
24
  export { JSXElementHelper as JSXElement };
@@ -15,5 +15,13 @@ export declare const Root: {
15
15
  module: string;
16
16
  specifiers: ImportData;
17
17
  }, fixer: Rule.RuleFixer): Rule.Fix;
18
+ upsertNamedImportDeclaration({ module, specifiers, }: {
19
+ module: string;
20
+ specifiers: string[];
21
+ }, context: Rule.RuleContext, fixer: Rule.RuleFixer): Rule.Fix | undefined;
22
+ upsertDefaultImportDeclaration({ module, localName, }: {
23
+ module: string;
24
+ localName: string;
25
+ }, context: Rule.RuleContext, fixer: Rule.RuleFixer): Rule.Fix | undefined;
18
26
  };
19
27
  export {};
@@ -28,6 +28,7 @@ export declare const configs: {
28
28
  '@atlaskit/design-system/prefer-primitives': string;
29
29
  '@atlaskit/design-system/use-button-group-label': string;
30
30
  '@atlaskit/design-system/use-drawer-label': string;
31
+ '@atlaskit/design-system/use-heading': string;
31
32
  '@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
32
33
  '@atlaskit/design-system/use-href-in-link-item': string;
33
34
  '@atlaskit/design-system/use-primitives': 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::d95217b658f807294de3c81123068bf1>>
3
+ * @codegen <<SignedSource::2e2cf6c0ecfe1b01f3eb24caa223f09e>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  declare const _default: {
@@ -31,6 +31,7 @@ declare const _default: {
31
31
  '@atlaskit/design-system/prefer-primitives': string;
32
32
  '@atlaskit/design-system/use-button-group-label': string;
33
33
  '@atlaskit/design-system/use-drawer-label': string;
34
+ '@atlaskit/design-system/use-heading': string;
34
35
  '@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
35
36
  '@atlaskit/design-system/use-href-in-link-item': string;
36
37
  '@atlaskit/design-system/use-primitives': string;
@@ -1,3 +1,3 @@
1
- import { LintRuleMeta } from '../utils/create-rule';
1
+ import type { LintRuleMeta } from '@atlaskit/eslint-utils/create-rule';
2
2
  declare const ruleMeta: LintRuleMeta;
3
3
  export default ruleMeta;
@@ -32,6 +32,7 @@ declare const _default: {
32
32
  'prefer-primitives': import("eslint").Rule.RuleModule;
33
33
  'use-button-group-label': import("eslint").Rule.RuleModule;
34
34
  'use-drawer-label': import("eslint").Rule.RuleModule;
35
+ 'use-heading': import("eslint").Rule.RuleModule;
35
36
  'use-heading-level-in-spotlight-card': import("eslint").Rule.RuleModule;
36
37
  'use-href-in-link-item': import("eslint").Rule.RuleModule;
37
38
  'use-primitives': import("eslint").Rule.RuleModule;
@@ -0,0 +1,6 @@
1
+ type Pattern = 'native-elements';
2
+ export interface RuleConfig {
3
+ patterns: Pattern[];
4
+ }
5
+ export declare const getConfig: (overrides: Partial<RuleConfig>) => Required<RuleConfig>;
6
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -0,0 +1,9 @@
1
+ import type { Rule } from 'eslint';
2
+ import { JSXElement } from 'eslint-codemod-utils';
3
+ import { RuleConfig } from '../config';
4
+ export type MetaData = {
5
+ context: Rule.RuleContext;
6
+ config: RuleConfig;
7
+ };
8
+ export declare function updateTestIdAttributeFix(node: JSXElement, fixer: Rule.RuleFixer): Rule.Fix | undefined;
9
+ export declare const allowedAttrs: string[];
@@ -0,0 +1 @@
1
+ export { NativeElements } from './native-elements';
@@ -0,0 +1,18 @@
1
+ import type { Rule } from 'eslint';
2
+ import { JSXElement, JSXIdentifier, JSXOpeningElement } from 'eslint-codemod-utils';
3
+ import { type MetaData } from './common';
4
+ type ValidTags = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
5
+ interface ValidHeadingElement extends JSXElement {
6
+ parent: Rule.Node;
7
+ openingElement: {
8
+ name: JSXIdentifier & {
9
+ name: ValidTags;
10
+ };
11
+ } & JSXOpeningElement;
12
+ }
13
+ export declare const NativeElements: {
14
+ lint(node: Rule.Node, { context, config }: MetaData): void;
15
+ _check(node: Rule.Node, { config }: MetaData): node is ValidHeadingElement;
16
+ _fix(node: ValidHeadingElement, { context }: MetaData): Rule.ReportFixer;
17
+ };
18
+ export {};
@@ -1,5 +1,4 @@
1
1
  import { ESLintUtils } from '@typescript-eslint/utils';
2
- import type { Rule } from 'eslint';
3
2
  /**
4
3
  * We are moving to our own small abstraction to create a lint rule that we have the power
5
4
  * to change and mold to our own needs.
@@ -10,44 +9,9 @@ import type { Rule } from 'eslint';
10
9
  * @deprecated
11
10
  */
12
11
  export declare const createRule: <TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends import("@typescript-eslint/utils/dist/ts-eslint").RuleListener = import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>({ name, meta, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<TOptions, TMessageIds, TRuleListener>>) => import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<TMessageIds, TOptions, TRuleListener>;
13
- export interface LintRule extends Omit<Rule.RuleModule, 'meta'> {
14
- /**
15
- * Including this for backwards compat moving from the typescript-eslint util.
16
- */
17
- name?: never;
18
- meta: LintRuleMeta;
19
- }
20
- export interface LintRuleMeta extends Omit<Rule.RuleMetaData, 'docs'> {
21
- /**
22
- * Name of the rule.
23
- * Must match the folder it is in exactly else build will throw.
24
- * Add an exception in codegen.tsx for nested rules.
25
- */
26
- name: string;
27
- docs: {
28
- /**
29
- * Short description of what this rule does.
30
- */
31
- description: string;
32
- /**
33
- * Specifies the URL at which the full documentation can be accessed.
34
- */
35
- url?: string | undefined;
36
- /**
37
- * If this rule should be in the recommended preset or not.
38
- * Set to `false` to exclude it from the recommended preset.
39
- */
40
- recommended: boolean;
41
- /**
42
- * The severity level to be applied to this rule.
43
- * When setting to `"error"` it will mean releasing a breaking change.
44
- */
45
- severity: 'error' | 'warn';
46
- };
47
- }
48
12
  /**
49
13
  * Tiny wrapped over the ESLint rule module type that ensures
50
14
  * there is a docs link to our ESLint plugin documentation page,
51
15
  * as well as improving type support.
52
16
  */
53
- export declare const createLintRule: (rule: LintRule) => Rule.RuleModule;
17
+ export declare const createLintRule: (rule: import("@atlaskit/eslint-utils/create-rule").LintRule) => import("eslint").Rule.RuleModule;
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": "9.2.5",
4
+ "version": "9.3.0",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {
@@ -37,7 +37,7 @@
37
37
  ".": "./src/index.tsx"
38
38
  },
39
39
  "dependencies": {
40
- "@atlaskit/eslint-utils": "^1.0.0",
40
+ "@atlaskit/eslint-utils": "^1.1.0",
41
41
  "@atlaskit/tokens": "*",
42
42
  "@babel/runtime": "^7.0.0",
43
43
  "@typescript-eslint/utils": "^5.48.1",
@@ -1,37 +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.upsertImportDeclaration = void 0;
8
- var ast = _interopRequireWildcard(require("../../../../ast-nodes"));
9
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
10
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
- /**
12
- * Currently this is defined here because it's not very general purpose.
13
- * If we were to move this to `ast-nodes`, half the implementation would be in `Root`,
14
- * and the other half would be in `Import`.
15
- *
16
- * TODO: Refactor and move to `ast-nodes`
17
- *
18
- * Note: It does not handle default imports, namespace imports, or aliased imports.
19
- */
20
- var upsertImportDeclaration = exports.upsertImportDeclaration = function upsertImportDeclaration(_ref, context, fixer) {
21
- var module = _ref.module,
22
- specifiers = _ref.specifiers;
23
- // Find any imports that match the packageName
24
- var root = context.getSourceCode().ast.body;
25
- var importDeclarations = ast.Root.findImportsByModule(root, module);
26
-
27
- // The import doesn't exist yet, we can just insert a whole new one
28
- if (importDeclarations.length === 0) {
29
- return ast.Root.insertImport(root, {
30
- module: module,
31
- specifiers: specifiers
32
- }, fixer);
33
- }
34
-
35
- // The import exists so, modify the existing one
36
- return ast.Import.insertNamedSpecifiers(importDeclarations[0], specifiers, fixer);
37
- };
@@ -1,37 +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.upsertImportDeclaration = void 0;
8
- var ast = _interopRequireWildcard(require("../../../../ast-nodes"));
9
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
10
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
- /**
12
- * Currently this is defined here because it's not very general purpose.
13
- * If we were to move this to `ast-nodes`, half the implementation would be in `Root`,
14
- * and the other half would be in `Import`.
15
- *
16
- * TODO: Refactor and move to `ast-nodes`
17
- *
18
- * Note: It does not handle default imports, namespace imports, or aliased imports.
19
- */
20
- var upsertImportDeclaration = exports.upsertImportDeclaration = function upsertImportDeclaration(_ref, context, fixer) {
21
- var module = _ref.module,
22
- specifiers = _ref.specifiers;
23
- // Find any imports that match the packageName
24
- var root = context.getSourceCode().ast.body;
25
- var importDeclarations = ast.Root.findImportsByModule(root, module);
26
-
27
- // The import doesn't exist yet, we can just insert a whole new one
28
- if (importDeclarations.length === 0) {
29
- return ast.Root.insertImport(root, {
30
- module: module,
31
- specifiers: specifiers
32
- }, fixer);
33
- }
34
-
35
- // The import exists so, modify the existing one
36
- return ast.Import.insertNamedSpecifiers(importDeclarations[0], specifiers, fixer);
37
- };
@@ -1,37 +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.upsertImportDeclaration = void 0;
8
- var ast = _interopRequireWildcard(require("../../../../ast-nodes"));
9
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
10
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
- /**
12
- * Currently this is defined here because it's not very general purpose.
13
- * If we were to move this to `ast-nodes`, half the implementation would be in `Root`,
14
- * and the other half would be in `Import`.
15
- *
16
- * TODO: Refactor and move to `ast-nodes`
17
- *
18
- * Note: It does not handle default imports, namespace imports, or aliased imports.
19
- */
20
- var upsertImportDeclaration = exports.upsertImportDeclaration = function upsertImportDeclaration(_ref, context, fixer) {
21
- var module = _ref.module,
22
- specifiers = _ref.specifiers;
23
- // Find any imports that match the packageName
24
- var root = context.getSourceCode().ast.body;
25
- var importDeclarations = ast.Root.findImportsByModule(root, module);
26
-
27
- // The import doesn't exist yet, we can just insert a whole new one
28
- if (importDeclarations.length === 0) {
29
- return ast.Root.insertImport(root, {
30
- module: module,
31
- specifiers: specifiers
32
- }, fixer);
33
- }
34
-
35
- // The import exists so, modify the existing one
36
- return ast.Import.insertNamedSpecifiers(importDeclarations[0], specifiers, fixer);
37
- };
@@ -1,30 +0,0 @@
1
- import * as ast from '../../../../ast-nodes';
2
-
3
- /**
4
- * Currently this is defined here because it's not very general purpose.
5
- * If we were to move this to `ast-nodes`, half the implementation would be in `Root`,
6
- * and the other half would be in `Import`.
7
- *
8
- * TODO: Refactor and move to `ast-nodes`
9
- *
10
- * Note: It does not handle default imports, namespace imports, or aliased imports.
11
- */
12
- export const upsertImportDeclaration = ({
13
- module,
14
- specifiers
15
- }, context, fixer) => {
16
- // Find any imports that match the packageName
17
- const root = context.getSourceCode().ast.body;
18
- const importDeclarations = ast.Root.findImportsByModule(root, module);
19
-
20
- // The import doesn't exist yet, we can just insert a whole new one
21
- if (importDeclarations.length === 0) {
22
- return ast.Root.insertImport(root, {
23
- module,
24
- specifiers
25
- }, fixer);
26
- }
27
-
28
- // The import exists so, modify the existing one
29
- return ast.Import.insertNamedSpecifiers(importDeclarations[0], specifiers, fixer);
30
- };
@@ -1,30 +0,0 @@
1
- import * as ast from '../../../../ast-nodes';
2
-
3
- /**
4
- * Currently this is defined here because it's not very general purpose.
5
- * If we were to move this to `ast-nodes`, half the implementation would be in `Root`,
6
- * and the other half would be in `Import`.
7
- *
8
- * TODO: Refactor and move to `ast-nodes`
9
- *
10
- * Note: It does not handle default imports, namespace imports, or aliased imports.
11
- */
12
- export const upsertImportDeclaration = ({
13
- module,
14
- specifiers
15
- }, context, fixer) => {
16
- // Find any imports that match the packageName
17
- const root = context.getSourceCode().ast.body;
18
- const importDeclarations = ast.Root.findImportsByModule(root, module);
19
-
20
- // The import doesn't exist yet, we can just insert a whole new one
21
- if (importDeclarations.length === 0) {
22
- return ast.Root.insertImport(root, {
23
- module,
24
- specifiers
25
- }, fixer);
26
- }
27
-
28
- // The import exists so, modify the existing one
29
- return ast.Import.insertNamedSpecifiers(importDeclarations[0], specifiers, fixer);
30
- };
@@ -1,30 +0,0 @@
1
- import * as ast from '../../../../ast-nodes';
2
-
3
- /**
4
- * Currently this is defined here because it's not very general purpose.
5
- * If we were to move this to `ast-nodes`, half the implementation would be in `Root`,
6
- * and the other half would be in `Import`.
7
- *
8
- * TODO: Refactor and move to `ast-nodes`
9
- *
10
- * Note: It does not handle default imports, namespace imports, or aliased imports.
11
- */
12
- export const upsertImportDeclaration = ({
13
- module,
14
- specifiers
15
- }, context, fixer) => {
16
- // Find any imports that match the packageName
17
- const root = context.getSourceCode().ast.body;
18
- const importDeclarations = ast.Root.findImportsByModule(root, module);
19
-
20
- // The import doesn't exist yet, we can just insert a whole new one
21
- if (importDeclarations.length === 0) {
22
- return ast.Root.insertImport(root, {
23
- module,
24
- specifiers
25
- }, fixer);
26
- }
27
-
28
- // The import exists so, modify the existing one
29
- return ast.Import.insertNamedSpecifiers(importDeclarations[0], specifiers, fixer);
30
- };