@atlaskit/eslint-plugin-platform 2.7.0 → 2.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/index.js +0 -2
  3. package/dist/cjs/rules/ensure-critical-dependency-resolutions/index.js +2 -2
  4. package/dist/cjs/rules/ensure-native-and-af-exports-synced/index.js +3 -0
  5. package/dist/cjs/rules/feature-gating/no-alias/index.js +1 -1
  6. package/dist/cjs/rules/util/context-compat.js +4 -2
  7. package/dist/es2019/index.js +0 -2
  8. package/dist/es2019/rules/ensure-critical-dependency-resolutions/index.js +2 -2
  9. package/dist/es2019/rules/ensure-native-and-af-exports-synced/index.js +3 -0
  10. package/dist/es2019/rules/feature-gating/no-alias/index.js +1 -1
  11. package/dist/es2019/rules/util/context-compat.js +4 -2
  12. package/dist/esm/index.js +0 -2
  13. package/dist/esm/rules/ensure-critical-dependency-resolutions/index.js +2 -2
  14. package/dist/esm/rules/ensure-native-and-af-exports-synced/index.js +3 -0
  15. package/dist/esm/rules/feature-gating/no-alias/index.js +1 -1
  16. package/dist/esm/rules/util/context-compat.js +4 -2
  17. package/dist/types/index.d.ts +4 -6
  18. package/dist/types/rules/util/handle-ast-object.d.ts +1 -1
  19. package/dist/types-ts4.5/index.d.ts +4 -6
  20. package/dist/types-ts4.5/rules/util/handle-ast-object.d.ts +1 -1
  21. package/package.json +2 -2
  22. package/afm-cc/tsconfig.json +0 -24
  23. package/afm-jira/tsconfig.json +0 -24
  24. package/build/tsconfig.json +0 -17
  25. package/dist/cjs/rules/ensure-valid-platform-yarn-protocol-usage/index.js +0 -79
  26. package/dist/es2019/rules/ensure-valid-platform-yarn-protocol-usage/index.js +0 -62
  27. package/dist/esm/rules/ensure-valid-platform-yarn-protocol-usage/index.js +0 -75
  28. package/dist/types/rules/ensure-valid-platform-yarn-protocol-usage/index.d.ts +0 -3
  29. package/dist/types-ts4.5/rules/ensure-valid-platform-yarn-protocol-usage/index.d.ts +0 -3
  30. package/src/__tests__/utils/_tester.tsx +0 -26
  31. package/src/index.tsx +0 -254
  32. package/src/rules/compiled/README.md +0 -3
  33. package/src/rules/compiled/expand-background-shorthand/README.md +0 -23
  34. package/src/rules/compiled/expand-background-shorthand/__tests__/rule.test.ts +0 -160
  35. package/src/rules/compiled/expand-background-shorthand/index.tsx +0 -43
  36. package/src/rules/compiled/expand-border-shorthand/README.md +0 -51
  37. package/src/rules/compiled/expand-border-shorthand/__tests__/rule.test.ts +0 -211
  38. package/src/rules/compiled/expand-border-shorthand/index.ts +0 -103
  39. package/src/rules/compiled/expand-spacing-shorthand/README.md +0 -38
  40. package/src/rules/compiled/expand-spacing-shorthand/__tests__/rule.test.ts +0 -448
  41. package/src/rules/compiled/expand-spacing-shorthand/index.ts +0 -240
  42. package/src/rules/constants.tsx +0 -20
  43. package/src/rules/ensure-atlassian-team/__tests__/unit/rule.test.ts +0 -24
  44. package/src/rules/ensure-atlassian-team/index.ts +0 -51
  45. package/src/rules/ensure-critical-dependency-resolutions/__test__/unit/rule.test.tsx +0 -200
  46. package/src/rules/ensure-critical-dependency-resolutions/index.tsx +0 -172
  47. package/src/rules/ensure-feature-flag-prefix/__tests__/unit/rule.test.tsx +0 -65
  48. package/src/rules/ensure-feature-flag-prefix/index.tsx +0 -81
  49. package/src/rules/ensure-feature-flag-registration/__tests__/unit/rule.test.tsx +0 -115
  50. package/src/rules/ensure-feature-flag-registration/index.tsx +0 -106
  51. package/src/rules/ensure-native-and-af-exports-synced/__tests__/unit/rule.test.tsx +0 -199
  52. package/src/rules/ensure-native-and-af-exports-synced/index.tsx +0 -188
  53. package/src/rules/ensure-no-private-dependencies/__tests__/unit/rule.test.ts +0 -212
  54. package/src/rules/ensure-no-private-dependencies/index.ts +0 -64
  55. package/src/rules/ensure-publish-valid/__tests__/unit/rule.test.ts +0 -39
  56. package/src/rules/ensure-publish-valid/index.ts +0 -81
  57. package/src/rules/ensure-test-runner-arguments/__tests__/unit/rule.test.tsx +0 -298
  58. package/src/rules/ensure-test-runner-arguments/index.tsx +0 -121
  59. package/src/rules/ensure-test-runner-nested-count/__tests__/unit/rule.test.tsx +0 -308
  60. package/src/rules/ensure-test-runner-nested-count/index.tsx +0 -82
  61. package/src/rules/ensure-valid-bin-values/__tests__/unit/rule.test.ts +0 -159
  62. package/src/rules/ensure-valid-bin-values/index.ts +0 -70
  63. package/src/rules/ensure-valid-platform-yarn-protocol-usage/__tests__/unit/rule.test.ts +0 -147
  64. package/src/rules/ensure-valid-platform-yarn-protocol-usage/index.ts +0 -67
  65. package/src/rules/feature-gating/README.md +0 -8
  66. package/src/rules/feature-gating/inline-usage/README.md +0 -53
  67. package/src/rules/feature-gating/inline-usage/__tests__/rule.test.tsx +0 -106
  68. package/src/rules/feature-gating/inline-usage/index.tsx +0 -135
  69. package/src/rules/feature-gating/no-alias/README.md +0 -29
  70. package/src/rules/feature-gating/no-alias/__tests__/rule.test.tsx +0 -76
  71. package/src/rules/feature-gating/no-alias/index.tsx +0 -80
  72. package/src/rules/feature-gating/no-module-level-eval/README.md +0 -53
  73. package/src/rules/feature-gating/no-module-level-eval/__tests__/test.tsx +0 -133
  74. package/src/rules/feature-gating/no-module-level-eval/index.tsx +0 -54
  75. package/src/rules/feature-gating/no-module-level-eval-nav4/README.md +0 -8
  76. package/src/rules/feature-gating/no-module-level-eval-nav4/__tests__/test.tsx +0 -130
  77. package/src/rules/feature-gating/no-module-level-eval-nav4/index.tsx +0 -73
  78. package/src/rules/feature-gating/no-preconditioning/README.md +0 -69
  79. package/src/rules/feature-gating/no-preconditioning/__tests__/rule.test.tsx +0 -164
  80. package/src/rules/feature-gating/no-preconditioning/index.tsx +0 -138
  81. package/src/rules/feature-gating/prefer-fg/README.md +0 -3
  82. package/src/rules/feature-gating/prefer-fg/__tests__/rule.test.tsx +0 -83
  83. package/src/rules/feature-gating/prefer-fg/index.tsx +0 -110
  84. package/src/rules/feature-gating/static-feature-flags/README.md +0 -3
  85. package/src/rules/feature-gating/static-feature-flags/__tests__/test.tsx +0 -135
  86. package/src/rules/feature-gating/static-feature-flags/index.tsx +0 -103
  87. package/src/rules/feature-gating/use-recommended-utils/README.md +0 -67
  88. package/src/rules/feature-gating/use-recommended-utils/__tests__/rule.test.tsx +0 -78
  89. package/src/rules/feature-gating/use-recommended-utils/index.tsx +0 -57
  90. package/src/rules/feature-gating/utils.tsx +0 -48
  91. package/src/rules/no-direct-document-usage/index.tsx +0 -111
  92. package/src/rules/no-duplicate-dependencies/__tests__/unit/rule.test.ts +0 -116
  93. package/src/rules/no-duplicate-dependencies/index.ts +0 -79
  94. package/src/rules/no-invalid-feature-flag-usage/__tests__/unit/rule.test.tsx +0 -69
  95. package/src/rules/no-invalid-feature-flag-usage/index.tsx +0 -128
  96. package/src/rules/no-invalid-storybook-decorator-usage/__tests__/unit/rule.test.tsx +0 -18
  97. package/src/rules/no-invalid-storybook-decorator-usage/index.tsx +0 -39
  98. package/src/rules/no-pre-post-installs/__tests__/unit/rule.test.ts +0 -41
  99. package/src/rules/no-pre-post-installs/index.ts +0 -35
  100. package/src/rules/no-set-immediate/index.tsx +0 -43
  101. package/src/rules/no-sparse-checkout/__tests__/unit/rule.test.tsx +0 -48
  102. package/src/rules/no-sparse-checkout/index.tsx +0 -54
  103. package/src/rules/use-entrypoints-in-examples/README.md +0 -27
  104. package/src/rules/use-entrypoints-in-examples/__tests__/rule.test.tsx +0 -34
  105. package/src/rules/use-entrypoints-in-examples/index.tsx +0 -43
  106. package/src/rules/util/__tests__/context-compat.test.ts +0 -122
  107. package/src/rules/util/compiled-utils.ts +0 -27
  108. package/src/rules/util/context-compat.ts +0 -41
  109. package/src/rules/util/file-exclusions.ts +0 -39
  110. package/src/rules/util/handle-ast-object.ts +0 -33
  111. package/src/rules/util/registration-utils.ts +0 -59
  112. package/tsconfig.app.json +0 -43
  113. package/tsconfig.dev.json +0 -40
  114. package/tsconfig.json +0 -23
@@ -1,69 +0,0 @@
1
- import { tester } from '../../../../__tests__/utils/_tester';
2
- import rule from '../../index';
3
-
4
- describe('enforce-feature-flag-usage-structure tests', () => {
5
- tester.run('ensure-feature-flag-registration', rule, {
6
- valid: [
7
- {
8
- // IfStatement
9
- code: `if(getBooleanFF('test-flag')) { }`,
10
- },
11
- {
12
- // negated IfStatement
13
- code: `if(!getBooleanFF('test-flag')) { }`,
14
- },
15
- {
16
- // ConditionalExpression
17
- code: `const val = getBooleanFF('test-flag') ? 'yay' : 'no';`,
18
- },
19
- {
20
- // LogicalExpression
21
- code: `const val = 100 + (getBooleanFF('test-flag') && 50 || 10);`,
22
- },
23
- ],
24
- invalid: [
25
- {
26
- code: `getBooleanFF('test-flag')`,
27
- errors: [{ messageId: 'onlyInlineIf' }],
28
- },
29
- {
30
- code: `const val = getBooleanFF('test-flag')`,
31
- errors: [{ messageId: 'onlyInlineIf' }],
32
- },
33
- {
34
- code: `const ff = "test-flag"; if(getBooleanFF(ff)) { }`,
35
- errors: [{ messageId: 'onlyStringLiteral' }],
36
- },
37
- {
38
- code: `if(getBooleanFF('test-flag') && getBooleanFF('test-flag')) { }`,
39
- errors: [
40
- { messageId: 'multipleFlagCheckInExpression' },
41
- { messageId: 'multipleFlagCheckInExpression' },
42
- ],
43
- },
44
- {
45
- code: `if(!getBooleanFF('test-flag') && !getBooleanFF('test-flag')) { }`,
46
- errors: [
47
- { messageId: 'multipleFlagCheckInExpression' },
48
- { messageId: 'multipleFlagCheckInExpression' },
49
- ],
50
- },
51
- {
52
- code: `if((!getBooleanFF('test-flag') || 1 == true) && getBooleanFF('test-flag')) { }`,
53
- errors: [
54
- { messageId: 'multipleFlagCheckInExpression' },
55
- { messageId: 'multipleFlagCheckInExpression' },
56
- ],
57
- },
58
- {
59
- code: `export default getBooleanFF('test-flag') ? "this is" : "not good";`,
60
- errors: [{ messageId: 'noModuleScope' }],
61
- },
62
- {
63
- only: true,
64
- code: `export const foo = getBooleanFF('test-flag') ? "this is" : "not good";`,
65
- errors: [{ messageId: 'noModuleScope' }],
66
- },
67
- ],
68
- });
69
- });
@@ -1,128 +0,0 @@
1
- // eslint-disable-next-line import/no-extraneous-dependencies
2
- import type { Rule } from 'eslint';
3
- import type { Node, Expression } from 'estree';
4
-
5
- const FF_GETTER_BOOLEAN_IDENTIFIER = 'getBooleanFF' as const;
6
-
7
- const __isOnlyOneFlagCheckInExpression = (root: Node | Expression, ignoredNode: Node): boolean => {
8
- switch (root.type) {
9
- case 'IfStatement':
10
- return __isOnlyOneFlagCheckInExpression(root.test, ignoredNode);
11
- case 'UnaryExpression':
12
- return __isOnlyOneFlagCheckInExpression(root.argument, ignoredNode);
13
-
14
- case 'CallExpression':
15
- if (root === ignoredNode) {
16
- return true;
17
- }
18
- return !(
19
- root.callee.type === 'Identifier' && root.callee.name === FF_GETTER_BOOLEAN_IDENTIFIER
20
- );
21
-
22
- // shouldn't ever get here but just in case
23
- case 'Identifier':
24
- return root.name !== FF_GETTER_BOOLEAN_IDENTIFIER;
25
-
26
- case 'BinaryExpression':
27
- case 'LogicalExpression':
28
- return (
29
- __isOnlyOneFlagCheckInExpression(root.left, ignoredNode) &&
30
- __isOnlyOneFlagCheckInExpression(root.right, ignoredNode)
31
- );
32
-
33
- default:
34
- return true;
35
- }
36
- };
37
-
38
- const isOnlyOneFlagCheckInExpression = (node: Rule.Node): boolean => {
39
- let root = node.parent;
40
- // find the root node of the expression
41
- // NOTE: This is not an exhaustive check for all ESTree.Expression types but is good enough
42
- while (root.type.endsWith('Expression')) {
43
- root = root.parent;
44
- }
45
-
46
- return __isOnlyOneFlagCheckInExpression(root, node);
47
- };
48
-
49
- const rule: Rule.RuleModule = {
50
- meta: {
51
- hasSuggestions: false,
52
- docs: {
53
- recommended: false,
54
- },
55
- type: 'problem',
56
- messages: {
57
- onlyInlineIf:
58
- "Only call feature flags as part of an expression, don't assign to a variable! See http://go/pff-eslint for more details",
59
- onlyStringLiteral:
60
- "Only get feature flags by string literal, don't use variables! See http://go/pff-eslint for more details",
61
- multipleFlagCheckInExpression: `Only check one flag per expression! See http://go/pff-eslint for more details`,
62
- noModuleScope: `Don't use platform feature flags in module scope! See http://go/pff-eslint for more details`,
63
- },
64
- },
65
- create(context) {
66
- return {
67
- [`CallExpression[callee.name=/${FF_GETTER_BOOLEAN_IDENTIFIER}/]`]: (node: Rule.Node) => {
68
- // to make typescript happy
69
- if (node.type === 'CallExpression') {
70
- const args = node.arguments;
71
-
72
- if (args.length === 1 && args[0].type !== 'Literal') {
73
- return context.report({
74
- node,
75
- messageId: 'onlyStringLiteral',
76
- });
77
- }
78
-
79
- switch (node.parent?.type) {
80
- case 'IfStatement':
81
- break;
82
- case 'ConditionalExpression':
83
- switch (node.parent?.parent.type) {
84
- case 'ExportDefaultDeclaration':
85
- // handles "export default getBooleanFF('test-flag') ? "this is" : "not good";"
86
- context.report({
87
- node,
88
- messageId: 'noModuleScope',
89
- });
90
- break;
91
- case 'VariableDeclarator':
92
- // handles "export const foo = getBooleanFF('test-flag') ? 'this is' : 'not good';"
93
- if (
94
- node.parent.parent.parent.type === 'VariableDeclaration' &&
95
- node.parent.parent.parent.parent.type === 'ExportNamedDeclaration'
96
- ) {
97
- context.report({
98
- node,
99
- messageId: 'noModuleScope',
100
- });
101
- }
102
- break;
103
- }
104
- break;
105
- case 'UnaryExpression':
106
- case 'LogicalExpression':
107
- if (!isOnlyOneFlagCheckInExpression(node)) {
108
- context.report({
109
- node,
110
- messageId: 'multipleFlagCheckInExpression',
111
- });
112
- }
113
- break;
114
- default:
115
- return context.report({
116
- node,
117
- messageId: 'onlyInlineIf',
118
- });
119
- }
120
- }
121
-
122
- return {};
123
- },
124
- };
125
- },
126
- };
127
-
128
- export default rule;
@@ -1,18 +0,0 @@
1
- import { tester } from '../../../../__tests__/utils/_tester';
2
- import rule from '../../index';
3
-
4
- describe('no-invalid-storybook-decorator-usage tests', () => {
5
- tester.run('no-invalid-storybook-decorator-usage', rule, {
6
- valid: [
7
- {
8
- code: `withPlatformFeatureFlags({})(<SampleComponent/>)`,
9
- },
10
- ],
11
- invalid: [
12
- {
13
- code: `const flags = {'uip.sample.color': true}; withPlatformFeatureFlags(flags)(<SampleComponent/>)`,
14
- errors: [{ messageId: 'onlyObjectExpression' }],
15
- },
16
- ],
17
- });
18
- });
@@ -1,39 +0,0 @@
1
- // eslint-disable-next-line import/no-extraneous-dependencies
2
- import type { Rule } from 'eslint';
3
-
4
- const STORYBOOK_DECORATOR_IDENTIFIER = 'withPlatformFeatureFlags' as const;
5
-
6
- const rule: Rule.RuleModule = {
7
- meta: {
8
- hasSuggestions: false,
9
- docs: {
10
- recommended: false,
11
- },
12
- type: 'problem',
13
- messages: {
14
- onlyObjectExpression:
15
- 'Only object literals allowed in the storybook decorator! See http://go/pff-eslint for more details',
16
- },
17
- },
18
- create(context) {
19
- return {
20
- [`CallExpression[callee.name=/${STORYBOOK_DECORATOR_IDENTIFIER}/]`]: (node: Rule.Node) => {
21
- // to make typescript happy
22
- if (node.type === 'CallExpression') {
23
- const args = node.arguments;
24
-
25
- if (args.length === 1 && args[0].type !== 'ObjectExpression') {
26
- return context.report({
27
- node,
28
- messageId: 'onlyObjectExpression',
29
- });
30
- }
31
- }
32
-
33
- return {};
34
- },
35
- };
36
- },
37
- };
38
-
39
- export default rule;
@@ -1,41 +0,0 @@
1
- import { tester } from '../../../../__tests__/utils/_tester';
2
- import rule from '../../index';
3
-
4
- describe('test no-pre-post-installs rule', () => {
5
- tester.run('no-pre-post-installs', rule, {
6
- valid: [
7
- {
8
- code: `const foo = { "scripts": { "preinstall": 1, "postinstall": 2 }}`,
9
- filename: 'hello/foo.ts',
10
- },
11
- {
12
- code: `const foo = { "scripts": { "preinstall": 1, "postinstall": 2 }}`,
13
- filename: 'foo/dummy.json',
14
- },
15
- {
16
- code: `const foo = { "scripts": { "bar": 1, "dummy": 'echo 1' }}`,
17
- filename: 'foo/package.json',
18
- },
19
- {
20
- code: `module.exports = { "scripts": { "fakePreinstall": 1 }};`,
21
- filename: 'bar/package.json',
22
- },
23
- {
24
- code: `module.exports = { "scripts": { "fakePostinstall": 1 }};`,
25
- filename: 'bar/package.json',
26
- },
27
- ],
28
- invalid: [
29
- {
30
- code: `module.exports = { "scripts": { "preinstall": 1 }};`,
31
- filename: 'bar/package.json',
32
- errors: [{ messageId: 'prePostInstallScriptsNotAllowed' }],
33
- },
34
- {
35
- code: `const foo = { "scripts": { "postinstall": 1 }}`,
36
- filename: 'baz/package.json',
37
- errors: [{ messageId: 'prePostInstallScriptsNotAllowed' }],
38
- },
39
- ],
40
- });
41
- });
@@ -1,35 +0,0 @@
1
- // eslint-disable-next-line import/no-extraneous-dependencies
2
- import type { Rule } from 'eslint';
3
-
4
- const rule: Rule.RuleModule = {
5
- meta: {
6
- type: 'problem',
7
- docs: {
8
- description:
9
- 'This rule disallows public packages to have pre/post install scripts as installations can happen on different environments',
10
- recommended: false,
11
- },
12
- hasSuggestions: false,
13
- messages: {
14
- prePostInstallScriptsNotAllowed: 'pre/post install scripts not allowed in package.json',
15
- },
16
- },
17
- create(context) {
18
- return {
19
- 'ObjectExpression Property[key.value=scripts] Property[key.value=/^(pre|post)install$/]': (
20
- node: Rule.Node,
21
- ) => {
22
- if (!context.getFilename().endsWith('/package.json')) {
23
- return;
24
- }
25
-
26
- return context.report({
27
- node,
28
- messageId: 'prePostInstallScriptsNotAllowed',
29
- });
30
- },
31
- };
32
- },
33
- };
34
-
35
- export default rule;
@@ -1,43 +0,0 @@
1
- import type { Rule } from 'eslint';
2
-
3
- const rule: Rule.RuleModule = {
4
- meta: {
5
- docs: {
6
- description:
7
- "Prevent usage of setImmediate in favor of React Testing Library's `waitFor` or similar",
8
- recommended: true,
9
- },
10
- type: 'problem',
11
- messages: {
12
- noSetImmediate:
13
- "Avoid using setImmediate. Use React Testing Library's waitFor or similar instead for better test reliability.",
14
- suggestWaitFor: 'Replace with waitFor from @testing-library/react or similar',
15
- },
16
- hasSuggestions: true,
17
- },
18
- create(context) {
19
- return {
20
- CallExpression(node) {
21
- if (node.callee.type === 'Identifier' && node.callee.name === 'setImmediate') {
22
- context.report({
23
- node,
24
- messageId: 'noSetImmediate',
25
- suggest: [
26
- {
27
- messageId: 'suggestWaitFor',
28
- fix(fixer) {
29
- return fixer.replaceText(
30
- node,
31
- 'await waitFor(() => { /* your assertion here */ })',
32
- );
33
- },
34
- },
35
- ],
36
- });
37
- }
38
- },
39
- };
40
- },
41
- };
42
-
43
- export default rule;
@@ -1,48 +0,0 @@
1
- import { tester } from '../../../../__tests__/utils/_tester';
2
- import rule from '../../index';
3
-
4
- describe('test no-sparse-checkout rule', () => {
5
- tester.run('no-sparse-checkout', rule, {
6
- valid: [
7
- {
8
- code: `
9
- const config = {
10
- clone: alias.afmClone({ sparseCheckout: false })
11
- };
12
- `,
13
- filename: 'hello/foo.ts',
14
- },
15
- {
16
- code: `
17
- const config = {
18
- clone: alias.afmClone({ cloneDepth: 1})
19
- };
20
- `,
21
- filename: 'hello/foo.ts',
22
- },
23
- ],
24
- invalid: [
25
- {
26
- code: `
27
- const config = {
28
- clone: alias.afmClone({ sparseCheckout: true })
29
- };
30
- `,
31
- filename: 'hello/foo.ts',
32
- errors: [{ messageId: 'noSparseCheckout' }],
33
- },
34
- {
35
- code: `
36
- const config = {
37
- clone: alias.afmClone({
38
- cloneDepth: 'full',
39
- sparseCheckout: true
40
- })
41
- };
42
- `,
43
- filename: 'hello/foo.ts',
44
- errors: [{ messageId: 'noSparseCheckout' }],
45
- },
46
- ],
47
- });
48
- });
@@ -1,54 +0,0 @@
1
- import type { Rule } from 'eslint';
2
- import type { Property } from 'estree';
3
-
4
- // We will be removing sparse checkout from pipelines in CI completely due to the load it causes on BBC.
5
- // We will be incrementally removing sparse-checkout from the files below as it is probably unnecessasry.
6
- // If you must add an exception below, please go through the chopper process before doing so
7
- const sparseCheckoutExceptions = [
8
- 'bitbucket-pipelines/pipelines/custom/run-issue-automat.ts',
9
- 'bitbucket-pipelines/pipelines/custom/marketplace/utils.ts',
10
- 'bitbucket-pipelines/pipelines/custom/confluence/utils/index.ts',
11
- 'bitbucket-pipelines/pipelines/custom/afm-tools/upload-afm-dependency-graph-cache.ts',
12
- 'bitbucket-pipelines/pipelines/custom/afm-tools/default-afm-tools.ts',
13
- 'bitbucket-pipelines/pipelines/custom/marketplace/utils.ts',
14
- 'bitbucket-pipelines/pipelines/custom/afm-git-hooks.ts',
15
- 'bitbucket-pipelines/pipelines/custom/update-codeowners-and-teams-gen.ts',
16
- 'bitbucket-pipelines/pipelines/custom/run-issue-automat.ts',
17
- ];
18
-
19
- const rule: Rule.RuleModule = {
20
- meta: {
21
- docs: {
22
- recommended: false,
23
- },
24
- type: 'problem',
25
- messages: {
26
- noSparseCheckout:
27
- 'Sparse checkout is not allowed in pipeline configurations. Use git-alternates instead by setting sparseCheckout to false or add this file to exceptions.',
28
- },
29
- },
30
-
31
- create(context) {
32
- const fileName = context.filename;
33
- if (sparseCheckoutExceptions.some((exception) => fileName.endsWith(exception))) {
34
- return {};
35
- }
36
-
37
- return {
38
- // Look for calls to afmClone or objects that match AFMCloneConfig type
39
- 'CallExpression[callee.object.name=alias][callee.property.name=afmClone] ObjectExpression Property':
40
- (node: Property) => {
41
- if (node.key.type === 'Identifier' && node.key.name === 'sparseCheckout') {
42
- if (node.value.type === 'Literal' && node.value.value === true) {
43
- context.report({
44
- node,
45
- messageId: 'noSparseCheckout',
46
- });
47
- }
48
- }
49
- },
50
- };
51
- },
52
- };
53
-
54
- export default rule;
@@ -1,27 +0,0 @@
1
- Using public entrypoints in our examples ensures that they reflect public API.
2
-
3
- It also has benefits for:
4
-
5
- - readability
6
- - bundle and code analysis
7
-
8
- ## Examples
9
-
10
- This rule marks imports as violations when they reach into the `src` folder through relative file
11
- paths.
12
-
13
- ### Incorrect
14
-
15
- ```js
16
- import Button from '../../../src';
17
-
18
- import { IconButton } from '../../../src/new';
19
- ```
20
-
21
- ### Correct
22
-
23
- ```js
24
- import Button from '@atlaskit/button';
25
-
26
- import { ExampleHelper } from '../not-src';
27
- ```
@@ -1,34 +0,0 @@
1
- import { tester } from '../../../__tests__/utils/_tester';
2
- import rule from '../index';
3
-
4
- const exampleFilename = 'packages/design-system/button/examples/0-basic.tsx';
5
- const nonExampleFilename = 'packages/design-system/button/scripts/my-script.tsx';
6
-
7
- tester.run('use-entrypoints-in-examples', rule, {
8
- valid: [
9
- {
10
- code: `import Button from '@atlaskit/button';`,
11
- filename: exampleFilename,
12
- },
13
- {
14
- code: `import { ExampleHelper } from '../not-src';`,
15
- filename: exampleFilename,
16
- },
17
- {
18
- code: `import Button from '../src';`,
19
- filename: nonExampleFilename,
20
- },
21
- ],
22
- invalid: [
23
- {
24
- code: `import Button from '../../../src';`,
25
- filename: exampleFilename,
26
- errors: [{ messageId: 'useEntrypointsInExamples' }],
27
- },
28
- {
29
- code: `import { IconButton } from '../../../src/new';`,
30
- filename: exampleFilename,
31
- errors: [{ messageId: 'useEntrypointsInExamples' }],
32
- },
33
- ],
34
- });
@@ -1,43 +0,0 @@
1
- import type { Rule } from 'eslint';
2
-
3
- const rule: Rule.RuleModule = {
4
- meta: {
5
- docs: {
6
- url: 'https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/browse/platform/packages/platform/eslint-plugin/src/rules/use-entrypoints-in-examples/README.md',
7
- description: 'Encourage usage of package entrypoints in examples.',
8
- },
9
- messages: {
10
- useEntrypointsInExamples:
11
- 'Use the package entrypoints instead of importing from src. This ensures examples reflect public API.\n\nFor example, use `@atlaskit/button/new` instead of `../../src/new`',
12
- },
13
- type: 'problem',
14
- },
15
- create(context) {
16
- /**
17
- * Even if it's enabled on non-example files it will ignore them.
18
- *
19
- * This is a defensive check, the rule should be configured to only run on examples.
20
- */
21
- if (!context.filename.includes('/examples/')) {
22
- return {};
23
- }
24
-
25
- return {
26
- ImportDeclaration(node) {
27
- const moduleName = node.source.value;
28
- if (typeof moduleName !== 'string') {
29
- return;
30
- }
31
-
32
- if (/^(\.\.\/)+src(\/|$)/.test(moduleName)) {
33
- context.report({
34
- node: node.source,
35
- messageId: 'useEntrypointsInExamples',
36
- });
37
- }
38
- },
39
- };
40
- },
41
- };
42
-
43
- export default rule;