@atlaskit/eslint-plugin-platform 2.6.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 (119) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/index.js +4 -3
  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/no-direct-document-usage/index.js +1 -1
  7. package/dist/cjs/rules/no-set-immediate/index.js +39 -0
  8. package/dist/cjs/rules/util/context-compat.js +4 -2
  9. package/dist/es2019/index.js +4 -3
  10. package/dist/es2019/rules/ensure-critical-dependency-resolutions/index.js +2 -2
  11. package/dist/es2019/rules/ensure-native-and-af-exports-synced/index.js +3 -0
  12. package/dist/es2019/rules/feature-gating/no-alias/index.js +1 -1
  13. package/dist/es2019/rules/no-direct-document-usage/index.js +1 -1
  14. package/dist/es2019/rules/no-set-immediate/index.js +33 -0
  15. package/dist/es2019/rules/util/context-compat.js +4 -2
  16. package/dist/esm/index.js +4 -3
  17. package/dist/esm/rules/ensure-critical-dependency-resolutions/index.js +2 -2
  18. package/dist/esm/rules/ensure-native-and-af-exports-synced/index.js +3 -0
  19. package/dist/esm/rules/feature-gating/no-alias/index.js +1 -1
  20. package/dist/esm/rules/no-direct-document-usage/index.js +1 -1
  21. package/dist/esm/rules/no-set-immediate/index.js +33 -0
  22. package/dist/esm/rules/util/context-compat.js +4 -2
  23. package/dist/types/index.d.ts +14 -6
  24. package/dist/types/rules/util/handle-ast-object.d.ts +1 -1
  25. package/dist/types-ts4.5/index.d.ts +14 -6
  26. package/dist/types-ts4.5/rules/util/handle-ast-object.d.ts +1 -1
  27. package/package.json +2 -2
  28. package/afm-cc/tsconfig.json +0 -24
  29. package/afm-jira/tsconfig.json +0 -24
  30. package/build/tsconfig.json +0 -17
  31. package/dist/cjs/rules/ensure-valid-platform-yarn-protocol-usage/index.js +0 -79
  32. package/dist/es2019/rules/ensure-valid-platform-yarn-protocol-usage/index.js +0 -62
  33. package/dist/esm/rules/ensure-valid-platform-yarn-protocol-usage/index.js +0 -75
  34. package/src/__tests__/utils/_tester.tsx +0 -26
  35. package/src/index.tsx +0 -251
  36. package/src/rules/compiled/README.md +0 -3
  37. package/src/rules/compiled/expand-background-shorthand/README.md +0 -23
  38. package/src/rules/compiled/expand-background-shorthand/__tests__/rule.test.ts +0 -160
  39. package/src/rules/compiled/expand-background-shorthand/index.tsx +0 -43
  40. package/src/rules/compiled/expand-border-shorthand/README.md +0 -51
  41. package/src/rules/compiled/expand-border-shorthand/__tests__/rule.test.ts +0 -211
  42. package/src/rules/compiled/expand-border-shorthand/index.ts +0 -103
  43. package/src/rules/compiled/expand-spacing-shorthand/README.md +0 -38
  44. package/src/rules/compiled/expand-spacing-shorthand/__tests__/rule.test.ts +0 -448
  45. package/src/rules/compiled/expand-spacing-shorthand/index.ts +0 -240
  46. package/src/rules/constants.tsx +0 -20
  47. package/src/rules/ensure-atlassian-team/__tests__/unit/rule.test.ts +0 -24
  48. package/src/rules/ensure-atlassian-team/index.ts +0 -51
  49. package/src/rules/ensure-critical-dependency-resolutions/__test__/unit/rule.test.tsx +0 -200
  50. package/src/rules/ensure-critical-dependency-resolutions/index.tsx +0 -172
  51. package/src/rules/ensure-feature-flag-prefix/__tests__/unit/rule.test.tsx +0 -65
  52. package/src/rules/ensure-feature-flag-prefix/index.tsx +0 -81
  53. package/src/rules/ensure-feature-flag-registration/__tests__/unit/rule.test.tsx +0 -115
  54. package/src/rules/ensure-feature-flag-registration/index.tsx +0 -106
  55. package/src/rules/ensure-native-and-af-exports-synced/__tests__/unit/rule.test.tsx +0 -199
  56. package/src/rules/ensure-native-and-af-exports-synced/index.tsx +0 -188
  57. package/src/rules/ensure-no-private-dependencies/__tests__/unit/rule.test.ts +0 -212
  58. package/src/rules/ensure-no-private-dependencies/index.ts +0 -64
  59. package/src/rules/ensure-publish-valid/__tests__/unit/rule.test.ts +0 -39
  60. package/src/rules/ensure-publish-valid/index.ts +0 -81
  61. package/src/rules/ensure-test-runner-arguments/__tests__/unit/rule.test.tsx +0 -298
  62. package/src/rules/ensure-test-runner-arguments/index.tsx +0 -121
  63. package/src/rules/ensure-test-runner-nested-count/__tests__/unit/rule.test.tsx +0 -308
  64. package/src/rules/ensure-test-runner-nested-count/index.tsx +0 -82
  65. package/src/rules/ensure-valid-bin-values/__tests__/unit/rule.test.ts +0 -159
  66. package/src/rules/ensure-valid-bin-values/index.ts +0 -70
  67. package/src/rules/ensure-valid-platform-yarn-protocol-usage/__tests__/unit/rule.test.ts +0 -147
  68. package/src/rules/ensure-valid-platform-yarn-protocol-usage/index.ts +0 -67
  69. package/src/rules/feature-gating/README.md +0 -8
  70. package/src/rules/feature-gating/inline-usage/README.md +0 -53
  71. package/src/rules/feature-gating/inline-usage/__tests__/rule.test.tsx +0 -106
  72. package/src/rules/feature-gating/inline-usage/index.tsx +0 -135
  73. package/src/rules/feature-gating/no-alias/README.md +0 -29
  74. package/src/rules/feature-gating/no-alias/__tests__/rule.test.tsx +0 -76
  75. package/src/rules/feature-gating/no-alias/index.tsx +0 -80
  76. package/src/rules/feature-gating/no-module-level-eval/README.md +0 -53
  77. package/src/rules/feature-gating/no-module-level-eval/__tests__/test.tsx +0 -133
  78. package/src/rules/feature-gating/no-module-level-eval/index.tsx +0 -54
  79. package/src/rules/feature-gating/no-module-level-eval-nav4/README.md +0 -8
  80. package/src/rules/feature-gating/no-module-level-eval-nav4/__tests__/test.tsx +0 -130
  81. package/src/rules/feature-gating/no-module-level-eval-nav4/index.tsx +0 -73
  82. package/src/rules/feature-gating/no-preconditioning/README.md +0 -69
  83. package/src/rules/feature-gating/no-preconditioning/__tests__/rule.test.tsx +0 -164
  84. package/src/rules/feature-gating/no-preconditioning/index.tsx +0 -138
  85. package/src/rules/feature-gating/prefer-fg/README.md +0 -3
  86. package/src/rules/feature-gating/prefer-fg/__tests__/rule.test.tsx +0 -83
  87. package/src/rules/feature-gating/prefer-fg/index.tsx +0 -110
  88. package/src/rules/feature-gating/static-feature-flags/README.md +0 -3
  89. package/src/rules/feature-gating/static-feature-flags/__tests__/test.tsx +0 -135
  90. package/src/rules/feature-gating/static-feature-flags/index.tsx +0 -103
  91. package/src/rules/feature-gating/use-recommended-utils/README.md +0 -67
  92. package/src/rules/feature-gating/use-recommended-utils/__tests__/rule.test.tsx +0 -78
  93. package/src/rules/feature-gating/use-recommended-utils/index.tsx +0 -57
  94. package/src/rules/feature-gating/utils.tsx +0 -48
  95. package/src/rules/no-direct-document-usage/index.tsx +0 -109
  96. package/src/rules/no-duplicate-dependencies/__tests__/unit/rule.test.ts +0 -116
  97. package/src/rules/no-duplicate-dependencies/index.ts +0 -79
  98. package/src/rules/no-invalid-feature-flag-usage/__tests__/unit/rule.test.tsx +0 -69
  99. package/src/rules/no-invalid-feature-flag-usage/index.tsx +0 -128
  100. package/src/rules/no-invalid-storybook-decorator-usage/__tests__/unit/rule.test.tsx +0 -18
  101. package/src/rules/no-invalid-storybook-decorator-usage/index.tsx +0 -39
  102. package/src/rules/no-pre-post-installs/__tests__/unit/rule.test.ts +0 -41
  103. package/src/rules/no-pre-post-installs/index.ts +0 -35
  104. package/src/rules/no-sparse-checkout/__tests__/unit/rule.test.tsx +0 -48
  105. package/src/rules/no-sparse-checkout/index.tsx +0 -54
  106. package/src/rules/use-entrypoints-in-examples/README.md +0 -27
  107. package/src/rules/use-entrypoints-in-examples/__tests__/rule.test.tsx +0 -34
  108. package/src/rules/use-entrypoints-in-examples/index.tsx +0 -43
  109. package/src/rules/util/__tests__/context-compat.test.ts +0 -122
  110. package/src/rules/util/compiled-utils.ts +0 -27
  111. package/src/rules/util/context-compat.ts +0 -41
  112. package/src/rules/util/file-exclusions.ts +0 -39
  113. package/src/rules/util/handle-ast-object.ts +0 -33
  114. package/src/rules/util/registration-utils.ts +0 -59
  115. package/tsconfig.app.json +0 -43
  116. package/tsconfig.dev.json +0 -40
  117. package/tsconfig.json +0 -23
  118. /package/dist/types/rules/{ensure-valid-platform-yarn-protocol-usage → no-set-immediate}/index.d.ts +0 -0
  119. /package/dist/types-ts4.5/rules/{ensure-valid-platform-yarn-protocol-usage → no-set-immediate}/index.d.ts +0 -0
@@ -6,7 +6,6 @@ declare const rules: {
6
6
  'ensure-test-runner-nested-count': import("eslint").Rule.RuleModule;
7
7
  'ensure-atlassian-team': import("eslint").Rule.RuleModule;
8
8
  'ensure-critical-dependency-resolutions': import("eslint").Rule.RuleModule;
9
- 'ensure-valid-platform-yarn-protocol-usage': import("eslint").Rule.RuleModule;
10
9
  'ensure-valid-bin-values': import("eslint").Rule.RuleModule;
11
10
  'ensure-no-private-dependencies': import("eslint").Rule.RuleModule;
12
11
  'expand-border-shorthand': import("eslint").Rule.RuleModule;
@@ -29,6 +28,7 @@ declare const rules: {
29
28
  'use-recommended-utils': import("eslint").Rule.RuleModule;
30
29
  'no-sparse-checkout': import("eslint").Rule.RuleModule;
31
30
  'no-direct-document-usage': import("eslint").Rule.RuleModule;
31
+ 'no-set-immediate': import("eslint").Rule.RuleModule;
32
32
  };
33
33
  declare const plugin: {
34
34
  meta: {
@@ -42,7 +42,6 @@ declare const plugin: {
42
42
  'ensure-test-runner-nested-count': import("eslint").Rule.RuleModule;
43
43
  'ensure-atlassian-team': import("eslint").Rule.RuleModule;
44
44
  'ensure-critical-dependency-resolutions': import("eslint").Rule.RuleModule;
45
- 'ensure-valid-platform-yarn-protocol-usage': import("eslint").Rule.RuleModule;
46
45
  'ensure-valid-bin-values': import("eslint").Rule.RuleModule;
47
46
  'ensure-no-private-dependencies': import("eslint").Rule.RuleModule;
48
47
  'expand-border-shorthand': import("eslint").Rule.RuleModule;
@@ -65,6 +64,7 @@ declare const plugin: {
65
64
  'use-recommended-utils': import("eslint").Rule.RuleModule;
66
65
  'no-sparse-checkout': import("eslint").Rule.RuleModule;
67
66
  'no-direct-document-usage': import("eslint").Rule.RuleModule;
67
+ 'no-set-immediate': import("eslint").Rule.RuleModule;
68
68
  };
69
69
  configs: {
70
70
  recommended: {
@@ -90,6 +90,7 @@ declare const plugin: {
90
90
  '@atlaskit/platform/ensure-atlassian-team': "error";
91
91
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
92
92
  '@atlaskit/platform/no-direct-document-usage': "warn";
93
+ '@atlaskit/platform/no-set-immediate': "error";
93
94
  '@atlaskit/platform/expand-border-shorthand': "error";
94
95
  '@atlaskit/platform/expand-background-shorthand': "error";
95
96
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -129,6 +130,7 @@ declare const plugin: {
129
130
  '@atlaskit/platform/ensure-atlassian-team': "error";
130
131
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
131
132
  '@atlaskit/platform/no-direct-document-usage': "warn";
133
+ '@atlaskit/platform/no-set-immediate': "error";
132
134
  '@atlaskit/platform/expand-border-shorthand': "error";
133
135
  '@atlaskit/platform/expand-background-shorthand': "error";
134
136
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -152,6 +154,7 @@ declare const plugin: {
152
154
  '@atlaskit/platform/ensure-atlassian-team': "error";
153
155
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
154
156
  '@atlaskit/platform/no-direct-document-usage': "warn";
157
+ '@atlaskit/platform/no-set-immediate': "error";
155
158
  '@atlaskit/platform/expand-border-shorthand': "error";
156
159
  '@atlaskit/platform/expand-background-shorthand': "error";
157
160
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -178,6 +181,7 @@ declare const plugin: {
178
181
  '@atlaskit/platform/ensure-atlassian-team': "error";
179
182
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
180
183
  '@atlaskit/platform/no-direct-document-usage': "warn";
184
+ '@atlaskit/platform/no-set-immediate': "error";
181
185
  '@atlaskit/platform/expand-border-shorthand': "error";
182
186
  '@atlaskit/platform/expand-background-shorthand': "error";
183
187
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -193,8 +197,8 @@ declare const plugin: {
193
197
  };
194
198
  };
195
199
  processors: {
196
- 'package-json-processor': Linter.Processor<string | Linter.ProcessorFile>;
197
- 'package-json-processor-for-flat-config': Linter.Processor<string | Linter.ProcessorFile>;
200
+ 'package-json-processor': Linter.Processor;
201
+ 'package-json-processor-for-flat-config': Linter.Processor;
198
202
  };
199
203
  };
200
204
  declare const configs: {
@@ -221,6 +225,7 @@ declare const configs: {
221
225
  '@atlaskit/platform/ensure-atlassian-team': "error";
222
226
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
223
227
  '@atlaskit/platform/no-direct-document-usage': "warn";
228
+ '@atlaskit/platform/no-set-immediate': "error";
224
229
  '@atlaskit/platform/expand-border-shorthand': "error";
225
230
  '@atlaskit/platform/expand-background-shorthand': "error";
226
231
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -260,6 +265,7 @@ declare const configs: {
260
265
  '@atlaskit/platform/ensure-atlassian-team': "error";
261
266
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
262
267
  '@atlaskit/platform/no-direct-document-usage': "warn";
268
+ '@atlaskit/platform/no-set-immediate': "error";
263
269
  '@atlaskit/platform/expand-border-shorthand': "error";
264
270
  '@atlaskit/platform/expand-background-shorthand': "error";
265
271
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -283,6 +289,7 @@ declare const configs: {
283
289
  '@atlaskit/platform/ensure-atlassian-team': "error";
284
290
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
285
291
  '@atlaskit/platform/no-direct-document-usage': "warn";
292
+ '@atlaskit/platform/no-set-immediate': "error";
286
293
  '@atlaskit/platform/expand-border-shorthand': "error";
287
294
  '@atlaskit/platform/expand-background-shorthand': "error";
288
295
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -309,6 +316,7 @@ declare const configs: {
309
316
  '@atlaskit/platform/ensure-atlassian-team': "error";
310
317
  '@atlaskit/platform/no-module-level-eval-nav4': "error";
311
318
  '@atlaskit/platform/no-direct-document-usage': "warn";
319
+ '@atlaskit/platform/no-set-immediate': "error";
312
320
  '@atlaskit/platform/expand-border-shorthand': "error";
313
321
  '@atlaskit/platform/expand-background-shorthand': "error";
314
322
  '@atlaskit/platform/expand-spacing-shorthand': "error";
@@ -324,8 +332,8 @@ declare const configs: {
324
332
  };
325
333
  };
326
334
  declare const processors: {
327
- 'package-json-processor': Linter.Processor<string | Linter.ProcessorFile>;
328
- 'package-json-processor-for-flat-config': Linter.Processor<string | Linter.ProcessorFile>;
335
+ 'package-json-processor': Linter.Processor;
336
+ 'package-json-processor-for-flat-config': Linter.Processor;
329
337
  };
330
338
  export { configs, plugin, processors, rules };
331
339
  export default plugin;
@@ -1,3 +1,3 @@
1
1
  import type { ObjectExpression, SimpleLiteral, RegExpLiteral, BigIntLiteral } from 'estree';
2
- export declare const getObjectPropertyAsLiteral: (node: ObjectExpression, property: string) => SimpleLiteral['value'] | RegExpLiteral['value'] | BigIntLiteral['value'];
2
+ export declare const getObjectPropertyAsLiteral: (node: ObjectExpression, property: string) => SimpleLiteral["value"] | RegExpLiteral["value"] | BigIntLiteral["value"];
3
3
  export declare const getObjectPropertyAsObject: (node: ObjectExpression, property: string) => ObjectExpression | null;
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.6.0",
4
+ "version": "2.7.1",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "atlassian": {
7
7
  "team": "Build Infra",
@@ -46,7 +46,7 @@
46
46
  "@types/eslint": "^8.56.6",
47
47
  "eslint": "^8.57.0",
48
48
  "find-up": "^4 || ^5",
49
- "outdent": "^0.5.0"
49
+ "outdent": "^0.7.1"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "find-up": "^4 || ^5"
@@ -1,24 +0,0 @@
1
- {
2
- "extends": "../../../../tsconfig.entry-points.confluence.json",
3
- "compilerOptions": {
4
- "target": "es5",
5
- "composite": true,
6
- "outDir": "../../../../../confluence/tsDist/@atlaskit__eslint-plugin-platform",
7
- "rootDir": "../"
8
- },
9
- "include": [
10
- "../src/**/*.ts",
11
- "../src/**/*.tsx"
12
- ],
13
- "exclude": [
14
- "../src/**/__tests__/*",
15
- "../__tests__/*",
16
- "../src/**/*.test.*",
17
- "../src/**/test.*"
18
- ],
19
- "references": [
20
- {
21
- "path": "../../../design-system/eslint-utils/afm-cc/tsconfig.json"
22
- }
23
- ]
24
- }
@@ -1,24 +0,0 @@
1
- {
2
- "extends": "../../../../tsconfig.entry-points.jira.json",
3
- "compilerOptions": {
4
- "target": "es5",
5
- "outDir": "../../../../../tsDist/@atlaskit__eslint-plugin-platform/app",
6
- "rootDir": "../",
7
- "composite": true
8
- },
9
- "include": [
10
- "../src/**/*.ts",
11
- "../src/**/*.tsx"
12
- ],
13
- "exclude": [
14
- "../src/**/__tests__/*",
15
- "../__tests__/*",
16
- "../src/**/*.test.*",
17
- "../src/**/test.*"
18
- ],
19
- "references": [
20
- {
21
- "path": "../../../design-system/eslint-utils/afm-jira/tsconfig.json"
22
- }
23
- ]
24
- }
@@ -1,17 +0,0 @@
1
- {
2
- "extends": "../tsconfig",
3
- "compilerOptions": {
4
- "target": "es5",
5
- "paths": {}
6
- },
7
- "include": [
8
- "../src/**/*.ts",
9
- "../src/**/*.tsx"
10
- ],
11
- "exclude": [
12
- "../src/**/__tests__/*",
13
- "../__tests__/*",
14
- "../src/**/*.test.*",
15
- "../src/**/test.*"
16
- ]
17
- }
@@ -1,79 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _handleAstObject = require("../util/handle-ast-object");
8
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
9
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
10
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } // eslint-disable-next-line import/no-extraneous-dependencies
11
- var rootProtocolRegex = /^root:[\^~\*]$/;
12
-
13
- /**
14
- * Checks if the 'workspace:' and 'root:' protocol are used as either dependencies or devDependencies
15
- */
16
- function getYarnProtocolsUsed(node) {
17
- var protocolsUsed = {
18
- workspace: false,
19
- root: false
20
- };
21
- var dependencies = (0, _handleAstObject.getObjectPropertyAsObject)(node, 'dependencies');
22
- var devDependencies = (0, _handleAstObject.getObjectPropertyAsObject)(node, 'devDependencies');
23
- var peerDependencies = (0, _handleAstObject.getObjectPropertyAsObject)(node, 'peerDependencies');
24
- for (var _i = 0, _arr = [dependencies, devDependencies, peerDependencies]; _i < _arr.length; _i++) {
25
- var obj = _arr[_i];
26
- var _iterator = _createForOfIteratorHelper((obj === null || obj === void 0 ? void 0 : obj.properties) || []),
27
- _step;
28
- try {
29
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
30
- var p = _step.value;
31
- if (p.type === 'Property' && p.value.type === 'Literal') {
32
- if (typeof p.value.value === 'string') {
33
- if (rootProtocolRegex.test(p.value.value)) {
34
- protocolsUsed.root = true;
35
- }
36
- }
37
- }
38
- }
39
- } catch (err) {
40
- _iterator.e(err);
41
- } finally {
42
- _iterator.f();
43
- }
44
- }
45
- return protocolsUsed;
46
- }
47
- var rule = {
48
- meta: {
49
- type: 'problem',
50
- docs: {
51
- description: "Ensures that yarn protocols 'workspace:' and 'root:' are used correctly.",
52
- recommended: true
53
- },
54
- hasSuggestions: false,
55
- messages: {
56
- invalidWorkspaceProtocolUsage: "The 'workspace:^'protocol is Used. To resolve this error, please use the 'workspace:*' protocol instead.",
57
- invalidRootProtocolUsage: "The 'root:' protocol is not allowed in platform packages. To resolve this error, replace the 'root:' protocol with specific package versions (e.g. '^1.0.0')."
58
- }
59
- },
60
- create: function create(context) {
61
- return {
62
- ObjectExpression: function ObjectExpression(node) {
63
- if (!context.filename.endsWith('package.json') || node.type !== 'ObjectExpression') {
64
- return;
65
- }
66
- var yarnProtocolsUsed = getYarnProtocolsUsed(node);
67
-
68
- // The 'root:' protocol can not be used in any platform packages
69
- if (yarnProtocolsUsed.root) {
70
- context.report({
71
- node: node,
72
- messageId: 'invalidRootProtocolUsage'
73
- });
74
- }
75
- }
76
- };
77
- }
78
- };
79
- var _default = exports.default = rule;
@@ -1,62 +0,0 @@
1
- // eslint-disable-next-line import/no-extraneous-dependencies
2
-
3
- import { getObjectPropertyAsObject } from '../util/handle-ast-object';
4
- const rootProtocolRegex = /^root:[\^~\*]$/;
5
-
6
- /**
7
- * Checks if the 'workspace:' and 'root:' protocol are used as either dependencies or devDependencies
8
- */
9
- function getYarnProtocolsUsed(node) {
10
- const protocolsUsed = {
11
- workspace: false,
12
- root: false
13
- };
14
- const dependencies = getObjectPropertyAsObject(node, 'dependencies');
15
- const devDependencies = getObjectPropertyAsObject(node, 'devDependencies');
16
- const peerDependencies = getObjectPropertyAsObject(node, 'peerDependencies');
17
- for (const obj of [dependencies, devDependencies, peerDependencies]) {
18
- for (const p of (obj === null || obj === void 0 ? void 0 : obj.properties) || []) {
19
- if (p.type === 'Property' && p.value.type === 'Literal') {
20
- if (typeof p.value.value === 'string') {
21
- if (rootProtocolRegex.test(p.value.value)) {
22
- protocolsUsed.root = true;
23
- }
24
- }
25
- }
26
- }
27
- }
28
- return protocolsUsed;
29
- }
30
- const rule = {
31
- meta: {
32
- type: 'problem',
33
- docs: {
34
- description: `Ensures that yarn protocols 'workspace:' and 'root:' are used correctly.`,
35
- recommended: true
36
- },
37
- hasSuggestions: false,
38
- messages: {
39
- invalidWorkspaceProtocolUsage: `The 'workspace:^'protocol is Used. To resolve this error, please use the 'workspace:*' protocol instead.`,
40
- invalidRootProtocolUsage: `The 'root:' protocol is not allowed in platform packages. To resolve this error, replace the 'root:' protocol with specific package versions (e.g. '^1.0.0').`
41
- }
42
- },
43
- create(context) {
44
- return {
45
- ObjectExpression: node => {
46
- if (!context.filename.endsWith('package.json') || node.type !== 'ObjectExpression') {
47
- return;
48
- }
49
- const yarnProtocolsUsed = getYarnProtocolsUsed(node);
50
-
51
- // The 'root:' protocol can not be used in any platform packages
52
- if (yarnProtocolsUsed.root) {
53
- context.report({
54
- node,
55
- messageId: 'invalidRootProtocolUsage'
56
- });
57
- }
58
- }
59
- };
60
- }
61
- };
62
- export default rule;
@@ -1,75 +0,0 @@
1
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
2
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
3
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
4
- // eslint-disable-next-line import/no-extraneous-dependencies
5
-
6
- import { getObjectPropertyAsObject } from '../util/handle-ast-object';
7
- var rootProtocolRegex = /^root:[\^~\*]$/;
8
-
9
- /**
10
- * Checks if the 'workspace:' and 'root:' protocol are used as either dependencies or devDependencies
11
- */
12
- function getYarnProtocolsUsed(node) {
13
- var protocolsUsed = {
14
- workspace: false,
15
- root: false
16
- };
17
- var dependencies = getObjectPropertyAsObject(node, 'dependencies');
18
- var devDependencies = getObjectPropertyAsObject(node, 'devDependencies');
19
- var peerDependencies = getObjectPropertyAsObject(node, 'peerDependencies');
20
- for (var _i = 0, _arr = [dependencies, devDependencies, peerDependencies]; _i < _arr.length; _i++) {
21
- var obj = _arr[_i];
22
- var _iterator = _createForOfIteratorHelper((obj === null || obj === void 0 ? void 0 : obj.properties) || []),
23
- _step;
24
- try {
25
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
26
- var p = _step.value;
27
- if (p.type === 'Property' && p.value.type === 'Literal') {
28
- if (typeof p.value.value === 'string') {
29
- if (rootProtocolRegex.test(p.value.value)) {
30
- protocolsUsed.root = true;
31
- }
32
- }
33
- }
34
- }
35
- } catch (err) {
36
- _iterator.e(err);
37
- } finally {
38
- _iterator.f();
39
- }
40
- }
41
- return protocolsUsed;
42
- }
43
- var rule = {
44
- meta: {
45
- type: 'problem',
46
- docs: {
47
- description: "Ensures that yarn protocols 'workspace:' and 'root:' are used correctly.",
48
- recommended: true
49
- },
50
- hasSuggestions: false,
51
- messages: {
52
- invalidWorkspaceProtocolUsage: "The 'workspace:^'protocol is Used. To resolve this error, please use the 'workspace:*' protocol instead.",
53
- invalidRootProtocolUsage: "The 'root:' protocol is not allowed in platform packages. To resolve this error, replace the 'root:' protocol with specific package versions (e.g. '^1.0.0')."
54
- }
55
- },
56
- create: function create(context) {
57
- return {
58
- ObjectExpression: function ObjectExpression(node) {
59
- if (!context.filename.endsWith('package.json') || node.type !== 'ObjectExpression') {
60
- return;
61
- }
62
- var yarnProtocolsUsed = getYarnProtocolsUsed(node);
63
-
64
- // The 'root:' protocol can not be used in any platform packages
65
- if (yarnProtocolsUsed.root) {
66
- context.report({
67
- node: node,
68
- messageId: 'invalidRootProtocolUsage'
69
- });
70
- }
71
- }
72
- };
73
- }
74
- };
75
- export default rule;
@@ -1,26 +0,0 @@
1
- /* eslint-disable @repo/internal/fs/filename-pattern-match */
2
- /* eslint-disable no-undef */
3
- import { RuleTester } from 'eslint';
4
-
5
- (RuleTester as any).describe = (text: string, method: Function) => {
6
- const origHasAssertions = expect.hasAssertions;
7
- describe(text, () => {
8
- beforeAll(() => {
9
- // Stub out expect.hasAssertions beforeEach from jest-presetup.js
10
- expect.hasAssertions = () => {};
11
- });
12
- afterAll(() => {
13
- expect.hasAssertions = origHasAssertions;
14
- });
15
-
16
- method();
17
- });
18
- };
19
-
20
- export const tester = new RuleTester({
21
- parser: require.resolve('@babel/eslint-parser'),
22
- parserOptions: {
23
- ecmaVersion: 6,
24
- sourceType: 'module',
25
- },
26
- });