@atlaskit/eslint-plugin-platform 2.6.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 +8 -0
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/rules/no-direct-document-usage/index.js +1 -1
- package/dist/cjs/rules/no-set-immediate/index.js +39 -0
- package/dist/es2019/index.js +4 -1
- package/dist/es2019/rules/no-direct-document-usage/index.js +1 -1
- package/dist/es2019/rules/no-set-immediate/index.js +33 -0
- package/dist/esm/index.js +4 -1
- package/dist/esm/rules/no-direct-document-usage/index.js +1 -1
- package/dist/esm/rules/no-set-immediate/index.js +33 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/rules/no-set-immediate/index.d.ts +3 -0
- package/dist/types-ts4.5/index.d.ts +10 -0
- package/dist/types-ts4.5/rules/no-set-immediate/index.d.ts +3 -0
- package/package.json +1 -1
- package/src/index.tsx +3 -0
- package/src/rules/no-direct-document-usage/index.tsx +3 -1
- package/src/rules/no-set-immediate/index.tsx +43 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-platform
|
|
2
2
|
|
|
3
|
+
## 2.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#157255](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/157255)
|
|
8
|
+
[`334db48ef3650`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/334db48ef3650) -
|
|
9
|
+
Linting rule to forbid use of non standard setImediate
|
|
10
|
+
|
|
3
11
|
## 2.6.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -36,6 +36,7 @@ var _expandBackgroundShorthand = _interopRequireDefault(require("./rules/compile
|
|
|
36
36
|
var _expandSpacingShorthand = _interopRequireDefault(require("./rules/compiled/expand-spacing-shorthand"));
|
|
37
37
|
var _noSparseCheckout = _interopRequireDefault(require("./rules/no-sparse-checkout"));
|
|
38
38
|
var _noDirectDocumentUsage = _interopRequireDefault(require("./rules/no-direct-document-usage"));
|
|
39
|
+
var _noSetImmediate = _interopRequireDefault(require("./rules/no-set-immediate"));
|
|
39
40
|
var _nodePath = require("node:path");
|
|
40
41
|
var _nodeFs = require("node:fs");
|
|
41
42
|
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; }
|
|
@@ -86,7 +87,8 @@ var rules = exports.rules = {
|
|
|
86
87
|
'use-entrypoints-in-examples': _useEntrypointsInExamples.default,
|
|
87
88
|
'use-recommended-utils': _useRecommendedUtils.default,
|
|
88
89
|
'no-sparse-checkout': _noSparseCheckout.default,
|
|
89
|
-
'no-direct-document-usage': _noDirectDocumentUsage.default
|
|
90
|
+
'no-direct-document-usage': _noDirectDocumentUsage.default,
|
|
91
|
+
'no-set-immediate': _noSetImmediate.default
|
|
90
92
|
};
|
|
91
93
|
var commonConfig = {
|
|
92
94
|
'@atlaskit/platform/ensure-test-runner-arguments': 'error',
|
|
@@ -96,6 +98,7 @@ var commonConfig = {
|
|
|
96
98
|
'@atlaskit/platform/ensure-atlassian-team': 'error',
|
|
97
99
|
'@atlaskit/platform/no-module-level-eval-nav4': 'error',
|
|
98
100
|
'@atlaskit/platform/no-direct-document-usage': 'warn',
|
|
101
|
+
'@atlaskit/platform/no-set-immediate': 'error',
|
|
99
102
|
// Compiled: rules that are not included via `@compiled/recommended
|
|
100
103
|
'@atlaskit/platform/expand-border-shorthand': 'error',
|
|
101
104
|
'@atlaskit/platform/expand-background-shorthand': 'error',
|
|
@@ -40,7 +40,7 @@ var rule = {
|
|
|
40
40
|
return {
|
|
41
41
|
ImportDeclaration: function ImportDeclaration(node) {
|
|
42
42
|
if (node.source.value === '@atlaskit/browser-apis' && node.specifiers.some(function (specifier) {
|
|
43
|
-
return specifier.type === 'ImportSpecifier' && specifier.imported.name === 'getDocument';
|
|
43
|
+
return specifier.type === 'ImportSpecifier' && specifier.imported.type === 'Identifier' && specifier.imported.name === 'getDocument';
|
|
44
44
|
})) {
|
|
45
45
|
hasGetDocumentImport = true;
|
|
46
46
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var rule = {
|
|
8
|
+
meta: {
|
|
9
|
+
docs: {
|
|
10
|
+
description: "Prevent usage of setImmediate in favor of React Testing Library's `waitFor` or similar",
|
|
11
|
+
recommended: true
|
|
12
|
+
},
|
|
13
|
+
type: 'problem',
|
|
14
|
+
messages: {
|
|
15
|
+
noSetImmediate: "Avoid using setImmediate. Use React Testing Library's waitFor or similar instead for better test reliability.",
|
|
16
|
+
suggestWaitFor: 'Replace with waitFor from @testing-library/react or similar'
|
|
17
|
+
},
|
|
18
|
+
hasSuggestions: true
|
|
19
|
+
},
|
|
20
|
+
create: function create(context) {
|
|
21
|
+
return {
|
|
22
|
+
CallExpression: function CallExpression(node) {
|
|
23
|
+
if (node.callee.type === 'Identifier' && node.callee.name === 'setImmediate') {
|
|
24
|
+
context.report({
|
|
25
|
+
node: node,
|
|
26
|
+
messageId: 'noSetImmediate',
|
|
27
|
+
suggest: [{
|
|
28
|
+
messageId: 'suggestWaitFor',
|
|
29
|
+
fix: function fix(fixer) {
|
|
30
|
+
return fixer.replaceText(node, 'await waitFor(() => { /* your assertion here */ })');
|
|
31
|
+
}
|
|
32
|
+
}]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var _default = exports.default = rule;
|
package/dist/es2019/index.js
CHANGED
|
@@ -29,6 +29,7 @@ import expandBackgroundShorthand from './rules/compiled/expand-background-shorth
|
|
|
29
29
|
import expandSpacingShorthand from './rules/compiled/expand-spacing-shorthand';
|
|
30
30
|
import noSparseCheckout from './rules/no-sparse-checkout';
|
|
31
31
|
import noDirectDocumentUsage from './rules/no-direct-document-usage';
|
|
32
|
+
import noSetImmediate from './rules/no-set-immediate';
|
|
32
33
|
import { join, normalize } from 'node:path';
|
|
33
34
|
import { readFileSync } from 'node:fs';
|
|
34
35
|
let jiraRoot;
|
|
@@ -77,7 +78,8 @@ const rules = {
|
|
|
77
78
|
'use-entrypoints-in-examples': useEntrypointsInExamples,
|
|
78
79
|
'use-recommended-utils': useRecommendedUtils,
|
|
79
80
|
'no-sparse-checkout': noSparseCheckout,
|
|
80
|
-
'no-direct-document-usage': noDirectDocumentUsage
|
|
81
|
+
'no-direct-document-usage': noDirectDocumentUsage,
|
|
82
|
+
'no-set-immediate': noSetImmediate
|
|
81
83
|
};
|
|
82
84
|
const commonConfig = {
|
|
83
85
|
'@atlaskit/platform/ensure-test-runner-arguments': 'error',
|
|
@@ -87,6 +89,7 @@ const commonConfig = {
|
|
|
87
89
|
'@atlaskit/platform/ensure-atlassian-team': 'error',
|
|
88
90
|
'@atlaskit/platform/no-module-level-eval-nav4': 'error',
|
|
89
91
|
'@atlaskit/platform/no-direct-document-usage': 'warn',
|
|
92
|
+
'@atlaskit/platform/no-set-immediate': 'error',
|
|
90
93
|
// Compiled: rules that are not included via `@compiled/recommended
|
|
91
94
|
'@atlaskit/platform/expand-border-shorthand': 'error',
|
|
92
95
|
'@atlaskit/platform/expand-background-shorthand': 'error',
|
|
@@ -33,7 +33,7 @@ const rule = {
|
|
|
33
33
|
}
|
|
34
34
|
return {
|
|
35
35
|
ImportDeclaration(node) {
|
|
36
|
-
if (node.source.value === '@atlaskit/browser-apis' && node.specifiers.some(specifier => specifier.type === 'ImportSpecifier' && specifier.imported.name === 'getDocument')) {
|
|
36
|
+
if (node.source.value === '@atlaskit/browser-apis' && node.specifiers.some(specifier => specifier.type === 'ImportSpecifier' && specifier.imported.type === 'Identifier' && specifier.imported.name === 'getDocument')) {
|
|
37
37
|
hasGetDocumentImport = true;
|
|
38
38
|
}
|
|
39
39
|
},
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const 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(context) {
|
|
15
|
+
return {
|
|
16
|
+
CallExpression(node) {
|
|
17
|
+
if (node.callee.type === 'Identifier' && node.callee.name === 'setImmediate') {
|
|
18
|
+
context.report({
|
|
19
|
+
node,
|
|
20
|
+
messageId: 'noSetImmediate',
|
|
21
|
+
suggest: [{
|
|
22
|
+
messageId: 'suggestWaitFor',
|
|
23
|
+
fix(fixer) {
|
|
24
|
+
return fixer.replaceText(node, 'await waitFor(() => { /* your assertion here */ })');
|
|
25
|
+
}
|
|
26
|
+
}]
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export default rule;
|
package/dist/esm/index.js
CHANGED
|
@@ -32,6 +32,7 @@ import expandBackgroundShorthand from './rules/compiled/expand-background-shorth
|
|
|
32
32
|
import expandSpacingShorthand from './rules/compiled/expand-spacing-shorthand';
|
|
33
33
|
import noSparseCheckout from './rules/no-sparse-checkout';
|
|
34
34
|
import noDirectDocumentUsage from './rules/no-direct-document-usage';
|
|
35
|
+
import noSetImmediate from './rules/no-set-immediate';
|
|
35
36
|
import { join, normalize } from 'node:path';
|
|
36
37
|
import { readFileSync } from 'node:fs';
|
|
37
38
|
var jiraRoot;
|
|
@@ -80,7 +81,8 @@ var rules = {
|
|
|
80
81
|
'use-entrypoints-in-examples': useEntrypointsInExamples,
|
|
81
82
|
'use-recommended-utils': useRecommendedUtils,
|
|
82
83
|
'no-sparse-checkout': noSparseCheckout,
|
|
83
|
-
'no-direct-document-usage': noDirectDocumentUsage
|
|
84
|
+
'no-direct-document-usage': noDirectDocumentUsage,
|
|
85
|
+
'no-set-immediate': noSetImmediate
|
|
84
86
|
};
|
|
85
87
|
var commonConfig = {
|
|
86
88
|
'@atlaskit/platform/ensure-test-runner-arguments': 'error',
|
|
@@ -90,6 +92,7 @@ var commonConfig = {
|
|
|
90
92
|
'@atlaskit/platform/ensure-atlassian-team': 'error',
|
|
91
93
|
'@atlaskit/platform/no-module-level-eval-nav4': 'error',
|
|
92
94
|
'@atlaskit/platform/no-direct-document-usage': 'warn',
|
|
95
|
+
'@atlaskit/platform/no-set-immediate': 'error',
|
|
93
96
|
// Compiled: rules that are not included via `@compiled/recommended
|
|
94
97
|
'@atlaskit/platform/expand-border-shorthand': 'error',
|
|
95
98
|
'@atlaskit/platform/expand-background-shorthand': 'error',
|
|
@@ -34,7 +34,7 @@ var rule = {
|
|
|
34
34
|
return {
|
|
35
35
|
ImportDeclaration: function ImportDeclaration(node) {
|
|
36
36
|
if (node.source.value === '@atlaskit/browser-apis' && node.specifiers.some(function (specifier) {
|
|
37
|
-
return specifier.type === 'ImportSpecifier' && specifier.imported.name === 'getDocument';
|
|
37
|
+
return specifier.type === 'ImportSpecifier' && specifier.imported.type === 'Identifier' && specifier.imported.name === 'getDocument';
|
|
38
38
|
})) {
|
|
39
39
|
hasGetDocumentImport = true;
|
|
40
40
|
}
|
|
@@ -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;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ declare const rules: {
|
|
|
29
29
|
'use-recommended-utils': import("eslint").Rule.RuleModule;
|
|
30
30
|
'no-sparse-checkout': import("eslint").Rule.RuleModule;
|
|
31
31
|
'no-direct-document-usage': import("eslint").Rule.RuleModule;
|
|
32
|
+
'no-set-immediate': import("eslint").Rule.RuleModule;
|
|
32
33
|
};
|
|
33
34
|
declare const plugin: {
|
|
34
35
|
meta: {
|
|
@@ -65,6 +66,7 @@ declare const plugin: {
|
|
|
65
66
|
'use-recommended-utils': import("eslint").Rule.RuleModule;
|
|
66
67
|
'no-sparse-checkout': import("eslint").Rule.RuleModule;
|
|
67
68
|
'no-direct-document-usage': import("eslint").Rule.RuleModule;
|
|
69
|
+
'no-set-immediate': import("eslint").Rule.RuleModule;
|
|
68
70
|
};
|
|
69
71
|
configs: {
|
|
70
72
|
recommended: {
|
|
@@ -87,6 +89,7 @@ declare const plugin: {
|
|
|
87
89
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
88
90
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
89
91
|
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
92
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
90
93
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
91
94
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
92
95
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -120,6 +123,7 @@ declare const plugin: {
|
|
|
120
123
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
121
124
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
122
125
|
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
126
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
123
127
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
124
128
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
125
129
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -140,6 +144,7 @@ declare const plugin: {
|
|
|
140
144
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
141
145
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
142
146
|
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
147
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
143
148
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
144
149
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
145
150
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -163,6 +168,7 @@ declare const plugin: {
|
|
|
163
168
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
164
169
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
165
170
|
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
171
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
166
172
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
167
173
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
168
174
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -200,6 +206,7 @@ declare const configs: {
|
|
|
200
206
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
201
207
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
202
208
|
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
209
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
203
210
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
204
211
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
205
212
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -233,6 +240,7 @@ declare const configs: {
|
|
|
233
240
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
234
241
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
235
242
|
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
243
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
236
244
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
237
245
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
238
246
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -253,6 +261,7 @@ declare const configs: {
|
|
|
253
261
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
254
262
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
255
263
|
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
264
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
256
265
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
257
266
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
258
267
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -276,6 +285,7 @@ declare const configs: {
|
|
|
276
285
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
277
286
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
278
287
|
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
288
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
279
289
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
280
290
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
281
291
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -29,6 +29,7 @@ declare const rules: {
|
|
|
29
29
|
'use-recommended-utils': import("eslint").Rule.RuleModule;
|
|
30
30
|
'no-sparse-checkout': import("eslint").Rule.RuleModule;
|
|
31
31
|
'no-direct-document-usage': import("eslint").Rule.RuleModule;
|
|
32
|
+
'no-set-immediate': import("eslint").Rule.RuleModule;
|
|
32
33
|
};
|
|
33
34
|
declare const plugin: {
|
|
34
35
|
meta: {
|
|
@@ -65,6 +66,7 @@ declare const plugin: {
|
|
|
65
66
|
'use-recommended-utils': import("eslint").Rule.RuleModule;
|
|
66
67
|
'no-sparse-checkout': import("eslint").Rule.RuleModule;
|
|
67
68
|
'no-direct-document-usage': import("eslint").Rule.RuleModule;
|
|
69
|
+
'no-set-immediate': import("eslint").Rule.RuleModule;
|
|
68
70
|
};
|
|
69
71
|
configs: {
|
|
70
72
|
recommended: {
|
|
@@ -90,6 +92,7 @@ declare const plugin: {
|
|
|
90
92
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
91
93
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
92
94
|
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
95
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
93
96
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
94
97
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
95
98
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -129,6 +132,7 @@ declare const plugin: {
|
|
|
129
132
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
130
133
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
131
134
|
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
135
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
132
136
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
133
137
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
134
138
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -152,6 +156,7 @@ declare const plugin: {
|
|
|
152
156
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
153
157
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
154
158
|
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
159
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
155
160
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
156
161
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
157
162
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -178,6 +183,7 @@ declare const plugin: {
|
|
|
178
183
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
179
184
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
180
185
|
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
186
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
181
187
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
182
188
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
183
189
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -221,6 +227,7 @@ declare const configs: {
|
|
|
221
227
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
222
228
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
223
229
|
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
230
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
224
231
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
225
232
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
226
233
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -260,6 +267,7 @@ declare const configs: {
|
|
|
260
267
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
261
268
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
262
269
|
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
270
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
263
271
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
264
272
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
265
273
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -283,6 +291,7 @@ declare const configs: {
|
|
|
283
291
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
284
292
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
285
293
|
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
294
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
286
295
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
287
296
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
288
297
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
|
@@ -309,6 +318,7 @@ declare const configs: {
|
|
|
309
318
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
310
319
|
'@atlaskit/platform/no-module-level-eval-nav4': "error";
|
|
311
320
|
'@atlaskit/platform/no-direct-document-usage': "warn";
|
|
321
|
+
'@atlaskit/platform/no-set-immediate': "error";
|
|
312
322
|
'@atlaskit/platform/expand-border-shorthand': "error";
|
|
313
323
|
'@atlaskit/platform/expand-background-shorthand': "error";
|
|
314
324
|
'@atlaskit/platform/expand-spacing-shorthand': "error";
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -30,6 +30,7 @@ import expandBackgroundShorthand from './rules/compiled/expand-background-shorth
|
|
|
30
30
|
import expandSpacingShorthand from './rules/compiled/expand-spacing-shorthand';
|
|
31
31
|
import noSparseCheckout from './rules/no-sparse-checkout';
|
|
32
32
|
import noDirectDocumentUsage from './rules/no-direct-document-usage';
|
|
33
|
+
import noSetImmediate from './rules/no-set-immediate';
|
|
33
34
|
import { join, normalize } from 'node:path';
|
|
34
35
|
import { readFileSync } from 'node:fs';
|
|
35
36
|
|
|
@@ -89,6 +90,7 @@ const rules = {
|
|
|
89
90
|
'use-recommended-utils': useRecommendedUtils,
|
|
90
91
|
'no-sparse-checkout': noSparseCheckout,
|
|
91
92
|
'no-direct-document-usage': noDirectDocumentUsage,
|
|
93
|
+
'no-set-immediate': noSetImmediate,
|
|
92
94
|
};
|
|
93
95
|
|
|
94
96
|
const commonConfig = {
|
|
@@ -99,6 +101,7 @@ const commonConfig = {
|
|
|
99
101
|
'@atlaskit/platform/ensure-atlassian-team': 'error',
|
|
100
102
|
'@atlaskit/platform/no-module-level-eval-nav4': 'error',
|
|
101
103
|
'@atlaskit/platform/no-direct-document-usage': 'warn',
|
|
104
|
+
'@atlaskit/platform/no-set-immediate': 'error',
|
|
102
105
|
// Compiled: rules that are not included via `@compiled/recommended
|
|
103
106
|
'@atlaskit/platform/expand-border-shorthand': 'error',
|
|
104
107
|
'@atlaskit/platform/expand-background-shorthand': 'error',
|
|
@@ -42,7 +42,9 @@ const rule: Rule.RuleModule = {
|
|
|
42
42
|
node.source.value === '@atlaskit/browser-apis' &&
|
|
43
43
|
node.specifiers.some(
|
|
44
44
|
(specifier) =>
|
|
45
|
-
specifier.type === 'ImportSpecifier' &&
|
|
45
|
+
specifier.type === 'ImportSpecifier' &&
|
|
46
|
+
specifier.imported.type === 'Identifier' &&
|
|
47
|
+
specifier.imported.name === 'getDocument',
|
|
46
48
|
)
|
|
47
49
|
) {
|
|
48
50
|
hasGetDocumentImport = true;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
|
|
3
|
+
const rule: Rule.RuleModule = {
|
|
4
|
+
meta: {
|
|
5
|
+
docs: {
|
|
6
|
+
description:
|
|
7
|
+
"Prevent usage of setImmediate in favor of React Testing Library's `waitFor` or similar",
|
|
8
|
+
recommended: true,
|
|
9
|
+
},
|
|
10
|
+
type: 'problem',
|
|
11
|
+
messages: {
|
|
12
|
+
noSetImmediate:
|
|
13
|
+
"Avoid using setImmediate. Use React Testing Library's waitFor or similar instead for better test reliability.",
|
|
14
|
+
suggestWaitFor: 'Replace with waitFor from @testing-library/react or similar',
|
|
15
|
+
},
|
|
16
|
+
hasSuggestions: true,
|
|
17
|
+
},
|
|
18
|
+
create(context) {
|
|
19
|
+
return {
|
|
20
|
+
CallExpression(node) {
|
|
21
|
+
if (node.callee.type === 'Identifier' && node.callee.name === 'setImmediate') {
|
|
22
|
+
context.report({
|
|
23
|
+
node,
|
|
24
|
+
messageId: 'noSetImmediate',
|
|
25
|
+
suggest: [
|
|
26
|
+
{
|
|
27
|
+
messageId: 'suggestWaitFor',
|
|
28
|
+
fix(fixer) {
|
|
29
|
+
return fixer.replaceText(
|
|
30
|
+
node,
|
|
31
|
+
'await waitFor(() => { /* your assertion here */ })',
|
|
32
|
+
);
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default rule;
|