@atlaskit/eslint-plugin-platform 2.7.0 → 2.7.2

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 (158) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/index.js +4 -9
  3. package/dist/cjs/rules/constants.js +1 -1
  4. package/dist/cjs/rules/ensure-critical-dependency-resolutions/index.js +7 -7
  5. package/dist/cjs/rules/ensure-native-and-af-exports-synced/index.js +3 -0
  6. package/dist/cjs/rules/ensure-no-private-dependencies/index.js +48 -66
  7. package/dist/cjs/rules/feature-gating/inline-usage/index.js +14 -3
  8. package/dist/cjs/rules/feature-gating/no-alias/index.js +2 -2
  9. package/dist/cjs/rules/feature-gating/no-module-level-eval/index.js +1 -1
  10. package/dist/cjs/rules/feature-gating/no-module-level-eval-nav4/index.js +1 -1
  11. package/dist/cjs/rules/feature-gating/no-preconditioning/index.js +4 -1
  12. package/dist/cjs/rules/feature-gating/prefer-fg/index.js +1 -1
  13. package/dist/cjs/rules/feature-gating/static-feature-flags/index.js +2 -2
  14. package/dist/cjs/rules/feature-gating/use-recommended-utils/index.js +1 -1
  15. package/dist/cjs/rules/no-invalid-storybook-decorator-usage/index.js +1 -1
  16. package/dist/cjs/rules/no-sparse-checkout/index.js +1 -1
  17. package/dist/cjs/rules/prefer-crypto-random-uuid/index.js +87 -0
  18. package/dist/cjs/rules/use-entrypoints-in-examples/index.js +1 -1
  19. package/dist/cjs/rules/util/context-compat.js +4 -2
  20. package/dist/es2019/index.js +4 -9
  21. package/dist/es2019/rules/constants.js +1 -1
  22. package/dist/es2019/rules/ensure-critical-dependency-resolutions/index.js +7 -7
  23. package/dist/es2019/rules/ensure-native-and-af-exports-synced/index.js +3 -0
  24. package/dist/es2019/rules/ensure-no-private-dependencies/index.js +10 -9
  25. package/dist/es2019/rules/feature-gating/inline-usage/index.js +14 -3
  26. package/dist/es2019/rules/feature-gating/no-alias/index.js +2 -2
  27. package/dist/es2019/rules/feature-gating/no-module-level-eval/index.js +1 -1
  28. package/dist/es2019/rules/feature-gating/no-module-level-eval-nav4/index.js +1 -1
  29. package/dist/es2019/rules/feature-gating/no-preconditioning/index.js +4 -1
  30. package/dist/es2019/rules/feature-gating/prefer-fg/index.js +1 -1
  31. package/dist/es2019/rules/feature-gating/static-feature-flags/index.js +2 -2
  32. package/dist/es2019/rules/feature-gating/use-recommended-utils/index.js +1 -1
  33. package/dist/es2019/rules/no-invalid-storybook-decorator-usage/index.js +1 -1
  34. package/dist/es2019/rules/no-sparse-checkout/index.js +1 -1
  35. package/dist/es2019/rules/prefer-crypto-random-uuid/index.js +81 -0
  36. package/dist/es2019/rules/use-entrypoints-in-examples/index.js +1 -1
  37. package/dist/es2019/rules/util/context-compat.js +4 -2
  38. package/dist/esm/index.js +4 -9
  39. package/dist/esm/rules/constants.js +1 -1
  40. package/dist/esm/rules/ensure-critical-dependency-resolutions/index.js +7 -7
  41. package/dist/esm/rules/ensure-native-and-af-exports-synced/index.js +3 -0
  42. package/dist/esm/rules/ensure-no-private-dependencies/index.js +48 -65
  43. package/dist/esm/rules/feature-gating/inline-usage/index.js +14 -3
  44. package/dist/esm/rules/feature-gating/no-alias/index.js +2 -2
  45. package/dist/esm/rules/feature-gating/no-module-level-eval/index.js +1 -1
  46. package/dist/esm/rules/feature-gating/no-module-level-eval-nav4/index.js +1 -1
  47. package/dist/esm/rules/feature-gating/no-preconditioning/index.js +4 -1
  48. package/dist/esm/rules/feature-gating/prefer-fg/index.js +1 -1
  49. package/dist/esm/rules/feature-gating/static-feature-flags/index.js +2 -2
  50. package/dist/esm/rules/feature-gating/use-recommended-utils/index.js +1 -1
  51. package/dist/esm/rules/no-invalid-storybook-decorator-usage/index.js +1 -1
  52. package/dist/esm/rules/no-sparse-checkout/index.js +1 -1
  53. package/dist/esm/rules/prefer-crypto-random-uuid/index.js +81 -0
  54. package/dist/esm/rules/use-entrypoints-in-examples/index.js +1 -1
  55. package/dist/esm/rules/util/context-compat.js +4 -2
  56. package/dist/types/index.d.ts +6 -20
  57. package/dist/types/rules/util/handle-ast-object.d.ts +1 -1
  58. package/dist/types-ts4.5/index.d.ts +6 -32
  59. package/dist/types-ts4.5/rules/util/handle-ast-object.d.ts +1 -1
  60. package/package.json +2 -5
  61. package/afm-cc/tsconfig.json +0 -24
  62. package/afm-jira/tsconfig.json +0 -24
  63. package/build/tsconfig.json +0 -17
  64. package/dist/cjs/rules/ensure-feature-flag-prefix/index.js +0 -75
  65. package/dist/cjs/rules/ensure-valid-platform-yarn-protocol-usage/index.js +0 -79
  66. package/dist/es2019/rules/ensure-feature-flag-prefix/index.js +0 -65
  67. package/dist/es2019/rules/ensure-valid-platform-yarn-protocol-usage/index.js +0 -62
  68. package/dist/esm/rules/ensure-feature-flag-prefix/index.js +0 -69
  69. package/dist/esm/rules/ensure-valid-platform-yarn-protocol-usage/index.js +0 -75
  70. package/dist/types/rules/ensure-feature-flag-prefix/index.d.ts +0 -3
  71. package/dist/types/rules/ensure-valid-platform-yarn-protocol-usage/index.d.ts +0 -3
  72. package/src/__tests__/utils/_tester.tsx +0 -26
  73. package/src/index.tsx +0 -254
  74. package/src/rules/compiled/README.md +0 -3
  75. package/src/rules/compiled/expand-background-shorthand/README.md +0 -23
  76. package/src/rules/compiled/expand-background-shorthand/__tests__/rule.test.ts +0 -160
  77. package/src/rules/compiled/expand-background-shorthand/index.tsx +0 -43
  78. package/src/rules/compiled/expand-border-shorthand/README.md +0 -51
  79. package/src/rules/compiled/expand-border-shorthand/__tests__/rule.test.ts +0 -211
  80. package/src/rules/compiled/expand-border-shorthand/index.ts +0 -103
  81. package/src/rules/compiled/expand-spacing-shorthand/README.md +0 -38
  82. package/src/rules/compiled/expand-spacing-shorthand/__tests__/rule.test.ts +0 -448
  83. package/src/rules/compiled/expand-spacing-shorthand/index.ts +0 -240
  84. package/src/rules/constants.tsx +0 -20
  85. package/src/rules/ensure-atlassian-team/__tests__/unit/rule.test.ts +0 -24
  86. package/src/rules/ensure-atlassian-team/index.ts +0 -51
  87. package/src/rules/ensure-critical-dependency-resolutions/__test__/unit/rule.test.tsx +0 -200
  88. package/src/rules/ensure-critical-dependency-resolutions/index.tsx +0 -172
  89. package/src/rules/ensure-feature-flag-prefix/__tests__/unit/rule.test.tsx +0 -65
  90. package/src/rules/ensure-feature-flag-prefix/index.tsx +0 -81
  91. package/src/rules/ensure-feature-flag-registration/__tests__/unit/rule.test.tsx +0 -115
  92. package/src/rules/ensure-feature-flag-registration/index.tsx +0 -106
  93. package/src/rules/ensure-native-and-af-exports-synced/__tests__/unit/rule.test.tsx +0 -199
  94. package/src/rules/ensure-native-and-af-exports-synced/index.tsx +0 -188
  95. package/src/rules/ensure-no-private-dependencies/__tests__/unit/rule.test.ts +0 -212
  96. package/src/rules/ensure-no-private-dependencies/index.ts +0 -64
  97. package/src/rules/ensure-publish-valid/__tests__/unit/rule.test.ts +0 -39
  98. package/src/rules/ensure-publish-valid/index.ts +0 -81
  99. package/src/rules/ensure-test-runner-arguments/__tests__/unit/rule.test.tsx +0 -298
  100. package/src/rules/ensure-test-runner-arguments/index.tsx +0 -121
  101. package/src/rules/ensure-test-runner-nested-count/__tests__/unit/rule.test.tsx +0 -308
  102. package/src/rules/ensure-test-runner-nested-count/index.tsx +0 -82
  103. package/src/rules/ensure-valid-bin-values/__tests__/unit/rule.test.ts +0 -159
  104. package/src/rules/ensure-valid-bin-values/index.ts +0 -70
  105. package/src/rules/ensure-valid-platform-yarn-protocol-usage/__tests__/unit/rule.test.ts +0 -147
  106. package/src/rules/ensure-valid-platform-yarn-protocol-usage/index.ts +0 -67
  107. package/src/rules/feature-gating/README.md +0 -8
  108. package/src/rules/feature-gating/inline-usage/README.md +0 -53
  109. package/src/rules/feature-gating/inline-usage/__tests__/rule.test.tsx +0 -106
  110. package/src/rules/feature-gating/inline-usage/index.tsx +0 -135
  111. package/src/rules/feature-gating/no-alias/README.md +0 -29
  112. package/src/rules/feature-gating/no-alias/__tests__/rule.test.tsx +0 -76
  113. package/src/rules/feature-gating/no-alias/index.tsx +0 -80
  114. package/src/rules/feature-gating/no-module-level-eval/README.md +0 -53
  115. package/src/rules/feature-gating/no-module-level-eval/__tests__/test.tsx +0 -133
  116. package/src/rules/feature-gating/no-module-level-eval/index.tsx +0 -54
  117. package/src/rules/feature-gating/no-module-level-eval-nav4/README.md +0 -8
  118. package/src/rules/feature-gating/no-module-level-eval-nav4/__tests__/test.tsx +0 -130
  119. package/src/rules/feature-gating/no-module-level-eval-nav4/index.tsx +0 -73
  120. package/src/rules/feature-gating/no-preconditioning/README.md +0 -69
  121. package/src/rules/feature-gating/no-preconditioning/__tests__/rule.test.tsx +0 -164
  122. package/src/rules/feature-gating/no-preconditioning/index.tsx +0 -138
  123. package/src/rules/feature-gating/prefer-fg/README.md +0 -3
  124. package/src/rules/feature-gating/prefer-fg/__tests__/rule.test.tsx +0 -83
  125. package/src/rules/feature-gating/prefer-fg/index.tsx +0 -110
  126. package/src/rules/feature-gating/static-feature-flags/README.md +0 -3
  127. package/src/rules/feature-gating/static-feature-flags/__tests__/test.tsx +0 -135
  128. package/src/rules/feature-gating/static-feature-flags/index.tsx +0 -103
  129. package/src/rules/feature-gating/use-recommended-utils/README.md +0 -67
  130. package/src/rules/feature-gating/use-recommended-utils/__tests__/rule.test.tsx +0 -78
  131. package/src/rules/feature-gating/use-recommended-utils/index.tsx +0 -57
  132. package/src/rules/feature-gating/utils.tsx +0 -48
  133. package/src/rules/no-direct-document-usage/index.tsx +0 -111
  134. package/src/rules/no-duplicate-dependencies/__tests__/unit/rule.test.ts +0 -116
  135. package/src/rules/no-duplicate-dependencies/index.ts +0 -79
  136. package/src/rules/no-invalid-feature-flag-usage/__tests__/unit/rule.test.tsx +0 -69
  137. package/src/rules/no-invalid-feature-flag-usage/index.tsx +0 -128
  138. package/src/rules/no-invalid-storybook-decorator-usage/__tests__/unit/rule.test.tsx +0 -18
  139. package/src/rules/no-invalid-storybook-decorator-usage/index.tsx +0 -39
  140. package/src/rules/no-pre-post-installs/__tests__/unit/rule.test.ts +0 -41
  141. package/src/rules/no-pre-post-installs/index.ts +0 -35
  142. package/src/rules/no-set-immediate/index.tsx +0 -43
  143. package/src/rules/no-sparse-checkout/__tests__/unit/rule.test.tsx +0 -48
  144. package/src/rules/no-sparse-checkout/index.tsx +0 -54
  145. package/src/rules/use-entrypoints-in-examples/README.md +0 -27
  146. package/src/rules/use-entrypoints-in-examples/__tests__/rule.test.tsx +0 -34
  147. package/src/rules/use-entrypoints-in-examples/index.tsx +0 -43
  148. package/src/rules/util/__tests__/context-compat.test.ts +0 -122
  149. package/src/rules/util/compiled-utils.ts +0 -27
  150. package/src/rules/util/context-compat.ts +0 -41
  151. package/src/rules/util/file-exclusions.ts +0 -39
  152. package/src/rules/util/handle-ast-object.ts +0 -33
  153. package/src/rules/util/registration-utils.ts +0 -59
  154. package/tsconfig.app.json +0 -43
  155. package/tsconfig.dev.json +0 -40
  156. package/tsconfig.json +0 -23
  157. /package/dist/{types-ts4.5/rules/ensure-valid-platform-yarn-protocol-usage → types/rules/prefer-crypto-random-uuid}/index.d.ts +0 -0
  158. /package/dist/types-ts4.5/rules/{ensure-feature-flag-prefix → prefer-crypto-random-uuid}/index.d.ts +0 -0
@@ -1,122 +0,0 @@
1
- import type { Rule, Scope, SourceCode } from 'eslint';
2
- import type { Node } from 'estree';
3
-
4
- import { getAncestors, getScope } from '../context-compat';
5
-
6
- describe('context-compat', () => {
7
- describe('getAncestors', () => {
8
- let context: Rule.RuleContext;
9
- let node: Node;
10
- let sourceCode: SourceCode;
11
- let ancestors: Node[];
12
-
13
- beforeEach(() => {
14
- node = {} as Node;
15
- ancestors = [];
16
- sourceCode = {
17
- getAncestors: jest.fn().mockReturnValue(ancestors),
18
- } as unknown as SourceCode;
19
- });
20
-
21
- it('should return ancestor nodes from context.sourceCode.getAncestors if available', () => {
22
- context = {
23
- sourceCode,
24
- } as unknown as Rule.RuleContext;
25
-
26
- const result = getAncestors(context, node);
27
- expect(result).toBe(ancestors);
28
- expect(sourceCode.getAncestors).toHaveBeenCalledWith(node);
29
- });
30
-
31
- it('should return ancestors from context.getSourceCode().getAncestors if context.sourceCode is not available', () => {
32
- context = {
33
- getSourceCode: jest.fn().mockReturnValue(sourceCode),
34
- } as unknown as Rule.RuleContext;
35
-
36
- const result = getAncestors(context, node);
37
- expect(result).toBe(ancestors);
38
- expect(context.getSourceCode).toHaveBeenCalled();
39
- expect(sourceCode.getAncestors).toHaveBeenCalledWith(node);
40
- });
41
-
42
- it('should return scope from context.getAncestors if neither context.sourceCode nor context.getSourceCode().getAncestors is available', () => {
43
- context = {
44
- getSourceCode: jest.fn().mockReturnValue({}),
45
- getAncestors: jest.fn().mockReturnValue(ancestors),
46
- } as unknown as Rule.RuleContext;
47
-
48
- const result = getAncestors(context, node);
49
- expect(result).toBe(ancestors);
50
- expect(context.getAncestors).toHaveBeenCalled();
51
- });
52
-
53
- it('should return scope from context.getAncestors if context.sourceCode does not have getAncestors', () => {
54
- context = {
55
- sourceCode: {},
56
- getAncestors: jest.fn().mockReturnValue(ancestors),
57
- } as unknown as Rule.RuleContext;
58
-
59
- const result = getAncestors(context, node);
60
- expect(result).toBe(ancestors);
61
- expect(context.getAncestors).toHaveBeenCalled();
62
- });
63
- });
64
-
65
- describe('getScope', () => {
66
- let context: Rule.RuleContext;
67
- let node: Node;
68
- let sourceCode: SourceCode;
69
- let scope: Scope.Scope;
70
-
71
- beforeEach(() => {
72
- node = {} as Node;
73
- scope = {} as Scope.Scope;
74
- sourceCode = {
75
- getScope: jest.fn().mockReturnValue(scope),
76
- } as unknown as SourceCode;
77
- });
78
-
79
- it('should return scope from context.sourceCode.getScope if available', () => {
80
- context = {
81
- sourceCode,
82
- } as unknown as Rule.RuleContext;
83
-
84
- const result = getScope(context, node);
85
- expect(result).toBe(scope);
86
- expect(sourceCode.getScope).toHaveBeenCalledWith(node);
87
- });
88
-
89
- it('should return scope from context.getSourceCode().getScope if context.sourceCode is not available', () => {
90
- context = {
91
- getSourceCode: jest.fn().mockReturnValue(sourceCode),
92
- } as unknown as Rule.RuleContext;
93
-
94
- const result = getScope(context, node);
95
- expect(result).toBe(scope);
96
- expect(context.getSourceCode).toHaveBeenCalled();
97
- expect(sourceCode.getScope).toHaveBeenCalledWith(node);
98
- });
99
-
100
- it('should return scope from context.getScope if neither context.sourceCode nor context.getSourceCode().getScope is available', () => {
101
- context = {
102
- getSourceCode: jest.fn().mockReturnValue({}),
103
- getScope: jest.fn().mockReturnValue(scope),
104
- } as unknown as Rule.RuleContext;
105
-
106
- const result = getScope(context, node);
107
- expect(result).toBe(scope);
108
- expect(context.getScope).toHaveBeenCalled();
109
- });
110
-
111
- it('should return scope from context.getScope if context.sourceCode does not have getScope', () => {
112
- context = {
113
- sourceCode: {},
114
- getScope: jest.fn().mockReturnValue(scope),
115
- } as unknown as Rule.RuleContext;
116
-
117
- const result = getScope(context, node);
118
- expect(result).toBe(scope);
119
- expect(context.getScope).toHaveBeenCalled();
120
- });
121
- });
122
- });
@@ -1,27 +0,0 @@
1
- import type { Node } from 'estree';
2
- import { getAncestors, getScope } from './context-compat';
3
- import type { Rule } from 'eslint';
4
- import {
5
- getImportSources,
6
- isCompiled,
7
- isAtlasKitCSS,
8
- } from '@atlaskit/eslint-utils/is-supported-import';
9
-
10
- // Checks if the function that holds the property is using a Compiled import package that this rule is targeting
11
- export const isCompiledAPI = (context: Rule.RuleContext, node: Node): boolean => {
12
- const importSources = getImportSources(context);
13
- const { references } = getScope(context, node);
14
- const ancestors = getAncestors(context, node);
15
- if (
16
- ancestors.some(
17
- (ancestor) =>
18
- ancestor.type === 'CallExpression' &&
19
- ancestor.callee &&
20
- (isCompiled(ancestor.callee, references, importSources) ||
21
- isAtlasKitCSS(ancestor.callee, references, importSources)),
22
- )
23
- ) {
24
- return true;
25
- }
26
- return false;
27
- };
@@ -1,41 +0,0 @@
1
- import type { Rule, Scope, SourceCode } from 'eslint';
2
- import type { Node } from 'estree';
3
-
4
- /**
5
- * TODO: Consider whether this should be replaced by ESLint's compat library.
6
- * Either way, this should be removed once we no longer need to support ESLint versions less than 8.40.
7
- */
8
-
9
- /**
10
- * A compatibility layer to support older versions of ESLint.
11
- * `context.sourceCode` is the preferred way to access SourceCode, as
12
- * `context.getSourceCode()` is deprecated in v8 and removed in v9.
13
- * @param context - The ESLint rule context
14
- */
15
- export const getSourceCode = (context: Rule.RuleContext): SourceCode => {
16
- return context.sourceCode ?? context.getSourceCode();
17
- };
18
-
19
- /**
20
- * A compatibility layer to support older versions of ESLint.
21
- * `context.sourceCode.getScope()` is the preferred way to access Scope, as
22
- * `context.getScope()` was removed in v9.
23
- * https://eslint.org/blog/2023/09/preparing-custom-rules-eslint-v9/#context.getscope()
24
- * @param context - The ESLint rule context
25
- * @param node - The node to get the scope for
26
- */
27
- export const getScope = (context: Rule.RuleContext, node: Node): Scope.Scope => {
28
- return getSourceCode(context)?.getScope?.(node) ?? context.getScope();
29
- };
30
-
31
- /**
32
- * A compatibility layer to support older versions of ESLint.
33
- * `context.sourceCode.getAncestors()` is the preferred way to access Ancestors, as
34
- * `context.getScope()` was removed in v9.
35
- * https://eslint.org/blog/2023/09/preparing-custom-rules-eslint-v9/#context.getancestors()
36
- * @param context - The ESLint rule context
37
- * @param node - The node to get the scope for
38
- */
39
- export const getAncestors = (context: Rule.RuleContext, node: Node): Node[] => {
40
- return getSourceCode(context)?.getAncestors?.(node) ?? context.getAncestors();
41
- };
@@ -1,39 +0,0 @@
1
- import type { Rule } from 'eslint';
2
-
3
- /**
4
- * Common patterns for test files that should be excluded from rules
5
- */
6
- const TEST_FILE_PATTERNS = ['__tests__', 'test', 'spec'] as const;
7
-
8
- /**
9
- * Checks if a file should be excluded from rules based on test file patterns
10
- * @param filename The filename to check
11
- * @returns true if the file should be excluded, false otherwise
12
- */
13
- const isTestFile = (filename: string): boolean => {
14
- return TEST_FILE_PATTERNS.some((pattern) => filename.includes(pattern));
15
- };
16
-
17
- /**
18
- * Helper function to skip rules for test files
19
- * @param context The ESLint rule context
20
- * @returns An empty RuleListener if the file is a test file, undefined otherwise
21
- */
22
- export const skipForTestFiles = (context: Rule.RuleContext): Rule.RuleListener | undefined => {
23
- if (isTestFile(context.filename)) {
24
- return {};
25
- }
26
- return undefined;
27
- };
28
-
29
- /**
30
- * Helper function to skip rules for example files
31
- * @param context The ESLint rule context
32
- * @returns An empty RuleListener if the file is an example file, undefined otherwise
33
- */
34
- export const skipForExampleFiles = (context: Rule.RuleContext): Rule.RuleListener | undefined => {
35
- if (context.filename.includes('example')) {
36
- return {};
37
- }
38
- return undefined;
39
- };
@@ -1,33 +0,0 @@
1
- import type { ObjectExpression, SimpleLiteral, RegExpLiteral, BigIntLiteral } from 'estree';
2
-
3
- export const getObjectPropertyAsLiteral = (
4
- node: ObjectExpression,
5
- property: string,
6
- ): SimpleLiteral['value'] | RegExpLiteral['value'] | BigIntLiteral['value'] => {
7
- const prop = node.properties.find(
8
- (p) => p.type === 'Property' && p.key.type === 'Literal' && p.key.value === property,
9
- );
10
-
11
- // double check for property is to make typescript happy
12
- if (prop?.type === 'Property' && prop?.value.type === 'Literal') {
13
- return prop.value.value ?? null;
14
- }
15
-
16
- return null;
17
- };
18
-
19
- export const getObjectPropertyAsObject = (
20
- node: ObjectExpression,
21
- property: string,
22
- ): ObjectExpression | null => {
23
- const prop = node.properties.find(
24
- (p) => p.type === 'Property' && p.key.type === 'Literal' && p.key.value === property,
25
- );
26
-
27
- // double check for property is to make typescript happy
28
- if (prop?.type === 'Property' && prop?.value.type === 'ObjectExpression') {
29
- return prop.value ?? null;
30
- }
31
-
32
- return null;
33
- };
@@ -1,59 +0,0 @@
1
- import readPkgUp from 'read-pkg-up';
2
- import path from 'path';
3
- import Fuse from 'fuse.js';
4
-
5
- // defines a "getter" to "type" map, if more types are required for feature flags (like string) add it here!
6
- // if you don't want to verify the type use `null` as the value
7
- export const getterIdentifierToFlagTypeMap = {
8
- getBooleanFF: 'boolean' as const,
9
- ffTest: 'boolean' as const,
10
- fg: 'boolean' as const,
11
- } as const;
12
-
13
- export type PlatformFeatureFlagRegistrationSection = {
14
- [key: string]: {
15
- // get the values of the object above
16
- type: (typeof getterIdentifierToFlagTypeMap)[keyof typeof getterIdentifierToFlagTypeMap];
17
- };
18
- };
19
-
20
- export type EnhancedPackageJson = readPkgUp.PackageJson & {
21
- 'platform-feature-flags'?: PlatformFeatureFlagRegistrationSection;
22
- };
23
-
24
- export type PkgJsonMetaData = {
25
- pkgJson: EnhancedPackageJson;
26
- fuse: Fuse<string> | null;
27
- };
28
- // make sure we cache reading the package.json so we don't end up reading it for every instance of this rule.
29
- const pkgJsonCache = new Map<string, PkgJsonMetaData>();
30
- // get the ancestor package.json for a given file
31
- export const getMetadataForFilename = (filename: string): PkgJsonMetaData => {
32
- const splitFilename = filename.split(path.sep);
33
- for (let i = 0; i < splitFilename.length; i++) {
34
- // attempt to search using the filename in the cache to see if we've read the package.json for a sibling file before
35
- const searchPath = path.join(...splitFilename.splice(0, i));
36
- const cachedMetaData = pkgJsonCache.get(searchPath);
37
-
38
- if (cachedMetaData) {
39
- return cachedMetaData;
40
- }
41
- }
42
-
43
- const { packageJson, path: pkgJsonPath } = readPkgUp.sync({
44
- cwd: filename,
45
- normalize: false,
46
- })!;
47
-
48
- const pkgJson = packageJson as EnhancedPackageJson;
49
-
50
- const fuse =
51
- packageJson['platform-feature-flags'] == null
52
- ? null
53
- : new Fuse(Object.keys(pkgJson['platform-feature-flags']!));
54
-
55
- const metaData = { pkgJson, fuse };
56
-
57
- pkgJsonCache.set(pkgJsonPath, metaData);
58
- return metaData;
59
- };
package/tsconfig.app.json DELETED
@@ -1,43 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.node.json",
3
- "include": ["./src/**/*.ts", "./src/**/*.tsx"],
4
- "exclude": [
5
- "**/docs/**/*",
6
- "**/__tests__/**/*",
7
- "**/vr-tests/**/*",
8
- "**/__perf__/**/*",
9
- "**/*.test.*",
10
- "**/test.*",
11
- "**/test-*",
12
- "**/examples.ts",
13
- "**/examples.tsx",
14
- "**/examples/*.ts",
15
- "**/examples/*.tsx",
16
- "**/examples/**/*.ts",
17
- "**/examples/**/*.tsx",
18
- "**/storybook/**/*",
19
- "**/constellation/**/*",
20
- ".storybook/*",
21
- "./__fixtures__/**/*",
22
- "./__generated__/**/*",
23
- "./mocks/**/*",
24
- "./__mocks__/**/*",
25
- "**/mock.*",
26
- "**/codemods/**/*.ts",
27
- "**/codemods/**/*.tsx"
28
- ],
29
- "compilerOptions": {
30
- "lib": ["ES2021.String"],
31
- "composite": true,
32
- "outDir": "../../../tsDist/@atlaskit__eslint-plugin-platform/app"
33
- },
34
- "references": [
35
- {
36
- "path": "../../design-system/eslint-utils/tsconfig.app.json"
37
- },
38
- {
39
- "path": "../../monorepo-tooling/ts-loader/tsconfig.app.json"
40
- }
41
- ],
42
- "files": []
43
- }
package/tsconfig.dev.json DELETED
@@ -1,40 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.node.json",
3
- "include": [
4
- "**/docs/**/*",
5
- "**/__tests__/**/*",
6
- "**/vr-tests/**/*",
7
- "**/__perf__/**/*",
8
- "**/*.test.*",
9
- "**/test.*",
10
- "**/test-*",
11
- "**/examples.ts",
12
- "**/examples.tsx",
13
- "**/examples/*.ts",
14
- "**/examples/*.tsx",
15
- "**/examples/**/*.ts",
16
- "**/examples/**/*.tsx",
17
- "**/storybook/**/*",
18
- "**/constellation/**/*",
19
- ".storybook/*",
20
- "./__fixtures__/**/*",
21
- "./__generated__/**/*",
22
- "./mocks/**/*",
23
- "./__mocks__/**/*",
24
- "**/mock.*",
25
- "**/codemods/**/*.ts",
26
- "**/codemods/**/*.tsx"
27
- ],
28
- "exclude": ["./dist/**/*", "./build/**/*", "./node_modules/**/*"],
29
- "compilerOptions": {
30
- "lib": ["ES2021.String"],
31
- "composite": true,
32
- "outDir": "../../../tsDist/@atlaskit__eslint-plugin-platform/dev"
33
- },
34
- "references": [
35
- {
36
- "path": "./tsconfig.app.json"
37
- }
38
- ],
39
- "files": []
40
- }
package/tsconfig.json DELETED
@@ -1,23 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.node.json",
3
- "include": [
4
- "__tests__/**/*.ts",
5
- "__tests__/**/*.tsx",
6
- "docs/**/*.ts",
7
- "docs/**/*.tsx",
8
- "examples/**/*.ts",
9
- "examples/**/*.tsx",
10
- "src/**/*.ts",
11
- "src/**/*.tsx",
12
- "scripts"
13
- ],
14
- "compilerOptions": {
15
- "lib": ["ES2021.String"]
16
- },
17
- "ts-node": {
18
- // It is faster to skip typechecking.
19
- "transpileOnly": true,
20
- // We must load files for third party defs - https://typestrong.org/ts-node/docs/types
21
- "files": true,
22
- }
23
- }