@atlaskit/eslint-plugin-platform 2.5.0 → 2.7.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 +17 -0
- package/afm-cc/tsconfig.json +1 -1
- package/dist/cjs/index.js +43 -3
- package/dist/cjs/rules/ensure-native-and-af-exports-synced/index.js +3 -0
- package/dist/cjs/rules/ensure-valid-platform-yarn-protocol-usage/index.js +1 -1
- package/dist/cjs/rules/feature-gating/no-preconditioning/index.js +1 -1
- package/dist/cjs/rules/no-direct-document-usage/index.js +103 -0
- package/dist/cjs/rules/no-set-immediate/index.js +39 -0
- package/dist/cjs/rules/no-sparse-checkout/index.js +43 -0
- package/dist/cjs/rules/util/file-exclusions.js +45 -0
- package/dist/es2019/index.js +43 -3
- package/dist/es2019/rules/ensure-native-and-af-exports-synced/index.js +3 -0
- package/dist/es2019/rules/ensure-valid-platform-yarn-protocol-usage/index.js +1 -1
- package/dist/es2019/rules/feature-gating/no-preconditioning/index.js +1 -1
- package/dist/es2019/rules/no-direct-document-usage/index.js +95 -0
- package/dist/es2019/rules/no-set-immediate/index.js +33 -0
- package/dist/es2019/rules/no-sparse-checkout/index.js +35 -0
- package/dist/es2019/rules/util/file-exclusions.js +37 -0
- package/dist/esm/index.js +43 -3
- package/dist/esm/rules/ensure-native-and-af-exports-synced/index.js +3 -0
- package/dist/esm/rules/ensure-valid-platform-yarn-protocol-usage/index.js +1 -1
- package/dist/esm/rules/feature-gating/no-preconditioning/index.js +1 -1
- package/dist/esm/rules/no-direct-document-usage/index.js +97 -0
- package/dist/esm/rules/no-set-immediate/index.js +33 -0
- package/dist/esm/rules/no-sparse-checkout/index.js +37 -0
- package/dist/esm/rules/util/file-exclusions.js +39 -0
- package/dist/types/index.d.ts +22 -0
- package/dist/types/rules/no-direct-document-usage/index.d.ts +3 -0
- package/dist/types/rules/no-set-immediate/index.d.ts +3 -0
- package/dist/types/rules/no-sparse-checkout/index.d.ts +3 -0
- package/dist/types/rules/util/file-exclusions.d.ts +13 -0
- package/dist/types-ts4.5/index.d.ts +22 -0
- package/dist/types-ts4.5/rules/no-direct-document-usage/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/no-set-immediate/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/no-sparse-checkout/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/util/file-exclusions.d.ts +13 -0
- package/package.json +10 -1
- package/src/index.tsx +47 -2
- package/src/rules/ensure-native-and-af-exports-synced/index.tsx +3 -0
- package/src/rules/ensure-valid-bin-values/__tests__/unit/rule.test.ts +3 -2
- package/src/rules/ensure-valid-platform-yarn-protocol-usage/index.ts +1 -1
- package/src/rules/feature-gating/no-preconditioning/index.tsx +1 -1
- package/src/rules/no-direct-document-usage/index.tsx +111 -0
- package/src/rules/no-set-immediate/index.tsx +43 -0
- package/src/rules/no-sparse-checkout/__tests__/unit/rule.test.tsx +48 -0
- package/src/rules/no-sparse-checkout/index.tsx +54 -0
- package/src/rules/util/file-exclusions.ts +39 -0
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
const 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
|
+
const 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(context) {
|
|
16
|
+
const fileName = context.filename;
|
|
17
|
+
if (sparseCheckoutExceptions.some(exception => fileName.endsWith(exception))) {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
// Look for calls to afmClone or objects that match AFMCloneConfig type
|
|
22
|
+
'CallExpression[callee.object.name=alias][callee.property.name=afmClone] ObjectExpression Property': node => {
|
|
23
|
+
if (node.key.type === 'Identifier' && node.key.name === 'sparseCheckout') {
|
|
24
|
+
if (node.value.type === 'Literal' && node.value.value === true) {
|
|
25
|
+
context.report({
|
|
26
|
+
node,
|
|
27
|
+
messageId: 'noSparseCheckout'
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
export default rule;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common patterns for test files that should be excluded from rules
|
|
3
|
+
*/
|
|
4
|
+
const 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
|
+
const isTestFile = filename => {
|
|
12
|
+
return TEST_FILE_PATTERNS.some(pattern => filename.includes(pattern));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Helper function to skip rules for test files
|
|
17
|
+
* @param context The ESLint rule context
|
|
18
|
+
* @returns An empty RuleListener if the file is a test file, undefined otherwise
|
|
19
|
+
*/
|
|
20
|
+
export const skipForTestFiles = context => {
|
|
21
|
+
if (isTestFile(context.filename)) {
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Helper function to skip rules for example files
|
|
29
|
+
* @param context The ESLint rule context
|
|
30
|
+
* @returns An empty RuleListener if the file is an example file, undefined otherwise
|
|
31
|
+
*/
|
|
32
|
+
export const skipForExampleFiles = context => {
|
|
33
|
+
if (context.filename.includes('example')) {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -30,6 +30,27 @@ import useEntrypointsInExamples from './rules/use-entrypoints-in-examples';
|
|
|
30
30
|
import useRecommendedUtils from './rules/feature-gating/use-recommended-utils';
|
|
31
31
|
import expandBackgroundShorthand from './rules/compiled/expand-background-shorthand';
|
|
32
32
|
import expandSpacingShorthand from './rules/compiled/expand-spacing-shorthand';
|
|
33
|
+
import noSparseCheckout from './rules/no-sparse-checkout';
|
|
34
|
+
import noDirectDocumentUsage from './rules/no-direct-document-usage';
|
|
35
|
+
import noSetImmediate from './rules/no-set-immediate';
|
|
36
|
+
import { join, normalize } from 'node:path';
|
|
37
|
+
import { readFileSync } from 'node:fs';
|
|
38
|
+
var jiraRoot;
|
|
39
|
+
try {
|
|
40
|
+
var findUp = require('find-up');
|
|
41
|
+
findUp.sync(function (dir) {
|
|
42
|
+
var productsJsonPath = join(dir, 'products.json');
|
|
43
|
+
if (findUp.sync.exists(productsJsonPath)) {
|
|
44
|
+
var productJson = JSON.parse(readFileSync(productsJsonPath, 'utf-8'));
|
|
45
|
+
if (productJson.Jira) {
|
|
46
|
+
jiraRoot = normalize(join(dir, productJson.Jira.path));
|
|
47
|
+
return findUp.stop;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
} catch (_unused) {
|
|
52
|
+
// we aren't running inside of AFM, so we can ignore this.
|
|
53
|
+
}
|
|
33
54
|
var packageJson = require('@atlaskit/eslint-plugin-platform/package.json');
|
|
34
55
|
var rules = {
|
|
35
56
|
'ensure-feature-flag-registration': ensureFeatureFlagRegistration,
|
|
@@ -58,7 +79,10 @@ var rules = {
|
|
|
58
79
|
'prefer-fg': preferFG,
|
|
59
80
|
'no-alias': noAlias,
|
|
60
81
|
'use-entrypoints-in-examples': useEntrypointsInExamples,
|
|
61
|
-
'use-recommended-utils': useRecommendedUtils
|
|
82
|
+
'use-recommended-utils': useRecommendedUtils,
|
|
83
|
+
'no-sparse-checkout': noSparseCheckout,
|
|
84
|
+
'no-direct-document-usage': noDirectDocumentUsage,
|
|
85
|
+
'no-set-immediate': noSetImmediate
|
|
62
86
|
};
|
|
63
87
|
var commonConfig = {
|
|
64
88
|
'@atlaskit/platform/ensure-test-runner-arguments': 'error',
|
|
@@ -67,6 +91,8 @@ var commonConfig = {
|
|
|
67
91
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': 'error',
|
|
68
92
|
'@atlaskit/platform/ensure-atlassian-team': 'error',
|
|
69
93
|
'@atlaskit/platform/no-module-level-eval-nav4': 'error',
|
|
94
|
+
'@atlaskit/platform/no-direct-document-usage': 'warn',
|
|
95
|
+
'@atlaskit/platform/no-set-immediate': 'error',
|
|
70
96
|
// Compiled: rules that are not included via `@compiled/recommended
|
|
71
97
|
'@atlaskit/platform/expand-border-shorthand': 'error',
|
|
72
98
|
'@atlaskit/platform/expand-background-shorthand': 'error',
|
|
@@ -95,6 +121,7 @@ var recommendedRules = _objectSpread(_objectSpread({}, commonConfig), {}, {
|
|
|
95
121
|
var jiraRules = commonConfig;
|
|
96
122
|
var jsonPrefix = '/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, @typescript-eslint/semi, no-template-curly-in-string */ module.exports = ';
|
|
97
123
|
var jsonPrefixForFlatConfig = '/* eslint-disable quote-props, comma-dangle, quotes, semi, eol-last, no-template-curly-in-string */ module.exports = ';
|
|
124
|
+
var jsonPrefixForJira = 'module.exports = ';
|
|
98
125
|
var name = packageJson.name,
|
|
99
126
|
version = packageJson.version;
|
|
100
127
|
var plugin = {
|
|
@@ -141,7 +168,14 @@ var plugin = {
|
|
|
141
168
|
},
|
|
142
169
|
processors: {
|
|
143
170
|
'package-json-processor': {
|
|
144
|
-
preprocess: function preprocess(source) {
|
|
171
|
+
preprocess: function preprocess(source, filename) {
|
|
172
|
+
// we only need to check for jiraRoot because it uses a different
|
|
173
|
+
// ESLint version and produces fake errors due to how this processor handles JSON
|
|
174
|
+
if (jiraRoot && filename.startsWith(jiraRoot)) {
|
|
175
|
+
// augment the json into a js file
|
|
176
|
+
return [jsonPrefixForJira + source.trim()];
|
|
177
|
+
}
|
|
178
|
+
|
|
145
179
|
// augment the json into a js file
|
|
146
180
|
return [jsonPrefix + source.trim()];
|
|
147
181
|
},
|
|
@@ -164,7 +198,13 @@ var plugin = {
|
|
|
164
198
|
// This processor is used for ESLint FlatConfig,
|
|
165
199
|
// once we roll out FlatConfig, we can remove the above processor
|
|
166
200
|
'package-json-processor-for-flat-config': {
|
|
167
|
-
|
|
201
|
+
// we only need to check for jiraRoot because it uses a different
|
|
202
|
+
// ESLint version and produces fake errors due to how this processor handles JSON
|
|
203
|
+
preprocess: function preprocess(source, filename) {
|
|
204
|
+
if (jiraRoot && filename.startsWith(jiraRoot)) {
|
|
205
|
+
// augment the json into a js file
|
|
206
|
+
return [jsonPrefixForJira + source.trim()];
|
|
207
|
+
}
|
|
168
208
|
// augment the json into a js file
|
|
169
209
|
return [jsonPrefixForFlatConfig + source.trim()];
|
|
170
210
|
},
|
|
@@ -6,6 +6,9 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { getMetadataForFilename } from '../util/registration-utils';
|
|
8
8
|
var exportsValidationExceptions = {
|
|
9
|
+
'@af/yarn-workspace': {
|
|
10
|
+
ignoredAfExportKeys: ['./lock-parser']
|
|
11
|
+
},
|
|
9
12
|
'@atlaskit/tokens': {
|
|
10
13
|
ignoredAfExportKeys: ['./babel-plugin']
|
|
11
14
|
},
|
|
@@ -49,7 +49,7 @@ var rule = {
|
|
|
49
49
|
},
|
|
50
50
|
hasSuggestions: false,
|
|
51
51
|
messages: {
|
|
52
|
-
invalidWorkspaceProtocolUsage: "The 'workspace:^'
|
|
52
|
+
invalidWorkspaceProtocolUsage: "The 'workspace:^'protocol is Used. To resolve this error, please use the 'workspace:*' protocol instead.",
|
|
53
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
54
|
}
|
|
55
55
|
},
|
|
@@ -49,7 +49,7 @@ var rule = {
|
|
|
49
49
|
url: 'https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/browse/platform/packages/platform/eslint-plugin/src/rules/no-preconditioning/README.md'
|
|
50
50
|
},
|
|
51
51
|
messages: {
|
|
52
|
-
useConfig: 'Do not precondition gates or experiments with another gate. Configure this in Statsig instead to reduce unnecessary code and
|
|
52
|
+
useConfig: 'Do not precondition gates or experiments with another gate. Configure this in Statsig instead to reduce unnecessary code, simplify cleanup and to ensure accurate exposures in Statsig.',
|
|
53
53
|
incorrectExposure: 'Evaluate gates or experiments at the end of your logical expression to ensure exposure is tracked correctly.'
|
|
54
54
|
}
|
|
55
55
|
},
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { skipForExampleFiles, skipForTestFiles } from '../util/file-exclusions';
|
|
2
|
+
var rule = {
|
|
3
|
+
meta: {
|
|
4
|
+
type: 'problem',
|
|
5
|
+
docs: {
|
|
6
|
+
description: 'Enforce using getDocument from @atlaskit/browser-apis instead of direct document usage',
|
|
7
|
+
recommended: true
|
|
8
|
+
},
|
|
9
|
+
messages: {
|
|
10
|
+
useGetDocument: 'Use getDocument from @atlaskit/browser-apis instead of direct document usage'
|
|
11
|
+
},
|
|
12
|
+
schema: []
|
|
13
|
+
},
|
|
14
|
+
create: function create(context) {
|
|
15
|
+
var hasGetDocumentImport = false;
|
|
16
|
+
var filename = context.filename;
|
|
17
|
+
|
|
18
|
+
// Skip test files
|
|
19
|
+
var skipResult = skipForTestFiles(context);
|
|
20
|
+
if (skipResult) {
|
|
21
|
+
return skipResult;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Skip example files
|
|
25
|
+
var skipResult2 = skipForExampleFiles(context);
|
|
26
|
+
if (skipResult2) {
|
|
27
|
+
return skipResult2;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Skip the getDocument.ts file itself
|
|
31
|
+
if (filename.endsWith('getDocument.ts')) {
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
ImportDeclaration: function ImportDeclaration(node) {
|
|
36
|
+
if (node.source.value === '@atlaskit/browser-apis' && node.specifiers.some(function (specifier) {
|
|
37
|
+
return specifier.type === 'ImportSpecifier' && specifier.imported.type === 'Identifier' && specifier.imported.name === 'getDocument';
|
|
38
|
+
})) {
|
|
39
|
+
hasGetDocumentImport = true;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
Identifier: function Identifier(node) {
|
|
43
|
+
if (node.name === 'document' && !hasGetDocumentImport) {
|
|
44
|
+
var parent = node.parent;
|
|
45
|
+
|
|
46
|
+
// Skip if 'document' is used as a property key in an object literal
|
|
47
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'Property' && parent.key === node) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Skip if 'document' is used as a shorthand property value
|
|
52
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'Property' && parent.value === node && parent.shorthand) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Skip if 'document' is used as a property being accessed in a member expression
|
|
57
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'MemberExpression' && parent.property === node && !parent.computed) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Skip if 'document' is being declared as a variable
|
|
62
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'VariableDeclarator' && parent.id === node) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Skip if 'document' is a function name
|
|
67
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'FunctionDeclaration' && 'id' in parent && parent.id === node) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'FunctionExpression' && 'id' in parent && parent.id === node) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Skip if 'document' is a method name in a class or object
|
|
75
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'MethodDefinition' && parent.key === node) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Skip if 'document' is being assigned to (shadowing the global)
|
|
80
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'AssignmentExpression' && parent.left === node) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Skip if 'document' is in a destructuring pattern (could be destructuring from an object)
|
|
85
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.type) === 'ObjectPattern' || (parent === null || parent === void 0 ? void 0 : parent.type) === 'ArrayPattern') {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
context.report({
|
|
89
|
+
node: node,
|
|
90
|
+
messageId: 'useGetDocument'
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
export default rule;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var rule = {
|
|
2
|
+
meta: {
|
|
3
|
+
docs: {
|
|
4
|
+
description: "Prevent usage of setImmediate in favor of React Testing Library's `waitFor` or similar",
|
|
5
|
+
recommended: true
|
|
6
|
+
},
|
|
7
|
+
type: 'problem',
|
|
8
|
+
messages: {
|
|
9
|
+
noSetImmediate: "Avoid using setImmediate. Use React Testing Library's waitFor or similar instead for better test reliability.",
|
|
10
|
+
suggestWaitFor: 'Replace with waitFor from @testing-library/react or similar'
|
|
11
|
+
},
|
|
12
|
+
hasSuggestions: true
|
|
13
|
+
},
|
|
14
|
+
create: function create(context) {
|
|
15
|
+
return {
|
|
16
|
+
CallExpression: function CallExpression(node) {
|
|
17
|
+
if (node.callee.type === 'Identifier' && node.callee.name === 'setImmediate') {
|
|
18
|
+
context.report({
|
|
19
|
+
node: node,
|
|
20
|
+
messageId: 'noSetImmediate',
|
|
21
|
+
suggest: [{
|
|
22
|
+
messageId: 'suggestWaitFor',
|
|
23
|
+
fix: function fix(fixer) {
|
|
24
|
+
return fixer.replaceText(node, 'await waitFor(() => { /* your assertion here */ })');
|
|
25
|
+
}
|
|
26
|
+
}]
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export default rule;
|
|
@@ -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
|
+
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -27,6 +27,9 @@ declare const rules: {
|
|
|
27
27
|
'no-alias': import("eslint").Rule.RuleModule;
|
|
28
28
|
'use-entrypoints-in-examples': import("eslint").Rule.RuleModule;
|
|
29
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;
|
|
32
|
+
'no-set-immediate': import("eslint").Rule.RuleModule;
|
|
30
33
|
};
|
|
31
34
|
declare const plugin: {
|
|
32
35
|
meta: {
|
|
@@ -61,6 +64,9 @@ declare const plugin: {
|
|
|
61
64
|
'no-alias': import("eslint").Rule.RuleModule;
|
|
62
65
|
'use-entrypoints-in-examples': import("eslint").Rule.RuleModule;
|
|
63
66
|
'use-recommended-utils': import("eslint").Rule.RuleModule;
|
|
67
|
+
'no-sparse-checkout': import("eslint").Rule.RuleModule;
|
|
68
|
+
'no-direct-document-usage': import("eslint").Rule.RuleModule;
|
|
69
|
+
'no-set-immediate': import("eslint").Rule.RuleModule;
|
|
64
70
|
};
|
|
65
71
|
configs: {
|
|
66
72
|
recommended: {
|
|
@@ -82,6 +88,8 @@ declare const plugin: {
|
|
|
82
88
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
83
89
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
84
90
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
91
|
+
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
92
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
85
93
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
86
94
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
87
95
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -114,6 +122,8 @@ declare const plugin: {
|
|
|
114
122
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
115
123
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
116
124
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
125
|
+
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
126
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
117
127
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
118
128
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
119
129
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -133,6 +143,8 @@ declare const plugin: {
|
|
|
133
143
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
134
144
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
135
145
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
146
|
+
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
147
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
136
148
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
137
149
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
138
150
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -155,6 +167,8 @@ declare const plugin: {
|
|
|
155
167
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
156
168
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
157
169
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
170
|
+
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
171
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
158
172
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
159
173
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
160
174
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -191,6 +205,8 @@ declare const configs: {
|
|
|
191
205
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
192
206
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
193
207
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
208
|
+
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
209
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
194
210
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
195
211
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
196
212
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -223,6 +239,8 @@ declare const configs: {
|
|
|
223
239
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
224
240
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
225
241
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
242
|
+
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
243
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
226
244
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
227
245
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
228
246
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -242,6 +260,8 @@ declare const configs: {
|
|
|
242
260
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
243
261
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
244
262
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
263
|
+
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
264
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
245
265
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
246
266
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
247
267
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -264,6 +284,8 @@ declare const configs: {
|
|
|
264
284
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
265
285
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
266
286
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
287
|
+
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
288
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
267
289
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
268
290
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
269
291
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -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;
|
|
@@ -27,6 +27,9 @@ declare const rules: {
|
|
|
27
27
|
'no-alias': import("eslint").Rule.RuleModule;
|
|
28
28
|
'use-entrypoints-in-examples': import("eslint").Rule.RuleModule;
|
|
29
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;
|
|
32
|
+
'no-set-immediate': import("eslint").Rule.RuleModule;
|
|
30
33
|
};
|
|
31
34
|
declare const plugin: {
|
|
32
35
|
meta: {
|
|
@@ -61,6 +64,9 @@ declare const plugin: {
|
|
|
61
64
|
'no-alias': import("eslint").Rule.RuleModule;
|
|
62
65
|
'use-entrypoints-in-examples': import("eslint").Rule.RuleModule;
|
|
63
66
|
'use-recommended-utils': import("eslint").Rule.RuleModule;
|
|
67
|
+
'no-sparse-checkout': import("eslint").Rule.RuleModule;
|
|
68
|
+
'no-direct-document-usage': import("eslint").Rule.RuleModule;
|
|
69
|
+
'no-set-immediate': import("eslint").Rule.RuleModule;
|
|
64
70
|
};
|
|
65
71
|
configs: {
|
|
66
72
|
recommended: {
|
|
@@ -85,6 +91,8 @@ declare const plugin: {
|
|
|
85
91
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
86
92
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
87
93
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
94
|
+
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
95
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
88
96
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
89
97
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
90
98
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -123,6 +131,8 @@ declare const plugin: {
|
|
|
123
131
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
124
132
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
125
133
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
134
|
+
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
135
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
126
136
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
127
137
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
128
138
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -145,6 +155,8 @@ declare const plugin: {
|
|
|
145
155
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
146
156
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
147
157
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
158
|
+
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
159
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
148
160
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
149
161
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
150
162
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -170,6 +182,8 @@ declare const plugin: {
|
|
|
170
182
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
171
183
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
172
184
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
185
|
+
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
186
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
173
187
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
174
188
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
175
189
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -212,6 +226,8 @@ declare const configs: {
|
|
|
212
226
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
213
227
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
214
228
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
229
|
+
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
230
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
215
231
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
216
232
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
217
233
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -250,6 +266,8 @@ declare const configs: {
|
|
|
250
266
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
251
267
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
252
268
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
269
|
+
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
270
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
253
271
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
254
272
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
255
273
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -272,6 +290,8 @@ declare const configs: {
|
|
|
272
290
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
273
291
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
274
292
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
293
|
+
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
294
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
275
295
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
276
296
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
277
297
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -297,6 +317,8 @@ declare const configs: {
|
|
|
297
317
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
298
318
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
299
319
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
320
|
+
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
321
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
300
322
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
301
323
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
302
324
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -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;
|