@atlaskit/eslint-plugin-platform 2.7.1 → 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.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/index.js +17 -9
- package/dist/cjs/rules/constants.js +1 -1
- package/dist/cjs/rules/ensure-critical-dependency-resolutions/index.js +5 -5
- package/dist/cjs/rules/ensure-no-private-dependencies/index.js +48 -66
- package/dist/cjs/rules/feature-gating/inline-usage/index.js +14 -3
- package/dist/cjs/rules/feature-gating/no-alias/index.js +1 -1
- package/dist/cjs/rules/feature-gating/no-module-level-eval/index.js +1 -1
- package/dist/cjs/rules/feature-gating/no-module-level-eval-nav4/index.js +1 -1
- package/dist/cjs/rules/feature-gating/no-preconditioning/index.js +4 -1
- package/dist/cjs/rules/feature-gating/prefer-fg/index.js +1 -1
- package/dist/cjs/rules/feature-gating/static-feature-flags/index.js +2 -2
- package/dist/cjs/rules/feature-gating/use-recommended-utils/index.js +1 -1
- package/dist/cjs/rules/feature-gating/valid-gate-name/index.js +60 -0
- package/dist/cjs/rules/import/no-barrel-entry-imports/index.js +871 -0
- package/dist/cjs/rules/import/no-barrel-entry-jest-mock/index.js +1384 -0
- package/dist/cjs/rules/import/no-conversation-assistant-barrel-imports/index.js +43 -0
- package/dist/cjs/rules/import/no-jest-mock-barrel-files/index.js +1401 -0
- package/dist/cjs/rules/import/no-relative-barrel-file-imports/index.js +777 -0
- package/dist/cjs/rules/import/shared/barrel-parsing.js +511 -0
- package/dist/cjs/rules/import/shared/file-system.js +186 -0
- package/dist/cjs/rules/import/shared/jest-utils.js +191 -0
- package/dist/cjs/rules/import/shared/package-registry.js +263 -0
- package/dist/cjs/rules/import/shared/package-resolution.js +185 -0
- package/dist/cjs/rules/import/shared/perf.js +89 -0
- package/dist/cjs/rules/import/shared/types.js +67 -0
- package/dist/cjs/rules/no-invalid-storybook-decorator-usage/index.js +1 -1
- package/dist/cjs/rules/no-sparse-checkout/index.js +1 -1
- package/dist/cjs/rules/prefer-crypto-random-uuid/index.js +87 -0
- package/dist/cjs/rules/use-entrypoints-in-examples/index.js +1 -1
- package/dist/es2019/index.js +17 -9
- package/dist/es2019/rules/constants.js +1 -1
- package/dist/es2019/rules/ensure-critical-dependency-resolutions/index.js +5 -5
- package/dist/es2019/rules/ensure-no-private-dependencies/index.js +10 -9
- package/dist/es2019/rules/feature-gating/inline-usage/index.js +14 -3
- package/dist/es2019/rules/feature-gating/no-alias/index.js +1 -1
- package/dist/es2019/rules/feature-gating/no-module-level-eval/index.js +1 -1
- package/dist/es2019/rules/feature-gating/no-module-level-eval-nav4/index.js +1 -1
- package/dist/es2019/rules/feature-gating/no-preconditioning/index.js +4 -1
- package/dist/es2019/rules/feature-gating/prefer-fg/index.js +1 -1
- package/dist/es2019/rules/feature-gating/static-feature-flags/index.js +2 -2
- package/dist/es2019/rules/feature-gating/use-recommended-utils/index.js +1 -1
- package/dist/es2019/rules/feature-gating/valid-gate-name/index.js +52 -0
- package/dist/es2019/rules/import/no-barrel-entry-imports/index.js +801 -0
- package/dist/es2019/rules/import/no-barrel-entry-jest-mock/index.js +1113 -0
- package/dist/es2019/rules/import/no-conversation-assistant-barrel-imports/index.js +37 -0
- package/dist/es2019/rules/import/no-jest-mock-barrel-files/index.js +1179 -0
- package/dist/es2019/rules/import/no-relative-barrel-file-imports/index.js +738 -0
- package/dist/es2019/rules/import/shared/barrel-parsing.js +433 -0
- package/dist/es2019/rules/import/shared/file-system.js +174 -0
- package/dist/es2019/rules/import/shared/jest-utils.js +159 -0
- package/dist/es2019/rules/import/shared/package-registry.js +240 -0
- package/dist/es2019/rules/import/shared/package-resolution.js +161 -0
- package/dist/es2019/rules/import/shared/perf.js +83 -0
- package/dist/es2019/rules/import/shared/types.js +57 -0
- package/dist/es2019/rules/no-invalid-storybook-decorator-usage/index.js +1 -1
- package/dist/es2019/rules/no-sparse-checkout/index.js +1 -1
- package/dist/es2019/rules/prefer-crypto-random-uuid/index.js +81 -0
- package/dist/es2019/rules/use-entrypoints-in-examples/index.js +1 -1
- package/dist/esm/index.js +17 -9
- package/dist/esm/rules/constants.js +1 -1
- package/dist/esm/rules/ensure-critical-dependency-resolutions/index.js +5 -5
- package/dist/esm/rules/ensure-no-private-dependencies/index.js +48 -65
- package/dist/esm/rules/feature-gating/inline-usage/index.js +14 -3
- package/dist/esm/rules/feature-gating/no-alias/index.js +1 -1
- package/dist/esm/rules/feature-gating/no-module-level-eval/index.js +1 -1
- package/dist/esm/rules/feature-gating/no-module-level-eval-nav4/index.js +1 -1
- package/dist/esm/rules/feature-gating/no-preconditioning/index.js +4 -1
- package/dist/esm/rules/feature-gating/prefer-fg/index.js +1 -1
- package/dist/esm/rules/feature-gating/static-feature-flags/index.js +2 -2
- package/dist/esm/rules/feature-gating/use-recommended-utils/index.js +1 -1
- package/dist/esm/rules/feature-gating/valid-gate-name/index.js +53 -0
- package/dist/esm/rules/import/no-barrel-entry-imports/index.js +864 -0
- package/dist/esm/rules/import/no-barrel-entry-jest-mock/index.js +1375 -0
- package/dist/esm/rules/import/no-conversation-assistant-barrel-imports/index.js +37 -0
- package/dist/esm/rules/import/no-jest-mock-barrel-files/index.js +1391 -0
- package/dist/esm/rules/import/no-relative-barrel-file-imports/index.js +770 -0
- package/dist/esm/rules/import/shared/barrel-parsing.js +500 -0
- package/dist/esm/rules/import/shared/file-system.js +176 -0
- package/dist/esm/rules/import/shared/jest-utils.js +179 -0
- package/dist/esm/rules/import/shared/package-registry.js +256 -0
- package/dist/esm/rules/import/shared/package-resolution.js +175 -0
- package/dist/esm/rules/import/shared/perf.js +80 -0
- package/dist/esm/rules/import/shared/types.js +61 -0
- package/dist/esm/rules/no-invalid-storybook-decorator-usage/index.js +1 -1
- package/dist/esm/rules/no-sparse-checkout/index.js +1 -1
- package/dist/esm/rules/prefer-crypto-random-uuid/index.js +81 -0
- package/dist/esm/rules/use-entrypoints-in-examples/index.js +1 -1
- package/dist/types/index.d.ts +18 -16
- package/dist/types/rules/import/no-barrel-entry-imports/index.d.ts +9 -0
- package/dist/types/rules/import/no-barrel-entry-jest-mock/index.d.ts +9 -0
- package/dist/types/rules/import/no-conversation-assistant-barrel-imports/index.d.ts +3 -0
- package/dist/types/rules/import/no-jest-mock-barrel-files/index.d.ts +22 -0
- package/dist/types/rules/import/no-relative-barrel-file-imports/index.d.ts +5 -0
- package/dist/types/rules/import/shared/barrel-parsing.d.ts +30 -0
- package/dist/types/rules/import/shared/file-system.d.ts +38 -0
- package/dist/types/rules/import/shared/jest-utils.d.ts +47 -0
- package/dist/types/rules/import/shared/package-registry.d.ts +26 -0
- package/dist/types/rules/import/shared/package-resolution.d.ts +38 -0
- package/dist/types/rules/import/shared/perf.d.ts +13 -0
- package/dist/types/rules/import/shared/types.d.ts +131 -0
- package/dist/types/rules/prefer-crypto-random-uuid/index.d.ts +3 -0
- package/dist/types-ts4.5/index.d.ts +18 -28
- package/dist/types-ts4.5/rules/import/no-barrel-entry-imports/index.d.ts +9 -0
- package/dist/types-ts4.5/rules/import/no-barrel-entry-jest-mock/index.d.ts +9 -0
- package/dist/types-ts4.5/rules/import/no-jest-mock-barrel-files/index.d.ts +22 -0
- package/dist/types-ts4.5/rules/import/no-relative-barrel-file-imports/index.d.ts +5 -0
- package/dist/types-ts4.5/rules/import/shared/barrel-parsing.d.ts +30 -0
- package/dist/types-ts4.5/rules/import/shared/file-system.d.ts +38 -0
- package/dist/types-ts4.5/rules/import/shared/jest-utils.d.ts +47 -0
- package/dist/types-ts4.5/rules/import/shared/package-registry.d.ts +26 -0
- package/dist/types-ts4.5/rules/import/shared/package-resolution.d.ts +38 -0
- package/dist/types-ts4.5/rules/import/shared/perf.d.ts +13 -0
- package/dist/types-ts4.5/rules/import/shared/types.d.ts +131 -0
- package/package.json +4 -5
- package/dist/cjs/rules/ensure-feature-flag-prefix/index.js +0 -75
- package/dist/cjs/rules/ensure-native-and-af-exports-synced/index.js +0 -158
- package/dist/es2019/rules/ensure-feature-flag-prefix/index.js +0 -65
- package/dist/es2019/rules/ensure-native-and-af-exports-synced/index.js +0 -146
- package/dist/esm/rules/ensure-feature-flag-prefix/index.js +0 -69
- package/dist/esm/rules/ensure-native-and-af-exports-synced/index.js +0 -151
- /package/dist/types/rules/{ensure-native-and-af-exports-synced → feature-gating/valid-gate-name}/index.d.ts +0 -0
- /package/dist/types-ts4.5/rules/{ensure-feature-flag-prefix → feature-gating/valid-gate-name}/index.d.ts +0 -0
- /package/dist/types-ts4.5/rules/{ensure-native-and-af-exports-synced → import/no-conversation-assistant-barrel-imports}/index.d.ts +0 -0
- /package/dist/{types/rules/ensure-feature-flag-prefix → types-ts4.5/rules/prefer-crypto-random-uuid}/index.d.ts +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
import { execSync as _execSync } from 'child_process';
|
|
5
|
+
import { existsSync, readdirSync as _readdirSync, readFileSync, realpathSync, statSync } from 'fs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Directory entry returned by readdirSync with withFileTypes option.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* State for the package registry cache.
|
|
13
|
+
* This is used to cache package name to directory mappings for efficient lookups.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Cache structure for file system operations.
|
|
18
|
+
* Contains both package registry cache and workspace root cache.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* File system abstraction for testability.
|
|
23
|
+
* This interface allows the core logic to be tested with mock file systems.
|
|
24
|
+
* The cache property holds package resolution state and can be passed as an empty
|
|
25
|
+
* object for tests to ensure fresh state for each test case.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Real file system implementation using Node.js fs module.
|
|
30
|
+
*/
|
|
31
|
+
export var realFileSystem = {
|
|
32
|
+
existsSync: existsSync,
|
|
33
|
+
readFileSync: readFileSync,
|
|
34
|
+
realpathSync: realpathSync,
|
|
35
|
+
statSync: statSync,
|
|
36
|
+
readdirSync: function readdirSync(path, options) {
|
|
37
|
+
return _readdirSync(path, options);
|
|
38
|
+
},
|
|
39
|
+
execSync: function execSync(command, options) {
|
|
40
|
+
try {
|
|
41
|
+
return _execSync(command, _objectSpread(_objectSpread({}, options), {}, {
|
|
42
|
+
encoding: 'utf-8'
|
|
43
|
+
})).trim();
|
|
44
|
+
} catch (_unused) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
cache: {}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Information about cross-package re-export origin.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Information about where an export originates.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Context for package resolution operations.
|
|
61
|
+
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
3
|
|
|
4
|
-
var STORYBOOK_DECORATOR_IDENTIFIER = '
|
|
4
|
+
var STORYBOOK_DECORATOR_IDENTIFIER = 'withPlatformFeatureGates';
|
|
5
5
|
var rule = {
|
|
6
6
|
meta: {
|
|
7
7
|
hasSuggestions: false,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// We will be removing sparse checkout from pipelines in CI completely due to the load it causes on BBC.
|
|
2
2
|
// We will be incrementally removing sparse-checkout from the files below as it is probably unnecessasry.
|
|
3
3
|
// If you must add an exception below, please go through the chopper process before doing so
|
|
4
|
-
var sparseCheckoutExceptions = ['
|
|
4
|
+
var sparseCheckoutExceptions = ['pipeline-definitions/pipelines/custom/run-issue-automat.ts', 'pipeline-definitions/pipelines/custom/marketplace/utils.ts', 'pipeline-definitions/pipelines/custom/confluence/utils/index.ts', 'pipeline-definitions/pipelines/custom/afm-tools/upload-afm-dependency-graph-cache.ts', 'pipeline-definitions/pipelines/custom/afm-tools/default-afm-tools.ts', 'pipeline-definitions/pipelines/custom/marketplace/utils.ts', 'pipeline-definitions/pipelines/custom/afm-git-hooks.ts', 'pipeline-definitions/pipelines/custom/update-codeowners-and-teams-gen.ts', 'pipeline-definitions/pipelines/custom/run-issue-automat.ts'];
|
|
5
5
|
var rule = {
|
|
6
6
|
meta: {
|
|
7
7
|
docs: {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
+
|
|
3
|
+
var rule = {
|
|
4
|
+
meta: {
|
|
5
|
+
type: 'problem',
|
|
6
|
+
// Problem type = can be error
|
|
7
|
+
docs: {
|
|
8
|
+
description: 'Prefer crypto.randomUUID() over uuid library. The uuid package causes Jest mocking issues.',
|
|
9
|
+
recommended: true
|
|
10
|
+
},
|
|
11
|
+
fixable: 'code',
|
|
12
|
+
// Enables --fix
|
|
13
|
+
messages: {
|
|
14
|
+
preferCryptoRandomUUID: 'Use crypto.randomUUID() instead of the uuid library. Run `eslint --fix` to auto-migrate.'
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
create: function create(context) {
|
|
18
|
+
var uuidImports = new Map(); // Track imported names
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
ImportDeclaration: function ImportDeclaration(node) {
|
|
22
|
+
if (node.type !== 'ImportDeclaration') {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
var source = node.source.value;
|
|
26
|
+
if (typeof source === 'string' && (source === 'uuid' || /^uuid\/v[14]$/.test(source))) {
|
|
27
|
+
// Track imported name (e.g., uuid, v4, etc.)
|
|
28
|
+
var specifier = node.specifiers[0];
|
|
29
|
+
if (specifier) {
|
|
30
|
+
uuidImports.set(specifier.local.name, node);
|
|
31
|
+
}
|
|
32
|
+
context.report({
|
|
33
|
+
node: node,
|
|
34
|
+
messageId: 'preferCryptoRandomUUID',
|
|
35
|
+
fix: function fix(fixer) {
|
|
36
|
+
// Remove the import - usages will be fixed separately
|
|
37
|
+
return fixer.remove(node);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
CallExpression: function CallExpression(node) {
|
|
43
|
+
var _node$arguments$;
|
|
44
|
+
if (node.type !== 'CallExpression') {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Handle direct uuid() or v4() calls
|
|
49
|
+
if (node.callee.type === 'Identifier') {
|
|
50
|
+
var calleeName = node.callee.name;
|
|
51
|
+
if (uuidImports.has(calleeName)) {
|
|
52
|
+
context.report({
|
|
53
|
+
node: node,
|
|
54
|
+
messageId: 'preferCryptoRandomUUID',
|
|
55
|
+
fix: function fix(fixer) {
|
|
56
|
+
// Replace uuid() with crypto.randomUUID()
|
|
57
|
+
return fixer.replaceText(node.callee, 'crypto.randomUUID');
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Handle require('uuid')
|
|
64
|
+
if (node.callee.type === 'Identifier' && node.callee.name === 'require' && ((_node$arguments$ = node.arguments[0]) === null || _node$arguments$ === void 0 ? void 0 : _node$arguments$.type) === 'Literal') {
|
|
65
|
+
var arg = node.arguments[0].value;
|
|
66
|
+
if (typeof arg === 'string' && (arg === 'uuid' || /^uuid\/v[14]$/.test(arg))) {
|
|
67
|
+
context.report({
|
|
68
|
+
node: node,
|
|
69
|
+
messageId: 'preferCryptoRandomUUID'
|
|
70
|
+
// require() needs manual refactoring
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
'Program:exit': function ProgramExit() {
|
|
76
|
+
uuidImports.clear();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
export default rule;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var rule = {
|
|
2
2
|
meta: {
|
|
3
3
|
docs: {
|
|
4
|
-
url: 'https://
|
|
4
|
+
url: 'https://bitbucket.org/atlassian/atlassian-frontend-monorepo/src/master/platform/packages/platform/eslint-plugin/src/rules/use-entrypoints-in-examples/README.md',
|
|
5
5
|
description: 'Encourage usage of package entrypoints in examples.'
|
|
6
6
|
},
|
|
7
7
|
messages: {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ESLint, Linter } from 'eslint';
|
|
2
2
|
declare const rules: {
|
|
3
3
|
'ensure-feature-flag-registration': import("eslint").Rule.RuleModule;
|
|
4
|
-
'ensure-feature-flag-prefix': import("eslint").Rule.RuleModule;
|
|
5
4
|
'ensure-test-runner-arguments': import("eslint").Rule.RuleModule;
|
|
6
5
|
'ensure-test-runner-nested-count': import("eslint").Rule.RuleModule;
|
|
7
6
|
'ensure-atlassian-team': import("eslint").Rule.RuleModule;
|
|
@@ -16,7 +15,6 @@ declare const rules: {
|
|
|
16
15
|
'no-pre-post-install-scripts': import("eslint").Rule.RuleModule;
|
|
17
16
|
'no-invalid-storybook-decorator-usage': import("eslint").Rule.RuleModule;
|
|
18
17
|
'ensure-publish-valid': import("eslint").Rule.RuleModule;
|
|
19
|
-
'ensure-native-and-af-exports-synced': import("eslint").Rule.RuleModule;
|
|
20
18
|
'no-module-level-eval': import("eslint").Rule.RuleModule;
|
|
21
19
|
'no-module-level-eval-nav4': import("eslint").Rule.RuleModule;
|
|
22
20
|
'static-feature-flags': import("eslint").Rule.RuleModule;
|
|
@@ -26,9 +24,16 @@ declare const rules: {
|
|
|
26
24
|
'no-alias': import("eslint").Rule.RuleModule;
|
|
27
25
|
'use-entrypoints-in-examples': import("eslint").Rule.RuleModule;
|
|
28
26
|
'use-recommended-utils': import("eslint").Rule.RuleModule;
|
|
27
|
+
'valid-gate-name': import("eslint").Rule.RuleModule;
|
|
29
28
|
'no-sparse-checkout': import("eslint").Rule.RuleModule;
|
|
30
29
|
'no-direct-document-usage': import("eslint").Rule.RuleModule;
|
|
31
30
|
'no-set-immediate': import("eslint").Rule.RuleModule;
|
|
31
|
+
'prefer-crypto-random-uuid': import("eslint").Rule.RuleModule;
|
|
32
|
+
'no-barrel-entry-imports': import("eslint").Rule.RuleModule;
|
|
33
|
+
'no-barrel-entry-jest-mock': import("eslint").Rule.RuleModule;
|
|
34
|
+
'no-jest-mock-barrel-files': import("eslint").Rule.RuleModule;
|
|
35
|
+
'no-relative-barrel-file-imports': import("eslint").Rule.RuleModule;
|
|
36
|
+
'no-conversation-assistant-barrel-imports': import("eslint").Rule.RuleModule;
|
|
32
37
|
};
|
|
33
38
|
declare const plugin: {
|
|
34
39
|
meta: {
|
|
@@ -37,7 +42,6 @@ declare const plugin: {
|
|
|
37
42
|
};
|
|
38
43
|
rules: {
|
|
39
44
|
'ensure-feature-flag-registration': import("eslint").Rule.RuleModule;
|
|
40
|
-
'ensure-feature-flag-prefix': import("eslint").Rule.RuleModule;
|
|
41
45
|
'ensure-test-runner-arguments': import("eslint").Rule.RuleModule;
|
|
42
46
|
'ensure-test-runner-nested-count': import("eslint").Rule.RuleModule;
|
|
43
47
|
'ensure-atlassian-team': import("eslint").Rule.RuleModule;
|
|
@@ -52,7 +56,6 @@ declare const plugin: {
|
|
|
52
56
|
'no-pre-post-install-scripts': import("eslint").Rule.RuleModule;
|
|
53
57
|
'no-invalid-storybook-decorator-usage': import("eslint").Rule.RuleModule;
|
|
54
58
|
'ensure-publish-valid': import("eslint").Rule.RuleModule;
|
|
55
|
-
'ensure-native-and-af-exports-synced': import("eslint").Rule.RuleModule;
|
|
56
59
|
'no-module-level-eval': import("eslint").Rule.RuleModule;
|
|
57
60
|
'no-module-level-eval-nav4': import("eslint").Rule.RuleModule;
|
|
58
61
|
'static-feature-flags': import("eslint").Rule.RuleModule;
|
|
@@ -62,9 +65,16 @@ declare const plugin: {
|
|
|
62
65
|
'no-alias': import("eslint").Rule.RuleModule;
|
|
63
66
|
'use-entrypoints-in-examples': import("eslint").Rule.RuleModule;
|
|
64
67
|
'use-recommended-utils': import("eslint").Rule.RuleModule;
|
|
68
|
+
'valid-gate-name': import("eslint").Rule.RuleModule;
|
|
65
69
|
'no-sparse-checkout': import("eslint").Rule.RuleModule;
|
|
66
70
|
'no-direct-document-usage': import("eslint").Rule.RuleModule;
|
|
67
71
|
'no-set-immediate': import("eslint").Rule.RuleModule;
|
|
72
|
+
'prefer-crypto-random-uuid': import("eslint").Rule.RuleModule;
|
|
73
|
+
'no-barrel-entry-imports': import("eslint").Rule.RuleModule;
|
|
74
|
+
'no-barrel-entry-jest-mock': import("eslint").Rule.RuleModule;
|
|
75
|
+
'no-jest-mock-barrel-files': import("eslint").Rule.RuleModule;
|
|
76
|
+
'no-relative-barrel-file-imports': import("eslint").Rule.RuleModule;
|
|
77
|
+
'no-conversation-assistant-barrel-imports': import("eslint").Rule.RuleModule;
|
|
68
78
|
};
|
|
69
79
|
configs: {
|
|
70
80
|
recommended: {
|
|
@@ -76,10 +86,8 @@ declare const plugin: {
|
|
|
76
86
|
'@atlaskit/platform/inline-usage': "error";
|
|
77
87
|
'@atlaskit/platform/prefer-fg': "error";
|
|
78
88
|
'@atlaskit/platform/no-alias': "error";
|
|
89
|
+
'@atlaskit/platform/valid-gate-name': "error";
|
|
79
90
|
'@atlaskit/platform/ensure-feature-flag-registration': "error";
|
|
80
|
-
'@atlaskit/platform/ensure-feature-flag-prefix': ["warn", {
|
|
81
|
-
allowedPrefixes: string[];
|
|
82
|
-
}];
|
|
83
91
|
'@atlaskit/platform/ensure-test-runner-arguments': "error";
|
|
84
92
|
'@atlaskit/platform/ensure-test-runner-nested-count': "warn";
|
|
85
93
|
'@atlaskit/platform/no-invalid-feature-flag-usage': "error";
|
|
@@ -110,10 +118,8 @@ declare const plugin: {
|
|
|
110
118
|
'@atlaskit/platform/inline-usage': "error";
|
|
111
119
|
'@atlaskit/platform/prefer-fg': "error";
|
|
112
120
|
'@atlaskit/platform/no-alias': "error";
|
|
121
|
+
'@atlaskit/platform/valid-gate-name': "error";
|
|
113
122
|
'@atlaskit/platform/ensure-feature-flag-registration': "error";
|
|
114
|
-
'@atlaskit/platform/ensure-feature-flag-prefix': ["warn", {
|
|
115
|
-
allowedPrefixes: string[];
|
|
116
|
-
}];
|
|
117
123
|
'@atlaskit/platform/ensure-test-runner-arguments': "error";
|
|
118
124
|
'@atlaskit/platform/ensure-test-runner-nested-count': "warn";
|
|
119
125
|
'@atlaskit/platform/no-invalid-feature-flag-usage': "error";
|
|
@@ -193,10 +199,8 @@ declare const configs: {
|
|
|
193
199
|
'@atlaskit/platform/inline-usage': "error";
|
|
194
200
|
'@atlaskit/platform/prefer-fg': "error";
|
|
195
201
|
'@atlaskit/platform/no-alias': "error";
|
|
202
|
+
'@atlaskit/platform/valid-gate-name': "error";
|
|
196
203
|
'@atlaskit/platform/ensure-feature-flag-registration': "error";
|
|
197
|
-
'@atlaskit/platform/ensure-feature-flag-prefix': ["warn", {
|
|
198
|
-
allowedPrefixes: string[];
|
|
199
|
-
}];
|
|
200
204
|
'@atlaskit/platform/ensure-test-runner-arguments': "error";
|
|
201
205
|
'@atlaskit/platform/ensure-test-runner-nested-count': "warn";
|
|
202
206
|
'@atlaskit/platform/no-invalid-feature-flag-usage': "error";
|
|
@@ -227,10 +231,8 @@ declare const configs: {
|
|
|
227
231
|
'@atlaskit/platform/inline-usage': "error";
|
|
228
232
|
'@atlaskit/platform/prefer-fg': "error";
|
|
229
233
|
'@atlaskit/platform/no-alias': "error";
|
|
234
|
+
'@atlaskit/platform/valid-gate-name': "error";
|
|
230
235
|
'@atlaskit/platform/ensure-feature-flag-registration': "error";
|
|
231
|
-
'@atlaskit/platform/ensure-feature-flag-prefix': ["warn", {
|
|
232
|
-
allowedPrefixes: string[];
|
|
233
|
-
}];
|
|
234
236
|
'@atlaskit/platform/ensure-test-runner-arguments': "error";
|
|
235
237
|
'@atlaskit/platform/ensure-test-runner-nested-count': "warn";
|
|
236
238
|
'@atlaskit/platform/no-invalid-feature-flag-usage': "error";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { type FileSystem } from '../shared/types';
|
|
3
|
+
/**
|
|
4
|
+
* Factory function to create the ESLint rule with a given file system.
|
|
5
|
+
* This enables testing with mock file systems.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createRule(fs: FileSystem): Rule.RuleModule;
|
|
8
|
+
declare const rule: Rule.RuleModule;
|
|
9
|
+
export default rule;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { type FileSystem } from '../shared/types';
|
|
3
|
+
/**
|
|
4
|
+
* Factory function to create the ESLint rule with a given file system.
|
|
5
|
+
* This enables testing with mock file systems.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createRule(fs: FileSystem): Rule.RuleModule;
|
|
8
|
+
declare const rule: Rule.RuleModule;
|
|
9
|
+
export default rule;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { type ExportInfo, type FileSystem } from '../shared/types';
|
|
3
|
+
/**
|
|
4
|
+
* Validate and resolve a barrel file from an import path
|
|
5
|
+
* Returns null if not a valid relative barrel import
|
|
6
|
+
*/
|
|
7
|
+
export declare function validateAndResolveBarrelFile({ importPath, basedir, workspaceRoot, fs, }: {
|
|
8
|
+
importPath: string;
|
|
9
|
+
basedir: string;
|
|
10
|
+
workspaceRoot: string;
|
|
11
|
+
fs: FileSystem;
|
|
12
|
+
}): {
|
|
13
|
+
resolvedPath: string;
|
|
14
|
+
exportMap: Map<string, ExportInfo>;
|
|
15
|
+
} | null;
|
|
16
|
+
/**
|
|
17
|
+
* Factory function to create the ESLint rule with a given file system.
|
|
18
|
+
* This enables testing with mock file systems.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createRule(fs: FileSystem): Rule.RuleModule;
|
|
21
|
+
declare const rule: Rule.RuleModule;
|
|
22
|
+
export default rule;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ExportInfo, FileSystem } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Get all named exports from a file.
|
|
4
|
+
* This extracts what names are exported from a file for star exports.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getNamedExportsFromFile({ filePath, fs, }: {
|
|
7
|
+
filePath: string;
|
|
8
|
+
fs: FileSystem;
|
|
9
|
+
}): Set<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Check if an export map represents a barrel file (has re-exports from other files)
|
|
12
|
+
*/
|
|
13
|
+
export declare function hasReExportsFromOtherFiles({ exportMap, sourceFilePath, }: {
|
|
14
|
+
exportMap: Map<string, ExportInfo>;
|
|
15
|
+
sourceFilePath: string;
|
|
16
|
+
}): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Parse export statements from a file to find where each export comes from.
|
|
19
|
+
* Returns a map of export name -> ExportInfo.
|
|
20
|
+
*
|
|
21
|
+
* This function recursively traces through nested barrels and cross-package re-exports
|
|
22
|
+
* to find the ultimate source file for each export.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseBarrelExports({ barrelFilePath, depth, fs, workspaceRoot, visitedPackages, }: {
|
|
25
|
+
barrelFilePath: string;
|
|
26
|
+
depth?: number;
|
|
27
|
+
fs: FileSystem;
|
|
28
|
+
workspaceRoot?: string;
|
|
29
|
+
visitedPackages?: Set<string>;
|
|
30
|
+
}): Map<string, ExportInfo>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { FileSystem } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* The default folder paths that barrel import rules apply to.
|
|
4
|
+
* Only imports from packages within these folders will be checked.
|
|
5
|
+
* This can be overridden via lint rule options.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_TARGET_FOLDERS: string[];
|
|
8
|
+
/**
|
|
9
|
+
* Try to read file contents with error handling.
|
|
10
|
+
* Returns null if file cannot be read.
|
|
11
|
+
*/
|
|
12
|
+
export declare function readFileContent({ filePath, fs, }: {
|
|
13
|
+
filePath: string;
|
|
14
|
+
fs: FileSystem;
|
|
15
|
+
}): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Check if a path is a relative import (starts with ./ or ../)
|
|
18
|
+
*/
|
|
19
|
+
export declare function isRelativeImport(importPath: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Resolve the actual file path from an import path.
|
|
22
|
+
* Handles extension inference and index file resolution.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveImportPath({ basedir, importPath, fs, }: {
|
|
25
|
+
basedir: string;
|
|
26
|
+
importPath: string;
|
|
27
|
+
fs: FileSystem;
|
|
28
|
+
}): string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Find the workspace root using git rev-parse --show-toplevel.
|
|
31
|
+
* The result is cached on fs.cache.gitRepoRoot to avoid repeated shell calls.
|
|
32
|
+
* Falls back to directory traversal if git command fails.
|
|
33
|
+
*/
|
|
34
|
+
export declare function findWorkspaceRoot({ startPath, fs, applyToImportsFrom, }: {
|
|
35
|
+
startPath: string;
|
|
36
|
+
fs: FileSystem;
|
|
37
|
+
applyToImportsFrom?: string[];
|
|
38
|
+
}): string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Shared utilities for jest.mock-related lint rules.
|
|
4
|
+
*
|
|
5
|
+
* These helpers are used by both `no-barrel-entry-jest-mock` (cross-package)
|
|
6
|
+
* and `no-jest-mock-barrel-files` (relative imports).
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Check if a CallExpression node is a jest.mock() call
|
|
10
|
+
*/
|
|
11
|
+
export declare function isJestMockCall(node: TSESTree.CallExpression): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Check if a node is a jest.requireActual() call
|
|
14
|
+
*/
|
|
15
|
+
export declare function isJestRequireActual(node: TSESTree.Node): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Check if a node is a jest.requireMock() call
|
|
18
|
+
*/
|
|
19
|
+
export declare function isJestRequireMock(node: TSESTree.Node): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Extract the import path string from a jest.mock/jest.requireMock/jest.requireActual call's arguments.
|
|
22
|
+
* Returns null if the path cannot be statically determined.
|
|
23
|
+
*/
|
|
24
|
+
export declare function extractImportPath(node: TSESTree.CallExpression): string | null;
|
|
25
|
+
/**
|
|
26
|
+
* Find all jest.requireMock() calls in the AST whose import path matches a given target.
|
|
27
|
+
*
|
|
28
|
+
* The `matchPath` callback allows callers to provide their own path-matching strategy:
|
|
29
|
+
* - Cross-package rules can use simple string equality
|
|
30
|
+
* - Relative import rules can use normalized/resolved path comparison
|
|
31
|
+
*/
|
|
32
|
+
export declare function findJestRequireMockCalls({ ast, matchPath, }: {
|
|
33
|
+
ast: TSESTree.Program;
|
|
34
|
+
matchPath: (candidatePath: string) => boolean;
|
|
35
|
+
}): TSESTree.CallExpression[];
|
|
36
|
+
/**
|
|
37
|
+
* Determine the best new import path for a jest.requireMock() call by inspecting
|
|
38
|
+
* the destructured symbols or property access at the call site.
|
|
39
|
+
*
|
|
40
|
+
* @param requireMockNode - The jest.requireMock() CallExpression node
|
|
41
|
+
* @param symbolToNewPath - Map from symbol name to the new mock path that provides it
|
|
42
|
+
* @returns The resolved new path, or null if it cannot be determined
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveNewPathForRequireMock({ requireMockNode, symbolToNewPath, }: {
|
|
45
|
+
requireMockNode: TSESTree.CallExpression;
|
|
46
|
+
symbolToNewPath: Map<string, string>;
|
|
47
|
+
}): string | null;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { FileSystem } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Find the package directory for a given package name.
|
|
4
|
+
* Returns the absolute path to the package directory or null if not found.
|
|
5
|
+
*
|
|
6
|
+
* This function uses lazy scanning - it will scan platform/packages on first lookup
|
|
7
|
+
* and cache results in fs.cache for subsequent lookups.
|
|
8
|
+
*
|
|
9
|
+
* Note: Package resolution is NOT constrained by applyToImportsFrom. Any package under
|
|
10
|
+
* platform/packages can be resolved. Use isPackageInApplyToImportsFrom to check if a
|
|
11
|
+
* package should be processed by the lint rule.
|
|
12
|
+
*/
|
|
13
|
+
export declare function findPackageInRegistry({ packageName, workspaceRoot, fs, }: {
|
|
14
|
+
packageName: string;
|
|
15
|
+
workspaceRoot: string;
|
|
16
|
+
fs: FileSystem;
|
|
17
|
+
}): string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a package is within one of the applyToImportsFrom folders.
|
|
20
|
+
* This can be used to quickly filter out packages that shouldn't be checked.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isPackageInApplyToImportsFrom({ packageDir, workspaceRoot, applyToImportsFrom, }: {
|
|
23
|
+
packageDir: string;
|
|
24
|
+
workspaceRoot: string;
|
|
25
|
+
applyToImportsFrom?: string[];
|
|
26
|
+
}): boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { FileSystem } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Parse the package.json exports field and return a map of export paths to resolved file paths.
|
|
4
|
+
*/
|
|
5
|
+
export declare function parsePackageExports({ packageDir, fs, }: {
|
|
6
|
+
packageDir: string;
|
|
7
|
+
fs: FileSystem;
|
|
8
|
+
}): Map<string, string>;
|
|
9
|
+
/**
|
|
10
|
+
* Find a matching export entry for a given source file path.
|
|
11
|
+
* Returns the export path (e.g., "./controllers/analytics") or null if not found.
|
|
12
|
+
*/
|
|
13
|
+
export declare function findExportForSourceFile({ sourceFilePath, exportsMap, }: {
|
|
14
|
+
sourceFilePath: string;
|
|
15
|
+
exportsMap: Map<string, string>;
|
|
16
|
+
}): string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Extract the package name and subpath from an import specifier.
|
|
19
|
+
* Returns null if the import is not a scoped package import.
|
|
20
|
+
*/
|
|
21
|
+
export declare function extractPackageNameFromImport(moduleSpecifier: string): {
|
|
22
|
+
packageName: string;
|
|
23
|
+
subPath: string;
|
|
24
|
+
} | null;
|
|
25
|
+
/**
|
|
26
|
+
* Resolve a cross-package import to its package directory and export info.
|
|
27
|
+
* Returns null if the package is not in the target folder or cannot be resolved.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveCrossPackageImport({ moduleSpecifier, workspaceRoot, fs, }: {
|
|
30
|
+
moduleSpecifier: string;
|
|
31
|
+
workspaceRoot: string;
|
|
32
|
+
fs: FileSystem;
|
|
33
|
+
}): {
|
|
34
|
+
packageName: string;
|
|
35
|
+
packageDir: string;
|
|
36
|
+
exportPath: string;
|
|
37
|
+
entryFilePath: string;
|
|
38
|
+
} | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FileSystem } from './types';
|
|
2
|
+
export declare const PERF_ENV_VAR = "INTERNAL_ESLINT_BARREL_PERF";
|
|
3
|
+
export declare function isPerfEnabled(): boolean;
|
|
4
|
+
export declare function perfInc({ fs, key, by }: {
|
|
5
|
+
fs: FileSystem;
|
|
6
|
+
key: string;
|
|
7
|
+
by?: number;
|
|
8
|
+
}): void;
|
|
9
|
+
export declare function perfTime<T>({ fs, key, fn }: {
|
|
10
|
+
fs: FileSystem;
|
|
11
|
+
key: string;
|
|
12
|
+
fn: () => T;
|
|
13
|
+
}): T;
|