forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest-eslint-alphabetize-primordials.js
More file actions
54 lines (50 loc) · 2.02 KB
/
test-eslint-alphabetize-primordials.js
File metadata and controls
54 lines (50 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'use strict';
const common = require('../common');
if ((!common.hasCrypto) || (!common.hasIntl)) {
common.skip('ESLint tests require crypto and Intl');
}
common.skipIfEslintMissing();
const RuleTester = require('../../tools/eslint/node_modules/eslint').RuleTester;
const rule = require('../../tools/eslint-rules/alphabetize-primordials');
new RuleTester()
.run('alphabetize-primordials', rule, {
valid: [
'new Array()',
'"use strict";const {\nArray\n} = primordials;',
'"use strict";const {\n\tArray,\n\tDate,\n} = primordials',
'"use strict";const {\nDate,Array\n} = notPrimordials',
'"use strict";const {\nDate,globalThis:{Array}\n} = primordials',
'"use strict";const {\nBigInt,globalThis:{Array,Date,SharedArrayBuffer,parseInt}\n} = primordials',
'"use strict";const {\nFunctionPrototypeBind,Uint32Array,globalThis:{SharedArrayBuffer}\n} = primordials',
{
code: '"use strict";const fs = require("fs");const {\nArray\n} = primordials',
options: [{ enforceTopPosition: false }],
},
],
invalid: [
{
code: '"use strict";const {Array} = primordials;',
errors: [{ message: /destructuring from primordials should be multiline/ }],
},
{
code: '"use strict";const fs = require("fs");const {Date,Array} = primordials',
errors: [
{ message: /destructuring from primordials should be multiline/ },
{ message: /destructuring from primordials should be the first expression/ },
{ message: /Date >= Array/ },
],
},
{
code: 'function fn() {"use strict";const {\nArray,\n} = primordials}',
errors: [{ message: /destructuring from primordials should be the first expression/ }],
},
{
code: '"use strict";const {\nDate,Array} = primordials',
errors: [{ message: /Date >= Array/ }],
},
{
code: '"use strict";const {\nglobalThis:{Date, Array}} = primordials',
errors: [{ message: /Date >= Array/ }],
},
]
});