@atlaskit/eslint-plugin-platform 2.7.2 → 2.8.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 (75) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/index.js +14 -3
  3. package/dist/cjs/rules/feature-gating/valid-gate-name/index.js +60 -0
  4. package/dist/cjs/rules/import/no-barrel-entry-imports/index.js +871 -0
  5. package/dist/cjs/rules/import/no-barrel-entry-jest-mock/index.js +1384 -0
  6. package/dist/cjs/rules/import/no-conversation-assistant-barrel-imports/index.js +43 -0
  7. package/dist/cjs/rules/import/no-jest-mock-barrel-files/index.js +1401 -0
  8. package/dist/cjs/rules/import/no-relative-barrel-file-imports/index.js +777 -0
  9. package/dist/cjs/rules/import/shared/barrel-parsing.js +511 -0
  10. package/dist/cjs/rules/import/shared/file-system.js +186 -0
  11. package/dist/cjs/rules/import/shared/jest-utils.js +191 -0
  12. package/dist/cjs/rules/import/shared/package-registry.js +263 -0
  13. package/dist/cjs/rules/import/shared/package-resolution.js +185 -0
  14. package/dist/cjs/rules/import/shared/perf.js +89 -0
  15. package/dist/cjs/rules/import/shared/types.js +67 -0
  16. package/dist/es2019/index.js +14 -3
  17. package/dist/es2019/rules/feature-gating/valid-gate-name/index.js +52 -0
  18. package/dist/es2019/rules/import/no-barrel-entry-imports/index.js +801 -0
  19. package/dist/es2019/rules/import/no-barrel-entry-jest-mock/index.js +1113 -0
  20. package/dist/es2019/rules/import/no-conversation-assistant-barrel-imports/index.js +37 -0
  21. package/dist/es2019/rules/import/no-jest-mock-barrel-files/index.js +1179 -0
  22. package/dist/es2019/rules/import/no-relative-barrel-file-imports/index.js +738 -0
  23. package/dist/es2019/rules/import/shared/barrel-parsing.js +433 -0
  24. package/dist/es2019/rules/import/shared/file-system.js +174 -0
  25. package/dist/es2019/rules/import/shared/jest-utils.js +159 -0
  26. package/dist/es2019/rules/import/shared/package-registry.js +240 -0
  27. package/dist/es2019/rules/import/shared/package-resolution.js +161 -0
  28. package/dist/es2019/rules/import/shared/perf.js +83 -0
  29. package/dist/es2019/rules/import/shared/types.js +57 -0
  30. package/dist/esm/index.js +14 -3
  31. package/dist/esm/rules/feature-gating/valid-gate-name/index.js +53 -0
  32. package/dist/esm/rules/import/no-barrel-entry-imports/index.js +864 -0
  33. package/dist/esm/rules/import/no-barrel-entry-jest-mock/index.js +1375 -0
  34. package/dist/esm/rules/import/no-conversation-assistant-barrel-imports/index.js +37 -0
  35. package/dist/esm/rules/import/no-jest-mock-barrel-files/index.js +1391 -0
  36. package/dist/esm/rules/import/no-relative-barrel-file-imports/index.js +770 -0
  37. package/dist/esm/rules/import/shared/barrel-parsing.js +500 -0
  38. package/dist/esm/rules/import/shared/file-system.js +176 -0
  39. package/dist/esm/rules/import/shared/jest-utils.js +179 -0
  40. package/dist/esm/rules/import/shared/package-registry.js +256 -0
  41. package/dist/esm/rules/import/shared/package-resolution.js +175 -0
  42. package/dist/esm/rules/import/shared/perf.js +80 -0
  43. package/dist/esm/rules/import/shared/types.js +61 -0
  44. package/dist/types/index.d.ts +16 -2
  45. package/dist/types/rules/feature-gating/valid-gate-name/index.d.ts +3 -0
  46. package/dist/types/rules/import/no-barrel-entry-imports/index.d.ts +9 -0
  47. package/dist/types/rules/import/no-barrel-entry-jest-mock/index.d.ts +9 -0
  48. package/dist/types/rules/import/no-conversation-assistant-barrel-imports/index.d.ts +3 -0
  49. package/dist/types/rules/import/no-jest-mock-barrel-files/index.d.ts +22 -0
  50. package/dist/types/rules/import/no-relative-barrel-file-imports/index.d.ts +5 -0
  51. package/dist/types/rules/import/shared/barrel-parsing.d.ts +30 -0
  52. package/dist/types/rules/import/shared/file-system.d.ts +38 -0
  53. package/dist/types/rules/import/shared/jest-utils.d.ts +47 -0
  54. package/dist/types/rules/import/shared/package-registry.d.ts +26 -0
  55. package/dist/types/rules/import/shared/package-resolution.d.ts +38 -0
  56. package/dist/types/rules/import/shared/perf.d.ts +13 -0
  57. package/dist/types/rules/import/shared/types.d.ts +131 -0
  58. package/dist/types-ts4.5/index.d.ts +16 -2
  59. package/dist/types-ts4.5/rules/import/no-barrel-entry-imports/index.d.ts +9 -0
  60. package/dist/types-ts4.5/rules/import/no-barrel-entry-jest-mock/index.d.ts +9 -0
  61. package/dist/types-ts4.5/rules/import/no-jest-mock-barrel-files/index.d.ts +22 -0
  62. package/dist/types-ts4.5/rules/import/no-relative-barrel-file-imports/index.d.ts +5 -0
  63. package/dist/types-ts4.5/rules/import/shared/barrel-parsing.d.ts +30 -0
  64. package/dist/types-ts4.5/rules/import/shared/file-system.d.ts +38 -0
  65. package/dist/types-ts4.5/rules/import/shared/jest-utils.d.ts +47 -0
  66. package/dist/types-ts4.5/rules/import/shared/package-registry.d.ts +26 -0
  67. package/dist/types-ts4.5/rules/import/shared/package-resolution.d.ts +38 -0
  68. package/dist/types-ts4.5/rules/import/shared/perf.d.ts +13 -0
  69. package/dist/types-ts4.5/rules/import/shared/types.d.ts +131 -0
  70. package/package.json +4 -2
  71. package/dist/cjs/rules/ensure-native-and-af-exports-synced/index.js +0 -158
  72. package/dist/es2019/rules/ensure-native-and-af-exports-synced/index.js +0 -146
  73. package/dist/esm/rules/ensure-native-and-af-exports-synced/index.js +0 -151
  74. /package/dist/types-ts4.5/rules/{ensure-native-and-af-exports-synced → feature-gating/valid-gate-name}/index.d.ts +0 -0
  75. /package/dist/{types/rules/ensure-native-and-af-exports-synced → types-ts4.5/rules/import/no-conversation-assistant-barrel-imports}/index.d.ts +0 -0
@@ -1,151 +0,0 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
- import path from 'path';
7
- import { getMetadataForFilename } from '../util/registration-utils';
8
- var exportsValidationExceptions = {
9
- '@af/yarn-workspace': {
10
- ignoredAfExportKeys: ['./lock-parser']
11
- },
12
- '@atlaskit/tokens': {
13
- ignoredAfExportKeys: ['./babel-plugin']
14
- },
15
- '@atlaskit/storybook-addon-design-system': {
16
- ignoredAfExportKeys: ['.']
17
- },
18
- '@atlassian/react-async': {
19
- ignoredAfExportKeys: ['./mock']
20
- }
21
- };
22
- var rule = {
23
- meta: {
24
- docs: {
25
- recommended: false
26
- },
27
- type: 'problem',
28
- messages: {
29
- missingExportsProperty: "The exports property must be defined for {{pkgName}}; it most likely can just be a duplicate of the \"af:exports\" property. See http://go/eslint-exports for details",
30
- missingExportsKey: "Missing package.json exports key \"{{expectedKey}}\" in {{pkgName}}. The exports entry should be \"{{expectedKey}}\": \"{{expectedValue}}\". See http://go/eslint-exports for details",
31
- unexpectedExportsKey: "Unexpected package.json exports key \"{{key}}\" in {{pkgName}}. The exports entry should be \"{{expectedKey}}\": \"{{expectedValue}}\". See http://go/eslint-exports for details",
32
- unexpectedExportsValue: "Unexpected package.json exports value in {{pkgName}} for the \"{{key}}\" key. The exports entry should be \"{{key}}\": \"{{expectedValue}}\". See http://go/eslint-exports for details"
33
- }
34
- },
35
- create: function create(context) {
36
- var fileName = context.getFilename();
37
- if (!fileName.endsWith('package.json')) {
38
- return {};
39
- }
40
- var _getMetadataForFilena = getMetadataForFilename(fileName),
41
- packageJson = _getMetadataForFilena.pkgJson;
42
- var pkgName = packageJson.name;
43
- if (!pkgName || !packageJson['af:exports']) {
44
- return {};
45
- }
46
- if (!packageJson['exports']) {
47
- context.report({
48
- node: context.getSourceCode().ast,
49
- messageId: 'missingExportsProperty',
50
- data: {
51
- pkgName: pkgName
52
- }
53
- });
54
- return {};
55
- }
56
- var afExports = packageJson['af:exports'];
57
- var nativeExports = packageJson['exports'];
58
- return {
59
- Program: function Program(node) {
60
- for (var _i = 0, _Object$entries = Object.entries(afExports); _i < _Object$entries.length; _i++) {
61
- var _exportsValidationExc;
62
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
63
- afExportsKey = _Object$entries$_i[0],
64
- afExportsValue = _Object$entries$_i[1];
65
- if ((_exportsValidationExc = exportsValidationExceptions[pkgName]) !== null && _exportsValidationExc !== void 0 && _exportsValidationExc.ignoredAfExportKeys.includes(afExportsKey)) {
66
- continue;
67
- }
68
- var exportKeyViolations = getExportKeyViolation(afExportsKey, afExportsValue, nativeExports);
69
- if (exportKeyViolations) {
70
- context.report({
71
- data: _objectSpread(_objectSpread({}, exportKeyViolations), {}, {
72
- key: afExportsKey,
73
- pkgName: pkgName
74
- }),
75
- node: node,
76
- messageId: exportKeyViolations.messageId
77
- });
78
- continue;
79
- }
80
- var exportValueViolations = getExportValueViolation(afExportsKey, afExportsValue, nativeExports);
81
- if (exportValueViolations) {
82
- context.report({
83
- data: _objectSpread(_objectSpread({}, exportValueViolations), {}, {
84
- pkgName: pkgName
85
- }),
86
- node: node,
87
- messageId: 'unexpectedExportsValue'
88
- });
89
- continue;
90
- }
91
- }
92
- }
93
- };
94
- }
95
- };
96
- function getExportKeyViolation(afExportsKey, afExportsValue, nativeExports) {
97
- var afExportsValueHasExtension = path.extname(afExportsValue) !== '';
98
- if (afExportsValueHasExtension && !nativeExports.hasOwnProperty(afExportsKey)) {
99
- return {
100
- messageId: 'missingExportsKey',
101
- expectedKey: afExportsKey,
102
- expectedValue: afExportsValue
103
- };
104
- }
105
- if (!afExportsValueHasExtension && nativeExports.hasOwnProperty(afExportsKey)) {
106
- return {
107
- messageId: 'unexpectedExportsKey',
108
- expectedKey: "".concat(afExportsKey, "/*"),
109
- expectedValue: "".concat(afExportsValue, "/*")
110
- };
111
- }
112
- if (!afExportsValueHasExtension && !nativeExports.hasOwnProperty("".concat(afExportsKey, "/*"))) {
113
- return {
114
- messageId: 'missingExportsKey',
115
- expectedKey: "".concat(afExportsKey, "/*"),
116
- expectedValue: "".concat(afExportsValue, "/*")
117
- };
118
- }
119
- }
120
- function getNativeExportsValue(afExportsKey, afExportsValueHasExtension, nativeExports) {
121
- var nativeExportsKey = afExportsValueHasExtension ? afExportsKey : "".concat(afExportsKey, "/*");
122
- if (_typeof(nativeExports[nativeExportsKey]) === 'object') {
123
- return nativeExports[nativeExportsKey].default;
124
- }
125
- return nativeExports[nativeExportsKey];
126
- }
127
- function getExportValueViolation(afExportsKey, afExportsValue, nativeExports) {
128
- var afExportsValueHasExtension = path.extname(afExportsValue) !== '';
129
- var nativeExportsValue = getNativeExportsValue(afExportsKey, afExportsValueHasExtension, nativeExports);
130
-
131
- // Some entrypoints have been updated to an index.js file that registers ts-node
132
- // Use path.basename to get the file name to see if it is equal to 'index.js'
133
- if (afExportsValueHasExtension && path.basename(nativeExportsValue) === 'index.js') {
134
- return;
135
- }
136
- if (afExportsValueHasExtension && nativeExportsValue !== afExportsValue) {
137
- return {
138
- key: afExportsKey,
139
- expectedValue: afExportsValue
140
- };
141
- }
142
-
143
- // af:exports entrypoints without a file extension export the whole directory so check to ensure the exports value includes the wildcard
144
- if (!afExportsValueHasExtension && !nativeExportsValue.startsWith("".concat(afExportsValue, "/*"))) {
145
- return {
146
- key: "".concat(afExportsKey, "/*"),
147
- expectedValue: "".concat(afExportsValue, "/*")
148
- };
149
- }
150
- }
151
- export default rule;