@atlaskit/eslint-plugin-platform 2.4.2 → 2.6.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 (49) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/afm-cc/tsconfig.json +1 -1
  3. package/dist/cjs/index.js +42 -3
  4. package/dist/cjs/rules/ensure-native-and-af-exports-synced/index.js +3 -0
  5. package/dist/cjs/rules/ensure-no-private-dependencies/index.js +101 -0
  6. package/dist/cjs/rules/ensure-valid-platform-yarn-protocol-usage/index.js +3 -15
  7. package/dist/cjs/rules/feature-gating/no-preconditioning/index.js +1 -1
  8. package/dist/cjs/rules/no-direct-document-usage/index.js +103 -0
  9. package/dist/cjs/rules/no-sparse-checkout/index.js +43 -0
  10. package/dist/cjs/rules/util/file-exclusions.js +45 -0
  11. package/dist/es2019/index.js +42 -3
  12. package/dist/es2019/rules/ensure-native-and-af-exports-synced/index.js +3 -0
  13. package/dist/es2019/rules/ensure-no-private-dependencies/index.js +63 -0
  14. package/dist/es2019/rules/ensure-valid-platform-yarn-protocol-usage/index.js +4 -16
  15. package/dist/es2019/rules/feature-gating/no-preconditioning/index.js +1 -1
  16. package/dist/es2019/rules/no-direct-document-usage/index.js +95 -0
  17. package/dist/es2019/rules/no-sparse-checkout/index.js +35 -0
  18. package/dist/es2019/rules/util/file-exclusions.js +37 -0
  19. package/dist/esm/index.js +42 -3
  20. package/dist/esm/rules/ensure-native-and-af-exports-synced/index.js +3 -0
  21. package/dist/esm/rules/ensure-no-private-dependencies/index.js +96 -0
  22. package/dist/esm/rules/ensure-valid-platform-yarn-protocol-usage/index.js +4 -16
  23. package/dist/esm/rules/feature-gating/no-preconditioning/index.js +1 -1
  24. package/dist/esm/rules/no-direct-document-usage/index.js +97 -0
  25. package/dist/esm/rules/no-sparse-checkout/index.js +37 -0
  26. package/dist/esm/rules/util/file-exclusions.js +39 -0
  27. package/dist/types/index.d.ts +14 -0
  28. package/dist/types/rules/ensure-no-private-dependencies/index.d.ts +3 -0
  29. package/dist/types/rules/no-direct-document-usage/index.d.ts +3 -0
  30. package/dist/types/rules/no-sparse-checkout/index.d.ts +3 -0
  31. package/dist/types/rules/util/file-exclusions.d.ts +13 -0
  32. package/dist/types-ts4.5/index.d.ts +14 -0
  33. package/dist/types-ts4.5/rules/ensure-no-private-dependencies/index.d.ts +3 -0
  34. package/dist/types-ts4.5/rules/no-direct-document-usage/index.d.ts +3 -0
  35. package/dist/types-ts4.5/rules/no-sparse-checkout/index.d.ts +3 -0
  36. package/dist/types-ts4.5/rules/util/file-exclusions.d.ts +13 -0
  37. package/package.json +12 -2
  38. package/src/index.tsx +46 -2
  39. package/src/rules/ensure-native-and-af-exports-synced/index.tsx +3 -0
  40. package/src/rules/ensure-no-private-dependencies/__tests__/unit/rule.test.ts +212 -0
  41. package/src/rules/ensure-no-private-dependencies/index.ts +64 -0
  42. package/src/rules/ensure-valid-bin-values/__tests__/unit/rule.test.ts +3 -2
  43. package/src/rules/ensure-valid-platform-yarn-protocol-usage/__tests__/unit/rule.test.ts +57 -109
  44. package/src/rules/ensure-valid-platform-yarn-protocol-usage/index.ts +4 -16
  45. package/src/rules/feature-gating/no-preconditioning/index.tsx +1 -1
  46. package/src/rules/no-direct-document-usage/index.tsx +109 -0
  47. package/src/rules/no-sparse-checkout/__tests__/unit/rule.test.tsx +48 -0
  48. package/src/rules/no-sparse-checkout/index.tsx +54 -0
  49. package/src/rules/util/file-exclusions.ts +39 -0
@@ -0,0 +1,37 @@
1
+ // We will be removing sparse checkout from pipelines in CI completely due to the load it causes on BBC.
2
+ // We will be incrementally removing sparse-checkout from the files below as it is probably unnecessasry.
3
+ // If you must add an exception below, please go through the chopper process before doing so
4
+ var sparseCheckoutExceptions = ['bitbucket-pipelines/pipelines/custom/run-issue-automat.ts', 'bitbucket-pipelines/pipelines/custom/marketplace/utils.ts', 'bitbucket-pipelines/pipelines/custom/confluence/utils/index.ts', 'bitbucket-pipelines/pipelines/custom/afm-tools/upload-afm-dependency-graph-cache.ts', 'bitbucket-pipelines/pipelines/custom/afm-tools/default-afm-tools.ts', 'bitbucket-pipelines/pipelines/custom/marketplace/utils.ts', 'bitbucket-pipelines/pipelines/custom/afm-git-hooks.ts', 'bitbucket-pipelines/pipelines/custom/update-codeowners-and-teams-gen.ts', 'bitbucket-pipelines/pipelines/custom/run-issue-automat.ts'];
5
+ var rule = {
6
+ meta: {
7
+ docs: {
8
+ recommended: false
9
+ },
10
+ type: 'problem',
11
+ messages: {
12
+ noSparseCheckout: 'Sparse checkout is not allowed in pipeline configurations. Use git-alternates instead by setting sparseCheckout to false or add this file to exceptions.'
13
+ }
14
+ },
15
+ create: function create(context) {
16
+ var fileName = context.filename;
17
+ if (sparseCheckoutExceptions.some(function (exception) {
18
+ return fileName.endsWith(exception);
19
+ })) {
20
+ return {};
21
+ }
22
+ return {
23
+ // Look for calls to afmClone or objects that match AFMCloneConfig type
24
+ 'CallExpression[callee.object.name=alias][callee.property.name=afmClone] ObjectExpression Property': function CallExpressionCalleeObjectNameAliasCalleePropertyNameAfmClone_ObjectExpression_Property(node) {
25
+ if (node.key.type === 'Identifier' && node.key.name === 'sparseCheckout') {
26
+ if (node.value.type === 'Literal' && node.value.value === true) {
27
+ context.report({
28
+ node: node,
29
+ messageId: 'noSparseCheckout'
30
+ });
31
+ }
32
+ }
33
+ }
34
+ };
35
+ }
36
+ };
37
+ export default rule;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Common patterns for test files that should be excluded from rules
3
+ */
4
+ var TEST_FILE_PATTERNS = ['__tests__', 'test', 'spec'];
5
+
6
+ /**
7
+ * Checks if a file should be excluded from rules based on test file patterns
8
+ * @param filename The filename to check
9
+ * @returns true if the file should be excluded, false otherwise
10
+ */
11
+ var isTestFile = function isTestFile(filename) {
12
+ return TEST_FILE_PATTERNS.some(function (pattern) {
13
+ return filename.includes(pattern);
14
+ });
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 var skipForTestFiles = function skipForTestFiles(context) {
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 var skipForExampleFiles = function skipForExampleFiles(context) {
35
+ if (context.filename.includes('example')) {
36
+ return {};
37
+ }
38
+ return undefined;
39
+ };
@@ -8,6 +8,7 @@ declare const rules: {
8
8
  'ensure-critical-dependency-resolutions': import("eslint").Rule.RuleModule;
9
9
  'ensure-valid-platform-yarn-protocol-usage': import("eslint").Rule.RuleModule;
10
10
  'ensure-valid-bin-values': import("eslint").Rule.RuleModule;
11
+ 'ensure-no-private-dependencies': import("eslint").Rule.RuleModule;
11
12
  'expand-border-shorthand': import("eslint").Rule.RuleModule;
12
13
  'expand-background-shorthand': import("eslint").Rule.RuleModule;
13
14
  'expand-spacing-shorthand': import("eslint").Rule.RuleModule;
@@ -26,6 +27,8 @@ declare const rules: {
26
27
  'no-alias': import("eslint").Rule.RuleModule;
27
28
  'use-entrypoints-in-examples': import("eslint").Rule.RuleModule;
28
29
  'use-recommended-utils': import("eslint").Rule.RuleModule;
30
+ 'no-sparse-checkout': import("eslint").Rule.RuleModule;
31
+ 'no-direct-document-usage': import("eslint").Rule.RuleModule;
29
32
  };
30
33
  declare const plugin: {
31
34
  meta: {
@@ -41,6 +44,7 @@ declare const plugin: {
41
44
  'ensure-critical-dependency-resolutions': import("eslint").Rule.RuleModule;
42
45
  'ensure-valid-platform-yarn-protocol-usage': import("eslint").Rule.RuleModule;
43
46
  'ensure-valid-bin-values': import("eslint").Rule.RuleModule;
47
+ 'ensure-no-private-dependencies': import("eslint").Rule.RuleModule;
44
48
  'expand-border-shorthand': import("eslint").Rule.RuleModule;
45
49
  'expand-background-shorthand': import("eslint").Rule.RuleModule;
46
50
  'expand-spacing-shorthand': import("eslint").Rule.RuleModule;
@@ -59,6 +63,8 @@ declare const plugin: {
59
63
  'no-alias': import("eslint").Rule.RuleModule;
60
64
  'use-entrypoints-in-examples': import("eslint").Rule.RuleModule;
61
65
  'use-recommended-utils': import("eslint").Rule.RuleModule;
66
+ 'no-sparse-checkout': import("eslint").Rule.RuleModule;
67
+ 'no-direct-document-usage': import("eslint").Rule.RuleModule;
62
68
  };
63
69
  configs: {
64
70
  recommended: {
@@ -80,6 +86,7 @@ declare const plugin: {
80
86
  '@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
81
87
  '@atlaskit/platform/ensure-atlassian-team': "error";
82
88
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
89
+ '@atlaskit/platform/no-direct-document-usage': "warn";
83
90
  '@atlaskit/platform/expand-border-shorthand': "error";
84
91
  '@atlaskit/platform/expand-background-shorthand': "error";
85
92
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -112,6 +119,7 @@ declare const plugin: {
112
119
  '@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
113
120
  '@atlaskit/platform/ensure-atlassian-team': "error";
114
121
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
122
+ '@atlaskit/platform/no-direct-document-usage': "warn";
115
123
  '@atlaskit/platform/expand-border-shorthand': "error";
116
124
  '@atlaskit/platform/expand-background-shorthand': "error";
117
125
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -131,6 +139,7 @@ declare const plugin: {
131
139
  '@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
132
140
  '@atlaskit/platform/ensure-atlassian-team': "error";
133
141
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
142
+ '@atlaskit/platform/no-direct-document-usage': "warn";
134
143
  '@atlaskit/platform/expand-border-shorthand': "error";
135
144
  '@atlaskit/platform/expand-background-shorthand': "error";
136
145
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -153,6 +162,7 @@ declare const plugin: {
153
162
  '@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
154
163
  '@atlaskit/platform/ensure-atlassian-team': "error";
155
164
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
165
+ '@atlaskit/platform/no-direct-document-usage': "warn";
156
166
  '@atlaskit/platform/expand-border-shorthand': "error";
157
167
  '@atlaskit/platform/expand-background-shorthand': "error";
158
168
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -189,6 +199,7 @@ declare const configs: {
189
199
  '@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
190
200
  '@atlaskit/platform/ensure-atlassian-team': "error";
191
201
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
202
+ '@atlaskit/platform/no-direct-document-usage': "warn";
192
203
  '@atlaskit/platform/expand-border-shorthand': "error";
193
204
  '@atlaskit/platform/expand-background-shorthand': "error";
194
205
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -221,6 +232,7 @@ declare const configs: {
221
232
  '@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
222
233
  '@atlaskit/platform/ensure-atlassian-team': "error";
223
234
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
235
+ '@atlaskit/platform/no-direct-document-usage': "warn";
224
236
  '@atlaskit/platform/expand-border-shorthand': "error";
225
237
  '@atlaskit/platform/expand-background-shorthand': "error";
226
238
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -240,6 +252,7 @@ declare const configs: {
240
252
  '@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
241
253
  '@atlaskit/platform/ensure-atlassian-team': "error";
242
254
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
255
+ '@atlaskit/platform/no-direct-document-usage': "warn";
243
256
  '@atlaskit/platform/expand-border-shorthand': "error";
244
257
  '@atlaskit/platform/expand-background-shorthand': "error";
245
258
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -262,6 +275,7 @@ declare const configs: {
262
275
  '@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
263
276
  '@atlaskit/platform/ensure-atlassian-team': "error";
264
277
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
278
+ '@atlaskit/platform/no-direct-document-usage': "warn";
265
279
  '@atlaskit/platform/expand-border-shorthand': "error";
266
280
  '@atlaskit/platform/expand-background-shorthand': "error";
267
281
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -0,0 +1,13 @@
1
+ import type { Rule } from 'eslint';
2
+ /**
3
+ * Helper function to skip rules for test files
4
+ * @param context The ESLint rule context
5
+ * @returns An empty RuleListener if the file is a test file, undefined otherwise
6
+ */
7
+ export declare const skipForTestFiles: (context: Rule.RuleContext) => Rule.RuleListener | undefined;
8
+ /**
9
+ * Helper function to skip rules for example files
10
+ * @param context The ESLint rule context
11
+ * @returns An empty RuleListener if the file is an example file, undefined otherwise
12
+ */
13
+ export declare const skipForExampleFiles: (context: Rule.RuleContext) => Rule.RuleListener | undefined;
@@ -8,6 +8,7 @@ declare const rules: {
8
8
  'ensure-critical-dependency-resolutions': import("eslint").Rule.RuleModule;
9
9
  'ensure-valid-platform-yarn-protocol-usage': import("eslint").Rule.RuleModule;
10
10
  'ensure-valid-bin-values': import("eslint").Rule.RuleModule;
11
+ 'ensure-no-private-dependencies': import("eslint").Rule.RuleModule;
11
12
  'expand-border-shorthand': import("eslint").Rule.RuleModule;
12
13
  'expand-background-shorthand': import("eslint").Rule.RuleModule;
13
14
  'expand-spacing-shorthand': import("eslint").Rule.RuleModule;
@@ -26,6 +27,8 @@ declare const rules: {
26
27
  'no-alias': import("eslint").Rule.RuleModule;
27
28
  'use-entrypoints-in-examples': import("eslint").Rule.RuleModule;
28
29
  'use-recommended-utils': import("eslint").Rule.RuleModule;
30
+ 'no-sparse-checkout': import("eslint").Rule.RuleModule;
31
+ 'no-direct-document-usage': import("eslint").Rule.RuleModule;
29
32
  };
30
33
  declare const plugin: {
31
34
  meta: {
@@ -41,6 +44,7 @@ declare const plugin: {
41
44
  'ensure-critical-dependency-resolutions': import("eslint").Rule.RuleModule;
42
45
  'ensure-valid-platform-yarn-protocol-usage': import("eslint").Rule.RuleModule;
43
46
  'ensure-valid-bin-values': import("eslint").Rule.RuleModule;
47
+ 'ensure-no-private-dependencies': import("eslint").Rule.RuleModule;
44
48
  'expand-border-shorthand': import("eslint").Rule.RuleModule;
45
49
  'expand-background-shorthand': import("eslint").Rule.RuleModule;
46
50
  'expand-spacing-shorthand': import("eslint").Rule.RuleModule;
@@ -59,6 +63,8 @@ declare const plugin: {
59
63
  'no-alias': import("eslint").Rule.RuleModule;
60
64
  'use-entrypoints-in-examples': import("eslint").Rule.RuleModule;
61
65
  'use-recommended-utils': import("eslint").Rule.RuleModule;
66
+ 'no-sparse-checkout': import("eslint").Rule.RuleModule;
67
+ 'no-direct-document-usage': import("eslint").Rule.RuleModule;
62
68
  };
63
69
  configs: {
64
70
  recommended: {
@@ -83,6 +89,7 @@ declare const plugin: {
83
89
  '@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
84
90
  '@atlaskit/platform/ensure-atlassian-team': "error";
85
91
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
92
+ '@atlaskit/platform/no-direct-document-usage': "warn";
86
93
  '@atlaskit/platform/expand-border-shorthand': "error";
87
94
  '@atlaskit/platform/expand-background-shorthand': "error";
88
95
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -121,6 +128,7 @@ declare const plugin: {
121
128
  '@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
122
129
  '@atlaskit/platform/ensure-atlassian-team': "error";
123
130
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
131
+ '@atlaskit/platform/no-direct-document-usage': "warn";
124
132
  '@atlaskit/platform/expand-border-shorthand': "error";
125
133
  '@atlaskit/platform/expand-background-shorthand': "error";
126
134
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -143,6 +151,7 @@ declare const plugin: {
143
151
  '@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
144
152
  '@atlaskit/platform/ensure-atlassian-team': "error";
145
153
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
154
+ '@atlaskit/platform/no-direct-document-usage': "warn";
146
155
  '@atlaskit/platform/expand-border-shorthand': "error";
147
156
  '@atlaskit/platform/expand-background-shorthand': "error";
148
157
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -168,6 +177,7 @@ declare const plugin: {
168
177
  '@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
169
178
  '@atlaskit/platform/ensure-atlassian-team': "error";
170
179
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
180
+ '@atlaskit/platform/no-direct-document-usage': "warn";
171
181
  '@atlaskit/platform/expand-border-shorthand': "error";
172
182
  '@atlaskit/platform/expand-background-shorthand': "error";
173
183
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -210,6 +220,7 @@ declare const configs: {
210
220
  '@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
211
221
  '@atlaskit/platform/ensure-atlassian-team': "error";
212
222
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
223
+ '@atlaskit/platform/no-direct-document-usage': "warn";
213
224
  '@atlaskit/platform/expand-border-shorthand': "error";
214
225
  '@atlaskit/platform/expand-background-shorthand': "error";
215
226
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -248,6 +259,7 @@ declare const configs: {
248
259
  '@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
249
260
  '@atlaskit/platform/ensure-atlassian-team': "error";
250
261
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
262
+ '@atlaskit/platform/no-direct-document-usage': "warn";
251
263
  '@atlaskit/platform/expand-border-shorthand': "error";
252
264
  '@atlaskit/platform/expand-background-shorthand': "error";
253
265
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -270,6 +282,7 @@ declare const configs: {
270
282
  '@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
271
283
  '@atlaskit/platform/ensure-atlassian-team': "error";
272
284
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
285
+ '@atlaskit/platform/no-direct-document-usage': "warn";
273
286
  '@atlaskit/platform/expand-border-shorthand': "error";
274
287
  '@atlaskit/platform/expand-background-shorthand': "error";
275
288
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -295,6 +308,7 @@ declare const configs: {
295
308
  '@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
296
309
  '@atlaskit/platform/ensure-atlassian-team': "error";
297
310
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
311
+ '@atlaskit/platform/no-direct-document-usage': "warn";
298
312
  '@atlaskit/platform/expand-border-shorthand': "error";
299
313
  '@atlaskit/platform/expand-background-shorthand': "error";
300
314
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -0,0 +1,13 @@
1
+ import type { Rule } from 'eslint';
2
+ /**
3
+ * Helper function to skip rules for test files
4
+ * @param context The ESLint rule context
5
+ * @returns An empty RuleListener if the file is a test file, undefined otherwise
6
+ */
7
+ export declare const skipForTestFiles: (context: Rule.RuleContext) => Rule.RuleListener | undefined;
8
+ /**
9
+ * Helper function to skip rules for example files
10
+ * @param context The ESLint rule context
11
+ * @returns An empty RuleListener if the file is an example file, undefined otherwise
12
+ */
13
+ export declare const skipForExampleFiles: (context: Rule.RuleContext) => Rule.RuleListener | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-platform",
3
3
  "description": "The essential plugin for use with Atlassian frontend platform tools",
4
- "version": "2.4.2",
4
+ "version": "2.6.0",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "atlassian": {
7
7
  "team": "Build Infra",
@@ -37,13 +37,23 @@
37
37
  "@babel/runtime": "^7.0.0",
38
38
  "@compiled/eslint-plugin": "^0.18.2",
39
39
  "@manypkg/find-root": "^1.1.0",
40
+ "@manypkg/get-packages": "^1.1.3",
40
41
  "fuse.js": "^6.6.2",
41
42
  "read-pkg-up": "^7.0.1"
42
43
  },
43
44
  "devDependencies": {
44
- "@atlassian/ts-loader": "*",
45
+ "@atlassian/ts-loader": "^0.1.0",
45
46
  "@types/eslint": "^8.56.6",
46
47
  "eslint": "^8.57.0",
48
+ "find-up": "^4 || ^5",
47
49
  "outdent": "^0.5.0"
50
+ },
51
+ "peerDependencies": {
52
+ "find-up": "^4 || ^5"
53
+ },
54
+ "peerDependenciesMeta": {
55
+ "find-up": {
56
+ "optional": true
57
+ }
48
58
  }
49
59
  }
package/src/index.tsx CHANGED
@@ -12,6 +12,7 @@ import ensureFeatureFlagPrefix from './rules/ensure-feature-flag-prefix';
12
12
  import ensureCriticalDependencyResolutions from './rules/ensure-critical-dependency-resolutions';
13
13
  import ensureValidPlatformYarnProtocolUsage from './rules/ensure-valid-platform-yarn-protocol-usage';
14
14
  import ensureValidBinValues from './rules/ensure-valid-bin-values';
15
+ import ensureNoPrivateDependencies from './rules/ensure-no-private-dependencies';
15
16
  import expandBorderShorthand from './rules/compiled/expand-border-shorthand';
16
17
  import noInvalidStorybookDecoratorUsage from './rules/no-invalid-storybook-decorator-usage';
17
18
  import ensurePublishValid from './rules/ensure-publish-valid';
@@ -27,6 +28,30 @@ import useEntrypointsInExamples from './rules/use-entrypoints-in-examples';
27
28
  import useRecommendedUtils from './rules/feature-gating/use-recommended-utils';
28
29
  import expandBackgroundShorthand from './rules/compiled/expand-background-shorthand';
29
30
  import expandSpacingShorthand from './rules/compiled/expand-spacing-shorthand';
31
+ import noSparseCheckout from './rules/no-sparse-checkout';
32
+ import noDirectDocumentUsage from './rules/no-direct-document-usage';
33
+ import { join, normalize } from 'node:path';
34
+ import { readFileSync } from 'node:fs';
35
+
36
+ let jiraRoot: string | undefined;
37
+
38
+ try {
39
+ const findUp = require('find-up') as typeof import('find-up');
40
+ findUp.sync((dir) => {
41
+ const productsJsonPath = join(dir, 'products.json');
42
+ if (findUp.sync.exists(productsJsonPath)) {
43
+ const productJson: Record<string, { path: string }> = JSON.parse(
44
+ readFileSync(productsJsonPath, 'utf-8'),
45
+ );
46
+ if (productJson.Jira) {
47
+ jiraRoot = normalize(join(dir, productJson.Jira.path));
48
+ return findUp.stop;
49
+ }
50
+ }
51
+ });
52
+ } catch {
53
+ // we aren't running inside of AFM, so we can ignore this.
54
+ }
30
55
 
31
56
  const packageJson: {
32
57
  name: string;
@@ -43,6 +68,7 @@ const rules = {
43
68
  'ensure-critical-dependency-resolutions': ensureCriticalDependencyResolutions,
44
69
  'ensure-valid-platform-yarn-protocol-usage': ensureValidPlatformYarnProtocolUsage,
45
70
  'ensure-valid-bin-values': ensureValidBinValues,
71
+ 'ensure-no-private-dependencies': ensureNoPrivateDependencies,
46
72
  'expand-border-shorthand': expandBorderShorthand,
47
73
  'expand-background-shorthand': expandBackgroundShorthand,
48
74
  'expand-spacing-shorthand': expandSpacingShorthand,
@@ -61,6 +87,8 @@ const rules = {
61
87
  'no-alias': noAlias,
62
88
  'use-entrypoints-in-examples': useEntrypointsInExamples,
63
89
  'use-recommended-utils': useRecommendedUtils,
90
+ 'no-sparse-checkout': noSparseCheckout,
91
+ 'no-direct-document-usage': noDirectDocumentUsage,
64
92
  };
65
93
 
66
94
  const commonConfig = {
@@ -70,6 +98,7 @@ const commonConfig = {
70
98
  '@atlaskit/platform/no-invalid-storybook-decorator-usage': 'error',
71
99
  '@atlaskit/platform/ensure-atlassian-team': 'error',
72
100
  '@atlaskit/platform/no-module-level-eval-nav4': 'error',
101
+ '@atlaskit/platform/no-direct-document-usage': 'warn',
73
102
  // Compiled: rules that are not included via `@compiled/recommended
74
103
  '@atlaskit/platform/expand-border-shorthand': 'error',
75
104
  '@atlaskit/platform/expand-background-shorthand': 'error',
@@ -110,6 +139,8 @@ const jsonPrefix =
110
139
  const jsonPrefixForFlatConfig =
111
140
  '/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, no-template-curly-in-string */ module.exports = ';
112
141
 
142
+ const jsonPrefixForJira = 'module.exports = ';
143
+
113
144
  const { name, version } = packageJson;
114
145
  const plugin = {
115
146
  meta: {
@@ -149,7 +180,14 @@ const plugin = {
149
180
  },
150
181
  processors: {
151
182
  'package-json-processor': {
152
- preprocess: (source: string) => {
183
+ preprocess: (source, filename) => {
184
+ // we only need to check for jiraRoot because it uses a different
185
+ // ESLint version and produces fake errors due to how this processor handles JSON
186
+ if (jiraRoot && filename.startsWith(jiraRoot)) {
187
+ // augment the json into a js file
188
+ return [jsonPrefixForJira + source.trim()];
189
+ }
190
+
153
191
  // augment the json into a js file
154
192
  return [jsonPrefix + source.trim()];
155
193
  },
@@ -175,7 +213,13 @@ const plugin = {
175
213
  // This processor is used for ESLint FlatConfig,
176
214
  // once we roll out FlatConfig, we can remove the above processor
177
215
  'package-json-processor-for-flat-config': {
178
- preprocess: (source: string) => {
216
+ // we only need to check for jiraRoot because it uses a different
217
+ // ESLint version and produces fake errors due to how this processor handles JSON
218
+ preprocess: (source, filename) => {
219
+ if (jiraRoot && filename.startsWith(jiraRoot)) {
220
+ // augment the json into a js file
221
+ return [jsonPrefixForJira + source.trim()];
222
+ }
179
223
  // augment the json into a js file
180
224
  return [jsonPrefixForFlatConfig + source.trim()];
181
225
  },
@@ -8,6 +8,9 @@ interface ExportsValidationExceptions {
8
8
  }
9
9
 
10
10
  const exportsValidationExceptions: ExportsValidationExceptions = {
11
+ '@af/yarn-workspace': {
12
+ ignoredAfExportKeys: ['./lock-parser'],
13
+ },
11
14
  '@atlaskit/tokens': {
12
15
  ignoredAfExportKeys: ['./babel-plugin'],
13
16
  },