eslint 7.7.0 → 7.10.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 +67 -0
- package/README.md +1 -1
- package/conf/config-schema.js +12 -0
- package/lib/cli-engine/cascading-config-array-factory.js +12 -0
- package/lib/cli-engine/cli-engine.js +2 -2
- package/lib/cli-engine/config-array/config-array.js +12 -0
- package/lib/cli-engine/config-array/config-dependency.js +12 -0
- package/lib/cli-engine/config-array/extracted-config.js +12 -0
- package/lib/cli-engine/config-array/ignore-pattern.js +12 -0
- package/lib/cli-engine/config-array/index.js +12 -0
- package/lib/cli-engine/config-array/override-tester.js +12 -0
- package/lib/cli-engine/config-array-factory.js +24 -6
- package/lib/eslint/eslint.js +7 -1
- package/lib/init/autoconfig.js +1 -1
- package/lib/init/config-initializer.js +3 -3
- package/lib/linter/code-path-analysis/code-path-analyzer.js +38 -0
- package/lib/linter/code-path-analysis/code-path-state.js +2 -2
- package/lib/linter/config-comment-parser.js +1 -1
- package/lib/linter/linter.js +6 -3
- package/lib/rules/constructor-super.js +17 -1
- package/lib/rules/id-length.js +20 -7
- package/lib/rules/no-inline-comments.js +25 -4
- package/lib/rules/no-loss-of-precision.js +10 -2
- package/lib/rules/no-magic-numbers.js +20 -3
- package/lib/rules/no-warning-comments.js +40 -7
- package/lib/rules/operator-assignment.js +1 -1
- package/lib/rules/prefer-destructuring.js +7 -0
- package/lib/rules/prefer-numeric-literals.js +10 -0
- package/lib/rules/utils/ast-utils.js +49 -13
- package/lib/shared/config-validator.js +14 -2
- package/lib/shared/relative-module-resolver.js +12 -0
- package/lib/shared/types.js +1 -1
- package/messages/plugin-invalid.txt +8 -0
- package/package.json +4 -3
- package/conf/environments.js +0 -168
- package/lib/shared/config-ops.js +0 -130
- package/lib/shared/naming.js +0 -97
@@ -36,6 +36,14 @@ module.exports = {
|
|
36
36
|
return typeof node.value === "number";
|
37
37
|
}
|
38
38
|
|
39
|
+
/**
|
40
|
+
* Gets the source code of the given number literal. Removes `_` numeric separators from the result.
|
41
|
+
* @param {Node} node the number `Literal` node
|
42
|
+
* @returns {string} raw source code of the literal, without numeric separators
|
43
|
+
*/
|
44
|
+
function getRaw(node) {
|
45
|
+
return node.raw.replace(/_/gu, "");
|
46
|
+
}
|
39
47
|
|
40
48
|
/**
|
41
49
|
* Checks whether the number is base ten
|
@@ -55,7 +63,7 @@ module.exports = {
|
|
55
63
|
* @returns {boolean} true if they do not match
|
56
64
|
*/
|
57
65
|
function notBaseTenLosesPrecision(node) {
|
58
|
-
const rawString = node.
|
66
|
+
const rawString = getRaw(node).toUpperCase();
|
59
67
|
let base = 0;
|
60
68
|
|
61
69
|
if (rawString.startsWith("0B")) {
|
@@ -161,7 +169,7 @@ module.exports = {
|
|
161
169
|
* @returns {boolean} true if they do not match
|
162
170
|
*/
|
163
171
|
function baseTenLosesPrecision(node) {
|
164
|
-
const normalizedRawNumber = convertNumberToScientificNotation(node
|
172
|
+
const normalizedRawNumber = convertNumberToScientificNotation(getRaw(node));
|
165
173
|
const requestedPrecision = normalizedRawNumber.split("e")[0].replace(".", "").length;
|
166
174
|
|
167
175
|
if (requestedPrecision > 100) {
|
@@ -61,6 +61,10 @@ module.exports = {
|
|
61
61
|
ignoreArrayIndexes: {
|
62
62
|
type: "boolean",
|
63
63
|
default: false
|
64
|
+
},
|
65
|
+
ignoreDefaultValues: {
|
66
|
+
type: "boolean",
|
67
|
+
default: false
|
64
68
|
}
|
65
69
|
},
|
66
70
|
additionalProperties: false
|
@@ -77,7 +81,8 @@ module.exports = {
|
|
77
81
|
detectObjects = !!config.detectObjects,
|
78
82
|
enforceConst = !!config.enforceConst,
|
79
83
|
ignore = (config.ignore || []).map(normalizeIgnoreValue),
|
80
|
-
ignoreArrayIndexes = !!config.ignoreArrayIndexes
|
84
|
+
ignoreArrayIndexes = !!config.ignoreArrayIndexes,
|
85
|
+
ignoreDefaultValues = !!config.ignoreDefaultValues;
|
81
86
|
|
82
87
|
const okTypes = detectObjects ? [] : ["ObjectExpression", "Property", "AssignmentExpression"];
|
83
88
|
|
@@ -90,6 +95,17 @@ module.exports = {
|
|
90
95
|
return ignore.indexOf(value) !== -1;
|
91
96
|
}
|
92
97
|
|
98
|
+
/**
|
99
|
+
* Returns whether the number is a default value assignment.
|
100
|
+
* @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node
|
101
|
+
* @returns {boolean} true if the number is a default value
|
102
|
+
*/
|
103
|
+
function isDefaultValue(fullNumberNode) {
|
104
|
+
const parent = fullNumberNode.parent;
|
105
|
+
|
106
|
+
return parent.type === "AssignmentPattern" && parent.right === fullNumberNode;
|
107
|
+
}
|
108
|
+
|
93
109
|
/**
|
94
110
|
* Returns whether the given node is used as a radix within parseInt() or Number.parseInt()
|
95
111
|
* @param {ASTNode} fullNumberNode `Literal` or `UnaryExpression` full number node
|
@@ -172,9 +188,12 @@ module.exports = {
|
|
172
188
|
raw = node.raw;
|
173
189
|
}
|
174
190
|
|
191
|
+
const parent = fullNumberNode.parent;
|
192
|
+
|
175
193
|
// Always allow radix arguments and JSX props
|
176
194
|
if (
|
177
195
|
isIgnoredValue(value) ||
|
196
|
+
(ignoreDefaultValues && isDefaultValue(fullNumberNode)) ||
|
178
197
|
isParseIntRadix(fullNumberNode) ||
|
179
198
|
isJSXNumber(fullNumberNode) ||
|
180
199
|
(ignoreArrayIndexes && isArrayIndex(fullNumberNode, value))
|
@@ -182,8 +201,6 @@ module.exports = {
|
|
182
201
|
return;
|
183
202
|
}
|
184
203
|
|
185
|
-
const parent = fullNumberNode.parent;
|
186
|
-
|
187
204
|
if (parent.type === "VariableDeclarator") {
|
188
205
|
if (enforceConst && parent.parent.kind !== "const") {
|
189
206
|
context.report({
|
@@ -8,6 +8,8 @@
|
|
8
8
|
const { escapeRegExp } = require("lodash");
|
9
9
|
const astUtils = require("./utils/ast-utils");
|
10
10
|
|
11
|
+
const CHAR_LIMIT = 40;
|
12
|
+
|
11
13
|
//------------------------------------------------------------------------------
|
12
14
|
// Rule Definition
|
13
15
|
//------------------------------------------------------------------------------
|
@@ -42,12 +44,11 @@ module.exports = {
|
|
42
44
|
],
|
43
45
|
|
44
46
|
messages: {
|
45
|
-
unexpectedComment: "Unexpected '{{matchedTerm}}' comment."
|
47
|
+
unexpectedComment: "Unexpected '{{matchedTerm}}' comment: '{{comment}}'."
|
46
48
|
}
|
47
49
|
},
|
48
50
|
|
49
51
|
create(context) {
|
50
|
-
|
51
52
|
const sourceCode = context.getSourceCode(),
|
52
53
|
configuration = context.options[0] || {},
|
53
54
|
warningTerms = configuration.terms || ["todo", "fixme", "xxx"],
|
@@ -107,7 +108,15 @@ module.exports = {
|
|
107
108
|
* \bTERM\b|\bTERM\b, this checks the entire comment
|
108
109
|
* for the term.
|
109
110
|
*/
|
110
|
-
return new RegExp(
|
111
|
+
return new RegExp(
|
112
|
+
prefix +
|
113
|
+
escaped +
|
114
|
+
suffix +
|
115
|
+
eitherOrWordBoundary +
|
116
|
+
term +
|
117
|
+
wordBoundary,
|
118
|
+
"iu"
|
119
|
+
);
|
111
120
|
}
|
112
121
|
|
113
122
|
const warningRegExps = warningTerms.map(convertToRegExp);
|
@@ -135,18 +144,40 @@ module.exports = {
|
|
135
144
|
* @returns {void} undefined.
|
136
145
|
*/
|
137
146
|
function checkComment(node) {
|
138
|
-
|
147
|
+
const comment = node.value;
|
148
|
+
|
149
|
+
if (
|
150
|
+
astUtils.isDirectiveComment(node) &&
|
151
|
+
selfConfigRegEx.test(comment)
|
152
|
+
) {
|
139
153
|
return;
|
140
154
|
}
|
141
155
|
|
142
|
-
const matches = commentContainsWarningTerm(
|
156
|
+
const matches = commentContainsWarningTerm(comment);
|
143
157
|
|
144
158
|
matches.forEach(matchedTerm => {
|
159
|
+
let commentToDisplay = "";
|
160
|
+
let truncated = false;
|
161
|
+
|
162
|
+
for (const c of comment.trim().split(/\s+/u)) {
|
163
|
+
const tmp = commentToDisplay ? `${commentToDisplay} ${c}` : c;
|
164
|
+
|
165
|
+
if (tmp.length <= CHAR_LIMIT) {
|
166
|
+
commentToDisplay = tmp;
|
167
|
+
} else {
|
168
|
+
truncated = true;
|
169
|
+
break;
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
145
173
|
context.report({
|
146
174
|
node,
|
147
175
|
messageId: "unexpectedComment",
|
148
176
|
data: {
|
149
|
-
matchedTerm
|
177
|
+
matchedTerm,
|
178
|
+
comment: `${commentToDisplay}${
|
179
|
+
truncated ? "..." : ""
|
180
|
+
}`
|
150
181
|
}
|
151
182
|
});
|
152
183
|
});
|
@@ -156,7 +187,9 @@ module.exports = {
|
|
156
187
|
Program() {
|
157
188
|
const comments = sourceCode.getAllComments();
|
158
189
|
|
159
|
-
comments
|
190
|
+
comments
|
191
|
+
.filter(token => token.type !== "Shebang")
|
192
|
+
.forEach(checkComment);
|
160
193
|
}
|
161
194
|
};
|
162
195
|
}
|
@@ -151,7 +151,7 @@ module.exports = {
|
|
151
151
|
* @returns {void}
|
152
152
|
*/
|
153
153
|
function prohibit(node) {
|
154
|
-
if (node.operator !== "=") {
|
154
|
+
if (node.operator !== "=" && !astUtils.isLogicalAssignmentOperator(node.operator)) {
|
155
155
|
context.report({
|
156
156
|
node,
|
157
157
|
messageId: "unexpected",
|
@@ -163,6 +163,8 @@ module.exports = {
|
|
163
163
|
return node.type === "VariableDeclarator" &&
|
164
164
|
node.id.type === "Identifier" &&
|
165
165
|
node.init.type === "MemberExpression" &&
|
166
|
+
!node.init.computed &&
|
167
|
+
node.init.property.type === "Identifier" &&
|
166
168
|
node.id.name === node.init.property.name;
|
167
169
|
}
|
168
170
|
|
@@ -178,6 +180,11 @@ module.exports = {
|
|
178
180
|
const rightNode = node.init;
|
179
181
|
const sourceCode = context.getSourceCode();
|
180
182
|
|
183
|
+
// Don't fix if that would remove any comments. Only comments inside `rightNode.object` can be preserved.
|
184
|
+
if (sourceCode.getCommentsInside(node).length > sourceCode.getCommentsInside(rightNode.object).length) {
|
185
|
+
return null;
|
186
|
+
}
|
187
|
+
|
181
188
|
return fixer.replaceText(
|
182
189
|
node,
|
183
190
|
`{${rightNode.property.name}} = ${sourceCode.getText(rightNode.object)}`
|
@@ -103,6 +103,16 @@ module.exports = {
|
|
103
103
|
/*
|
104
104
|
* If the newly-produced literal would be invalid, (e.g. 0b1234),
|
105
105
|
* or it would yield an incorrect parseInt result for some other reason, don't make a fix.
|
106
|
+
*
|
107
|
+
* If `str` had numeric separators, `+replacement` will evaluate to `NaN` because unary `+`
|
108
|
+
* per the specification doesn't support numeric separators. Thus, the above condition will be `true`
|
109
|
+
* (`NaN !== anything` is always `true`) regardless of the `parseInt(str, radix)` value.
|
110
|
+
* Consequently, no autofixes will be made. This is correct behavior because `parseInt` also
|
111
|
+
* doesn't support numeric separators, but it does parse part of the string before the first `_`,
|
112
|
+
* so the autofix would be invalid:
|
113
|
+
*
|
114
|
+
* parseInt("1_1", 2) // === 1
|
115
|
+
* 0b1_1 // === 3
|
106
116
|
*/
|
107
117
|
return null;
|
108
118
|
}
|
@@ -37,9 +37,11 @@ const LINEBREAKS = new Set(["\r\n", "\r", "\n", "\u2028", "\u2029"]);
|
|
37
37
|
// A set of node types that can contain a list of statements
|
38
38
|
const STATEMENT_LIST_PARENTS = new Set(["Program", "BlockStatement", "SwitchCase"]);
|
39
39
|
|
40
|
-
const DECIMAL_INTEGER_PATTERN = /^(0|[1-9]
|
40
|
+
const DECIMAL_INTEGER_PATTERN = /^(?:0|0[0-7]*[89]\d*|[1-9](?:_?\d)*)$/u;
|
41
41
|
const OCTAL_ESCAPE_PATTERN = /^(?:[^\\]|\\[^0-7]|\\0(?![0-9]))*\\(?:[1-7]|0[0-9])/u;
|
42
42
|
|
43
|
+
const LOGICAL_ASSIGNMENT_OPERATORS = new Set(["&&=", "||=", "??="]);
|
44
|
+
|
43
45
|
/**
|
44
46
|
* Checks reference if is non initializer and writable.
|
45
47
|
* @param {Reference} reference A reference to check.
|
@@ -722,6 +724,15 @@ function isMixedLogicalAndCoalesceExpressions(left, right) {
|
|
722
724
|
);
|
723
725
|
}
|
724
726
|
|
727
|
+
/**
|
728
|
+
* Checks if the given operator is a logical assignment operator.
|
729
|
+
* @param {string} operator The operator to check.
|
730
|
+
* @returns {boolean} `true` if the operator is a logical assignment operator.
|
731
|
+
*/
|
732
|
+
function isLogicalAssignmentOperator(operator) {
|
733
|
+
return LOGICAL_ASSIGNMENT_OPERATORS.has(operator);
|
734
|
+
}
|
735
|
+
|
725
736
|
//------------------------------------------------------------------------------
|
726
737
|
// Public Interface
|
727
738
|
//------------------------------------------------------------------------------
|
@@ -1228,16 +1239,27 @@ module.exports = {
|
|
1228
1239
|
* @returns {boolean} `true` if this node is a decimal integer.
|
1229
1240
|
* @example
|
1230
1241
|
*
|
1231
|
-
*
|
1232
|
-
* 5
|
1233
|
-
*
|
1234
|
-
*
|
1235
|
-
*
|
1236
|
-
*
|
1237
|
-
*
|
1238
|
-
*
|
1239
|
-
*
|
1240
|
-
*
|
1242
|
+
* 0 // true
|
1243
|
+
* 5 // true
|
1244
|
+
* 50 // true
|
1245
|
+
* 5_000 // true
|
1246
|
+
* 1_234_56 // true
|
1247
|
+
* 08 // true
|
1248
|
+
* 0192 // true
|
1249
|
+
* 5. // false
|
1250
|
+
* .5 // false
|
1251
|
+
* 5.0 // false
|
1252
|
+
* 5.00_00 // false
|
1253
|
+
* 05 // false
|
1254
|
+
* 0x5 // false
|
1255
|
+
* 0b101 // false
|
1256
|
+
* 0b11_01 // false
|
1257
|
+
* 0o5 // false
|
1258
|
+
* 5e0 // false
|
1259
|
+
* 5e1_000 // false
|
1260
|
+
* 5n // false
|
1261
|
+
* 1_000n // false
|
1262
|
+
* '5' // false
|
1241
1263
|
*/
|
1242
1264
|
isDecimalInteger(node) {
|
1243
1265
|
return node.type === "Literal" && typeof node.value === "number" &&
|
@@ -1567,7 +1589,20 @@ module.exports = {
|
|
1567
1589
|
return true; // possibly an error object.
|
1568
1590
|
|
1569
1591
|
case "AssignmentExpression":
|
1570
|
-
|
1592
|
+
if (["=", "&&="].includes(node.operator)) {
|
1593
|
+
return module.exports.couldBeError(node.right);
|
1594
|
+
}
|
1595
|
+
|
1596
|
+
if (["||=", "??="].includes(node.operator)) {
|
1597
|
+
return module.exports.couldBeError(node.left) || module.exports.couldBeError(node.right);
|
1598
|
+
}
|
1599
|
+
|
1600
|
+
/**
|
1601
|
+
* All other assignment operators are mathematical assignment operators (arithmetic or bitwise).
|
1602
|
+
* An assignment expression with a mathematical operator can either evaluate to a primitive value,
|
1603
|
+
* or throw, depending on the operands. Thus, it cannot evaluate to an `Error` object.
|
1604
|
+
*/
|
1605
|
+
return false;
|
1571
1606
|
|
1572
1607
|
case "SequenceExpression": {
|
1573
1608
|
const exprs = node.expressions;
|
@@ -1754,5 +1789,6 @@ module.exports = {
|
|
1754
1789
|
isSpecificId,
|
1755
1790
|
isSpecificMemberAccess,
|
1756
1791
|
equalLiteralValue,
|
1757
|
-
isSameReference
|
1792
|
+
isSameReference,
|
1793
|
+
isLogicalAssignmentOperator
|
1758
1794
|
};
|
@@ -1,3 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* STOP!!! DO NOT MODIFY.
|
3
|
+
*
|
4
|
+
* This file is part of the ongoing work to move the eslintrc-style config
|
5
|
+
* system into the @eslint/eslintrc package. This file needs to remain
|
6
|
+
* unchanged in order for this work to proceed.
|
7
|
+
*
|
8
|
+
* If you think you need to change this file, please contact @nzakas first.
|
9
|
+
*
|
10
|
+
* Thanks in advance for your cooperation.
|
11
|
+
*/
|
12
|
+
|
1
13
|
/**
|
2
14
|
* @fileoverview Validates configs.
|
3
15
|
* @author Brandon Mills
|
@@ -12,9 +24,9 @@
|
|
12
24
|
const
|
13
25
|
util = require("util"),
|
14
26
|
configSchema = require("../../conf/config-schema"),
|
15
|
-
BuiltInEnvironments = require("
|
27
|
+
BuiltInEnvironments = require("@eslint/eslintrc/conf/environments"),
|
16
28
|
BuiltInRules = require("../rules"),
|
17
|
-
ConfigOps = require("
|
29
|
+
ConfigOps = require("@eslint/eslintrc/lib/shared/config-ops"),
|
18
30
|
{ emitDeprecationWarning } = require("./deprecation-warnings");
|
19
31
|
|
20
32
|
const ajv = require("./ajv")();
|
@@ -1,3 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* STOP!!! DO NOT MODIFY.
|
3
|
+
*
|
4
|
+
* This file is part of the ongoing work to move the eslintrc-style config
|
5
|
+
* system into the @eslint/eslintrc package. This file needs to remain
|
6
|
+
* unchanged in order for this work to proceed.
|
7
|
+
*
|
8
|
+
* If you think you need to change this file, please contact @nzakas first.
|
9
|
+
*
|
10
|
+
* Thanks in advance for your cooperation.
|
11
|
+
*/
|
12
|
+
|
1
13
|
/**
|
2
14
|
* Utility for resolving a module relative to another module
|
3
15
|
* @author Teddy Katz
|
package/lib/shared/types.js
CHANGED
@@ -21,7 +21,7 @@ module.exports = {};
|
|
21
21
|
/**
|
22
22
|
* @typedef {Object} ParserOptions
|
23
23
|
* @property {EcmaFeatures} [ecmaFeatures] The optional features.
|
24
|
-
* @property {3|5|6|7|8|9|10|11|2015|2016|2017|2018|2019|2020} [ecmaVersion] The ECMAScript version (or revision number).
|
24
|
+
* @property {3|5|6|7|8|9|10|11|12|2015|2016|2017|2018|2019|2020|2021} [ecmaVersion] The ECMAScript version (or revision number).
|
25
25
|
* @property {"script"|"module"} [sourceType] The source code type.
|
26
26
|
*/
|
27
27
|
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"<%- configName %>" is invalid syntax for a config specifier.
|
2
|
+
|
3
|
+
* If your intention is to extend from a configuration exported from the plugin, add the configuration name after a slash: e.g. "<%- configName %>/myConfig".
|
4
|
+
* If this is the name of a shareable config instead of a plugin, remove the "plugin:" prefix: i.e. "<%- configName.slice("plugin:".length) %>".
|
5
|
+
|
6
|
+
"<%- configName %>" was referenced from the config file in "<%- importerName %>".
|
7
|
+
|
8
|
+
If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.10.0",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"bin": {
|
@@ -47,16 +47,17 @@
|
|
47
47
|
"bugs": "https://github.com/eslint/eslint/issues/",
|
48
48
|
"dependencies": {
|
49
49
|
"@babel/code-frame": "^7.0.0",
|
50
|
+
"@eslint/eslintrc": "^0.1.3",
|
50
51
|
"ajv": "^6.10.0",
|
51
52
|
"chalk": "^4.0.0",
|
52
53
|
"cross-spawn": "^7.0.2",
|
53
54
|
"debug": "^4.0.1",
|
54
55
|
"doctrine": "^3.0.0",
|
55
56
|
"enquirer": "^2.3.5",
|
56
|
-
"eslint-scope": "^5.1.
|
57
|
+
"eslint-scope": "^5.1.1",
|
57
58
|
"eslint-utils": "^2.1.0",
|
58
59
|
"eslint-visitor-keys": "^1.3.0",
|
59
|
-
"espree": "^7.
|
60
|
+
"espree": "^7.3.0",
|
60
61
|
"esquery": "^1.2.0",
|
61
62
|
"esutils": "^2.0.2",
|
62
63
|
"file-entry-cache": "^5.0.1",
|
package/conf/environments.js
DELETED
@@ -1,168 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @fileoverview Defines environment settings and globals.
|
3
|
-
* @author Elan Shanker
|
4
|
-
*/
|
5
|
-
"use strict";
|
6
|
-
|
7
|
-
//------------------------------------------------------------------------------
|
8
|
-
// Requirements
|
9
|
-
//------------------------------------------------------------------------------
|
10
|
-
|
11
|
-
const globals = require("globals");
|
12
|
-
|
13
|
-
//------------------------------------------------------------------------------
|
14
|
-
// Helpers
|
15
|
-
//------------------------------------------------------------------------------
|
16
|
-
|
17
|
-
/**
|
18
|
-
* Get the object that has difference.
|
19
|
-
* @param {Record<string,boolean>} current The newer object.
|
20
|
-
* @param {Record<string,boolean>} prev The older object.
|
21
|
-
* @returns {Record<string,boolean>} The difference object.
|
22
|
-
*/
|
23
|
-
function getDiff(current, prev) {
|
24
|
-
const retv = {};
|
25
|
-
|
26
|
-
for (const [key, value] of Object.entries(current)) {
|
27
|
-
if (!Object.hasOwnProperty.call(prev, key)) {
|
28
|
-
retv[key] = value;
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
return retv;
|
33
|
-
}
|
34
|
-
|
35
|
-
const newGlobals2015 = getDiff(globals.es2015, globals.es5); // 19 variables such as Promise, Map, ...
|
36
|
-
const newGlobals2017 = {
|
37
|
-
Atomics: false,
|
38
|
-
SharedArrayBuffer: false
|
39
|
-
};
|
40
|
-
const newGlobals2020 = {
|
41
|
-
BigInt: false,
|
42
|
-
BigInt64Array: false,
|
43
|
-
BigUint64Array: false,
|
44
|
-
globalThis: false
|
45
|
-
};
|
46
|
-
|
47
|
-
//------------------------------------------------------------------------------
|
48
|
-
// Public Interface
|
49
|
-
//------------------------------------------------------------------------------
|
50
|
-
|
51
|
-
/** @type {Map<string, import("../lib/shared/types").Environment>} */
|
52
|
-
module.exports = new Map(Object.entries({
|
53
|
-
|
54
|
-
// Language
|
55
|
-
builtin: {
|
56
|
-
globals: globals.es5
|
57
|
-
},
|
58
|
-
es6: {
|
59
|
-
globals: newGlobals2015,
|
60
|
-
parserOptions: {
|
61
|
-
ecmaVersion: 6
|
62
|
-
}
|
63
|
-
},
|
64
|
-
es2015: {
|
65
|
-
globals: newGlobals2015,
|
66
|
-
parserOptions: {
|
67
|
-
ecmaVersion: 6
|
68
|
-
}
|
69
|
-
},
|
70
|
-
es2017: {
|
71
|
-
globals: { ...newGlobals2015, ...newGlobals2017 },
|
72
|
-
parserOptions: {
|
73
|
-
ecmaVersion: 8
|
74
|
-
}
|
75
|
-
},
|
76
|
-
es2020: {
|
77
|
-
globals: { ...newGlobals2015, ...newGlobals2017, ...newGlobals2020 },
|
78
|
-
parserOptions: {
|
79
|
-
ecmaVersion: 11
|
80
|
-
}
|
81
|
-
},
|
82
|
-
|
83
|
-
// Platforms
|
84
|
-
browser: {
|
85
|
-
globals: globals.browser
|
86
|
-
},
|
87
|
-
node: {
|
88
|
-
globals: globals.node,
|
89
|
-
parserOptions: {
|
90
|
-
ecmaFeatures: {
|
91
|
-
globalReturn: true
|
92
|
-
}
|
93
|
-
}
|
94
|
-
},
|
95
|
-
"shared-node-browser": {
|
96
|
-
globals: globals["shared-node-browser"]
|
97
|
-
},
|
98
|
-
worker: {
|
99
|
-
globals: globals.worker
|
100
|
-
},
|
101
|
-
serviceworker: {
|
102
|
-
globals: globals.serviceworker
|
103
|
-
},
|
104
|
-
|
105
|
-
// Frameworks
|
106
|
-
commonjs: {
|
107
|
-
globals: globals.commonjs,
|
108
|
-
parserOptions: {
|
109
|
-
ecmaFeatures: {
|
110
|
-
globalReturn: true
|
111
|
-
}
|
112
|
-
}
|
113
|
-
},
|
114
|
-
amd: {
|
115
|
-
globals: globals.amd
|
116
|
-
},
|
117
|
-
mocha: {
|
118
|
-
globals: globals.mocha
|
119
|
-
},
|
120
|
-
jasmine: {
|
121
|
-
globals: globals.jasmine
|
122
|
-
},
|
123
|
-
jest: {
|
124
|
-
globals: globals.jest
|
125
|
-
},
|
126
|
-
phantomjs: {
|
127
|
-
globals: globals.phantomjs
|
128
|
-
},
|
129
|
-
jquery: {
|
130
|
-
globals: globals.jquery
|
131
|
-
},
|
132
|
-
qunit: {
|
133
|
-
globals: globals.qunit
|
134
|
-
},
|
135
|
-
prototypejs: {
|
136
|
-
globals: globals.prototypejs
|
137
|
-
},
|
138
|
-
shelljs: {
|
139
|
-
globals: globals.shelljs
|
140
|
-
},
|
141
|
-
meteor: {
|
142
|
-
globals: globals.meteor
|
143
|
-
},
|
144
|
-
mongo: {
|
145
|
-
globals: globals.mongo
|
146
|
-
},
|
147
|
-
protractor: {
|
148
|
-
globals: globals.protractor
|
149
|
-
},
|
150
|
-
applescript: {
|
151
|
-
globals: globals.applescript
|
152
|
-
},
|
153
|
-
nashorn: {
|
154
|
-
globals: globals.nashorn
|
155
|
-
},
|
156
|
-
atomtest: {
|
157
|
-
globals: globals.atomtest
|
158
|
-
},
|
159
|
-
embertest: {
|
160
|
-
globals: globals.embertest
|
161
|
-
},
|
162
|
-
webextensions: {
|
163
|
-
globals: globals.webextensions
|
164
|
-
},
|
165
|
-
greasemonkey: {
|
166
|
-
globals: globals.greasemonkey
|
167
|
-
}
|
168
|
-
}));
|