-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathes-builtins.ts
125 lines (122 loc) · 6.62 KB
/
es-builtins.ts
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import { ASTUtils } from '@typescript-eslint/utils';
import { checkUnsupportedBuiltins } from '../../util/check-unsupported-builtins';
import type { IRawOptions, SupportMap } from '../../util/check-unsupported-builtins';
import { createRule } from '../../util/create-rule';
import { enumeratePropertyNames } from '../../util/enumerate-property-names';
const trackMap: { globals: SupportMap } = {
globals: {
AggregateError: { [ASTUtils.ReferenceTracker.READ]: { supported: '15.0.0' } },
Array: {
from: { [ASTUtils.ReferenceTracker.READ]: { supported: '4.0.0' } },
of: { [ASTUtils.ReferenceTracker.READ]: { supported: '4.0.0' } },
},
BigInt: { [ASTUtils.ReferenceTracker.READ]: { supported: '10.4.0' } },
FinalizationRegistry: { [ASTUtils.ReferenceTracker.READ]: { supported: '14.6.0' } },
Map: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
Math: {
acosh: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
asinh: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
atanh: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
cbrt: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
clz32: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
cosh: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
expm1: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
fround: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
hypot: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
imul: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
log10: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
log1p: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
log2: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
sign: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
sinh: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
tanh: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
trunc: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
},
Number: {
EPSILON: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
isFinite: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.10.0' } },
isInteger: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
isNaN: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.10.0' } },
isSafeInteger: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
MAX_SAFE_INTEGER: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
MIN_SAFE_INTEGER: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
parseFloat: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
parseInt: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
},
Object: {
assign: { [ASTUtils.ReferenceTracker.READ]: { supported: '4.0.0' } },
fromEntries: { [ASTUtils.ReferenceTracker.READ]: { supported: '12.0.0' } },
getOwnPropertySymbols: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
is: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.10.0' } },
setPrototypeOf: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
values: { [ASTUtils.ReferenceTracker.READ]: { supported: '7.0.0' } },
entries: { [ASTUtils.ReferenceTracker.READ]: { supported: '7.0.0' } },
getOwnPropertyDescriptors: { [ASTUtils.ReferenceTracker.READ]: { supported: '7.0.0' } },
},
Promise: {
[ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' },
allSettled: { [ASTUtils.ReferenceTracker.READ]: { supported: '12.9.0' } },
any: { [ASTUtils.ReferenceTracker.READ]: { supported: '15.0.0' } },
},
Proxy: { [ASTUtils.ReferenceTracker.READ]: { supported: '6.0.0' } },
Reflect: { [ASTUtils.ReferenceTracker.READ]: { supported: '6.0.0' } },
Set: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
String: {
fromCodePoint: { [ASTUtils.ReferenceTracker.READ]: { supported: '4.0.0' } },
raw: { [ASTUtils.ReferenceTracker.READ]: { supported: '4.0.0' } },
},
Symbol: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
Int8Array: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.10.0' } },
Uint8Array: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.10.0' } },
Uint8ClampedArray: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.10.0' } },
Int16Array: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.10.0' } },
Uint16Array: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.10.0' } },
Int32Array: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.10.0' } },
Uint32Array: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.10.0' } },
BigInt64Array: { [ASTUtils.ReferenceTracker.READ]: { supported: '10.4.0' } },
BigUint64Array: { [ASTUtils.ReferenceTracker.READ]: { supported: '10.4.0' } },
Float32Array: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.10.0' } },
Float64Array: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.10.0' } },
DataView: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.10.0' } },
WeakMap: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
WeakRef: { [ASTUtils.ReferenceTracker.READ]: { supported: '14.6.0' } },
WeakSet: { [ASTUtils.ReferenceTracker.READ]: { supported: '0.12.0' } },
Atomics: { [ASTUtils.ReferenceTracker.READ]: { supported: '8.10.0' } },
SharedArrayBuffer: { [ASTUtils.ReferenceTracker.READ]: { supported: '8.10.0' } },
globalThis: { [ASTUtils.ReferenceTracker.READ]: { supported: '12.0.0' } },
},
};
export const category = 'Possible Errors';
export default createRule<[options: IRawOptions], 'unsupported'>({
name: 'no-unsupported-features/es-builtins',
meta: {
type: 'problem',
docs: { description: 'disallow unsupported ECMAScript built-ins on the specified version', recommended: 'error' },
schema: [
{
type: 'object',
properties: {
version: { type: 'string' },
ignores: {
type: 'array',
items: { enum: [...enumeratePropertyNames(trackMap.globals)] },
uniqueItems: true,
},
},
additionalProperties: false,
},
],
messages: {
unsupported:
"The '{{name}}' is not supported until Node.js {{supported}}. The configured version range is '{{version}}'.",
},
},
defaultOptions: [{}],
create(context, options) {
return {
'Program:exit'() {
checkUnsupportedBuiltins(context, options, trackMap);
},
};
},
});